Initialer Upload neues Unity-Projekt
This commit is contained in:
@ -0,0 +1,44 @@
|
||||
float3 orientCubePointToSegmentWithWidth(float3 localPt, float3 p0, float3 p1, float width0, float width1)
|
||||
{
|
||||
float3 localSpaceVert = localPt;
|
||||
|
||||
float len = length(p1 - p0);
|
||||
float3 up = float3(0.0f, 1.0f, 0.0f);
|
||||
float3 forward = normalize(p1 - p0);
|
||||
|
||||
if(len < 0.0001f) // near zero length line segment
|
||||
{
|
||||
forward = float3(1.0f, 0.0f, 0.0f);
|
||||
}
|
||||
|
||||
if(abs(forward.y) > 0.99999f) // vertical line segment
|
||||
{
|
||||
up = float3(1.0f, 0.0f, 0.0f);
|
||||
}
|
||||
|
||||
// Build lookAt matrix
|
||||
float3 zaxis = forward;
|
||||
float3 xaxis = normalize(cross(up, zaxis));
|
||||
float3 yaxis = cross(zaxis, xaxis);
|
||||
float4x4 lookAtMatrix = {
|
||||
xaxis.x, yaxis.x, zaxis.x, p0.x,
|
||||
xaxis.y, yaxis.y, zaxis.y, p0.y,
|
||||
xaxis.z, yaxis.z, zaxis.z, p0.z,
|
||||
0, 0, 0, 1
|
||||
};
|
||||
|
||||
// Apply widths
|
||||
if(localSpaceVert.z > 0.0f)
|
||||
{
|
||||
localSpaceVert.xy *= width0;
|
||||
localSpaceVert.z = len + width0/2.0f;
|
||||
}
|
||||
else
|
||||
{
|
||||
localSpaceVert.xy *= width1;
|
||||
localSpaceVert.z = -1.0f * width1/2.0f;
|
||||
}
|
||||
|
||||
// Apply lookAt matrix
|
||||
return mul(lookAtMatrix, float4(localSpaceVert, 1.0)).xyz;
|
||||
}
|
||||
@ -0,0 +1,9 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 4d946b34836b79f41846424301cf06c8
|
||||
ShaderImporter:
|
||||
externalObjects: {}
|
||||
defaultTextures: []
|
||||
nonModifiableTextures: []
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@ -0,0 +1,89 @@
|
||||
/************************************************************************************
|
||||
Copyright : Copyright (c) Facebook Technologies, LLC and its affiliates. All rights reserved.
|
||||
|
||||
Your use of this SDK or tool is subject to the Oculus SDK License Agreement, available at
|
||||
https://developer.oculus.com/licenses/oculussdk/
|
||||
|
||||
Unless required by applicable law or agreed to in writing, the Utilities SDK distributed
|
||||
under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF
|
||||
ANY KIND, either express or implied. See the License for the specific language governing
|
||||
permissions and limitations under the License.
|
||||
************************************************************************************/
|
||||
|
||||
Shader "Interaction/DotGridUnlit"
|
||||
{
|
||||
Properties {
|
||||
_Color("Color", Color) = (0, 0, 0, 1)
|
||||
|
||||
// rows, columns, radius
|
||||
_Dimensions("Dimensions", Vector) = (1, 1, .1, 0)
|
||||
}
|
||||
|
||||
SubShader
|
||||
{
|
||||
Tags {"Queue"="Transparent" "RenderType"="Transparent"}
|
||||
ZWrite Off
|
||||
Blend SrcAlpha OneMinusSrcAlpha
|
||||
LOD 100
|
||||
|
||||
Pass
|
||||
{
|
||||
CGPROGRAM
|
||||
#pragma vertex vert
|
||||
#pragma fragment frag
|
||||
#pragma multi_compile_instancing
|
||||
|
||||
#include "UnityCG.cginc"
|
||||
|
||||
struct appdata
|
||||
{
|
||||
UNITY_VERTEX_INPUT_INSTANCE_ID
|
||||
float4 vertex : POSITION;
|
||||
float2 uv : TEXCOORD0;
|
||||
};
|
||||
|
||||
struct v2f
|
||||
{
|
||||
UNITY_VERTEX_INPUT_INSTANCE_ID
|
||||
float4 vertex : SV_POSITION;
|
||||
float2 uv : TEXCOORD0;
|
||||
};
|
||||
|
||||
UNITY_INSTANCING_BUFFER_START(Props)
|
||||
UNITY_DEFINE_INSTANCED_PROP(fixed4, _Color)
|
||||
UNITY_DEFINE_INSTANCED_PROP(fixed4, _Dimensions)
|
||||
UNITY_INSTANCING_BUFFER_END(Props)
|
||||
|
||||
v2f vert (appdata v)
|
||||
{
|
||||
v2f o;
|
||||
UNITY_SETUP_INSTANCE_ID(v);
|
||||
UNITY_TRANSFER_INSTANCE_ID(v, o);
|
||||
|
||||
o.vertex = UnityObjectToClipPos(v.vertex);
|
||||
o.uv = v.uv;
|
||||
|
||||
return o;
|
||||
}
|
||||
|
||||
fixed4 frag (v2f i) : SV_Target
|
||||
{
|
||||
UNITY_SETUP_INSTANCE_ID(i);
|
||||
|
||||
float4 color = UNITY_ACCESS_INSTANCED_PROP(Props, _Color);
|
||||
float4 dimensions = UNITY_ACCESS_INSTANCED_PROP(Props, _Dimensions);
|
||||
|
||||
float2 diameter = float2(1.0f/dimensions.x, 1.0f/dimensions.y);
|
||||
float2 uvOffset = i.uv + diameter / 2.0f;
|
||||
float2 index = floor(uvOffset / diameter);
|
||||
float2 xy = index * diameter;
|
||||
float dist = distance(i.uv, xy);
|
||||
|
||||
clip(dimensions.z - dist);
|
||||
|
||||
return color;
|
||||
}
|
||||
ENDCG
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -0,0 +1,9 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 43bc449c40895214cac9066b6664fc67
|
||||
ShaderImporter:
|
||||
externalObjects: {}
|
||||
defaultTextures: []
|
||||
nonModifiableTextures: []
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
161
Assets/Oculus/Interaction/Runtime/Shaders/GlowFunctions.cginc
Normal file
161
Assets/Oculus/Interaction/Runtime/Shaders/GlowFunctions.cginc
Normal file
@ -0,0 +1,161 @@
|
||||
/*
|
||||
* Copyright (c) Meta Platforms, Inc. and affiliates.
|
||||
* All rights reserved.
|
||||
*
|
||||
* Licensed under the Oculus SDK License Agreement (the "License");
|
||||
* you may not use the Oculus SDK except in compliance with the License,
|
||||
* which is provided at the time of installation or download, or which
|
||||
* otherwise accompanies this software in either electronic or hard copy form.
|
||||
*
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* https://developer.oculus.com/licenses/oculussdk/
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, the Oculus SDK
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
float inverseLerp(float t, float a, float b) {
|
||||
return (t - a)/(b - a);
|
||||
}
|
||||
|
||||
float sinEasing(float value) {
|
||||
return sin((value - 0.5) * 3.14) * 0.5 + 0.5;
|
||||
}
|
||||
|
||||
float3 lineDistance(float2 uv, float4 linePoints) {
|
||||
float2 start = linePoints.xy;
|
||||
float2 end = linePoints.zw;
|
||||
float2 startToUv = uv - start;
|
||||
float2 lineVector = end - start;
|
||||
float lineSqrLength = dot(lineVector, lineVector);
|
||||
float projectedValue = dot(lineVector, startToUv) / lineSqrLength;
|
||||
float projectedValueClamped = saturate(projectedValue);
|
||||
float2 positionOnLine = start + lineVector * projectedValueClamped;
|
||||
float distanceToLine = length(uv - positionOnLine);
|
||||
|
||||
return float3(distanceToLine, projectedValue, length(lineVector) * projectedValueClamped);
|
||||
}
|
||||
|
||||
float4 resizeLine(float4 linePoints, float param) {
|
||||
float2 lStart = linePoints.xy;
|
||||
float2 lEnd = linePoints.zw;
|
||||
float2 lEndCorrected = lStart + (lEnd - lStart) * param;
|
||||
return float4(lStart, lEndCorrected);
|
||||
}
|
||||
|
||||
float computeRadiusMovingMask(float2 radiusMinMax, float param, float sizeParm) {
|
||||
float radParam = saturate(saturate(param - 0.1) / 0.9);
|
||||
float radScaleParam = saturate(param / 0.1);
|
||||
float maxRadCorrected = lerp(radiusMinMax.x, radiusMinMax.y, radParam);
|
||||
return lerp(radiusMinMax.x, maxRadCorrected, sizeParm) * radScaleParam;
|
||||
}
|
||||
|
||||
void getPalmFingerRadius(out float2 lineRadius[5]) {
|
||||
float2 palmFingerRadius[5] = {
|
||||
float2(0.070, 0.14),
|
||||
float2(0.06, 0.06),
|
||||
float2(0.06, 0.06),
|
||||
float2(0.06, 0.06),
|
||||
float2(0.06, 0.06)
|
||||
};
|
||||
lineRadius = palmFingerRadius;
|
||||
}
|
||||
|
||||
float2 getPalmFingerRadiusByIndex(int index) {
|
||||
if(index == 0) { return float2(0.070, 0.14); }
|
||||
if(index == 1) { return float2(0.06, 0.06); }
|
||||
if(index == 2) { return float2(0.06, 0.06); }
|
||||
if(index == 3) { return float2(0.06, 0.06); }
|
||||
if(index == 4) { return float2(0.06, 0.06); }
|
||||
return float2(0.0,0.0);
|
||||
}
|
||||
|
||||
void getFingerRadius(out float2 lineRadius[5]) {
|
||||
float2 fingerRadius[5] = {
|
||||
float2(0.2, 0.2),
|
||||
float2(0.065, 0.055),
|
||||
float2(0.055, 0.055),
|
||||
float2(0.050, 0.045),
|
||||
float2(0.045, 0.05)
|
||||
};
|
||||
lineRadius = fingerRadius;
|
||||
}
|
||||
|
||||
float2 getFingerRadiusByIndex(int index) {
|
||||
if(index == 0) { return float2(0.2, 0.2); }
|
||||
if(index == 1) { return float2(0.065, 0.055); }
|
||||
if(index == 2) { return float2(0.055, 0.055); }
|
||||
if(index == 3) { return float2(0.050, 0.045); }
|
||||
if(index == 4) { return float2(0.045, 0.05); }
|
||||
return float2(0.0,0.0);
|
||||
}
|
||||
|
||||
float fingerLineGlow(float2 handUV, float strengthValues[5], float distanceScale, float4 lines[5], float2 linesRadius[5]) {
|
||||
float2 uv = handUV;
|
||||
float distValue = 2.0;
|
||||
for(int index = 0; index < 5; index++) {
|
||||
|
||||
float param = saturate(strengthValues[index]);
|
||||
float4 linePoints = resizeLine(lines[index], param);
|
||||
float2 lDist = lineDistance(uv, linePoints);
|
||||
float radius = computeRadiusMovingMask(linesRadius[index], param, saturate(lDist.y));
|
||||
|
||||
float dist = lDist.x - radius;
|
||||
distValue = min(dist, distValue);
|
||||
}
|
||||
|
||||
float invDist = distValue * -1.0;
|
||||
float glowMask = saturate(invDist * distanceScale);
|
||||
return sinEasing(glowMask);
|
||||
}
|
||||
|
||||
float2 movingFingerGradient(float2 handUV, float4 gradientLine, float2 gradientRadius, float strength, float gradientLength, out bool useGlow) {
|
||||
float2 lDist = lineDistance(handUV, gradientLine);
|
||||
float radius = lerp(gradientRadius.x, gradientRadius.y, saturate(lDist.y));
|
||||
if (lDist.x < radius) {
|
||||
float distance = max(0.0, (lDist.x - radius) * -1.0);
|
||||
float hDist = lDist.y;
|
||||
float param = inverseLerp(hDist, strength - gradientLength, strength);
|
||||
useGlow = true;
|
||||
return float2(distance, param);
|
||||
}
|
||||
useGlow = false;
|
||||
return float2(0.0, 0.0);
|
||||
}
|
||||
|
||||
float movingFingersGradient(float2 handUV, float strengthValues[5], float gradientLength, float4 lines[5], float2 linesRadius[5]) {
|
||||
float2 uv = handUV;
|
||||
float distValue = 0.0;
|
||||
float value = 0.0;
|
||||
for(int index = 0; index < 5; index++) {
|
||||
float strength = saturate(strengthValues[index]);
|
||||
float2 lDist = lineDistance(uv, lines[index]);
|
||||
float radius = lerp(linesRadius[index].x, linesRadius[index].y, saturate(lDist.y));
|
||||
if (lDist.x < radius) {
|
||||
float lValue = max(0.0, (lDist.x - radius) * -1.0);
|
||||
float hDist = lDist.y;
|
||||
float param = saturate(inverseLerp(hDist, strength - gradientLength, strength));
|
||||
if ( lValue > distValue) {
|
||||
value = sinEasing(1.0 - param);
|
||||
distValue = lValue;
|
||||
}
|
||||
}
|
||||
}
|
||||
return value;
|
||||
}
|
||||
|
||||
float invertedSphereGradient(float3 gradientCenter, float3 worldPosition, float gradientLength) {
|
||||
float distance = length(worldPosition - gradientCenter);
|
||||
float gradient = 1.0 - saturate(distance / gradientLength);
|
||||
return sinEasing(gradient);
|
||||
}
|
||||
|
||||
float movingSphereGradient(float3 gradientCenter, float3 worldPosition, float gradientLength, float offset, float gradientMultiplier) {
|
||||
float normalizedDistance = length(worldPosition - gradientCenter) / gradientLength;
|
||||
float gradient = saturate((normalizedDistance - offset) * gradientMultiplier);
|
||||
return sinEasing(gradient);
|
||||
}
|
||||
@ -0,0 +1,10 @@
|
||||
fileFormatVersion: 2
|
||||
guid: a82fbf39518dc40cdb77a4e40dfbfbc9
|
||||
ShaderImporter:
|
||||
externalObjects: {}
|
||||
defaultTextures: []
|
||||
nonModifiableTextures: []
|
||||
preprocessorOverride: 0
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@ -0,0 +1,8 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 0e55987fbba11b749aed4c36b2c35230
|
||||
folderAsset: yes
|
||||
DefaultImporter:
|
||||
externalObjects: {}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@ -0,0 +1,84 @@
|
||||
Shader "Unlit/Hotspot"
|
||||
{
|
||||
Properties
|
||||
{
|
||||
_MainTex("Texture", 2D) = "white" {}
|
||||
_Color("Color", COLOR) = (1,1,1,1)
|
||||
_Progress("Progress",Range(0,1)) = 0
|
||||
_Highlight("Highlight Strength",Range(0,1)) = 0
|
||||
_HighlightColor("Highlight Color", COLOR) = (1,1,1,1)
|
||||
_ShrinkLimit("Shrink Limit",float) = 0.227
|
||||
[Toggle(NORMALS_SHRINK)] _NormalsShrink("Shrink along normal", Float) = 0
|
||||
}
|
||||
SubShader
|
||||
{
|
||||
Tags { "RenderType" = "Transparent" "Queue" = "Transparent-10" }
|
||||
LOD 100
|
||||
Blend SrcAlpha OneMinusSrcAlpha
|
||||
Pass
|
||||
{
|
||||
CGPROGRAM
|
||||
#pragma vertex vert
|
||||
#pragma fragment frag
|
||||
#pragma multi_compile_fwdbase nolightmap nodirlightmap nodynlightmap novertexlight
|
||||
#pragma multi_compile_local __ NORMALS_SHRINK
|
||||
|
||||
#include "UnityCG.cginc"
|
||||
|
||||
struct VertexInput
|
||||
{
|
||||
float4 vertex : POSITION;
|
||||
float2 uv : TEXCOORD0;
|
||||
#if NORMALS_SHRINK
|
||||
float3 normal : NORMAL;
|
||||
#endif
|
||||
UNITY_VERTEX_INPUT_INSTANCE_ID
|
||||
};
|
||||
|
||||
struct VertexOutput
|
||||
{
|
||||
float2 uv : TEXCOORD0;
|
||||
float4 vertex : SV_POSITION;
|
||||
UNITY_VERTEX_INPUT_INSTANCE_ID
|
||||
UNITY_VERTEX_OUTPUT_STEREO
|
||||
};
|
||||
|
||||
sampler2D _MainTex;
|
||||
half4 _Color;
|
||||
half _Progress;
|
||||
half _Highlight;
|
||||
half4 _HighlightColor;
|
||||
half _ShrinkLimit;
|
||||
|
||||
VertexOutput vert(VertexInput v)
|
||||
{
|
||||
VertexOutput o;
|
||||
UNITY_SETUP_INSTANCE_ID(v);
|
||||
UNITY_INITIALIZE_VERTEX_OUTPUT_STEREO(o);
|
||||
UNITY_TRANSFER_INSTANCE_ID(v, o);
|
||||
|
||||
#if NORMALS_SHRINK
|
||||
float2 radius = v.normal.xz;
|
||||
#else
|
||||
float2 radius = v.uv - float2(0.5, 0.5);
|
||||
radius = normalize(radius);
|
||||
_Progress = 1 - _Progress;
|
||||
#endif
|
||||
half2 shrink = radius * _Progress * _ShrinkLimit;
|
||||
v.vertex.xz += shrink;
|
||||
v.uv -= shrink;
|
||||
o.vertex = UnityObjectToClipPos(v.vertex);
|
||||
o.uv = v.uv;
|
||||
return o;
|
||||
}
|
||||
|
||||
half4 frag(VertexOutput i) : SV_Target
|
||||
{
|
||||
half4 col = tex2D(_MainTex, i.uv) * _Color;
|
||||
col.rgb = lerp(col.rgb, _HighlightColor.rgb, _Highlight * _HighlightColor.a);
|
||||
return col;
|
||||
}
|
||||
ENDCG
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -0,0 +1,10 @@
|
||||
fileFormatVersion: 2
|
||||
guid: c6205320beaf25644968a9120395a1ad
|
||||
ShaderImporter:
|
||||
externalObjects: {}
|
||||
defaultTextures: []
|
||||
nonModifiableTextures: []
|
||||
preprocessorOverride: 0
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@ -0,0 +1,83 @@
|
||||
Shader "Unlit/TransparentVertexTexture"
|
||||
{
|
||||
Properties
|
||||
{
|
||||
_Color("Color",COLOR) = (1,1,1,1)
|
||||
_FadeLimit("Fade Limit",VECTOR) = (0,0,1,1)
|
||||
_FadeSign("Fade Sign",Range(-1,1)) = 1
|
||||
_Fade("Fade",Range(0,1)) = 1
|
||||
_Highlight("Highlight Strength",Range(0,1)) = 0
|
||||
_HighlightColor("Highlight Color", COLOR) = (1,1,1,1)
|
||||
|
||||
_OffsetFactor("Offset Factor", float) = 0
|
||||
_OffsetUnits("Offset Units", float) = 0
|
||||
}
|
||||
SubShader
|
||||
{
|
||||
Tags { "RenderType"="Transparent" "Queue"="Transparent" }
|
||||
LOD 100
|
||||
Blend SrcAlpha OneMinusSrcAlpha
|
||||
|
||||
Pass
|
||||
{
|
||||
Offset[_OffsetFactor],[_OffsetUnits]
|
||||
CGPROGRAM
|
||||
#pragma vertex vert
|
||||
#pragma fragment frag
|
||||
#pragma multi_compile_fwdbase nolightmap nodirlightmap nodynlightmap novertexlight
|
||||
|
||||
#include "UnityCG.cginc"
|
||||
|
||||
struct VertexInput
|
||||
{
|
||||
float4 vertex : POSITION;
|
||||
float4 color : COLOR;
|
||||
float2 uv : TEXCOORD0;
|
||||
UNITY_VERTEX_INPUT_INSTANCE_ID
|
||||
};
|
||||
|
||||
struct VertexOutput
|
||||
{
|
||||
float4 vertex : SV_POSITION;
|
||||
float4 color : TEXCOORD1;
|
||||
float2 uv : TEXCOORD0;
|
||||
UNITY_VERTEX_INPUT_INSTANCE_ID
|
||||
UNITY_VERTEX_OUTPUT_STEREO
|
||||
};
|
||||
|
||||
half4 _Color;
|
||||
half4 _FadeLimit;
|
||||
half _FadeSign;
|
||||
half _Fade;
|
||||
half _Highlight;
|
||||
half4 _HighlightColor;
|
||||
|
||||
float _OffsetFactor;
|
||||
float _OffsetUnits;
|
||||
|
||||
VertexOutput vert (VertexInput v)
|
||||
{
|
||||
VertexOutput o;
|
||||
UNITY_SETUP_INSTANCE_ID(v);
|
||||
UNITY_INITIALIZE_VERTEX_OUTPUT_STEREO(o);
|
||||
UNITY_TRANSFER_INSTANCE_ID(v, o);
|
||||
|
||||
o.vertex = UnityObjectToClipPos(v.vertex);
|
||||
o.uv = v.uv;
|
||||
o.color = lerp(v.color * _Color, _HighlightColor, _Highlight);
|
||||
return o;
|
||||
}
|
||||
|
||||
half4 frag(VertexOutput i) : SV_Target
|
||||
{
|
||||
half4 color = i.color;
|
||||
half lowLimit = smoothstep(_FadeLimit.x, _FadeLimit.y, i.uv.y);
|
||||
half highLimit = smoothstep(_FadeLimit.z, _FadeLimit.w, i.uv.y);
|
||||
color.a *= saturate(lowLimit - _FadeSign * highLimit) * _Fade;
|
||||
|
||||
return color;
|
||||
}
|
||||
ENDCG
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -0,0 +1,10 @@
|
||||
fileFormatVersion: 2
|
||||
guid: faff192ad5862624d8a3be26ae4d15d6
|
||||
ShaderImporter:
|
||||
externalObjects: {}
|
||||
defaultTextures: []
|
||||
nonModifiableTextures: []
|
||||
preprocessorOverride: 0
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@ -0,0 +1,71 @@
|
||||
/************************************************************************************
|
||||
Copyright : Copyright (c) Facebook Technologies, LLC and its affiliates. All rights reserved.
|
||||
|
||||
Your use of this SDK or tool is subject to the Oculus SDK License Agreement, available at
|
||||
https://developer.oculus.com/licenses/oculussdk/
|
||||
|
||||
Unless required by applicable law or agreed to in writing, the Utilities SDK distributed
|
||||
under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF
|
||||
ANY KIND, either express or implied. See the License for the specific language governing
|
||||
permissions and limitations under the License.
|
||||
************************************************************************************/
|
||||
|
||||
Shader "Interaction/OculusControllerRayShader"
|
||||
{
|
||||
Properties
|
||||
{
|
||||
_Color0 ("Color0", Color) = (1,1,1,1)
|
||||
_Color1 ("Color1", Color) = (1,1,1,0)
|
||||
}
|
||||
SubShader
|
||||
{
|
||||
Tags
|
||||
{
|
||||
"Queue"="Transparent" "IgnoreProjector"="True" "RenderType"="Transparent"
|
||||
}
|
||||
LOD 100
|
||||
|
||||
ZWrite Off
|
||||
Blend SrcAlpha OneMinusSrcAlpha
|
||||
|
||||
Pass
|
||||
{
|
||||
CGPROGRAM
|
||||
#pragma vertex vert
|
||||
#pragma fragment frag
|
||||
|
||||
#include "UnityCG.cginc"
|
||||
|
||||
struct appdata {
|
||||
float4 vertex : POSITION;
|
||||
float2 uv : TEXCOORD0;
|
||||
UNITY_VERTEX_INPUT_INSTANCE_ID
|
||||
};
|
||||
|
||||
struct v2f {
|
||||
float2 uv : TEXCOORD0;
|
||||
float4 vertex : SV_POSITION;
|
||||
UNITY_VERTEX_OUTPUT_STEREO
|
||||
};
|
||||
|
||||
v2f vert(appdata v) {
|
||||
v2f o;
|
||||
UNITY_SETUP_INSTANCE_ID(v);
|
||||
UNITY_INITIALIZE_OUTPUT(v2f, o);
|
||||
UNITY_INITIALIZE_VERTEX_OUTPUT_STEREO(o);
|
||||
o.vertex = UnityObjectToClipPos(v.vertex);
|
||||
o.uv = v.vertex.zz * 2.0f;
|
||||
return o;
|
||||
}
|
||||
|
||||
uniform float4 _Color0;
|
||||
uniform float4 _Color1;
|
||||
|
||||
fixed4 frag(v2f i) : SV_Target {
|
||||
fixed4 col = lerp(_Color0, _Color1, clamp(i.uv.x, 0.0f, 1.0f) * 1.5f);
|
||||
return col;
|
||||
}
|
||||
ENDCG
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -0,0 +1,10 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 1fd0c0add1014e349be27442ff000696
|
||||
ShaderImporter:
|
||||
externalObjects: {}
|
||||
defaultTextures: []
|
||||
nonModifiableTextures: []
|
||||
preprocessorOverride: 0
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
231
Assets/Oculus/Interaction/Runtime/Shaders/OculusHand.shader
Normal file
231
Assets/Oculus/Interaction/Runtime/Shaders/OculusHand.shader
Normal file
@ -0,0 +1,231 @@
|
||||
/*
|
||||
* Copyright (c) Meta Platforms, Inc. and affiliates.
|
||||
* All rights reserved.
|
||||
*
|
||||
* Licensed under the Oculus SDK License Agreement (the "License");
|
||||
* you may not use the Oculus SDK except in compliance with the License,
|
||||
* which is provided at the time of installation or download, or which
|
||||
* otherwise accompanies this software in either electronic or hard copy form.
|
||||
*
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* https://developer.oculus.com/licenses/oculussdk/
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, the Oculus SDK
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
Shader "Interaction/OculusHand"
|
||||
{
|
||||
Properties
|
||||
{
|
||||
[Header(General)]
|
||||
_ColorTop("Color Top", Color) = (0.1960784, 0.2039215, 0.2117647, 1)
|
||||
_ColorBottom("Color Bottom", Color) = (0.1215686, 0.1254902, 0.1294117, 1)
|
||||
_Opacity("Opacity", Range(0 , 1)) = 0.8
|
||||
|
||||
[Header(Fresnel)]
|
||||
_FresnelPower("FresnelPower", Range(0 , 5)) = 0.16
|
||||
|
||||
[Header(Outline)]
|
||||
_OutlineColor("Outline Color", Color) = (0.5377358,0.5377358,0.5377358,1)
|
||||
_OutlineJointColor("Outline Joint Error Color", Color) = (1,0,0,1)
|
||||
_OutlineWidth("Outline Width", Range(0 , 0.005)) = 0.00134
|
||||
_OutlineOpacity("Outline Opacity", Range(0 , 1)) = 0.4
|
||||
|
||||
[Header(Wrist)]
|
||||
_WristFade("Wrist Fade", Range(0 , 1)) = 0.5
|
||||
|
||||
[Header(Finger Glow)]
|
||||
_FingerGlowMask("Finger Glow Mask", 2D) = "white" {}
|
||||
|
||||
[HideInInspector] _texcoord("", 2D) = "white" {}
|
||||
_GlowColor("GlowColor", Color) = (1,1,1,1)
|
||||
[HideInInspector] _ThumbGlowValue("", Float) = 0
|
||||
[HideInInspector] _IndexGlowValue("", Float) = 0
|
||||
[HideInInspector] _MiddleGlowValue("", Float) = 0
|
||||
[HideInInspector] _RingGlowValue("", Float) = 0
|
||||
[HideInInspector] _PinkyGlowValue("", Float) = 0
|
||||
[HideInInspector] _GenerateGlow("", Int) = 0
|
||||
[HideInInspector] _OcclusionEnabled("", Int) = 0
|
||||
}
|
||||
|
||||
CGINCLUDE
|
||||
#include "UnityCG.cginc"
|
||||
|
||||
#pragma target 2.0
|
||||
|
||||
// CBUFFER named UnityPerMaterial, SRP can cache the material properties between frames and reduce significantly the cost of each drawcall.
|
||||
CBUFFER_START(UnityPerMaterial)
|
||||
// General
|
||||
uniform float4 _ColorTop;
|
||||
uniform float4 _ColorBottom;
|
||||
uniform float _Opacity;
|
||||
uniform float _FresnelPower;
|
||||
|
||||
// Outline
|
||||
uniform float4 _OutlineColor;
|
||||
uniform half4 _OutlineJointColor;
|
||||
uniform float _OutlineWidth;
|
||||
uniform float _OutlineOpacity;
|
||||
|
||||
// Wrist
|
||||
uniform half _WristFade;
|
||||
|
||||
// Finger Glow
|
||||
uniform sampler2D _FingerGlowMask;
|
||||
|
||||
uniform float _ThumbGlowValue;
|
||||
uniform float _IndexGlowValue;
|
||||
uniform float _MiddleGlowValue;
|
||||
uniform float _RingGlowValue;
|
||||
uniform float _PinkyGlowValue;
|
||||
|
||||
uniform int _FingerGlowIndex;
|
||||
|
||||
uniform int _GenerateGlow;
|
||||
uniform float3 _GlowColor;
|
||||
|
||||
uniform float3 _GlowPosition;
|
||||
uniform float _GlowParameter;
|
||||
uniform float _GlowMaxLength;
|
||||
uniform int _GlowType;
|
||||
|
||||
//Finger Masks
|
||||
//Finger Tip To Knuckles
|
||||
uniform float4 _ThumbLine;
|
||||
uniform float4 _IndexLine;
|
||||
uniform float4 _MiddleLine;
|
||||
uniform float4 _RingLine;
|
||||
uniform float4 _PinkyLine;
|
||||
//Finger Tip To Palm
|
||||
uniform float4 _PalmThumbLine;
|
||||
uniform float4 _PalmIndexLine;
|
||||
uniform float4 _PalmMiddleLine;
|
||||
uniform float4 _PalmRingLine;
|
||||
uniform float4 _PalmPinkyLine;
|
||||
|
||||
CBUFFER_END
|
||||
ENDCG
|
||||
|
||||
SubShader
|
||||
{
|
||||
Tags
|
||||
{
|
||||
"RenderType" = "Transparent" "Queue" = "Transparent" "IgnoreProjector" = "True"
|
||||
}
|
||||
|
||||
Cull Back
|
||||
AlphaToMask Off
|
||||
|
||||
Pass
|
||||
{
|
||||
Name "Depth"
|
||||
ZWrite On
|
||||
ColorMask 0
|
||||
}
|
||||
|
||||
Pass
|
||||
{
|
||||
Name "HandOutline"
|
||||
Tags
|
||||
{
|
||||
"RenderType" = "Transparent" "Queue" = "Transparent" "IgnoreProjector" = "True"
|
||||
}
|
||||
|
||||
Cull Front
|
||||
Blend SrcAlpha OneMinusSrcAlpha
|
||||
Stencil
|
||||
{
|
||||
Ref 1
|
||||
Comp Always
|
||||
Pass Replace
|
||||
}
|
||||
|
||||
CGPROGRAM
|
||||
#pragma vertex outlineVertex
|
||||
#pragma fragment outlineFragment
|
||||
#include "OculusHandOutlineCG.cginc"
|
||||
ENDCG
|
||||
}
|
||||
|
||||
Pass
|
||||
{
|
||||
PackageRequirements { "com.unity.render-pipelines.universal": "10.0.0" }
|
||||
Name "HandOutlineURP"
|
||||
Tags
|
||||
{
|
||||
"LightMode" = "UniversalForwardOnly" "RenderType" = "Transparent" "Queue" = "Transparent" "IgnoreProjector" = "True" "RenderPipeline" = "UniversalPipeline"
|
||||
}
|
||||
|
||||
Cull Front
|
||||
Blend SrcAlpha OneMinusSrcAlpha
|
||||
Stencil
|
||||
{
|
||||
Ref 1
|
||||
Comp Always
|
||||
Pass Replace
|
||||
}
|
||||
|
||||
CGPROGRAM
|
||||
#pragma vertex outlineVertex
|
||||
#pragma fragment outlineFragment
|
||||
#include "OculusHandOutlineCG.cginc"
|
||||
ENDCG
|
||||
}
|
||||
|
||||
Pass
|
||||
{
|
||||
Name "HandFill"
|
||||
Tags
|
||||
{
|
||||
"RenderType" = "Transparent" "Queue" = "Transparent" "IgnoreProjector" = "True"
|
||||
}
|
||||
|
||||
Blend SrcAlpha OneMinusSrcAlpha
|
||||
ZWrite Off
|
||||
ZTest LEqual
|
||||
Stencil
|
||||
{
|
||||
Ref 1
|
||||
Comp Always
|
||||
Pass Replace
|
||||
}
|
||||
|
||||
CGPROGRAM
|
||||
#pragma vertex baseVertex
|
||||
#pragma fragment baseFragment
|
||||
#include "OculusHandFillCG.cginc"
|
||||
ENDCG
|
||||
}
|
||||
|
||||
Pass
|
||||
{
|
||||
PackageRequirements { "com.unity.render-pipelines.universal": "10.0.0" }
|
||||
Name "HandFillURP"
|
||||
Tags
|
||||
{
|
||||
"LightMode" = "UniversalForward" "RenderType" = "Transparent" "Queue" = "Transparent" "IgnoreProjector" = "True" "RenderPipeline" = "UniversalPipeline"
|
||||
}
|
||||
|
||||
Blend SrcAlpha OneMinusSrcAlpha
|
||||
ZWrite Off
|
||||
ZTest LEqual
|
||||
Stencil
|
||||
{
|
||||
Ref 1
|
||||
Comp Always
|
||||
Pass Replace
|
||||
}
|
||||
|
||||
CGPROGRAM
|
||||
#pragma vertex baseVertex
|
||||
#pragma fragment baseFragment
|
||||
#include "OculusHandFillCG.cginc"
|
||||
ENDCG
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -0,0 +1,9 @@
|
||||
fileFormatVersion: 2
|
||||
guid: b895d3431e75dc345a72e171f82bfbea
|
||||
ShaderImporter:
|
||||
externalObjects: {}
|
||||
defaultTextures: []
|
||||
nonModifiableTextures: []
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@ -0,0 +1,140 @@
|
||||
/************************************************************************************
|
||||
Copyright : Copyright (c) Facebook Technologies, LLC and its affiliates. All rights reserved.
|
||||
|
||||
Your use of this SDK or tool is subject to the Oculus SDK License Agreement, available at
|
||||
https://developer.oculus.com/licenses/oculussdk/
|
||||
|
||||
Unless required by applicable law or agreed to in writing, the Utilities SDK distributed
|
||||
under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF
|
||||
ANY KIND, either express or implied. See the License for the specific language governing
|
||||
permissions and limitations under the License.
|
||||
************************************************************************************/
|
||||
|
||||
Shader "Interaction/OculusHandCursor"
|
||||
{
|
||||
Properties
|
||||
{
|
||||
_OutlineWidth("OutlineWidth", Range( 0 , 0.4)) = 0.03
|
||||
_CenterSize("Center Size", Range( 0 , 0.5)) = 0.15
|
||||
_Color("Inner Color", Color) = (0,0,0,0)
|
||||
_OutlineColor("OutlineColor", Color) = (0,0.4410214,1,0)
|
||||
_Alpha("Alpha", Range( 0 , 1)) = 0
|
||||
_RadialGradientIntensity("RadialGradientIntensity", Range( 0 , 1)) = 0
|
||||
_RadialGradientScale("RadialGradientScale", Range( 0 , 1)) = 1
|
||||
_RadialGradientBackgroundOpacity("RadialGradientBackgroundOpacity", Range( 0 , 1)) = 0.1
|
||||
_RadialGradientOpacity("RadialGradientOpacity", Range( 0 , 1)) = 0.8550259
|
||||
[HideInInspector] _texcoord( "", 2D ) = "white" {}
|
||||
[HideInInspector] __dirty( "", Int ) = 1
|
||||
}
|
||||
|
||||
SubShader
|
||||
{
|
||||
Tags{ "RenderType" = "Transparent" "Queue" = "Transparent+10" "IgnoreProjector" = "True" }
|
||||
Cull Off
|
||||
ZTest LEqual
|
||||
ZWrite Off
|
||||
Blend SrcAlpha OneMinusSrcAlpha
|
||||
|
||||
Offset -5, -5
|
||||
Pass
|
||||
{
|
||||
CGPROGRAM
|
||||
#pragma vertex vert
|
||||
#pragma fragment frag
|
||||
|
||||
#include "UnityCG.cginc"
|
||||
|
||||
uniform float _RadialGradientScale;
|
||||
uniform float _RadialGradientOpacity;
|
||||
uniform float _RadialGradientIntensity;
|
||||
uniform float _RadialGradientBackgroundOpacity;
|
||||
uniform float _OutlineWidth;
|
||||
uniform float4 _Color;
|
||||
uniform float4 _OutlineColor;
|
||||
uniform float _CenterSize;
|
||||
uniform float _Alpha;
|
||||
|
||||
struct appdata
|
||||
{
|
||||
float4 vertex : POSITION;
|
||||
float2 uv_texcoord : TEXCOORD0;
|
||||
UNITY_VERTEX_INPUT_INSTANCE_ID
|
||||
};
|
||||
|
||||
struct v2f
|
||||
{
|
||||
float2 uv_texcoord : TEXCOORD0;
|
||||
float4 vertex : SV_POSITION;
|
||||
UNITY_VERTEX_OUTPUT_STEREO
|
||||
};
|
||||
|
||||
v2f vert(appdata v)
|
||||
{
|
||||
v2f o;
|
||||
UNITY_SETUP_INSTANCE_ID(v);
|
||||
UNITY_INITIALIZE_OUTPUT(v2f, o);
|
||||
UNITY_INITIALIZE_VERTEX_OUTPUT_STEREO(o);
|
||||
o.vertex = UnityObjectToClipPos(v.vertex);
|
||||
o.uv_texcoord = v.uv_texcoord;
|
||||
return o;
|
||||
}
|
||||
|
||||
fixed4 frag(v2f i) : SV_Target
|
||||
{
|
||||
float RadialGradientScaleRaw149 = _RadialGradientScale;
|
||||
float RadialGradientScale94 = (0.16 + (_RadialGradientScale - 0.0) * (0.45 - 0.16) / (1.0 - 0.0));
|
||||
float temp_output_1_0_g49 = ( 1.0 - ( ( distance( i.uv_texcoord , float2( 0.5,0.5 ) ) * 1.0 ) / RadialGradientScale94 ) );
|
||||
float RadialGradientIntensity96 = (5.0 + (_RadialGradientIntensity - 0.0) * (1.5 - 5.0) / (1.0 - 0.0));
|
||||
float ifLocalVar12_g49 = 0;
|
||||
if( temp_output_1_0_g49 <= 0.0 )
|
||||
ifLocalVar12_g49 = 1.0;
|
||||
else
|
||||
ifLocalVar12_g49 = ( 1.0 / pow( 2.718282 , ( temp_output_1_0_g49 * RadialGradientIntensity96 ) ) );
|
||||
float temp_output_1_0_g47 = ( 1.0 - ( ( distance( i.uv_texcoord , float2( 0.5,0.5 ) ) * 1.0 ) / RadialGradientScale94 ) );
|
||||
float RadialDensity131 = 70.0;
|
||||
float ifLocalVar12_g47 = 0;
|
||||
if( temp_output_1_0_g47 <= 0.0 )
|
||||
ifLocalVar12_g47 = 1.0;
|
||||
else
|
||||
ifLocalVar12_g47 = ( 1.0 / pow( 2.718282 , ( temp_output_1_0_g47 * RadialDensity131 ) ) );
|
||||
float temp_output_75_0 = ( 1.0 - ifLocalVar12_g47 );
|
||||
float RadialGradient102 = saturate( ( ( _RadialGradientOpacity * ( ( 1.0 - ( 1.0 - ifLocalVar12_g49 ) ) - ( 1.0 - temp_output_75_0 ) ) ) + ( temp_output_75_0 * _RadialGradientBackgroundOpacity ) ) );
|
||||
float temp_output_1_0_g77 = ( 1.0 - ( ( distance( i.uv_texcoord , float2( 0.5,0.5 ) ) * 1.0 ) / ( RadialGradientScale94 + _OutlineWidth ) ) );
|
||||
float ifLocalVar12_g77 = 0;
|
||||
if( temp_output_1_0_g77 <= 0.0 )
|
||||
ifLocalVar12_g77 = 1.0;
|
||||
else
|
||||
ifLocalVar12_g77 = ( 1.0 / pow( 2.718282 , ( temp_output_1_0_g77 * 20.0 ) ) );
|
||||
float4 RadialGradientWithOutline147 = ( RadialGradient102 + ( ( ( 1.0 - ifLocalVar12_g77 ) - temp_output_75_0 ) * _OutlineColor ) );
|
||||
float temp_output_1_0_g81 = ( 1.0 - ( ( distance( i.uv_texcoord , float2( 0.5,0.5 ) ) * 1.0 ) / _CenterSize ) );
|
||||
float RadialDensityOutline189 = 20.0;
|
||||
float ifLocalVar12_g81 = 0;
|
||||
if( temp_output_1_0_g81 <= 0.0 )
|
||||
ifLocalVar12_g81 = 1.0;
|
||||
else
|
||||
ifLocalVar12_g81 = ( 1.0 / pow( 2.718282 , ( temp_output_1_0_g81 * RadialDensityOutline189 ) ) );
|
||||
float temp_output_1_0_g79 = ( 1.0 - ( ( distance( i.uv_texcoord , float2( 0.5,0.5 ) ) * 1.0 ) / ( _CenterSize + 0.06 ) ) );
|
||||
float ifLocalVar12_g79 = 0;
|
||||
if( temp_output_1_0_g79 <= 0.0 )
|
||||
ifLocalVar12_g79 = 1.0;
|
||||
else
|
||||
ifLocalVar12_g79 = ( 1.0 / pow( 2.718282 , ( temp_output_1_0_g79 * RadialDensityOutline189 ) ) );
|
||||
float4 OutlineColor183 = _OutlineColor;
|
||||
float4 CenterDot143 = ( ( 1.0 - ifLocalVar12_g81 ) + ( ( 1.0 - ifLocalVar12_g79 ) * OutlineColor183 ) );
|
||||
float4 ifLocalVar29 = 0;
|
||||
if( RadialGradientScaleRaw149 <= 0.1 )
|
||||
ifLocalVar29 = CenterDot143;
|
||||
else
|
||||
ifLocalVar29 = RadialGradientWithOutline147;
|
||||
float4 Emission151 = ifLocalVar29 * _Color;
|
||||
|
||||
float Opacity152 = ((ifLocalVar29).a * _Alpha);
|
||||
if (Opacity152 < 0.01)
|
||||
discard;
|
||||
return float4 (Emission151.rgb, Opacity152);
|
||||
}
|
||||
ENDCG
|
||||
}
|
||||
}
|
||||
Fallback "Diffuse"
|
||||
}
|
||||
@ -0,0 +1,9 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 57c328e70d404164ab9b23ac6fc12df6
|
||||
ShaderImporter:
|
||||
externalObjects: {}
|
||||
defaultTextures: []
|
||||
nonModifiableTextures: []
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
147
Assets/Oculus/Interaction/Runtime/Shaders/OculusHandFillCG.cginc
Normal file
147
Assets/Oculus/Interaction/Runtime/Shaders/OculusHandFillCG.cginc
Normal file
@ -0,0 +1,147 @@
|
||||
/*
|
||||
* Copyright (c) Meta Platforms, Inc. and affiliates.
|
||||
* All rights reserved.
|
||||
*
|
||||
* Licensed under the Oculus SDK License Agreement (the "License");
|
||||
* you may not use the Oculus SDK except in compliance with the License,
|
||||
* which is provided at the time of installation or download, or which
|
||||
* otherwise accompanies this software in either electronic or hard copy form.
|
||||
*
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* https://developer.oculus.com/licenses/oculussdk/
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, the Oculus SDK
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
#pragma multi_compile_fwdbase nolightmap nodirlightmap nodynlightmap novertexlight
|
||||
|
||||
#pragma prefer_hlslcc gles
|
||||
#pragma exclude_renderers d3d11_9x
|
||||
#pragma target 2.0
|
||||
|
||||
//
|
||||
|
||||
struct VertexInput {
|
||||
float4 vertex : POSITION;
|
||||
half3 normal : NORMAL;
|
||||
half4 vertexColor : COLOR;
|
||||
float4 texcoord : TEXCOORD0;
|
||||
float4 texcoord1 : TEXCOORD1;
|
||||
UNITY_VERTEX_INPUT_INSTANCE_ID
|
||||
};
|
||||
|
||||
struct VertexOutput {
|
||||
float4 vertex : SV_POSITION;
|
||||
float3 worldPos : TEXCOORD1;
|
||||
float3 worldNormal : TEXCOORD2;
|
||||
half4 glowColor : COLOR;
|
||||
float4 texcoord1 : TEXCOORD3;
|
||||
UNITY_VERTEX_INPUT_INSTANCE_ID
|
||||
UNITY_VERTEX_OUTPUT_STEREO
|
||||
};
|
||||
|
||||
VertexOutput baseVertex(VertexInput v) {
|
||||
VertexOutput o;
|
||||
UNITY_SETUP_INSTANCE_ID(v);
|
||||
UNITY_INITIALIZE_VERTEX_OUTPUT_STEREO(o);
|
||||
UNITY_TRANSFER_INSTANCE_ID(v, o);
|
||||
|
||||
o.worldPos = mul(unity_ObjectToWorld, v.vertex);
|
||||
o.worldNormal = UnityObjectToWorldNormal(v.normal);
|
||||
o.vertex = UnityObjectToClipPos(v.vertex);
|
||||
o.texcoord1 = v.texcoord1;
|
||||
half4 maskPixelColor = tex2Dlod( _FingerGlowMask, float4(v.texcoord.xy, 0.0, 0.0));
|
||||
o.glowColor.rgb = float3(0.0, 0.0, 0.0);
|
||||
o.glowColor.a = saturate(maskPixelColor.a + _WristFade) * _Opacity;
|
||||
return o;
|
||||
}
|
||||
|
||||
#include "GlowFunctions.cginc"
|
||||
|
||||
void getFingerStrength(out float fingerStrength[5]) {
|
||||
float strengthValuesUniforms[5] = {
|
||||
_ThumbGlowValue,
|
||||
_IndexGlowValue,
|
||||
_MiddleGlowValue,
|
||||
_RingGlowValue,
|
||||
_PinkyGlowValue
|
||||
};
|
||||
fingerStrength = strengthValuesUniforms;
|
||||
}
|
||||
|
||||
void getFillFingerLines(out float4 lines[5]) {
|
||||
float4 _lines[5] = {
|
||||
_ThumbLine,
|
||||
_IndexLine,
|
||||
_MiddleLine,
|
||||
_RingLine,
|
||||
_PinkyLine
|
||||
};
|
||||
lines = _lines;
|
||||
}
|
||||
|
||||
float4 getFillFingerLineByIndex(int index) {
|
||||
if(index == 0) { return _ThumbLine; }
|
||||
if(index == 1) { return _IndexLine; }
|
||||
if(index == 2) { return _MiddleLine; }
|
||||
if(index == 3) { return _RingLine; }
|
||||
if(index == 4) { return _PinkyLine; }
|
||||
return float4(0.0,0.0,0.0,0.0);
|
||||
}
|
||||
|
||||
half4 applyGlow(int glowType, float3 color, float alpha, float2 texCoord, float3 worldPosition) {
|
||||
if (glowType == 30 || glowType == 32) {
|
||||
float4 gradientLine = getFillFingerLineByIndex(_FingerGlowIndex);
|
||||
float2 gradientRadius = getFingerRadiusByIndex(_FingerGlowIndex);
|
||||
bool useGlow;
|
||||
float2 fingerGradient = movingFingerGradient(texCoord, gradientLine, gradientRadius, _GlowParameter, _GlowMaxLength, useGlow);
|
||||
if (useGlow) {
|
||||
float param = 1.0 - fingerGradient.y;
|
||||
float glowValue = saturate(param * param * step(0.0, param));
|
||||
return half4(color + _GlowColor * glowValue, alpha);
|
||||
}else {
|
||||
return half4(color, alpha);
|
||||
}
|
||||
}
|
||||
else if (glowType == 27 || glowType == 29) {
|
||||
float fingerStrength[5];
|
||||
getFingerStrength(fingerStrength);
|
||||
float4 lines[5];
|
||||
getFillFingerLines(lines);
|
||||
float2 fingerRadius[5];
|
||||
getFingerRadius(fingerRadius);
|
||||
float glowValue = movingFingersGradient(texCoord, fingerStrength, _GlowParameter, lines, fingerRadius);
|
||||
return half4(color + _GlowColor * glowValue, alpha);
|
||||
}
|
||||
else if (glowType == 16 || glowType == 17) {
|
||||
float gradient = invertedSphereGradient(_GlowPosition, worldPosition, _GlowMaxLength);
|
||||
float3 glowColor = _GlowColor * gradient * _GlowParameter;
|
||||
return float4(saturate(color + glowColor), alpha);
|
||||
}
|
||||
else if (glowType == 11 || glowType == 15) {
|
||||
float gradient = movingSphereGradient(_GlowPosition, worldPosition, _GlowMaxLength, _GlowParameter, 1.5);
|
||||
float3 glowColor = _GlowColor * gradient;
|
||||
return float4(saturate(color + glowColor), alpha);
|
||||
}
|
||||
else {
|
||||
return half4(color, alpha);
|
||||
}
|
||||
}
|
||||
|
||||
half4 baseFragment(VertexOutput i) : SV_Target {
|
||||
float3 worldViewDir = normalize(UnityWorldSpaceViewDir(i.worldPos));
|
||||
float fresnelNdot = dot(i.worldNormal, worldViewDir);
|
||||
float fresnel = 1.0 * pow(1.0 - fresnelNdot, _FresnelPower);
|
||||
float4 color = lerp(_ColorTop, _ColorBottom, fresnel);
|
||||
|
||||
if (_GenerateGlow == 1) {
|
||||
return applyGlow(_GlowType, color.rgb, i.glowColor.a, i.texcoord1, i.worldPos);
|
||||
} else {
|
||||
return half4(color.rgb, i.glowColor.a);
|
||||
}
|
||||
}
|
||||
@ -0,0 +1,10 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 2806b25272d987d409c259aeab719be4
|
||||
ShaderImporter:
|
||||
externalObjects: {}
|
||||
defaultTextures: []
|
||||
nonModifiableTextures: []
|
||||
preprocessorOverride: 0
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@ -0,0 +1,146 @@
|
||||
/*
|
||||
* Copyright (c) Meta Platforms, Inc. and affiliates.
|
||||
* All rights reserved.
|
||||
*
|
||||
* Licensed under the Oculus SDK License Agreement (the "License");
|
||||
* you may not use the Oculus SDK except in compliance with the License,
|
||||
* which is provided at the time of installation or download, or which
|
||||
* otherwise accompanies this software in either electronic or hard copy form.
|
||||
*
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* https://developer.oculus.com/licenses/oculussdk/
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, the Oculus SDK
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
#pragma multi_compile_local __ CONFIDENCE
|
||||
|
||||
#pragma prefer_hlslcc gles
|
||||
#pragma exclude_renderers d3d11_9x
|
||||
#pragma target 2.0
|
||||
|
||||
//
|
||||
|
||||
struct OutlineVertexInput {
|
||||
float4 vertex : POSITION;
|
||||
float3 normal : NORMAL;
|
||||
float4 texcoord : TEXCOORD0;
|
||||
float4 texcoord1 : TEXCOORD1;
|
||||
UNITY_VERTEX_INPUT_INSTANCE_ID
|
||||
};
|
||||
|
||||
struct OutlineVertexOutput {
|
||||
float4 vertex : SV_POSITION;
|
||||
half4 color : TEXCOORD1;
|
||||
float3 worldPos : TEXCOORD2;
|
||||
float4 texcoord1 : TEXCOORD3;
|
||||
UNITY_VERTEX_INPUT_INSTANCE_ID
|
||||
UNITY_VERTEX_OUTPUT_STEREO
|
||||
};
|
||||
|
||||
OutlineVertexOutput outlineVertex(OutlineVertexInput v) {
|
||||
OutlineVertexOutput o;
|
||||
UNITY_SETUP_INSTANCE_ID(v);
|
||||
UNITY_INITIALIZE_VERTEX_OUTPUT_STEREO(o);
|
||||
UNITY_TRANSFER_INSTANCE_ID(v, o);
|
||||
|
||||
o.worldPos = mul(unity_ObjectToWorld, v.vertex);
|
||||
v.vertex.xyz += v.normal * _OutlineWidth;
|
||||
o.vertex = UnityObjectToClipPos(v.vertex);
|
||||
o.texcoord1 = v.texcoord1;
|
||||
half4 maskPixelColor = tex2Dlod(_FingerGlowMask, v.texcoord);
|
||||
o.color.rgb = _OutlineColor;
|
||||
o.color.a = saturate(maskPixelColor.a + _WristFade) * _OutlineColor.a *
|
||||
_OutlineOpacity;
|
||||
return o;
|
||||
}
|
||||
|
||||
#include "GlowFunctions.cginc"
|
||||
|
||||
void getFingerStrength(out float fingerStrength[5]) {
|
||||
float strengthValuesUniforms[5] = {
|
||||
_ThumbGlowValue,
|
||||
_IndexGlowValue,
|
||||
_MiddleGlowValue,
|
||||
_RingGlowValue,
|
||||
_PinkyGlowValue
|
||||
};
|
||||
fingerStrength = strengthValuesUniforms;
|
||||
}
|
||||
|
||||
void getOutlineFingerLines(out float4 lines[5]) {
|
||||
float4 _lines[5] = {
|
||||
_PalmThumbLine,
|
||||
_PalmIndexLine,
|
||||
_PalmMiddleLine,
|
||||
_PalmRingLine,
|
||||
_PalmPinkyLine
|
||||
};
|
||||
lines = _lines;
|
||||
}
|
||||
|
||||
float4 getOutlineFingerLinesByIndex(int index) {
|
||||
if(index == 0) { return _PalmThumbLine; }
|
||||
if(index == 1) { return _PalmIndexLine; }
|
||||
if(index == 2) { return _PalmMiddleLine; }
|
||||
if(index == 3) { return _PalmRingLine; }
|
||||
if(index == 4) { return _PalmPinkyLine; }
|
||||
return float4(0.0,0.0,0.0,0.0);
|
||||
}
|
||||
|
||||
half4 applyGlow(int glowType, float3 color, float alpha, float2 texCoord, float3 worldPosition) {
|
||||
if (glowType == 31 || glowType == 32) {
|
||||
float4 gradientLine = getOutlineFingerLinesByIndex(_FingerGlowIndex);
|
||||
float2 gradientRadius = getPalmFingerRadiusByIndex(_FingerGlowIndex);
|
||||
bool useGlow;
|
||||
float2 fingerGradient = movingFingerGradient(texCoord, gradientLine, gradientRadius, _GlowParameter, _GlowMaxLength, useGlow);
|
||||
if (useGlow) {
|
||||
float param = 1.0 - fingerGradient.y;
|
||||
float glowValue = saturate(param * param * step(0.0, param));
|
||||
return half4(color + _GlowColor * glowValue, alpha);
|
||||
}else {
|
||||
return half4(color, alpha);
|
||||
}
|
||||
}
|
||||
else if (glowType == 28 || glowType == 29) {
|
||||
float fingerStrength[5];
|
||||
getFingerStrength(fingerStrength);
|
||||
float4 lines[5];
|
||||
getOutlineFingerLines(lines);
|
||||
float2 fingerRadius[5];
|
||||
getPalmFingerRadius(fingerRadius);
|
||||
float glowValue = fingerLineGlow(texCoord, fingerStrength, 30, lines, fingerRadius);
|
||||
return half4(color + _GlowColor * glowValue, alpha);
|
||||
}
|
||||
else if (glowType == 16 || glowType == 18) {
|
||||
float gradient = invertedSphereGradient(_GlowPosition, worldPosition, _GlowMaxLength);
|
||||
float3 glowColor = _GlowColor * gradient * _GlowParameter;
|
||||
return float4(saturate(color + glowColor), alpha);
|
||||
}
|
||||
else if (glowType == 12 || glowType == 15) {
|
||||
float gradient = movingSphereGradient(_GlowPosition, worldPosition, _GlowMaxLength, _GlowParameter, 1.5);
|
||||
float3 glowColor = _GlowColor * gradient;
|
||||
return float4(saturate(color + glowColor), alpha);
|
||||
}
|
||||
else {
|
||||
return float4(color, alpha);
|
||||
}
|
||||
}
|
||||
|
||||
half4 outlineFragment(OutlineVertexOutput i) : SV_Target {
|
||||
UNITY_SETUP_INSTANCE_ID(i);
|
||||
UNITY_SETUP_STEREO_EYE_INDEX_POST_VERTEX(i);
|
||||
half4 fragColor;
|
||||
|
||||
if (_GenerateGlow == 1) {
|
||||
fragColor = applyGlow(_GlowType, i.color.rgb, i.color.a, i.texcoord1, i.worldPos);
|
||||
} else {
|
||||
fragColor = i.color;
|
||||
}
|
||||
return fragColor;
|
||||
}
|
||||
@ -0,0 +1,10 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 1ef476d3d3314714fbd78909394b2843
|
||||
ShaderImporter:
|
||||
externalObjects: {}
|
||||
defaultTextures: []
|
||||
nonModifiableTextures: []
|
||||
preprocessorOverride: 0
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
124
Assets/Oculus/Interaction/Runtime/Shaders/PolylineUnlit.shader
Normal file
124
Assets/Oculus/Interaction/Runtime/Shaders/PolylineUnlit.shader
Normal file
@ -0,0 +1,124 @@
|
||||
/************************************************************************************
|
||||
Copyright : Copyright (c) Facebook Technologies, LLC and its affiliates. All rights reserved.
|
||||
|
||||
Your use of this SDK or tool is subject to the Oculus SDK License Agreement, available at
|
||||
https://developer.oculus.com/licenses/oculussdk/
|
||||
|
||||
Unless required by applicable law or agreed to in writing, the Utilities SDK distributed
|
||||
under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF
|
||||
ANY KIND, either express or implied. See the License for the specific language governing
|
||||
permissions and limitations under the License.
|
||||
************************************************************************************/
|
||||
|
||||
Shader "Custom/PolylineUnlit" {
|
||||
|
||||
Properties { }
|
||||
|
||||
SubShader
|
||||
{
|
||||
|
||||
Tags { "Queue"="Geometry" }
|
||||
|
||||
Pass
|
||||
{
|
||||
CGPROGRAM
|
||||
#pragma vertex vert
|
||||
#pragma fragment frag
|
||||
#pragma multi_compile_fwdbase nolightmap nodirlightmap nodynlightmap novertexlight
|
||||
#pragma target 5.0
|
||||
#include "UnityCG.cginc"
|
||||
#include "./CubePointToSegment.cginc"
|
||||
#include "../ThirdParty/Shaders/CapsuleRayIntersect.cginc"
|
||||
|
||||
#if SHADER_TARGET >= 45
|
||||
StructuredBuffer<float4> _PositionBuffer;
|
||||
StructuredBuffer<float4> _ColorBuffer;
|
||||
#endif
|
||||
|
||||
struct appdata_full_instance : appdata_full
|
||||
{
|
||||
UNITY_VERTEX_INPUT_INSTANCE_ID
|
||||
};
|
||||
|
||||
struct v2f {
|
||||
float4 pos : SV_POSITION;
|
||||
sample float3 worldPos : TEXCOORD0;
|
||||
float4 p0 : TEXCOORD1;
|
||||
float4 p1 : TEXCOORD2;
|
||||
float4 col0 : TEXCOORD3;
|
||||
float4 col1 : TEXCOORD4;
|
||||
UNITY_VERTEX_OUTPUT_STEREO
|
||||
};
|
||||
|
||||
float _Scale;
|
||||
float4x4 _LocalToWorld;
|
||||
|
||||
v2f vert(appdata_full_instance v, uint instanceID : SV_InstanceID)
|
||||
{
|
||||
v2f o;
|
||||
|
||||
UNITY_SETUP_INSTANCE_ID(v);
|
||||
UNITY_INITIALIZE_OUTPUT(v2f, o);
|
||||
UNITY_INITIALIZE_VERTEX_OUTPUT_STEREO(o);
|
||||
|
||||
#if SHADER_TARGET >= 45
|
||||
float4 p0 = _PositionBuffer[instanceID * 2];
|
||||
float4 p1 = _PositionBuffer[instanceID * 2 + 1];
|
||||
float4 col0 = _ColorBuffer[instanceID * 2];
|
||||
float4 col1 = _ColorBuffer[instanceID * 2 + 1];
|
||||
#else
|
||||
float4 p0 = 0;
|
||||
float4 p1 = 0;
|
||||
float4 col0 = 0;
|
||||
float4 col1 = 0;
|
||||
#endif
|
||||
|
||||
float3 localPos = orientCubePointToSegmentWithWidth(v.vertex.xyz, p0.xyz, p1.xyz, p0.w, p0.w);
|
||||
float3 worldPos = mul(_LocalToWorld, float4(localPos, 1.0)).xyz;
|
||||
|
||||
// Apply VP matrix to model
|
||||
o.pos = mul(UNITY_MATRIX_VP, float4(worldPos, 1.0));
|
||||
o.worldPos = worldPos;
|
||||
o.p0 = float4(mul(_LocalToWorld, float4(p0.xyz, 1.0)).xyz, p0.w);
|
||||
o.p1 = float4(mul(_LocalToWorld, float4(p1.xyz, 1.0)).xyz, p1.w);
|
||||
o.col0 = col0;
|
||||
o.col1 = col1;
|
||||
|
||||
return o;
|
||||
}
|
||||
|
||||
fixed4 frag (v2f i, out float out_depth : SV_Depth) : SV_Target
|
||||
{
|
||||
UNITY_SETUP_STEREO_EYE_INDEX_POST_VERTEX(i);
|
||||
float3 rayDir = normalize(i.worldPos - _WorldSpaceCameraPos.xyz);
|
||||
float dist = capIntersect(_WorldSpaceCameraPos.xyz, rayDir, i.p0, i.p1,
|
||||
i.p0.w/2.0f * _Scale); // hardcoded sphere at 0,0,0 radius .5
|
||||
clip(dist);
|
||||
|
||||
// calculate world space hit position
|
||||
float3 hitPos = _WorldSpaceCameraPos.xyz + rayDir * dist;
|
||||
|
||||
// set output depth
|
||||
float4 clipPos = UnityWorldToClipPos(hitPos);
|
||||
|
||||
out_depth = clipPos.z / clipPos.w;
|
||||
|
||||
#if !defined(UNITY_REVERSED_Z)
|
||||
out_depth = out_depth * 0.5 + 0.5;
|
||||
#endif
|
||||
|
||||
float3 vec = i.p1.xyz - i.p0.xyz;
|
||||
float dotvecvec = dot(vec, vec);
|
||||
float t = 0.0f;
|
||||
if(abs(dotvecvec) > 0.0f)
|
||||
{
|
||||
float3 toHit = hitPos - i.p0.xyz;
|
||||
t = dot(toHit, vec)/dotvecvec;
|
||||
}
|
||||
return float4(lerp(i.col0, i.col1, t).rgb, 1.0f);
|
||||
}
|
||||
ENDCG
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
@ -0,0 +1,9 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 8fd0b9a6fa1abd34393da45b7f791d6f
|
||||
ShaderImporter:
|
||||
externalObjects: {}
|
||||
defaultTextures: []
|
||||
nonModifiableTextures: []
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
195
Assets/Oculus/Interaction/Runtime/Shaders/RoundedBoxUnlit.shader
Normal file
195
Assets/Oculus/Interaction/Runtime/Shaders/RoundedBoxUnlit.shader
Normal file
@ -0,0 +1,195 @@
|
||||
/************************************************************************************
|
||||
Copyright : Copyright (c) Facebook Technologies, LLC and its affiliates. All rights reserved.
|
||||
|
||||
Your use of this SDK or tool is subject to the Oculus SDK License Agreement, available at
|
||||
https://developer.oculus.com/licenses/oculussdk/
|
||||
|
||||
Unless required by applicable law or agreed to in writing, the Utilities SDK distributed
|
||||
under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF
|
||||
ANY KIND, either express or implied. See the License for the specific language governing
|
||||
permissions and limitations under the License.
|
||||
************************************************************************************/
|
||||
|
||||
Shader "Interaction/RoundedBoxUnlit"
|
||||
{
|
||||
Properties
|
||||
{
|
||||
_Color("Color", Color) = (0, 0, 0, 1)
|
||||
|
||||
_BorderColor("BorderColor", Color) = (0, 0, 0, 1)
|
||||
|
||||
// width, height, border radius, unused
|
||||
_Dimensions("Dimensions", Vector) = (0, 0, 0, 0)
|
||||
|
||||
// radius corners
|
||||
_Radii("Radii", Vector) = (0, 0, 0, 0)
|
||||
|
||||
// defaults to LEqual
|
||||
[Enum(UnityEngine.Rendering.CompareFunction)] _ZTest("ZTest", Float) = 4
|
||||
|
||||
//Border X, Inner Y
|
||||
_ProximityStrength("Proximity Strength", Vector) = (0,0,0,0)
|
||||
_ProximityTransitionRange("Proximity Transition Range", Vector) = (0,1,0,0)
|
||||
_ProximityColor("Proximity Color", Color) = (0,0,0,1)
|
||||
}
|
||||
|
||||
SubShader
|
||||
{
|
||||
Tags
|
||||
{
|
||||
"Queue"="Transparent" "RenderType"="Transparent"
|
||||
}
|
||||
ZWrite Off
|
||||
Blend SrcAlpha OneMinusSrcAlpha
|
||||
ZTest [_ZTest]
|
||||
LOD 100
|
||||
|
||||
Pass
|
||||
{
|
||||
CGPROGRAM
|
||||
#pragma vertex vert
|
||||
#pragma fragment frag
|
||||
#pragma multi_compile_instancing
|
||||
|
||||
#include "UnityCG.cginc"
|
||||
#include "../ThirdParty/Box2DSignedDistance.cginc"
|
||||
|
||||
struct appdata
|
||||
{
|
||||
UNITY_VERTEX_INPUT_INSTANCE_ID
|
||||
float4 vertex : POSITION;
|
||||
float2 uv : TEXCOORD0;
|
||||
};
|
||||
|
||||
struct v2f
|
||||
{
|
||||
float4 vertex : SV_POSITION;
|
||||
float2 uv : TEXCOORD0;
|
||||
fixed4 color : COLOR;
|
||||
fixed4 borderColor : TEXCOORD1;
|
||||
fixed4 dimensions : TEXCOORD2;
|
||||
fixed4 radii : TEXCOORD3;
|
||||
fixed3 positionWorld: TEXCOORD4;
|
||||
UNITY_VERTEX_INPUT_INSTANCE_ID
|
||||
UNITY_VERTEX_OUTPUT_STEREO
|
||||
};
|
||||
|
||||
UNITY_INSTANCING_BUFFER_START(Props)
|
||||
UNITY_DEFINE_INSTANCED_PROP(fixed4, _Color)
|
||||
UNITY_DEFINE_INSTANCED_PROP(fixed4, _BorderColor)
|
||||
UNITY_DEFINE_INSTANCED_PROP(fixed4, _Dimensions)
|
||||
UNITY_DEFINE_INSTANCED_PROP(fixed4, _Radii)
|
||||
//Proximity Spheres XYZ position W radius
|
||||
UNITY_DEFINE_INSTANCED_PROP(int, _ProximitySphereCount)
|
||||
UNITY_DEFINE_INSTANCED_PROP(fixed4, _ProximitySphere0)
|
||||
UNITY_DEFINE_INSTANCED_PROP(fixed4, _ProximitySphere1)
|
||||
UNITY_DEFINE_INSTANCED_PROP(fixed4, _ProximitySphere2)
|
||||
UNITY_DEFINE_INSTANCED_PROP(fixed4, _ProximitySphere3)
|
||||
UNITY_DEFINE_INSTANCED_PROP(fixed4, _ProximitySphere4)
|
||||
UNITY_DEFINE_INSTANCED_PROP(fixed4, _ProximitySphere5)
|
||||
UNITY_DEFINE_INSTANCED_PROP(fixed4, _ProximitySphere6)
|
||||
UNITY_DEFINE_INSTANCED_PROP(fixed4, _ProximitySphere7)
|
||||
UNITY_DEFINE_INSTANCED_PROP(fixed4, _ProximitySphere8)
|
||||
UNITY_DEFINE_INSTANCED_PROP(fixed4, _ProximitySphere9)
|
||||
UNITY_DEFINE_INSTANCED_PROP(fixed4, _ProximityColor)
|
||||
UNITY_DEFINE_INSTANCED_PROP(fixed2, _ProximityTransitionRange)
|
||||
UNITY_DEFINE_INSTANCED_PROP(fixed2, _ProximityStrength)
|
||||
UNITY_INSTANCING_BUFFER_END(Props)
|
||||
|
||||
v2f vert (appdata v)
|
||||
{
|
||||
v2f o;
|
||||
|
||||
UNITY_SETUP_INSTANCE_ID(v);
|
||||
UNITY_INITIALIZE_OUTPUT(v2f, o);
|
||||
UNITY_TRANSFER_INSTANCE_ID(v, o);
|
||||
UNITY_INITIALIZE_VERTEX_OUTPUT_STEREO(o);
|
||||
|
||||
o.radii = UNITY_ACCESS_INSTANCED_PROP(Props, _Radii);
|
||||
o.dimensions = UNITY_ACCESS_INSTANCED_PROP(Props, _Dimensions);
|
||||
o.borderColor = UNITY_ACCESS_INSTANCED_PROP(Props, _BorderColor);
|
||||
o.color = UNITY_ACCESS_INSTANCED_PROP(Props, _Color);
|
||||
o.positionWorld = mul(unity_ObjectToWorld, float4(v.vertex.xyz, 1.0)).xyz;
|
||||
o.vertex = UnityObjectToClipPos(v.vertex);
|
||||
o.uv = (v.uv-float2(.5f,.5f))*2.0f*o.dimensions.xy;
|
||||
return o;
|
||||
}
|
||||
|
||||
float inverseLerp(float t, float a, float b) {
|
||||
return (t - a)/(b - a);
|
||||
}
|
||||
|
||||
float getProximityMinDistance(float3 positionWorld, int proxSphereCount, fixed4 proxSpheres[10]) {
|
||||
float minDistance = 0.0;
|
||||
for(int i = 0; i < proxSphereCount; i++) {
|
||||
float3 spherePos = proxSpheres[i].xyz;
|
||||
float sphereRadius = proxSpheres[i].w;
|
||||
float distance = length(positionWorld - spherePos);
|
||||
distance = min(distance - sphereRadius, 0.0);
|
||||
minDistance = min(distance, minDistance);
|
||||
}
|
||||
return minDistance;
|
||||
}
|
||||
|
||||
fixed4 frag (v2f i) : SV_Target
|
||||
{
|
||||
UNITY_SETUP_INSTANCE_ID(i);
|
||||
fixed4 proxSpheres[10] = {
|
||||
UNITY_ACCESS_INSTANCED_PROP(Props, _ProximitySphere0),
|
||||
UNITY_ACCESS_INSTANCED_PROP(Props, _ProximitySphere1),
|
||||
UNITY_ACCESS_INSTANCED_PROP(Props, _ProximitySphere2),
|
||||
UNITY_ACCESS_INSTANCED_PROP(Props, _ProximitySphere3),
|
||||
UNITY_ACCESS_INSTANCED_PROP(Props, _ProximitySphere4),
|
||||
UNITY_ACCESS_INSTANCED_PROP(Props, _ProximitySphere5),
|
||||
UNITY_ACCESS_INSTANCED_PROP(Props, _ProximitySphere6),
|
||||
UNITY_ACCESS_INSTANCED_PROP(Props, _ProximitySphere7),
|
||||
UNITY_ACCESS_INSTANCED_PROP(Props, _ProximitySphere8),
|
||||
UNITY_ACCESS_INSTANCED_PROP(Props, _ProximitySphere9),
|
||||
};
|
||||
int proxSphereCount = UNITY_ACCESS_INSTANCED_PROP(Props, _ProximitySphereCount);
|
||||
float2 proximityTransitionRange = UNITY_ACCESS_INSTANCED_PROP(Props, _ProximityTransitionRange);
|
||||
float2 proximityStrength = UNITY_ACCESS_INSTANCED_PROP(Props, _ProximityStrength);
|
||||
float4 proximityColor = UNITY_ACCESS_INSTANCED_PROP(Props, _ProximityColor);
|
||||
|
||||
float proxDistance = 0.0;
|
||||
if(proxSphereCount > 0) {
|
||||
proxDistance = abs(getProximityMinDistance(i.positionWorld, proxSphereCount, proxSpheres));
|
||||
}
|
||||
|
||||
float dist = sdRoundBox(i.uv, i.dimensions.xy - i.dimensions.ww * 2.0f, i.radii);
|
||||
float2 ddDist = float2(ddx(dist), ddy(dist));
|
||||
float ddDistLen = length(ddDist);
|
||||
|
||||
float outerRadius = i.dimensions.w;
|
||||
float innerRadius = i.dimensions.z;
|
||||
|
||||
float borderMask = (outerRadius > 0.0f | innerRadius > 0.0f)? 1.0 : 0.0;
|
||||
|
||||
float outerDist = dist - outerRadius * 2.0;
|
||||
float outerDistOverLen = outerDist / ddDistLen;
|
||||
clip(1.0 - outerDistOverLen < 0.1f ? -1:1);
|
||||
|
||||
float innerDist = dist + innerRadius * 2.0;
|
||||
float innerDistOverLen = innerDist / ddDistLen;
|
||||
|
||||
float4 borderColor = i.borderColor;
|
||||
float4 innerColor = i.color;
|
||||
|
||||
if(proxSphereCount > 0) {
|
||||
float normalizedDistance = saturate(inverseLerp(proxDistance, proximityTransitionRange.x, proximityTransitionRange.y));
|
||||
normalizedDistance = sin((normalizedDistance - 0.5) * 3.14) * 0.5 + 0.5;
|
||||
borderColor = lerp(borderColor, proximityColor, normalizedDistance * proximityStrength.x);
|
||||
innerColor = lerp(innerColor, proximityColor, normalizedDistance * proximityStrength.y);
|
||||
}
|
||||
|
||||
float colorLerpParam = saturate(innerDistOverLen) * borderMask;
|
||||
float4 elementMainColor = lerp(innerColor, borderColor, colorLerpParam);
|
||||
|
||||
float4 fragColor = elementMainColor;
|
||||
fragColor.a *= (1.0 - saturate(outerDistOverLen));
|
||||
return fragColor;
|
||||
}
|
||||
ENDCG
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -0,0 +1,9 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 2f6ffd8c4413a1c4b8d833fc76c445ed
|
||||
ShaderImporter:
|
||||
externalObjects: {}
|
||||
defaultTextures: []
|
||||
nonModifiableTextures: []
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
108
Assets/Oculus/Interaction/Runtime/Shaders/UIStyleShader.shader
Normal file
108
Assets/Oculus/Interaction/Runtime/Shaders/UIStyleShader.shader
Normal file
@ -0,0 +1,108 @@
|
||||
/************************************************************************************
|
||||
Copyright : Copyright (c) Facebook Technologies, LLC and its affiliates. All rights reserved.
|
||||
|
||||
Your use of this SDK or tool is subject to the Oculus SDK License Agreement, available at
|
||||
https://developer.oculus.com/licenses/oculussdk/
|
||||
|
||||
Unless required by applicable law or agreed to in writing, the Utilities SDK distributed
|
||||
under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF
|
||||
ANY KIND, either express or implied. See the License for the specific language governing
|
||||
permissions and limitations under the License.
|
||||
************************************************************************************/
|
||||
|
||||
Shader "Oculus/Interaction/UIStyle"
|
||||
{
|
||||
Properties
|
||||
{
|
||||
_Color("Color", Color) = (1,1,1,1)
|
||||
|
||||
[HideInInspector] _texcoord("", 2D) = "white" {}
|
||||
}
|
||||
|
||||
SubShader
|
||||
{
|
||||
Tags{ "RenderType" = "Transparent" "Queue" = "Transparent+0"}
|
||||
LOD 100
|
||||
|
||||
CGINCLUDE
|
||||
#pragma target 3.0
|
||||
ENDCG
|
||||
Blend SrcAlpha OneMinusSrcAlpha
|
||||
|
||||
Pass
|
||||
{
|
||||
Name "Base"
|
||||
CGPROGRAM
|
||||
|
||||
#ifndef UNITY_SETUP_STEREO_EYE_INDEX_POST_VERTEX
|
||||
//only defining to not throw compilation error over Unity 5.5
|
||||
#define UNITY_SETUP_STEREO_EYE_INDEX_POST_VERTEX(input)
|
||||
#endif
|
||||
#pragma vertex vert
|
||||
#pragma fragment frag
|
||||
#pragma multi_compile_instancing
|
||||
|
||||
#include "UnityCG.cginc"
|
||||
#include "UnityShaderVariables.cginc"
|
||||
|
||||
struct VertexInput
|
||||
{
|
||||
float4 vertex : POSITION;
|
||||
half4 vertexColor : COLOR;
|
||||
half3 normal : NORMAL;
|
||||
UNITY_VERTEX_INPUT_INSTANCE_ID
|
||||
};
|
||||
|
||||
struct VertexOutput
|
||||
{
|
||||
float4 vertex : SV_POSITION;
|
||||
float3 worldPos : TEXCOORD0;
|
||||
half3 normal : TEXCOORD2;
|
||||
half4 vertexColor : COLOR;
|
||||
UNITY_VERTEX_INPUT_INSTANCE_ID
|
||||
UNITY_VERTEX_OUTPUT_STEREO
|
||||
};
|
||||
|
||||
uniform half4 _Color;
|
||||
|
||||
VertexOutput vert(VertexInput v)
|
||||
{
|
||||
VertexOutput o;
|
||||
UNITY_SETUP_INSTANCE_ID(v);
|
||||
UNITY_INITIALIZE_VERTEX_OUTPUT_STEREO(o);
|
||||
UNITY_TRANSFER_INSTANCE_ID(v, o);
|
||||
o.normal = UnityObjectToWorldNormal(v.normal);
|
||||
half pulse = sin(_Time.z) * 0.5 + 0.5;
|
||||
float4 vertexPos = UnityObjectToClipPos(v.vertex);
|
||||
vertexPos.xyz = vertexPos + ((0.002 * pulse) * o.normal * v.vertexColor.a);
|
||||
o.vertex = vertexPos;
|
||||
o.vertexColor = v.vertexColor;
|
||||
o.worldPos = mul(unity_ObjectToWorld, v.vertex).xyz;
|
||||
|
||||
return o;
|
||||
}
|
||||
|
||||
half4 frag(VertexOutput i) : SV_Target
|
||||
{
|
||||
UNITY_SETUP_INSTANCE_ID(i);
|
||||
UNITY_SETUP_STEREO_EYE_INDEX_POST_VERTEX(i);
|
||||
float3 worldViewDir = normalize(UnityWorldSpaceViewDir(i.worldPos));
|
||||
half3 worldNormal = i.normal;
|
||||
half fresnel = saturate(dot(worldViewDir, worldNormal));
|
||||
fresnel = saturate(pow(fresnel + .1, 3) * 2);
|
||||
|
||||
half opacity = fresnel * i.vertexColor.a;
|
||||
|
||||
half4 debug = half4(i.vertexColor.a, i.vertexColor.a, i.vertexColor.a, 1.0);
|
||||
|
||||
half4 finalColor = _Color * i.vertexColor;
|
||||
return half4(finalColor.rgb, opacity);
|
||||
}
|
||||
ENDCG
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
@ -0,0 +1,9 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 945300705d5265c40880df9dc394ebd5
|
||||
ShaderImporter:
|
||||
externalObjects: {}
|
||||
defaultTextures: []
|
||||
nonModifiableTextures: []
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@ -0,0 +1,17 @@
|
||||
Shader "Interaction/UnlitTransparentColor" {
|
||||
Properties {
|
||||
_Color ("Main Color", Color) = (1,1,1,1)
|
||||
}
|
||||
|
||||
SubShader {
|
||||
Tags {"Queue"="Transparent" "IgnoreProjector"="True" "RenderType"="Transparent"}
|
||||
LOD 100
|
||||
Fog {Mode Off}
|
||||
|
||||
ZTest Always
|
||||
Blend SrcAlpha OneMinusSrcAlpha
|
||||
Color [_Color]
|
||||
|
||||
Pass {}
|
||||
}
|
||||
}
|
||||
@ -0,0 +1,10 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 30ad2a53abd6f3e4aa5a1b0e0899691f
|
||||
ShaderImporter:
|
||||
externalObjects: {}
|
||||
defaultTextures: []
|
||||
nonModifiableTextures: []
|
||||
preprocessorOverride: 0
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
Reference in New Issue
Block a user