Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- Shader "StandardBoostedXrayExtrude"
- {
- Properties
- {
- _ColorXray("Color Xray", Color) = (1,0.792,0,1)
- _BumpScale("Scale NormalMap", Float) = 1.0
- }
- SubShader{
- Pass
- {
- Tags
- {
- //"RenderType" = "Opaque"
- "Queue" = "Opaque"//AlphaTest+49
- "ForceNoShadowCasting" = "True"
- }
- Stencil
- {
- Ref 32//WriteMask 32//
- Comp always
- Pass replace// IncrSat//
- ZFail keep
- }
- Blend SrcAlpha OneMinusSrcAlpha
- CGPROGRAM
- #pragma vertex vert
- #pragma fragment frag
- #include "UnityCG.cginc"
- // Properties
- uniform float4 _ColorXray;
- // sampler2D _BumpMap;
- struct vertexInput
- {
- float4 vertex : POSITION;
- float3 normal : NORMAL;
- };
- struct vertexOutput
- {
- float4 pos : SV_POSITION;
- };
- vertexOutput vert(vertexInput input)
- {
- input.vertex.xyz += input.normal *0.01;
- vertexOutput output;
- output.pos = UnityObjectToClipPos(input.vertex);
- return output;
- }
- float4 frag(vertexOutput input) : COLOR
- {
- return float4(0, 0, 0, 0);
- }
- ENDCG
- }
- Pass
- {
- Tags
- {
- //"RenderType" = "Opaque"
- "Queue" = "AlphaTest+49"//AlphaTest+49
- "ForceNoShadowCasting" = "True"
- }
- // Won't draw where it sees ref value 32
- Cull Back // draw front faces
- ZWrite OFF
- ZTest Always
- Stencil
- {
- //Ref 32
- ReadMask 32//Ref 32
- Comp Equal//NotEqual
- Pass keep
- }
- Blend SrcAlpha OneMinusSrcAlpha
- CGPROGRAM
- #pragma vertex vert
- #pragma fragment frag
- #include "UnityCG.cginc"
- // Properties
- uniform float4 _ColorXray;
- uniform sampler2D _CameraDepthTexture;
- // sampler2D _BumpMap;
- struct vertexInput
- {
- float4 vertex : POSITION;
- float3 normal : NORMAL;
- };
- struct vertexOutput
- {
- float4 pos : SV_POSITION;
- float3 normal : TEXCOORD0;
- float3 viewDirection : POSITION2;
- float4 projPos : TEXCOORD1;
- };
- vertexOutput vert(vertexInput v)
- {
- v.vertex.xyz += v.normal *0.01;
- vertexOutput output;
- output.pos = UnityObjectToClipPos(v.vertex);
- output.normal = normalize(mul(float4(v.normal,0), unity_WorldToObject).xyz);
- float3 mulRes = mul(unity_ObjectToWorld, v.vertex);
- output.viewDirection = normalize(_WorldSpaceCameraPos - mulRes);
- output.projPos = ComputeScreenPos(output.pos);
- COMPUTE_EYEDEPTH(output.projPos.z);
- return output;
- }
- float4 frag(vertexOutput input) : COLOR
- {
- float SceneWaterDepth = max(0, input.projPos.z - _ProjectionParams.g)-max(0, LinearEyeDepth(UNITY_SAMPLE_DEPTH(tex2Dproj(_CameraDepthTexture, UNITY_PROJ_COORD(input.projPos)))) - _ProjectionParams.g);
- if(SceneWaterDepth<3)
- return float4(0, 0, 0,0);
- float newOpacity =1.15 -abs(dot(input.viewDirection, input.normal));
- newOpacity = (newOpacity*(newOpacity)+0.1)*_ColorXray.a;
- float4 output = float4(_ColorXray.rgb, newOpacity);
- return output;
- }
- ENDCG
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement