Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- Shader "Custom/EdgeBlend" {
- Properties {
- blendFactor ("Edge blend", Range(0.01,5)) = .15
- }
- Subshader {
- Tags {"RenderType"="Transparent" "Queue"="Transparent"}
- Lod 500
- ColorMask RGB
- Pass {
- Blend SrcAlpha OneMinusSrcAlpha
- ZTest LEqual
- ZWrite Off
- Cull Off
- CGPROGRAM
- #pragma target 3.0
- #pragma vertex vert
- #pragma fragment frag
- ENDCG
- }
- CGINCLUDE
- #include "UnityCG.cginc"
- struct appdata
- {
- float4 vertex : POSITION;
- float3 normal : NORMAL;
- };
- struct v2f
- {
- float4 pos : SV_POSITION;
- float4 screenPos : TEXCOORD3;
- };
- sampler2D_float _CameraDepthTexture;
- float blendFactor;
- v2f vert(appdata_full v)
- {
- v2f o;
- o.pos = mul(UNITY_MATRIX_MVP, v.vertex);//
- o.screenPos = ComputeNonStereoScreenPos(o.pos);
- return o;
- }
- half4 frag( v2f i ) : SV_Target
- {
- half depth = SAMPLE_DEPTH_TEXTURE_PROJ(_CameraDepthTexture, UNITY_PROJ_COORD(i.screenPos));
- depth = LinearEyeDepth(depth);
- float baseColour = saturate(blendFactor * (depth-i.screenPos.w)).x;
- return baseColour;
- }
- ENDCG
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement