deltavr multiplayer 2.0
This commit is contained in:
8
Assets/Oculus/VR/Shaders/OVRTrackedKeyboard.meta
Normal file
8
Assets/Oculus/VR/Shaders/OVRTrackedKeyboard.meta
Normal file
@@ -0,0 +1,8 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 00644b74c8ac5304dbc24df028ab523e
|
||||
folderAsset: yes
|
||||
DefaultImporter:
|
||||
externalObjects: {}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -0,0 +1,142 @@
|
||||
Shader "Hands Billboard Edge Fading Mask"
|
||||
{
|
||||
Properties
|
||||
{
|
||||
_Intensity("Intensity", Range(0,1)) = 1.0
|
||||
|
||||
[Space(5)]
|
||||
[Header(PARAMETRIC GLOW)]
|
||||
_Scale("Scale", Range(0,.1)) = 0.055
|
||||
_Falloff("Falloff", float) = 4.0
|
||||
_Power("Power", float) = 15.0
|
||||
|
||||
[Space(5)]
|
||||
[Header(EDGE FADING)]
|
||||
[Toggle] _EdgeFading("Enable", Int) = 1
|
||||
_KeyboardPosition("Keyboard Position", Vector) = (0, 0, 0, 0)
|
||||
_KeyboardRotation("Keyboard Rotation", Vector) = (0, 0, 0, 0)
|
||||
_KeyboardScale("Keyboard Scale", Vector) = (1, 1, 1, 0)
|
||||
_FadingFalloff("Falloff", Range(0, .1)) = 0.05
|
||||
_ColorMultiply("Color multiply", Range(0, 3)) = 2.0
|
||||
|
||||
// Blend modes
|
||||
[Enum(UnityEngine.Rendering.BlendMode)]_SrcBlendMode("Src Blend Factor", Int) = 0 // Zero
|
||||
[Enum(UnityEngine.Rendering.BlendMode)]_DstBlendMode("Dst Blend Factor", Int) = 4 // SrcColor
|
||||
}
|
||||
SubShader
|
||||
{
|
||||
// Transparent+1 to render after key labels
|
||||
Tags {"Queue" = "Transparent+1" "IgnoreProjector" = "True" "RenderType" = "Transparent"}
|
||||
ZWrite Off
|
||||
Cull Off
|
||||
ZTest Always
|
||||
|
||||
Blend [_SrcBlendMode] [_DstBlendMode]
|
||||
|
||||
Pass
|
||||
{
|
||||
CGPROGRAM
|
||||
|
||||
#pragma vertex vert
|
||||
#pragma fragment frag
|
||||
#pragma multi_compile_instancing
|
||||
#include "UnityCG.cginc"
|
||||
|
||||
uniform float _Intensity;
|
||||
uniform float _Scale;
|
||||
float _Falloff;
|
||||
float _Power;
|
||||
|
||||
int _EdgeFading;
|
||||
float4 _KeyboardPosition;
|
||||
float4 _KeyboardRotation;
|
||||
float4 _KeyboardScale;
|
||||
float _FadingFalloff;
|
||||
float _ColorMultiply;
|
||||
|
||||
struct vertexInput
|
||||
{
|
||||
UNITY_VERTEX_INPUT_INSTANCE_ID
|
||||
float4 vertex : POSITION;
|
||||
float4 tex : TEXCOORD0;
|
||||
float4 color : COLOR;
|
||||
};
|
||||
|
||||
struct vertexOutput
|
||||
{
|
||||
UNITY_VERTEX_INPUT_INSTANCE_ID
|
||||
float4 pos : SV_POSITION;
|
||||
float4 tex : TEXCOORD0;
|
||||
float4 color : COLOR;
|
||||
};
|
||||
|
||||
UNITY_INSTANCING_BUFFER_START(Props)
|
||||
//UNITY_DEFINE_INSTANCED_PROP(float4, _Color)
|
||||
UNITY_INSTANCING_BUFFER_END(Props)
|
||||
|
||||
float4 RotateAroundYInDegrees(float4 vertex, float degrees)
|
||||
{
|
||||
float alpha = degrees * UNITY_PI / 180.0;
|
||||
float sina, cosa;
|
||||
sincos(alpha, sina, cosa);
|
||||
float2x2 m = float2x2(cosa, -sina, sina, cosa);
|
||||
return float4(mul(m, vertex.xz), vertex.yw).xzyw;
|
||||
}
|
||||
|
||||
float4 BoundingBox(float4 vert, float4 position, float4 rotation, float4 scale)
|
||||
{
|
||||
float4 worldPos = mul(unity_ObjectToWorld, vert);
|
||||
float4 bboxOrientation = RotateAroundYInDegrees(worldPos - position, rotation.y);
|
||||
bboxOrientation = abs(bboxOrientation);
|
||||
|
||||
scale *= 0.5f;
|
||||
|
||||
float distX = (bboxOrientation.x - scale.x) / ((scale.x + _FadingFalloff) - scale.x);
|
||||
float distY = (bboxOrientation.y - scale.y) / ((scale.y + _FadingFalloff) - scale.y);
|
||||
float distZ = (bboxOrientation.z - scale.z) / ((scale.z + _FadingFalloff) - scale.z);
|
||||
float bBoxH = max(distX, distZ);
|
||||
float bBoxV = max(bBoxH, distY);
|
||||
float bBox = clamp(0,1,bBoxV);
|
||||
return float4(bBox, bBox, bBox, bBox);
|
||||
}
|
||||
|
||||
vertexOutput vert(vertexInput input)
|
||||
{
|
||||
UNITY_SETUP_INSTANCE_ID(input);
|
||||
|
||||
vertexOutput output;
|
||||
output.pos = mul(UNITY_MATRIX_P,
|
||||
mul(UNITY_MATRIX_MV, float4(0.0, 0.0, 0.0, 1.0))
|
||||
+ float4(input.vertex.x, input.vertex.y, 0.0, 0.0)
|
||||
* float4(_Scale, _Scale, 1.0, 1.0));
|
||||
|
||||
output.tex = input.tex;
|
||||
output.color = BoundingBox(input.vertex, _KeyboardPosition, _KeyboardRotation, _KeyboardScale);
|
||||
|
||||
return output;
|
||||
}
|
||||
|
||||
fixed BorderFade(float2 uv, float falloff, float intensity)
|
||||
{
|
||||
uv *= 1.0 - uv.yx;
|
||||
float fade = uv.x * uv.y * intensity;
|
||||
fade = pow(fade, falloff);
|
||||
return fade;
|
||||
}
|
||||
|
||||
float4 frag(vertexOutput input) : COLOR
|
||||
{
|
||||
UNITY_SETUP_INSTANCE_ID(input);
|
||||
float glow = BorderFade(input.tex, _Falloff, _Power);
|
||||
float color = glow * _ColorMultiply;
|
||||
float4 circleAlpha = float4(color, color, color, glow) * _Intensity;
|
||||
float4 finalAlpha = circleAlpha * (1 - input.color.a);
|
||||
float4 transition = 1 - lerp(circleAlpha, finalAlpha, _EdgeFading);
|
||||
|
||||
return transition;
|
||||
}
|
||||
|
||||
ENDCG
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,9 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 488b60f10f2b48e4f9ff49f81068b166
|
||||
ShaderImporter:
|
||||
externalObjects: {}
|
||||
defaultTextures: []
|
||||
nonModifiableTextures: []
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
37
Assets/Oculus/VR/Shaders/OVRTrackedKeyboard/HandMask.shader
Normal file
37
Assets/Oculus/VR/Shaders/OVRTrackedKeyboard/HandMask.shader
Normal file
@@ -0,0 +1,37 @@
|
||||
Shader "Unlit/HandMask"
|
||||
{
|
||||
Properties
|
||||
{
|
||||
_Color("Color", Color) = (1, 1, 1, 1)
|
||||
_MainTex ("Texture", 2D) = "white" {}
|
||||
}
|
||||
SubShader
|
||||
{
|
||||
Tags { "Queue" = "Transparent" "RenderType"="Transparent" }
|
||||
LOD 200
|
||||
Blend One Zero, One Zero
|
||||
|
||||
CGPROGRAM
|
||||
#pragma surface surf NoLighting keepalpha
|
||||
|
||||
#pragma target 3.0
|
||||
|
||||
sampler2D _MainTex;
|
||||
|
||||
fixed4 LightingNoLighting(SurfaceOutput s, fixed3 lightDir, fixed atten) {
|
||||
return fixed4(s.Albedo, s.Alpha);
|
||||
}
|
||||
|
||||
struct Input {
|
||||
float2 uv_MainTex;
|
||||
};
|
||||
fixed4 _Color;
|
||||
|
||||
void surf(Input IN, inout SurfaceOutput o) {
|
||||
o.Albedo = 0;
|
||||
float alpha = tex2D(_MainTex, IN.uv_MainTex);
|
||||
o.Alpha = 0;
|
||||
}
|
||||
ENDCG
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,9 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 96496359528875c4f87b57d6ee52723a
|
||||
ShaderImporter:
|
||||
externalObjects: {}
|
||||
defaultTextures: []
|
||||
nonModifiableTextures: []
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -0,0 +1,54 @@
|
||||
Shader "Punch Through Passthrough"
|
||||
{
|
||||
Properties
|
||||
{
|
||||
_MainTex ("Texture", 2D) = "white" {}
|
||||
}
|
||||
SubShader
|
||||
{
|
||||
Tags {"Queue" = "Geometry"}
|
||||
ZWrite On
|
||||
Cull Off
|
||||
ZTest Always
|
||||
|
||||
Blend Zero Zero
|
||||
|
||||
Pass
|
||||
{
|
||||
CGPROGRAM
|
||||
#pragma vertex vert
|
||||
#pragma fragment frag
|
||||
|
||||
#include "UnityCG.cginc"
|
||||
|
||||
struct appdata
|
||||
{
|
||||
float4 vertex : POSITION;
|
||||
float2 uv : TEXCOORD0;
|
||||
};
|
||||
|
||||
struct v2f
|
||||
{
|
||||
float2 uv : TEXCOORD0;
|
||||
float4 vertex : SV_POSITION;
|
||||
};
|
||||
|
||||
sampler2D _MainTex;
|
||||
float4 _MainTex_ST;
|
||||
|
||||
v2f vert (appdata v)
|
||||
{
|
||||
v2f o;
|
||||
o.vertex = UnityObjectToClipPos(v.vertex);
|
||||
o.uv = v.uv;
|
||||
return o;
|
||||
}
|
||||
|
||||
fixed4 frag (v2f i) : SV_Target
|
||||
{
|
||||
return fixed4(0, 0, 0, 0);
|
||||
}
|
||||
ENDCG
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,10 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 8120257754b48344b8a1a0961bad0c46
|
||||
ShaderImporter:
|
||||
externalObjects: {}
|
||||
defaultTextures: []
|
||||
nonModifiableTextures: []
|
||||
preprocessorOverride: 0
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -0,0 +1,69 @@
|
||||
// Unity built-in shader source. Copyright (c) 2016 Unity Technologies. MIT license (see license.txt)
|
||||
|
||||
// Unlit alpha-blended shader.
|
||||
// - no lighting
|
||||
// - no lightmap support
|
||||
// - no per-material color
|
||||
// Only change from the original: added MipMap bias support
|
||||
|
||||
Shader "Unlit/Transparent MMBias" {
|
||||
Properties {
|
||||
_MainTex ("Base (RGB) Trans (A)", 2D) = "white" {}
|
||||
_MainTexMMBias("Base MipMap Bias", Float) = 0.0
|
||||
}
|
||||
|
||||
SubShader {
|
||||
Tags {"Queue"="Transparent" "IgnoreProjector"="True" "RenderType"="Transparent"}
|
||||
LOD 100
|
||||
|
||||
ZWrite Off
|
||||
Blend SrcAlpha OneMinusSrcAlpha
|
||||
|
||||
Pass {
|
||||
CGPROGRAM
|
||||
#pragma vertex vert
|
||||
#pragma fragment frag
|
||||
#pragma target 2.0
|
||||
#pragma multi_compile_fog
|
||||
|
||||
#include "UnityCG.cginc"
|
||||
|
||||
struct appdata_t {
|
||||
float4 vertex : POSITION;
|
||||
float2 texcoord : TEXCOORD0;
|
||||
UNITY_VERTEX_INPUT_INSTANCE_ID
|
||||
};
|
||||
|
||||
struct v2f {
|
||||
float4 vertex : SV_POSITION;
|
||||
float2 texcoord : TEXCOORD0;
|
||||
UNITY_FOG_COORDS(1)
|
||||
UNITY_VERTEX_OUTPUT_STEREO
|
||||
};
|
||||
|
||||
sampler2D _MainTex;
|
||||
float4 _MainTex_ST;
|
||||
half _MainTexMMBias;
|
||||
|
||||
v2f vert (appdata_t v)
|
||||
{
|
||||
v2f o;
|
||||
UNITY_SETUP_INSTANCE_ID(v);
|
||||
UNITY_INITIALIZE_VERTEX_OUTPUT_STEREO(o);
|
||||
o.vertex = UnityObjectToClipPos(v.vertex);
|
||||
o.texcoord = TRANSFORM_TEX(v.texcoord, _MainTex);
|
||||
UNITY_TRANSFER_FOG(o,o.vertex);
|
||||
return o;
|
||||
}
|
||||
|
||||
fixed4 frag (v2f i) : SV_Target
|
||||
{
|
||||
fixed4 col = tex2Dbias(_MainTex, half4(i.texcoord.x, i.texcoord.y, 0.0, _MainTexMMBias)); // original: tex2D(_MainTex, i.texcoord);
|
||||
UNITY_APPLY_FOG(i.fogCoord, col);
|
||||
return col;
|
||||
}
|
||||
ENDCG
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,10 @@
|
||||
fileFormatVersion: 2
|
||||
guid: d2d85b7dbb1832e4bb13239ecd555f29
|
||||
ShaderImporter:
|
||||
externalObjects: {}
|
||||
defaultTextures: []
|
||||
nonModifiableTextures: []
|
||||
preprocessorOverride: 0
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -0,0 +1,70 @@
|
||||
// Unity built-in shader source. Copyright (c) 2016 Unity Technologies. MIT license (see license.txt)
|
||||
|
||||
// Unlit alpha-cutout shader.
|
||||
// - no lighting
|
||||
// - no lightmap support
|
||||
// - no per-material color
|
||||
// Only change from the original: added MipMap bias support
|
||||
|
||||
Shader "Unlit/Transparent Cutout MMBias" {
|
||||
Properties {
|
||||
_MainTex ("Base (RGB) Trans (A)", 2D) = "white" {}
|
||||
_Cutoff ("Alpha cutoff", Range(0,1)) = 0.5
|
||||
_MainTexMMBias("Base MipMap Bias", Float) = 0.0
|
||||
}
|
||||
SubShader {
|
||||
Tags {"Queue"="AlphaTest" "IgnoreProjector"="True" "RenderType"="TransparentCutout"}
|
||||
LOD 100
|
||||
|
||||
Lighting Off
|
||||
|
||||
Pass {
|
||||
CGPROGRAM
|
||||
#pragma vertex vert
|
||||
#pragma fragment frag
|
||||
#pragma target 2.0
|
||||
#pragma multi_compile_fog
|
||||
|
||||
#include "UnityCG.cginc"
|
||||
|
||||
struct appdata_t {
|
||||
float4 vertex : POSITION;
|
||||
float2 texcoord : TEXCOORD0;
|
||||
UNITY_VERTEX_INPUT_INSTANCE_ID
|
||||
};
|
||||
|
||||
struct v2f {
|
||||
float4 vertex : SV_POSITION;
|
||||
float2 texcoord : TEXCOORD0;
|
||||
UNITY_FOG_COORDS(1)
|
||||
UNITY_VERTEX_OUTPUT_STEREO
|
||||
};
|
||||
|
||||
sampler2D _MainTex;
|
||||
float4 _MainTex_ST;
|
||||
fixed _Cutoff;
|
||||
half _MainTexMMBias;
|
||||
|
||||
v2f vert (appdata_t v)
|
||||
{
|
||||
v2f o;
|
||||
UNITY_SETUP_INSTANCE_ID(v);
|
||||
UNITY_INITIALIZE_VERTEX_OUTPUT_STEREO(o);
|
||||
o.vertex = UnityObjectToClipPos(v.vertex);
|
||||
o.texcoord = TRANSFORM_TEX(v.texcoord, _MainTex);
|
||||
UNITY_TRANSFER_FOG(o,o.vertex);
|
||||
return o;
|
||||
}
|
||||
|
||||
fixed4 frag (v2f i) : SV_Target
|
||||
{
|
||||
fixed4 col = tex2Dbias(_MainTex, half4(i.texcoord.x, i.texcoord.y, 0.0, _MainTexMMBias)); // original: tex2D(_MainTex, i.texcoord);
|
||||
clip(col.a - _Cutoff);
|
||||
UNITY_APPLY_FOG(i.fogCoord, col);
|
||||
return col;
|
||||
}
|
||||
ENDCG
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,10 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 672c396d97853fa4a9aed2f4ae7347aa
|
||||
ShaderImporter:
|
||||
externalObjects: {}
|
||||
defaultTextures: []
|
||||
nonModifiableTextures: []
|
||||
preprocessorOverride: 0
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -0,0 +1,67 @@
|
||||
// Unity built-in shader source. Copyright (c) 2016 Unity Technologies. MIT license (see license.txt)
|
||||
|
||||
// Unlit shader. Simplest possible textured shader.
|
||||
// - no lighting
|
||||
// - no lightmap support
|
||||
// - no per-material color
|
||||
// Only change from the original: added MipMap bias support
|
||||
|
||||
Shader "Unlit/Texture MMBias" {
|
||||
Properties {
|
||||
_MainTex ("Base (RGB)", 2D) = "white" {}
|
||||
_MainTexMMBias("Base MipMap Bias", Float) = 0.0
|
||||
}
|
||||
|
||||
SubShader {
|
||||
Tags { "RenderType"="Opaque" }
|
||||
LOD 100
|
||||
|
||||
Pass {
|
||||
CGPROGRAM
|
||||
#pragma vertex vert
|
||||
#pragma fragment frag
|
||||
#pragma target 2.0
|
||||
#pragma multi_compile_fog
|
||||
|
||||
#include "UnityCG.cginc"
|
||||
|
||||
struct appdata_t {
|
||||
float4 vertex : POSITION;
|
||||
float2 texcoord : TEXCOORD0;
|
||||
UNITY_VERTEX_INPUT_INSTANCE_ID
|
||||
};
|
||||
|
||||
struct v2f {
|
||||
float4 vertex : SV_POSITION;
|
||||
float2 texcoord : TEXCOORD0;
|
||||
UNITY_FOG_COORDS(1)
|
||||
UNITY_VERTEX_OUTPUT_STEREO
|
||||
};
|
||||
|
||||
sampler2D _MainTex;
|
||||
float4 _MainTex_ST;
|
||||
half _MainTexMMBias;
|
||||
|
||||
v2f vert (appdata_t v)
|
||||
{
|
||||
v2f o;
|
||||
UNITY_SETUP_INSTANCE_ID(v);
|
||||
UNITY_INITIALIZE_VERTEX_OUTPUT_STEREO(o);
|
||||
o.vertex = UnityObjectToClipPos(v.vertex);
|
||||
o.texcoord = TRANSFORM_TEX(v.texcoord, _MainTex);
|
||||
UNITY_TRANSFER_FOG(o,o.vertex);
|
||||
return o;
|
||||
}
|
||||
|
||||
fixed4 frag (v2f i) : SV_Target
|
||||
{
|
||||
fixed4 col = tex2Dbias(_MainTex, half4(i.texcoord.x, i.texcoord.y, 0.0, _MainTexMMBias)); // original: tex2D(_MainTex, i.texcoord);
|
||||
UNITY_APPLY_FOG(i.fogCoord, col);
|
||||
UNITY_OPAQUE_ALPHA(col.a);
|
||||
return col;
|
||||
}
|
||||
ENDCG
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,10 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 31d0aa80bfd61974cb31771e0a522854
|
||||
ShaderImporter:
|
||||
externalObjects: {}
|
||||
defaultTextures: []
|
||||
nonModifiableTextures: []
|
||||
preprocessorOverride: 0
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
8
Assets/Oculus/VR/Shaders/OVRVirtualKeyboard.meta
Normal file
8
Assets/Oculus/VR/Shaders/OVRVirtualKeyboard.meta
Normal file
@@ -0,0 +1,8 @@
|
||||
fileFormatVersion: 2
|
||||
guid: cd0e8fa136a69c34ebc3c23501cdc04e
|
||||
folderAsset: yes
|
||||
DefaultImporter:
|
||||
externalObjects: {}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -0,0 +1,109 @@
|
||||
Shader "Oculus/VirtualKeyboard/VirtualKeyboardCursor"
|
||||
{
|
||||
Properties
|
||||
{
|
||||
_MainTex ("Texture", 2D) = "white" {}
|
||||
_Color ("Cursor Color", Color) = (0.1921568, 0.4862745, 0.9490196, 1)
|
||||
_InnerRadius ("Inner Radius", Range(0, 1)) = 0.4
|
||||
_OuterRadius ("Outer Radius", Range(0, 1)) = 0.7
|
||||
_fadeOff ("Fade Off", Range(0, 1)) = 0
|
||||
}
|
||||
SubShader
|
||||
{
|
||||
Tags
|
||||
{
|
||||
"Queue" = "Transparent"
|
||||
"IgnoreProjector" = "True"
|
||||
"RenderType" = "Opaque"
|
||||
}
|
||||
|
||||
Cull Off
|
||||
ZWrite On
|
||||
Blend SrcAlpha OneMinusSrcAlpha
|
||||
AlphaTest Greater 0
|
||||
|
||||
Blend SrcAlpha OneMinusSrcAlpha // Traditional transparency
|
||||
|
||||
Pass
|
||||
{
|
||||
AlphaTest Greater 0.5
|
||||
|
||||
CGPROGRAM
|
||||
#pragma vertex vert
|
||||
#pragma fragment frag
|
||||
|
||||
#include "UnityCG.cginc"
|
||||
|
||||
struct appdata
|
||||
{
|
||||
float4 vertex : POSITION;
|
||||
float2 uv : TEXCOORD0;
|
||||
};
|
||||
|
||||
struct v2f
|
||||
{
|
||||
float2 uv : TEXCOORD0;
|
||||
float4 vertex : SV_POSITION;
|
||||
};
|
||||
|
||||
sampler2D _MainTex;
|
||||
float4 _MainTex_ST;
|
||||
float4 _Color;
|
||||
float _InnerRadius;
|
||||
float _OuterRadius;
|
||||
float _fadeOff;
|
||||
|
||||
v2f vert (appdata v)
|
||||
{
|
||||
v2f o;
|
||||
o.vertex = UnityObjectToClipPos(v.vertex);
|
||||
o.uv = TRANSFORM_TEX(v.uv, _MainTex);
|
||||
return o;
|
||||
}
|
||||
|
||||
fixed4 frag (v2f i) : SV_Target
|
||||
{
|
||||
const float4 transparentColor = float4(_Color.x, _Color.y, _Color.z, 0);
|
||||
const float edgeSmoothDistance = 0.005f;
|
||||
|
||||
const fixed2 pixelPoint = fixed2(i.uv.x, i.uv.y);
|
||||
const float xDist = pow(pixelPoint.x - 0.5, 2);
|
||||
const float yDist = pow(pixelPoint.y - 0.5, 2);
|
||||
const float dist = sqrt(xDist + yDist) / 0.5;
|
||||
|
||||
|
||||
// Hard transparency
|
||||
if (dist < _InnerRadius) {
|
||||
return transparentColor;
|
||||
}
|
||||
if (dist > _OuterRadius) {
|
||||
return transparentColor;
|
||||
}
|
||||
|
||||
float weight = 0;
|
||||
|
||||
// handle fade
|
||||
if (_fadeOff > 0) {
|
||||
weight = (dist) / (1 - (1 - _OuterRadius));
|
||||
// apply fade scale
|
||||
weight = clamp(weight - (1 - _fadeOff), 0, 1);
|
||||
}
|
||||
|
||||
// edge smoothing
|
||||
if (_InnerRadius > edgeSmoothDistance && dist - _InnerRadius < edgeSmoothDistance) {
|
||||
weight = lerp(weight, 1, 1 - ((dist - _InnerRadius) / edgeSmoothDistance));
|
||||
} else if (dist >= _OuterRadius - edgeSmoothDistance && dist < _OuterRadius) {
|
||||
weight = lerp(1, weight, ((_OuterRadius - dist) / edgeSmoothDistance));
|
||||
}
|
||||
|
||||
// Color
|
||||
fixed4 col = lerp(_Color, transparentColor, weight);
|
||||
|
||||
|
||||
|
||||
return col;
|
||||
}
|
||||
ENDCG
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: fdbdac1866c33d54b8bed8e5c7703bf6
|
||||
ShaderImporter:
|
||||
externalObjects: {}
|
||||
defaultTextures:
|
||||
- _MainTex: {fileID: 10305, guid: 0000000000000000f000000000000000, type: 0}
|
||||
nonModifiableTextures: []
|
||||
preprocessorOverride: 0
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
Reference in New Issue
Block a user