forked from cgvr/DeltaVR
deltavr multiplayer 2.0
This commit is contained in:
302
Assets/XRI_Examples/UI_2D/Shaders/BackgroundOverlayBlur.shader
Normal file
302
Assets/XRI_Examples/UI_2D/Shaders/BackgroundOverlayBlur.shader
Normal file
@@ -0,0 +1,302 @@
|
||||
Shader "XRContent/BackgroundOverlayBlur"
|
||||
{
|
||||
Properties
|
||||
{
|
||||
_Blur("Blur", Range(0, 10)) = 1
|
||||
_VerticalOffset("Offset", Range(-1, 1)) = 1
|
||||
_Alpha("Alpha", Range(0, 1)) = 1
|
||||
_GradientSize("Gradient Size", Range(0, 6)) = 2
|
||||
_MainTex("Noise Texture (REQUIRED for Blur Noise)", 2D) = "white" {}
|
||||
_BlurNoise("Blur Noise Direction", Range(-1, 1)) = 1
|
||||
_BlurNoiseAmount("Blur Noise Amount", Range(-5, 5)) = 0.125
|
||||
}
|
||||
|
||||
Category
|
||||
{
|
||||
Tags{ "Queue" = "Overlay+5600" "LightMode" = "Always" "IgnoreProjector" = "True" "RenderType" = "Transparent" }
|
||||
ZWrite On
|
||||
ZTest LEqual
|
||||
Lighting Off
|
||||
Blend SrcAlpha OneMinusSrcAlpha
|
||||
|
||||
SubShader
|
||||
{
|
||||
GrabPass {}
|
||||
|
||||
Pass
|
||||
{
|
||||
Name "SpatialUIBlurHorizontal"
|
||||
CGPROGRAM
|
||||
|
||||
#pragma vertex vert
|
||||
#pragma fragment frag
|
||||
#include "UnityCG.cginc"
|
||||
|
||||
struct appdata_t
|
||||
{
|
||||
float4 position : POSITION;
|
||||
float2 texcoord : TEXCOORD0;
|
||||
};
|
||||
|
||||
struct v2f
|
||||
{
|
||||
float4 position : POSITION;
|
||||
float4 grab : TEXCOORD0;
|
||||
float yPos : FLOAT;
|
||||
float2 cleanUV : TEXCOORD2;
|
||||
};
|
||||
|
||||
sampler2D _GrabTexture;
|
||||
float4 _GrabTexture_TexelSize;
|
||||
float _Blur;
|
||||
float _VerticalOffset;
|
||||
float _WorldScale;
|
||||
half _GradientSize;
|
||||
sampler2D _MainTex;
|
||||
half _BlurNoise;
|
||||
half _BlurNoiseAmount;
|
||||
|
||||
v2f vert(appdata_t v)
|
||||
{
|
||||
v2f output;
|
||||
output.position = UnityObjectToClipPos(v.position);
|
||||
#if UNITY_UV_STARTS_AT_TOP
|
||||
float sign = -1.0;
|
||||
output.yPos = v.texcoord.y;
|
||||
#else
|
||||
float sign = 1.0;
|
||||
output.yPos = -v.texcoord.y;
|
||||
#endif
|
||||
output.grab.xy = (float2(output.position.x, output.position.y * sign) + output.position.w) * 0.5;
|
||||
output.grab.zw = output.position.zw;
|
||||
output.grab *= _WorldScale;
|
||||
|
||||
output.cleanUV = v.texcoord;
|
||||
return output;
|
||||
}
|
||||
|
||||
half4 frag(v2f input) : COLOR
|
||||
{
|
||||
float uvPos = length(input.cleanUV - float2(0.5, 0.5));
|
||||
float xAdjustedPosition = pow(input.cleanUV.x * (1 - input.cleanUV.x) * 3, 1);
|
||||
float yAdjustedPosition = (1 - input.cleanUV.y);
|
||||
half positionAdjustedBlur = _Blur * yAdjustedPosition * xAdjustedPosition;
|
||||
|
||||
float4 sum = half4(0,0,0,0);
|
||||
#define GrabAndOffset(weight,kernelX) tex2Dproj(_GrabTexture, UNITY_PROJ_COORD(float4(input.grab.x + _GrabTexture_TexelSize.x * kernelX * (positionAdjustedBlur * input.yPos), input.grab.y, input.grab.z, input.grab.w))) * weight
|
||||
|
||||
half4 color = tex2D(_MainTex, input.cleanUV);
|
||||
half noiseSampledTextureAmount = 1 + color.r - _BlurNoiseAmount * dot(input.cleanUV, float2(0.5, 0.5));
|
||||
|
||||
half blurAdjustmentModifier = _BlurNoise * 0.25;
|
||||
float adjustedBlur = 1;
|
||||
half adjustedBlurKernel = input.cleanUV.y;
|
||||
sum += GrabAndOffset(0.02 * adjustedBlur, -6.0 * noiseSampledTextureAmount);
|
||||
noiseSampledTextureAmount -= noiseSampledTextureAmount * blurAdjustmentModifier;
|
||||
sum += GrabAndOffset(0.04 * adjustedBlur, -5.0 * noiseSampledTextureAmount);
|
||||
noiseSampledTextureAmount += noiseSampledTextureAmount * blurAdjustmentModifier;
|
||||
sum += GrabAndOffset(0.06 * adjustedBlur, -4.0 * noiseSampledTextureAmount);
|
||||
noiseSampledTextureAmount -= noiseSampledTextureAmount * blurAdjustmentModifier;
|
||||
sum += GrabAndOffset(0.08 * adjustedBlur, -3.0 * noiseSampledTextureAmount);
|
||||
noiseSampledTextureAmount += noiseSampledTextureAmount * blurAdjustmentModifier;
|
||||
sum += GrabAndOffset(0.10 * adjustedBlur, -2.0 * noiseSampledTextureAmount);
|
||||
noiseSampledTextureAmount -= noiseSampledTextureAmount * blurAdjustmentModifier;
|
||||
sum += GrabAndOffset(0.12 * adjustedBlur, -1.0 * noiseSampledTextureAmount);
|
||||
noiseSampledTextureAmount += noiseSampledTextureAmount * blurAdjustmentModifier;
|
||||
sum += GrabAndOffset(0.14 * adjustedBlur, 0.0);
|
||||
sum += GrabAndOffset(0.12 * adjustedBlur, 1.0 * noiseSampledTextureAmount);
|
||||
noiseSampledTextureAmount -= noiseSampledTextureAmount * blurAdjustmentModifier;
|
||||
sum += GrabAndOffset(0.10 * adjustedBlur, 2.0 * noiseSampledTextureAmount);
|
||||
noiseSampledTextureAmount += noiseSampledTextureAmount * blurAdjustmentModifier;
|
||||
sum += GrabAndOffset(0.08 * adjustedBlur, 3.0 * noiseSampledTextureAmount);
|
||||
noiseSampledTextureAmount -= noiseSampledTextureAmount * blurAdjustmentModifier;
|
||||
sum += GrabAndOffset(0.06 * adjustedBlur, 4.0 * noiseSampledTextureAmount);
|
||||
noiseSampledTextureAmount += noiseSampledTextureAmount * blurAdjustmentModifier;
|
||||
sum += GrabAndOffset(0.04 * adjustedBlur, 5.0 * noiseSampledTextureAmount);
|
||||
noiseSampledTextureAmount -= noiseSampledTextureAmount * blurAdjustmentModifier;
|
||||
sum += GrabAndOffset(0.02 * adjustedBlur, +6.0 * noiseSampledTextureAmount);
|
||||
|
||||
// Fade blur amount based on fragment distance to center UV coord
|
||||
float fadeFromBorderAmount = 1 - clamp(0, 1, pow(uvPos, _GradientSize) * 2);
|
||||
sum.a = clamp(0, 1 - pow((uvPos * 2), _GradientSize * (_Blur / 10)), fadeFromBorderAmount);
|
||||
|
||||
return sum;
|
||||
}
|
||||
ENDCG
|
||||
}
|
||||
|
||||
GrabPass{}
|
||||
|
||||
Pass
|
||||
{
|
||||
Name "SpatialUIBlurVertical"
|
||||
|
||||
CGPROGRAM
|
||||
#pragma vertex vert
|
||||
#pragma fragment frag
|
||||
#include "UnityCG.cginc"
|
||||
|
||||
struct appdata_t
|
||||
{
|
||||
float4 position : POSITION;
|
||||
float2 texcoord: TEXCOORD0;
|
||||
};
|
||||
|
||||
struct v2f
|
||||
{
|
||||
float4 position : POSITION;
|
||||
float4 grab : TEXCOORD0;
|
||||
float yPos : FLOAT;
|
||||
float2 cleanUV : TEXCOORD2;
|
||||
};
|
||||
|
||||
sampler2D _GrabTexture;
|
||||
float4 _GrabTexture_TexelSize;
|
||||
float _Blur;
|
||||
float _VerticalOffset;
|
||||
float _WorldScale;
|
||||
half _GradientSize;
|
||||
sampler2D _MainTex;
|
||||
half _BlurNoise;
|
||||
half _BlurNoiseAmount;
|
||||
|
||||
v2f vert(appdata_t v)
|
||||
{
|
||||
v2f output;
|
||||
output.position = UnityObjectToClipPos(v.position);
|
||||
#if UNITY_UV_STARTS_AT_TOP
|
||||
float sign = -1.0;
|
||||
output.yPos = v.texcoord.y;
|
||||
#else
|
||||
float sign = 1.0;
|
||||
output.yPos = -v.texcoord.y;
|
||||
#endif
|
||||
output.grab.xy = (float2(output.position.x, output.position.y * sign) + output.position.w) * 0.5;
|
||||
output.grab.zw = output.position.zw;
|
||||
output.grab *= _WorldScale;
|
||||
|
||||
output.cleanUV = v.texcoord;
|
||||
return output;
|
||||
}
|
||||
|
||||
half4 frag(v2f input) : COLOR
|
||||
{
|
||||
float uvPos = length(input.cleanUV - float2(0.5, 0.5));
|
||||
float xAdjustedPosition = pow(input.cleanUV.x * (1 - input.cleanUV.x) * 3, 1);
|
||||
float yAdjustedPosition = (1 - input.cleanUV.y);
|
||||
half positionAdjustedBlur = _Blur * yAdjustedPosition * xAdjustedPosition;
|
||||
|
||||
half4 sum = half4(0,0,0,0);
|
||||
#define GrabAndOffset(weight,kernelY) tex2Dproj( _GrabTexture, UNITY_PROJ_COORD(float4(input.grab.x, input.grab.y + _GrabTexture_TexelSize.y * kernelY * (positionAdjustedBlur * input.yPos + _VerticalOffset), input.grab.z, input.grab.w))) * weight
|
||||
|
||||
half4 color = tex2D(_MainTex, input.cleanUV);
|
||||
half noiseSampledTextureAmount = 1 + color.g - _BlurNoiseAmount * dot(input.cleanUV, float2(0.5, 0.5));
|
||||
|
||||
float adjustedBlur = 1;
|
||||
half blurAdjustmentModifier = _BlurNoise * 0.25;
|
||||
half adjustedBlurKernel = input.cleanUV.y;
|
||||
sum += GrabAndOffset(0.02 * adjustedBlur, -6.0 * noiseSampledTextureAmount);
|
||||
noiseSampledTextureAmount += noiseSampledTextureAmount * blurAdjustmentModifier;
|
||||
sum += GrabAndOffset(0.04 * adjustedBlur, -5.0 * noiseSampledTextureAmount);
|
||||
noiseSampledTextureAmount -= noiseSampledTextureAmount * blurAdjustmentModifier;
|
||||
sum += GrabAndOffset(0.06 * adjustedBlur, -4.0 * noiseSampledTextureAmount);
|
||||
noiseSampledTextureAmount += noiseSampledTextureAmount * blurAdjustmentModifier;
|
||||
sum += GrabAndOffset(0.08 * adjustedBlur, -3.0 * noiseSampledTextureAmount);
|
||||
noiseSampledTextureAmount -= noiseSampledTextureAmount * blurAdjustmentModifier;
|
||||
sum += GrabAndOffset(0.10 * adjustedBlur, -2.0 * noiseSampledTextureAmount);
|
||||
noiseSampledTextureAmount += noiseSampledTextureAmount * blurAdjustmentModifier;
|
||||
sum += GrabAndOffset(0.12 * adjustedBlur, -1.0 * noiseSampledTextureAmount);
|
||||
noiseSampledTextureAmount -= noiseSampledTextureAmount * blurAdjustmentModifier;
|
||||
sum += GrabAndOffset(0.14 * adjustedBlur, 0.0);
|
||||
sum += GrabAndOffset(0.12 * adjustedBlur, +1.0 * noiseSampledTextureAmount);
|
||||
noiseSampledTextureAmount += noiseSampledTextureAmount * blurAdjustmentModifier;
|
||||
sum += GrabAndOffset(0.10 * adjustedBlur, +2.0 * noiseSampledTextureAmount);
|
||||
noiseSampledTextureAmount -= noiseSampledTextureAmount * blurAdjustmentModifier;
|
||||
sum += GrabAndOffset(0.08 * adjustedBlur, +3.0 * noiseSampledTextureAmount);
|
||||
noiseSampledTextureAmount += noiseSampledTextureAmount * blurAdjustmentModifier;
|
||||
sum += GrabAndOffset(0.06 * adjustedBlur, +4.0 * noiseSampledTextureAmount);
|
||||
noiseSampledTextureAmount -= noiseSampledTextureAmount * blurAdjustmentModifier;
|
||||
sum += GrabAndOffset(0.04 * adjustedBlur, +5.0 * noiseSampledTextureAmount);
|
||||
noiseSampledTextureAmount += noiseSampledTextureAmount * blurAdjustmentModifier;
|
||||
sum += GrabAndOffset(0.02 * adjustedBlur, +6.0 * noiseSampledTextureAmount);
|
||||
|
||||
float fadeFromBorderAmount = 1 - clamp(0, 1, pow(uvPos, _GradientSize) * 2);
|
||||
sum.a = clamp(0, 1 - pow((uvPos * 2), _GradientSize * (_Blur / 10)), fadeFromBorderAmount);
|
||||
|
||||
return sum;
|
||||
}
|
||||
ENDCG
|
||||
}
|
||||
|
||||
GrabPass{}
|
||||
|
||||
Pass
|
||||
{
|
||||
CGPROGRAM
|
||||
#pragma vertex vert
|
||||
#pragma fragment frag
|
||||
#pragma fragmentoption ARB_precision_hint_fastest
|
||||
#include "UnityCG.cginc"
|
||||
|
||||
struct appdata_t
|
||||
{
|
||||
float4 position : POSITION;
|
||||
float2 texcoord: TEXCOORD0;
|
||||
};
|
||||
|
||||
struct v2f
|
||||
{
|
||||
float4 position : POSITION;
|
||||
float4 grab : TEXCOORD0;
|
||||
float2 uvmain : TEXCOORD2;
|
||||
};
|
||||
|
||||
float4 _MainTex_ST;
|
||||
fixed4 _Color;
|
||||
sampler2D _GrabTexture;
|
||||
float4 _GrabTexture_TexelSize;
|
||||
sampler2D _MainTex;
|
||||
half _Alpha;
|
||||
float _WorldScale;
|
||||
half _GradientSize;
|
||||
|
||||
v2f vert(appdata_t v)
|
||||
{
|
||||
v2f output;
|
||||
output.position = UnityObjectToClipPos(v.position);
|
||||
#if UNITY_UV_STARTS_AT_TOP
|
||||
float sign = -1.0;
|
||||
#else
|
||||
float sign = 1.0;
|
||||
#endif
|
||||
output.grab.xy = (float2(output.position.x, output.position.y * sign) + output.position.w) * 0.5;
|
||||
output.grab.zw = output.position.zw;
|
||||
output.grab *= _WorldScale;
|
||||
output.uvmain = TRANSFORM_TEX(v.texcoord, _MainTex);
|
||||
return output;
|
||||
}
|
||||
|
||||
half4 frag(v2f i) : COLOR
|
||||
{
|
||||
i.grab.xy = _GrabTexture_TexelSize.xy * i.grab.z + i.grab.xy;
|
||||
half4 col = tex2Dproj(_GrabTexture, UNITY_PROJ_COORD(i.grab));
|
||||
half4 desatCol = dot(col, col);
|
||||
col = lerp(col * col, desatCol, 0.2);
|
||||
half4 tint = tex2D(_MainTex, i.uvmain) * _Color;
|
||||
|
||||
col.a = _Alpha;
|
||||
tint.a = _Alpha;
|
||||
|
||||
float t = length(i.grab - float2(0.5, 0.5)) * 1.41421356237;
|
||||
half4 combinedColor = col * tint;
|
||||
combinedColor.a *= t * lerp(0, 1, t + (_GradientSize - 0.5) * 2);;
|
||||
|
||||
combinedColor.a = 0;
|
||||
|
||||
return combinedColor;
|
||||
}
|
||||
ENDCG
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,10 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 84fc373fc19080b44b0cbddb1ca18b85
|
||||
ShaderImporter:
|
||||
externalObjects: {}
|
||||
defaultTextures: []
|
||||
nonModifiableTextures: []
|
||||
preprocessorOverride: 0
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
170
Assets/XRI_Examples/UI_2D/Shaders/Silhouette.cginc
Normal file
170
Assets/XRI_Examples/UI_2D/Shaders/Silhouette.cginc
Normal file
@@ -0,0 +1,170 @@
|
||||
#pragma target 5.0
|
||||
#include "UnityCG.cginc"
|
||||
|
||||
//-------------------------------------------------------------------------------------------------------------------------------------------------------------
|
||||
float4 _Color;
|
||||
float g_flOutlineWidth;
|
||||
float g_flCornerAdjust;
|
||||
|
||||
float4x4 _InverseRotation;
|
||||
float4 _GlobalClipCenter;
|
||||
float4 _GlobalClipExtents;
|
||||
|
||||
//-------------------------------------------------------------------------------------------------------------------------------------------------------------
|
||||
struct VS_INPUT
|
||||
{
|
||||
float4 vPositionOs : POSITION;
|
||||
float3 vNormalOs : NORMAL;
|
||||
};
|
||||
|
||||
struct PS_INPUT
|
||||
{
|
||||
float4 vPositionOs : TEXCOORD0;
|
||||
float3 vNormalOs : TEXCOORD1;
|
||||
float3 clipPos : TEXCOORD2;
|
||||
float4 vPositionPs : SV_POSITION;
|
||||
};
|
||||
|
||||
//-------------------------------------------------------------------------------------------------------------------------------------------------------------
|
||||
PS_INPUT MainVs(VS_INPUT i)
|
||||
{
|
||||
PS_INPUT o;
|
||||
o.vPositionOs.xyzw = i.vPositionOs.xyzw;
|
||||
o.vNormalOs.xyz = i.vNormalOs.xyz;
|
||||
#if UNITY_VERSION >= 540
|
||||
o.vPositionPs = UnityObjectToClipPos(i.vPositionOs.xyzw);
|
||||
#else
|
||||
o.vPositionPs = UnityObjectToClipPos(i.vPositionOs.xyzw);
|
||||
#endif
|
||||
|
||||
o.clipPos = (float3)0;
|
||||
|
||||
return o;
|
||||
}
|
||||
|
||||
PS_INPUT MainVsExtrude(VS_INPUT i)
|
||||
{
|
||||
PS_INPUT o;
|
||||
o.vPositionOs.xyzw = i.vPositionOs.xyzw;
|
||||
o.vNormalOs.xyz = i.vNormalOs.xyz;
|
||||
#if UNITY_VERSION >= 540
|
||||
o.vPositionPs = UnityObjectToClipPos(i.vPositionOs.xyzw);
|
||||
#else
|
||||
o.vPositionPs = UnityObjectToClipPos(i.vPositionOs.xyzw);
|
||||
#endif
|
||||
|
||||
float3 vNormalVs = mul((float3x3)UNITY_MATRIX_IT_MV, o.vNormalOs.xyz);
|
||||
float2 vOffsetPs = TransformViewToProjection(vNormalVs.xy);
|
||||
vOffsetPs.xy = normalize(vOffsetPs.xy);
|
||||
o.vPositionPs.xy += vOffsetPs.xy * o.vPositionPs.w * g_flOutlineWidth * 0.5;
|
||||
|
||||
o.clipPos = (float3)0;
|
||||
|
||||
return o;
|
||||
}
|
||||
|
||||
PS_INPUT MainVsClip(VS_INPUT i)
|
||||
{
|
||||
PS_INPUT o;
|
||||
o.vPositionOs.xyzw = i.vPositionOs.xyzw;
|
||||
o.vNormalOs.xyz = i.vNormalOs.xyz;
|
||||
#if UNITY_VERSION >= 540
|
||||
o.vPositionPs = UnityObjectToClipPos(i.vPositionOs.xyzw);
|
||||
#else
|
||||
o.vPositionPs = UnityObjectToClipPos(i.vPositionOs.xyzw);
|
||||
#endif
|
||||
|
||||
o.clipPos = mul(_InverseRotation, mul(unity_ObjectToWorld, i.vPositionOs));
|
||||
|
||||
return o;
|
||||
}
|
||||
|
||||
//-------------------------------------------------------------------------------------------------------------------------------------------------------------
|
||||
PS_INPUT Extrude(PS_INPUT vertex)
|
||||
{
|
||||
PS_INPUT extruded = vertex;
|
||||
|
||||
// Offset along normal in projection space
|
||||
float3 vNormalVs = mul((float3x3)UNITY_MATRIX_IT_MV, vertex.vNormalOs.xyz);
|
||||
float2 vOffsetPs = TransformViewToProjection(vNormalVs.xy);
|
||||
vOffsetPs.xy = normalize(vOffsetPs.xy);
|
||||
|
||||
// Calculate position
|
||||
#if UNITY_VERSION >= 540
|
||||
extruded.vPositionPs = UnityObjectToClipPos(vertex.vPositionOs.xyzw);
|
||||
#else
|
||||
extruded.vPositionPs = UnityObjectToClipPos(vertex.vPositionOs.xyzw);
|
||||
#endif
|
||||
extruded.vPositionPs.xy += vOffsetPs.xy * extruded.vPositionPs.w * g_flOutlineWidth;
|
||||
|
||||
return extruded;
|
||||
}
|
||||
|
||||
//-------------------------------------------------------------------------------------------------------------------------------------------------------------
|
||||
[maxvertexcount(18)]
|
||||
void ExtrudeGs(triangle PS_INPUT inputTriangle[3], inout TriangleStream<PS_INPUT> outputStream)
|
||||
{
|
||||
float3 a = normalize(inputTriangle[0].vPositionOs.xyz - inputTriangle[1].vPositionOs.xyz);
|
||||
float3 b = normalize(inputTriangle[1].vPositionOs.xyz - inputTriangle[2].vPositionOs.xyz);
|
||||
float3 c = normalize(inputTriangle[2].vPositionOs.xyz - inputTriangle[0].vPositionOs.xyz);
|
||||
|
||||
inputTriangle[0].vNormalOs = inputTriangle[0].vNormalOs + normalize(a - c) * g_flCornerAdjust;
|
||||
inputTriangle[1].vNormalOs = inputTriangle[1].vNormalOs + normalize(-a + b) * g_flCornerAdjust;
|
||||
inputTriangle[2].vNormalOs = inputTriangle[2].vNormalOs + normalize(-b + c) * g_flCornerAdjust;
|
||||
|
||||
PS_INPUT extrudedTriangle0 = Extrude(inputTriangle[0]);
|
||||
PS_INPUT extrudedTriangle1 = Extrude(inputTriangle[1]);
|
||||
PS_INPUT extrudedTriangle2 = Extrude(inputTriangle[2]);
|
||||
|
||||
outputStream.Append(inputTriangle[0]);
|
||||
outputStream.Append(extrudedTriangle0);
|
||||
outputStream.Append(inputTriangle[1]);
|
||||
outputStream.Append(extrudedTriangle0);
|
||||
outputStream.Append(extrudedTriangle1);
|
||||
outputStream.Append(inputTriangle[1]);
|
||||
|
||||
outputStream.Append(inputTriangle[1]);
|
||||
outputStream.Append(extrudedTriangle1);
|
||||
outputStream.Append(extrudedTriangle2);
|
||||
outputStream.Append(inputTriangle[1]);
|
||||
outputStream.Append(extrudedTriangle2);
|
||||
outputStream.Append(inputTriangle[2]);
|
||||
|
||||
outputStream.Append(inputTriangle[2]);
|
||||
outputStream.Append(extrudedTriangle2);
|
||||
outputStream.Append(inputTriangle[0]);
|
||||
outputStream.Append(extrudedTriangle2);
|
||||
outputStream.Append(extrudedTriangle0);
|
||||
outputStream.Append(inputTriangle[0]);
|
||||
}
|
||||
|
||||
//-------------------------------------------------------------------------------------------------------------------------------------------------------------
|
||||
fixed4 MainPs(PS_INPUT IN) : SV_Target
|
||||
{
|
||||
return _Color;
|
||||
}
|
||||
|
||||
//-------------------------------------------------------------------------------------------------------------------------------------------------------------
|
||||
fixed4 NullPs(PS_INPUT IN) : SV_Target
|
||||
{
|
||||
return float4(1.0, 0.0, 1.0, 1.0);
|
||||
}
|
||||
//-------------------------------------------------------------------------------------------------------------------------------------------------------------
|
||||
fixed4 MainPsClip(PS_INPUT IN) : SV_Target
|
||||
{
|
||||
float3 diff = abs(IN.clipPos - _GlobalClipCenter);
|
||||
if (diff.x > _GlobalClipExtents.x || diff.y > _GlobalClipExtents.y || diff.z > _GlobalClipExtents.z)
|
||||
discard;
|
||||
|
||||
return _Color;
|
||||
}
|
||||
|
||||
//-------------------------------------------------------------------------------------------------------------------------------------------------------------
|
||||
fixed4 NullPsClip (PS_INPUT IN) : SV_Target
|
||||
{
|
||||
float3 diff = abs(IN.clipPos - _GlobalClipCenter);
|
||||
if (diff.x > _GlobalClipExtents.x || diff.y > _GlobalClipExtents.y || diff.z > _GlobalClipExtents.z)
|
||||
discard;
|
||||
|
||||
return float4(1.0, 0.0, 1.0, 1.0);
|
||||
}
|
||||
10
Assets/XRI_Examples/UI_2D/Shaders/Silhouette.cginc.meta
Normal file
10
Assets/XRI_Examples/UI_2D/Shaders/Silhouette.cginc.meta
Normal file
@@ -0,0 +1,10 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 68e90fde0a0ab4142bdd4fc5b377953e
|
||||
ShaderImporter:
|
||||
externalObjects: {}
|
||||
defaultTextures: []
|
||||
nonModifiableTextures: []
|
||||
preprocessorOverride: 0
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
81
Assets/XRI_Examples/UI_2D/Shaders/SilhouetteURP.shader
Normal file
81
Assets/XRI_Examples/UI_2D/Shaders/SilhouetteURP.shader
Normal file
@@ -0,0 +1,81 @@
|
||||
//======= Copyright (c) Valve Corporation, All rights reserved. ===============
|
||||
//
|
||||
// Purpose: Used to show the outline of the object
|
||||
//
|
||||
// Used with permission (3/20/17)
|
||||
// Copyright (C) 2017 Unity Technologies ApS - Fix for hard edges
|
||||
// Copyright (C) 2021 Unity Technologies ApS - Adjustment for URP Support
|
||||
//=============================================================================
|
||||
Shader "XRContent/OutlineURP"
|
||||
{
|
||||
Properties
|
||||
{
|
||||
_Color("Color", Color) = (.5, .5, .5, 1)
|
||||
g_flOutlineWidth("OutlineWidth", Range(.001, 0.03)) = .0005
|
||||
g_flCornerAdjust("Corner Adjustment", Range(0, 2)) = .5
|
||||
}
|
||||
|
||||
CGINCLUDE
|
||||
#include "Silhouette.cginc"
|
||||
ENDCG
|
||||
|
||||
SubShader
|
||||
{
|
||||
//-------------------------------------------------------------------------------------------------------------------------------------------------------------
|
||||
// Render the object with stencil=1 to mask out the part that isn't the silhouette
|
||||
//-------------------------------------------------------------------------------------------------------------------------------------------------------------
|
||||
Pass
|
||||
{
|
||||
Tags
|
||||
{
|
||||
"RenderType" = "Opaque"
|
||||
"LightMode"="UniversalForward"
|
||||
}
|
||||
|
||||
ColorMask 0
|
||||
Cull Off
|
||||
ZWrite Off
|
||||
ZTest Off
|
||||
Stencil
|
||||
{
|
||||
Ref 1
|
||||
Comp always
|
||||
Pass replace
|
||||
}
|
||||
|
||||
CGPROGRAM
|
||||
#pragma vertex MainVs
|
||||
#pragma fragment NullPs
|
||||
ENDCG
|
||||
}
|
||||
|
||||
//-------------------------------------------------------------------------------------------------------------------------------------------------------------
|
||||
// Render the outline by extruding along vertex normals and using the stencil mask previously rendered. Only render depth, so that the final pass executes
|
||||
// once per fragment (otherwise alpha blending will look bad).
|
||||
//-------------------------------------------------------------------------------------------------------------------------------------------------------------
|
||||
Pass
|
||||
{
|
||||
|
||||
Tags
|
||||
{
|
||||
"RenderType" = "Opaque"
|
||||
}
|
||||
|
||||
Cull Off
|
||||
|
||||
ZTest LEqual
|
||||
Stencil
|
||||
{
|
||||
Ref 1
|
||||
Comp notequal
|
||||
Pass keep
|
||||
Fail keep
|
||||
}
|
||||
|
||||
CGPROGRAM
|
||||
#pragma vertex MainVsExtrude
|
||||
#pragma fragment MainPs
|
||||
ENDCG
|
||||
}
|
||||
}
|
||||
}
|
||||
10
Assets/XRI_Examples/UI_2D/Shaders/SilhouetteURP.shader.meta
Normal file
10
Assets/XRI_Examples/UI_2D/Shaders/SilhouetteURP.shader.meta
Normal file
@@ -0,0 +1,10 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 7200aef8a341733498b6598b176e0828
|
||||
ShaderImporter:
|
||||
externalObjects: {}
|
||||
defaultTextures: []
|
||||
nonModifiableTextures: []
|
||||
preprocessorOverride: 0
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
114
Assets/XRI_Examples/UI_2D/Shaders/WorldUI.shader
Normal file
114
Assets/XRI_Examples/UI_2D/Shaders/WorldUI.shader
Normal file
@@ -0,0 +1,114 @@
|
||||
Shader "UI/World"
|
||||
{
|
||||
Properties
|
||||
{
|
||||
[PerRendererData] _MainTex("Sprite Texture", 2D) = "white" {}
|
||||
_Color("Tint", Color) = (1,1,1,1)
|
||||
|
||||
_StencilComp("Stencil Comparison", Float) = 8
|
||||
_Stencil("Stencil ID", Float) = 0
|
||||
_StencilOp("Stencil Operation", Float) = 0
|
||||
_StencilWriteMask("Stencil Write Mask", Float) = 255
|
||||
_StencilReadMask("Stencil Read Mask", Float) = 255
|
||||
|
||||
_ColorMask("Color Mask", Float) = 15
|
||||
|
||||
[Toggle(UNITY_UI_ALPHACLIP)] _UseUIAlphaClip("Use Alpha Clip", Float) = 0
|
||||
}
|
||||
|
||||
SubShader
|
||||
{
|
||||
Tags
|
||||
{
|
||||
"Queue" = "Transparent"
|
||||
"IgnoreProjector" = "True"
|
||||
"RenderType" = "Transparent"
|
||||
"PreviewType" = "Plane"
|
||||
"CanUseSpriteAtlas" = "True"
|
||||
}
|
||||
|
||||
Stencil
|
||||
{
|
||||
Ref[_Stencil]
|
||||
Comp[_StencilComp]
|
||||
Pass[_StencilOp]
|
||||
ReadMask[_StencilReadMask]
|
||||
WriteMask[_StencilWriteMask]
|
||||
}
|
||||
|
||||
Cull Back
|
||||
Lighting Off
|
||||
ZWrite Off
|
||||
ZTest LEqual
|
||||
Blend SrcAlpha OneMinusSrcAlpha
|
||||
ColorMask[_ColorMask]
|
||||
|
||||
Pass
|
||||
{
|
||||
Name "Default"
|
||||
CGPROGRAM
|
||||
#pragma vertex vert
|
||||
#pragma fragment frag
|
||||
#pragma target 2.0
|
||||
|
||||
#include "UnityCG.cginc"
|
||||
#include "UnityUI.cginc"
|
||||
|
||||
#pragma multi_compile_local _ UNITY_UI_CLIP_RECT
|
||||
#pragma multi_compile_local _ UNITY_UI_ALPHACLIP
|
||||
|
||||
struct appdata_t
|
||||
{
|
||||
float4 vertex : POSITION;
|
||||
float4 color : COLOR;
|
||||
float2 texcoord : TEXCOORD0;
|
||||
UNITY_VERTEX_INPUT_INSTANCE_ID
|
||||
};
|
||||
|
||||
struct v2f
|
||||
{
|
||||
float4 vertex : SV_POSITION;
|
||||
fixed4 color : COLOR;
|
||||
float2 texcoord : TEXCOORD0;
|
||||
float4 worldPosition : TEXCOORD1;
|
||||
UNITY_VERTEX_OUTPUT_STEREO
|
||||
};
|
||||
|
||||
sampler2D _MainTex;
|
||||
fixed4 _Color;
|
||||
fixed4 _TextureSampleAdd;
|
||||
float4 _ClipRect;
|
||||
float4 _MainTex_ST;
|
||||
|
||||
v2f vert(appdata_t v)
|
||||
{
|
||||
v2f OUT;
|
||||
UNITY_SETUP_INSTANCE_ID(v);
|
||||
UNITY_INITIALIZE_VERTEX_OUTPUT_STEREO(OUT);
|
||||
OUT.worldPosition = v.vertex;
|
||||
OUT.vertex = UnityObjectToClipPos(OUT.worldPosition);
|
||||
|
||||
OUT.texcoord = TRANSFORM_TEX(v.texcoord, _MainTex);
|
||||
|
||||
OUT.color = v.color * _Color;
|
||||
return OUT;
|
||||
}
|
||||
|
||||
fixed4 frag(v2f IN) : SV_Target
|
||||
{
|
||||
half4 color = (tex2D(_MainTex, IN.texcoord) + _TextureSampleAdd) * IN.color;
|
||||
|
||||
#ifdef UNITY_UI_CLIP_RECT
|
||||
color.a *= UnityGet2DClipping(IN.worldPosition.xy, _ClipRect);
|
||||
#endif
|
||||
|
||||
#ifdef UNITY_UI_ALPHACLIP
|
||||
clip(color.a - 0.001);
|
||||
#endif
|
||||
|
||||
return color;
|
||||
}
|
||||
ENDCG
|
||||
}
|
||||
}
|
||||
}
|
||||
10
Assets/XRI_Examples/UI_2D/Shaders/WorldUI.shader.meta
Normal file
10
Assets/XRI_Examples/UI_2D/Shaders/WorldUI.shader.meta
Normal file
@@ -0,0 +1,10 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 9b83b58c1a14548419f56ef6631192cb
|
||||
ShaderImporter:
|
||||
externalObjects: {}
|
||||
defaultTextures: []
|
||||
nonModifiableTextures: []
|
||||
preprocessorOverride: 0
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
Reference in New Issue
Block a user