forked from cgvr/DeltaVR
Initial Commit
This commit is contained in:
92243
Assets/Scripts/DeltaHoone/Other/Wall_Clip_Shader/CLip_Test.unity
Normal file
92243
Assets/Scripts/DeltaHoone/Other/Wall_Clip_Shader/CLip_Test.unity
Normal file
File diff suppressed because it is too large
Load Diff
@@ -0,0 +1,7 @@
|
||||
fileFormatVersion: 2
|
||||
guid: a0ecfe2f9de70b0428967a9ada0e15f0
|
||||
DefaultImporter:
|
||||
externalObjects: {}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -0,0 +1,75 @@
|
||||
Shader "Custom/ClipShaderV2"
|
||||
{
|
||||
Properties
|
||||
{
|
||||
_Color ("Color", Color) = (1,1,1,1)
|
||||
_MainTex ("Albedo (RGB)", 2D) = "white" {}
|
||||
_Glossiness ("Smoothness", Range(0,1)) = 0.5
|
||||
_Metallic ("Metallic", Range(0,1)) = 0.0
|
||||
|
||||
_BackFaceColor ("Inside color", Color) = (1,1,1,1)
|
||||
_FadeColor ("Rim color", Color) = (1,1,1,1)
|
||||
_FadeDistance ("Fade distance", Float) = 10
|
||||
_FadeSmooth ("Fade smooth distance", Float) = 1
|
||||
}
|
||||
SubShader
|
||||
{
|
||||
Tags { "RenderType"="Opaque"}
|
||||
Cull Off
|
||||
LOD 200
|
||||
|
||||
CGPROGRAM
|
||||
#pragma surface surf Standard noshadow
|
||||
#pragma target 3.0
|
||||
|
||||
#include "UnityCG.cginc"
|
||||
|
||||
sampler2D _MainTex;
|
||||
float4 _FadeColor, _BackFaceColor;
|
||||
float _FadeDistance, _FadeSmooth;
|
||||
|
||||
struct Input {
|
||||
float3 worldPos;
|
||||
float2 uv_MainTex;
|
||||
float facing : VFACE;//-1 = if backface
|
||||
};
|
||||
|
||||
half _Glossiness;
|
||||
half _Metallic;
|
||||
fixed4 _Color;
|
||||
|
||||
void surf (Input IN, inout SurfaceOutputStandard o) {
|
||||
//color
|
||||
fixed4 c = tex2D (_MainTex, IN.uv_MainTex) * _Color;
|
||||
o.Albedo = c.rgb;
|
||||
// Other unity stuff
|
||||
o.Metallic = _Metallic;
|
||||
o.Smoothness = _Glossiness;
|
||||
o.Alpha = c.a;
|
||||
|
||||
if(IN.facing == -1) {//backface
|
||||
o.Albedo = _BackFaceColor;
|
||||
}
|
||||
|
||||
//Camera sphere clip
|
||||
fixed3 vec = IN.worldPos.xyz - _WorldSpaceCameraPos;
|
||||
float dis = vec.x*vec.x + vec.y*vec.y + vec.z*vec.z;
|
||||
|
||||
float fadeDis = _FadeDistance * _FadeDistance;
|
||||
float fade = _FadeSmooth * _FadeSmooth;
|
||||
float fadeSmooth = fadeDis + fade;
|
||||
|
||||
if(dis < fadeDis) {
|
||||
clip(-1);
|
||||
}
|
||||
else if (dis < fadeSmooth && IN.facing == 1) {
|
||||
float v = (1-(fadeSmooth-dis)/fade);
|
||||
o.Albedo = o.Albedo * v + (1-v) * _FadeColor;
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
ENDCG
|
||||
}
|
||||
FallBack "Diffuse"
|
||||
}
|
||||
@@ -0,0 +1,9 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 1403bcce49d7b7643abd13849ba8da2e
|
||||
ShaderImporter:
|
||||
externalObjects: {}
|
||||
defaultTextures: []
|
||||
nonModifiableTextures: []
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -0,0 +1,91 @@
|
||||
Shader "DBV/Kristo/WallClip"
|
||||
{
|
||||
Properties
|
||||
{
|
||||
_Color ("Color", Color) = (1,1,1,1)
|
||||
_MainTex ("Albedo (RGB)", 2D) = "white" {}
|
||||
_Glossiness ("Smoothness", Range(0,1)) = 0.5
|
||||
_Metallic ("Metallic", Range(0,1)) = 0.0
|
||||
|
||||
_Color ("Main color", Color) = (1,1,1,1)
|
||||
_FadeDistance ("Fade distance", Float) = 10
|
||||
_FadeSmooth ("Fade smooth distance", Float) = 1
|
||||
|
||||
_DitherTex ("Texture", 2D) = "grey" {}
|
||||
}
|
||||
SubShader
|
||||
{
|
||||
Tags { "RenderType"="Opaque" }
|
||||
LOD 200
|
||||
|
||||
CGPROGRAM
|
||||
// Physically based Standard lighting model, and enable shadows on all light types
|
||||
#pragma surface surf Standard fullforwardshadows
|
||||
|
||||
// Use shader model 3.0 target, to get nicer looking lighting
|
||||
#pragma target 3.0
|
||||
|
||||
half _Glossiness;
|
||||
half _Metallic;
|
||||
|
||||
sampler2D _MainTex, _DitherTex;
|
||||
float4 _DitherTex_TexelSize;
|
||||
|
||||
float4 _Color;
|
||||
float _FadeDistance, _FadeSmooth;
|
||||
|
||||
struct Input
|
||||
{
|
||||
float2 uv_MainTex;
|
||||
float4 screenPos;
|
||||
float3 worldPos;
|
||||
};
|
||||
|
||||
// Add instancing support for this shader. You need to check 'Enable Instancing' on materials that use the shader.
|
||||
// See https://docs.unity3d.com/Manual/GPUInstancing.html for more information about instancing.
|
||||
// #pragma instancing_options assumeuniformscaling
|
||||
UNITY_INSTANCING_BUFFER_START(Props)
|
||||
// put more per-instance properties here
|
||||
UNITY_INSTANCING_BUFFER_END(Props)
|
||||
|
||||
void surf (Input IN, inout SurfaceOutputStandard o) {
|
||||
// Albedo comes from a texture tinted by color
|
||||
fixed4 c = tex2D (_MainTex, IN.uv_MainTex) * _Color;
|
||||
o.Albedo = c.rgb;
|
||||
// Metallic and smoothness come from slider variables
|
||||
o.Metallic = _Metallic;
|
||||
o.Smoothness = _Glossiness;
|
||||
o.Alpha = c.a;
|
||||
|
||||
// sample the texture
|
||||
fixed3 vec = IN.worldPos.xyz - _WorldSpaceCameraPos;
|
||||
float dis = vec.x*vec.x + vec.y*vec.y + vec.z*vec.z;
|
||||
|
||||
float fadeDis = _FadeDistance * _FadeDistance;
|
||||
float fade = _FadeSmooth * _FadeSmooth;
|
||||
float fadeSmooth = fadeDis + fade;
|
||||
|
||||
float2 screenPos = IN.screenPos.xy / IN.screenPos.w;
|
||||
float2 ditherCoordinate = screenPos * _ScreenParams.xy * _DitherTex_TexelSize.xy;
|
||||
float ditherValue = tex2D(_DitherTex, ditherCoordinate).r;
|
||||
|
||||
if(dis < fadeDis) {
|
||||
clip(-1);
|
||||
}
|
||||
else if (dis < fadeSmooth) {
|
||||
float v = (1-(fadeSmooth-dis)/fade);
|
||||
float d = v * c.a - ditherValue;
|
||||
clip(d);
|
||||
c.a = d;
|
||||
}
|
||||
else {
|
||||
float d = c.a - ditherValue;
|
||||
clip(d);
|
||||
c.a = d;
|
||||
}
|
||||
//o.Alpha = c.a;
|
||||
}
|
||||
ENDCG
|
||||
}
|
||||
FallBack "Diffuse"
|
||||
}
|
||||
@@ -0,0 +1,9 @@
|
||||
fileFormatVersion: 2
|
||||
guid: aa14134e6108b06409c88340f5573714
|
||||
ShaderImporter:
|
||||
externalObjects: {}
|
||||
defaultTextures: []
|
||||
nonModifiableTextures: []
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -0,0 +1,81 @@
|
||||
%YAML 1.1
|
||||
%TAG !u! tag:unity3d.com,2011:
|
||||
--- !u!21 &2100000
|
||||
Material:
|
||||
serializedVersion: 6
|
||||
m_ObjectHideFlags: 0
|
||||
m_CorrespondingSourceObject: {fileID: 0}
|
||||
m_PrefabInstance: {fileID: 0}
|
||||
m_PrefabAsset: {fileID: 0}
|
||||
m_Name: Clip_Material_1
|
||||
m_Shader: {fileID: 4800000, guid: 8634eab98f82cd4499699cbc2190acf1, type: 3}
|
||||
m_ShaderKeywords:
|
||||
m_LightmapFlags: 4
|
||||
m_EnableInstancingVariants: 0
|
||||
m_DoubleSidedGI: 0
|
||||
m_CustomRenderQueue: -1
|
||||
stringTagMap: {}
|
||||
disabledShaderPasses: []
|
||||
m_SavedProperties:
|
||||
serializedVersion: 3
|
||||
m_TexEnvs:
|
||||
- _BumpMap:
|
||||
m_Texture: {fileID: 0}
|
||||
m_Scale: {x: 1, y: 1}
|
||||
m_Offset: {x: 0, y: 0}
|
||||
- _DetailAlbedoMap:
|
||||
m_Texture: {fileID: 0}
|
||||
m_Scale: {x: 1, y: 1}
|
||||
m_Offset: {x: 0, y: 0}
|
||||
- _DetailMask:
|
||||
m_Texture: {fileID: 0}
|
||||
m_Scale: {x: 1, y: 1}
|
||||
m_Offset: {x: 0, y: 0}
|
||||
- _DetailNormalMap:
|
||||
m_Texture: {fileID: 0}
|
||||
m_Scale: {x: 1, y: 1}
|
||||
m_Offset: {x: 0, y: 0}
|
||||
- _EmissionMap:
|
||||
m_Texture: {fileID: 0}
|
||||
m_Scale: {x: 1, y: 1}
|
||||
m_Offset: {x: 0, y: 0}
|
||||
- _MainTex:
|
||||
m_Texture: {fileID: 0}
|
||||
m_Scale: {x: 1, y: 1}
|
||||
m_Offset: {x: 0, y: 0}
|
||||
- _MetallicGlossMap:
|
||||
m_Texture: {fileID: 0}
|
||||
m_Scale: {x: 1, y: 1}
|
||||
m_Offset: {x: 0, y: 0}
|
||||
- _OcclusionMap:
|
||||
m_Texture: {fileID: 0}
|
||||
m_Scale: {x: 1, y: 1}
|
||||
m_Offset: {x: 0, y: 0}
|
||||
- _ParallaxMap:
|
||||
m_Texture: {fileID: 0}
|
||||
m_Scale: {x: 1, y: 1}
|
||||
m_Offset: {x: 0, y: 0}
|
||||
m_Floats:
|
||||
- _BumpScale: 1
|
||||
- _Cutoff: 0.5
|
||||
- _DetailNormalMapScale: 1
|
||||
- _DstBlend: 0
|
||||
- _FadeDistance: 60
|
||||
- _FadeSmooth: 7.6
|
||||
- _GlossMapScale: 1
|
||||
- _Glossiness: 0.5
|
||||
- _GlossyReflections: 1
|
||||
- _Metallic: 0
|
||||
- _Mode: 0
|
||||
- _OcclusionStrength: 1
|
||||
- _Parallax: 0.02
|
||||
- _SmoothnessTextureChannel: 0
|
||||
- _SpecularHighlights: 1
|
||||
- _SrcBlend: 1
|
||||
- _UVSec: 0
|
||||
- _ZWrite: 1
|
||||
m_Colors:
|
||||
- _BackFaceColor: {r: 0.08627451, g: 0.3803922, b: 0.08235294, a: 1}
|
||||
- _Color: {r: 0.20000002, g: 0.24313727, b: 0.3019608, a: 1}
|
||||
- _EmissionColor: {r: 0, g: 0, b: 0, a: 1}
|
||||
- _FadeColor: {r: 0.121568635, g: 0.4784314, b: 0.09019608, a: 1}
|
||||
@@ -0,0 +1,8 @@
|
||||
fileFormatVersion: 2
|
||||
guid: e5d667f7053dde3488569c31e919ed15
|
||||
NativeFormatImporter:
|
||||
externalObjects: {}
|
||||
mainObjectFileID: 0
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -0,0 +1,81 @@
|
||||
%YAML 1.1
|
||||
%TAG !u! tag:unity3d.com,2011:
|
||||
--- !u!21 &2100000
|
||||
Material:
|
||||
serializedVersion: 6
|
||||
m_ObjectHideFlags: 0
|
||||
m_CorrespondingSourceObject: {fileID: 0}
|
||||
m_PrefabInstance: {fileID: 0}
|
||||
m_PrefabAsset: {fileID: 0}
|
||||
m_Name: Clip_Material_2
|
||||
m_Shader: {fileID: 4800000, guid: 8634eab98f82cd4499699cbc2190acf1, type: 3}
|
||||
m_ShaderKeywords:
|
||||
m_LightmapFlags: 4
|
||||
m_EnableInstancingVariants: 0
|
||||
m_DoubleSidedGI: 0
|
||||
m_CustomRenderQueue: -1
|
||||
stringTagMap: {}
|
||||
disabledShaderPasses: []
|
||||
m_SavedProperties:
|
||||
serializedVersion: 3
|
||||
m_TexEnvs:
|
||||
- _BumpMap:
|
||||
m_Texture: {fileID: 0}
|
||||
m_Scale: {x: 1, y: 1}
|
||||
m_Offset: {x: 0, y: 0}
|
||||
- _DetailAlbedoMap:
|
||||
m_Texture: {fileID: 0}
|
||||
m_Scale: {x: 1, y: 1}
|
||||
m_Offset: {x: 0, y: 0}
|
||||
- _DetailMask:
|
||||
m_Texture: {fileID: 0}
|
||||
m_Scale: {x: 1, y: 1}
|
||||
m_Offset: {x: 0, y: 0}
|
||||
- _DetailNormalMap:
|
||||
m_Texture: {fileID: 0}
|
||||
m_Scale: {x: 1, y: 1}
|
||||
m_Offset: {x: 0, y: 0}
|
||||
- _EmissionMap:
|
||||
m_Texture: {fileID: 0}
|
||||
m_Scale: {x: 1, y: 1}
|
||||
m_Offset: {x: 0, y: 0}
|
||||
- _MainTex:
|
||||
m_Texture: {fileID: 0}
|
||||
m_Scale: {x: 1, y: 1}
|
||||
m_Offset: {x: 0, y: 0}
|
||||
- _MetallicGlossMap:
|
||||
m_Texture: {fileID: 0}
|
||||
m_Scale: {x: 1, y: 1}
|
||||
m_Offset: {x: 0, y: 0}
|
||||
- _OcclusionMap:
|
||||
m_Texture: {fileID: 0}
|
||||
m_Scale: {x: 1, y: 1}
|
||||
m_Offset: {x: 0, y: 0}
|
||||
- _ParallaxMap:
|
||||
m_Texture: {fileID: 0}
|
||||
m_Scale: {x: 1, y: 1}
|
||||
m_Offset: {x: 0, y: 0}
|
||||
m_Floats:
|
||||
- _BumpScale: 1
|
||||
- _Cutoff: 0.5
|
||||
- _DetailNormalMapScale: 1
|
||||
- _DstBlend: 0
|
||||
- _FadeDistance: 10
|
||||
- _FadeSmooth: 1.17
|
||||
- _GlossMapScale: 1
|
||||
- _Glossiness: 0.5
|
||||
- _GlossyReflections: 1
|
||||
- _Metallic: 0
|
||||
- _Mode: 0
|
||||
- _OcclusionStrength: 1
|
||||
- _Parallax: 0.02
|
||||
- _SmoothnessTextureChannel: 0
|
||||
- _SpecularHighlights: 1
|
||||
- _SrcBlend: 1
|
||||
- _UVSec: 0
|
||||
- _ZWrite: 1
|
||||
m_Colors:
|
||||
- _BackFaceColor: {r: 0, g: 0, b: 0, a: 1}
|
||||
- _Color: {r: 0.5568628, g: 0.53333336, b: 0.4666667, a: 1}
|
||||
- _EmissionColor: {r: 0, g: 0, b: 0, a: 1}
|
||||
- _FadeColor: {r: 0.7725491, g: 0.7372549, b: 0.64705884, a: 1}
|
||||
@@ -0,0 +1,8 @@
|
||||
fileFormatVersion: 2
|
||||
guid: dd5c6c710c2688640a02ca8bb8598015
|
||||
NativeFormatImporter:
|
||||
externalObjects: {}
|
||||
mainObjectFileID: 0
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -0,0 +1,81 @@
|
||||
%YAML 1.1
|
||||
%TAG !u! tag:unity3d.com,2011:
|
||||
--- !u!21 &2100000
|
||||
Material:
|
||||
serializedVersion: 6
|
||||
m_ObjectHideFlags: 0
|
||||
m_CorrespondingSourceObject: {fileID: 0}
|
||||
m_PrefabInstance: {fileID: 0}
|
||||
m_PrefabAsset: {fileID: 0}
|
||||
m_Name: Clip_Material_3
|
||||
m_Shader: {fileID: 4800000, guid: 1403bcce49d7b7643abd13849ba8da2e, type: 3}
|
||||
m_ShaderKeywords:
|
||||
m_LightmapFlags: 4
|
||||
m_EnableInstancingVariants: 0
|
||||
m_DoubleSidedGI: 0
|
||||
m_CustomRenderQueue: -1
|
||||
stringTagMap: {}
|
||||
disabledShaderPasses: []
|
||||
m_SavedProperties:
|
||||
serializedVersion: 3
|
||||
m_TexEnvs:
|
||||
- _BumpMap:
|
||||
m_Texture: {fileID: 0}
|
||||
m_Scale: {x: 1, y: 1}
|
||||
m_Offset: {x: 0, y: 0}
|
||||
- _DetailAlbedoMap:
|
||||
m_Texture: {fileID: 0}
|
||||
m_Scale: {x: 1, y: 1}
|
||||
m_Offset: {x: 0, y: 0}
|
||||
- _DetailMask:
|
||||
m_Texture: {fileID: 0}
|
||||
m_Scale: {x: 1, y: 1}
|
||||
m_Offset: {x: 0, y: 0}
|
||||
- _DetailNormalMap:
|
||||
m_Texture: {fileID: 0}
|
||||
m_Scale: {x: 1, y: 1}
|
||||
m_Offset: {x: 0, y: 0}
|
||||
- _EmissionMap:
|
||||
m_Texture: {fileID: 0}
|
||||
m_Scale: {x: 1, y: 1}
|
||||
m_Offset: {x: 0, y: 0}
|
||||
- _MainTex:
|
||||
m_Texture: {fileID: 0}
|
||||
m_Scale: {x: 1, y: 1}
|
||||
m_Offset: {x: 0, y: 0}
|
||||
- _MetallicGlossMap:
|
||||
m_Texture: {fileID: 0}
|
||||
m_Scale: {x: 1, y: 1}
|
||||
m_Offset: {x: 0, y: 0}
|
||||
- _OcclusionMap:
|
||||
m_Texture: {fileID: 0}
|
||||
m_Scale: {x: 1, y: 1}
|
||||
m_Offset: {x: 0, y: 0}
|
||||
- _ParallaxMap:
|
||||
m_Texture: {fileID: 0}
|
||||
m_Scale: {x: 1, y: 1}
|
||||
m_Offset: {x: 0, y: 0}
|
||||
m_Floats:
|
||||
- _BumpScale: 1
|
||||
- _Cutoff: 0.5
|
||||
- _DetailNormalMapScale: 1
|
||||
- _DstBlend: 0
|
||||
- _FadeDistance: 59
|
||||
- _FadeSmooth: 8.2
|
||||
- _GlossMapScale: 1
|
||||
- _Glossiness: 0.37
|
||||
- _GlossyReflections: 1
|
||||
- _Metallic: 0.712
|
||||
- _Mode: 0
|
||||
- _OcclusionStrength: 1
|
||||
- _Parallax: 0.02
|
||||
- _SmoothnessTextureChannel: 0
|
||||
- _SpecularHighlights: 1
|
||||
- _SrcBlend: 1
|
||||
- _UVSec: 0
|
||||
- _ZWrite: 1
|
||||
m_Colors:
|
||||
- _BackFaceColor: {r: 0, g: 0, b: 0, a: 1}
|
||||
- _Color: {r: 1, g: 0.98764145, b: 0, a: 1}
|
||||
- _EmissionColor: {r: 0, g: 0, b: 0, a: 1}
|
||||
- _FadeColor: {r: 1, g: 0, b: 0, a: 1}
|
||||
@@ -0,0 +1,8 @@
|
||||
fileFormatVersion: 2
|
||||
guid: b8283e148ad316f40bca20bbdf89f5fe
|
||||
NativeFormatImporter:
|
||||
externalObjects: {}
|
||||
mainObjectFileID: 0
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -0,0 +1,159 @@
|
||||
Shader "DBV/Kristo/UnlitClip"
|
||||
{
|
||||
Properties
|
||||
{
|
||||
_MainTex ("Texture", 2D) = "white" {}
|
||||
_Color ("Main color", Color) = (1,1,1,1)
|
||||
_BackFaceColor ("Inside color", Color) = (1,1,1,1)
|
||||
_FadeColor ("Rim color", Color) = (1,1,1,1)
|
||||
_FadeDistance ("Fade distance", Float) = 10
|
||||
_FadeSmooth ("Fade smooth distance", Float) = 1
|
||||
|
||||
_DitherTex ("Texture", 2D) = "grey" {}
|
||||
}
|
||||
SubShader {
|
||||
Tags {
|
||||
"RenderType"="Opaque"
|
||||
}
|
||||
LOD 100
|
||||
|
||||
Pass {
|
||||
Cull Back
|
||||
CGPROGRAM
|
||||
#pragma vertex vert
|
||||
#pragma fragment frag
|
||||
|
||||
#pragma multi_compile_fog// make fog work
|
||||
|
||||
#include "UnityCG.cginc"
|
||||
|
||||
struct appdata {
|
||||
float4 vertex : POSITION;
|
||||
float2 uv : TEXCOORD0;
|
||||
float4 screenPos : TEXCOORD1;
|
||||
};
|
||||
|
||||
struct v2f {
|
||||
float2 uv : TEXCOORD0;
|
||||
UNITY_FOG_COORDS(1)
|
||||
float4 vertex : SV_POSITION;
|
||||
float4 worldSpace : TEXCOORD1;
|
||||
float4 screenPos : TEXCOORD2;
|
||||
};
|
||||
|
||||
sampler2D _MainTex, _DitherTex;
|
||||
float4 _DitherTex_TexelSize;
|
||||
float4 _MainTex_ST;
|
||||
|
||||
float4 _FadeColor, _BackFaceColor, _Color;
|
||||
float _FadeDistance, _FadeSmooth;
|
||||
|
||||
v2f vert (appdata v) {
|
||||
v2f o;
|
||||
o.vertex = UnityObjectToClipPos(v.vertex);
|
||||
o.uv = TRANSFORM_TEX(v.uv, _MainTex);
|
||||
o.worldSpace = mul(unity_ObjectToWorld, v.vertex);
|
||||
o.screenPos = ComputeScreenPos(o.vertex);
|
||||
UNITY_TRANSFER_FOG(o,o.vertex);
|
||||
return o;
|
||||
}
|
||||
|
||||
fixed4 frag (v2f i) : SV_Target {
|
||||
// sample the texture
|
||||
fixed4 col = tex2D(_MainTex, i.uv) * _Color;
|
||||
fixed3 vec = i.worldSpace.xyz - _WorldSpaceCameraPos;
|
||||
float dis = vec.x*vec.x + vec.y*vec.y + vec.z*vec.z;
|
||||
|
||||
float fadeDis = _FadeDistance * _FadeDistance;
|
||||
float fade = _FadeSmooth * _FadeSmooth;
|
||||
float fadeSmooth = fadeDis + fade;
|
||||
|
||||
if(dis < fadeDis) {
|
||||
col = 0;
|
||||
clip(-1);
|
||||
}
|
||||
else if (dis < fadeSmooth) {
|
||||
float v = (1-(fadeSmooth-dis)/fade);
|
||||
//Do dither fade
|
||||
//https://www.ronja-tutorials.com/2019/05/11/dithering.html
|
||||
float2 screenPos = i.screenPos.xy / i.screenPos.w;
|
||||
float2 ditherCoordinate = screenPos * _ScreenParams.xy * _DitherTex_TexelSize.xy;
|
||||
float ditherValue = tex2D(_DitherTex, ditherCoordinate).r;
|
||||
clip(v - ditherValue);
|
||||
col = col * v + (1-v) * _FadeColor;
|
||||
}
|
||||
else{
|
||||
//col.rgb *= i.worldSpace.xyz;
|
||||
}
|
||||
|
||||
// apply fog
|
||||
UNITY_APPLY_FOG(i.fogCoord, col);
|
||||
return col;
|
||||
}
|
||||
ENDCG
|
||||
}
|
||||
|
||||
Pass {
|
||||
Cull Front
|
||||
CGPROGRAM
|
||||
#pragma vertex vert
|
||||
#pragma fragment frag
|
||||
|
||||
#pragma multi_compile_fog// make fog work
|
||||
|
||||
#include "UnityCG.cginc"
|
||||
|
||||
struct appdata {
|
||||
float4 vertex : POSITION;
|
||||
float2 uv : TEXCOORD0;
|
||||
float4 screenPos : TEXCOORD1;
|
||||
};
|
||||
|
||||
struct v2f {
|
||||
float2 uv : TEXCOORD0;
|
||||
UNITY_FOG_COORDS(1)
|
||||
float4 vertex : SV_POSITION;
|
||||
float4 worldSpace : TEXCOORD1;
|
||||
float4 screenPos : TEXCOORD2;
|
||||
};
|
||||
|
||||
float4 _BackFaceColor;
|
||||
float _FadeDistance, _FadeSmooth;
|
||||
|
||||
sampler2D _DitherTex;
|
||||
float4 _DitherTex_TexelSize;
|
||||
|
||||
v2f vert (appdata v) {
|
||||
v2f o;
|
||||
o.vertex = UnityObjectToClipPos(v.vertex);
|
||||
o.worldSpace = mul(unity_ObjectToWorld, v.vertex);
|
||||
return o;
|
||||
}
|
||||
|
||||
fixed4 frag (v2f i) : SV_Target {
|
||||
fixed3 vec = i.worldSpace.xyz - _WorldSpaceCameraPos;
|
||||
float dis = vec.x*vec.x + vec.y*vec.y + vec.z*vec.z;
|
||||
|
||||
float fadeDis = _FadeDistance * _FadeDistance;
|
||||
float fade = _FadeSmooth * _FadeSmooth;
|
||||
float fadeSmooth = fadeDis + fade;
|
||||
|
||||
if(dis < fadeDis) {
|
||||
clip(-1);
|
||||
}
|
||||
else if (dis < fadeSmooth) {
|
||||
float v = (1-(fadeSmooth-dis)/fade);
|
||||
//Do dither fade
|
||||
//https://www.ronja-tutorials.com/2019/05/11/dithering.html
|
||||
float2 screenPos = i.screenPos.xy / i.screenPos.w;
|
||||
float2 ditherCoordinate = screenPos * _ScreenParams.xy * _DitherTex_TexelSize.xy;
|
||||
float ditherValue = tex2D(_DitherTex, ditherCoordinate).r;
|
||||
clip(v - ditherValue);
|
||||
}
|
||||
return _BackFaceColor;
|
||||
}
|
||||
ENDCG
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,9 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 8634eab98f82cd4499699cbc2190acf1
|
||||
ShaderImporter:
|
||||
externalObjects: {}
|
||||
defaultTextures: []
|
||||
nonModifiableTextures: []
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
Reference in New Issue
Block a user