CreaseApply.shader 1.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263
  1. // Upgrade NOTE: replaced 'mul(UNITY_MATRIX_MVP,*)' with 'UnityObjectToClipPos(*)'
  2. Shader "Hidden/CreaseApply" {
  3. Properties {
  4. _MainTex ("Base (RGB)", 2D) = "white" {}
  5. _HrDepthTex ("Base (RGB)", 2D) = "white" {}
  6. _LrDepthTex ("Base (RGB)", 2D) = "white" {}
  7. }
  8. SubShader {
  9. Pass {
  10. ZTest Always Cull Off ZWrite Off
  11. CGPROGRAM
  12. #pragma vertex vert
  13. #pragma fragment frag
  14. #include "UnityCG.cginc"
  15. sampler2D _MainTex;
  16. sampler2D _HrDepthTex;
  17. sampler2D _LrDepthTex;
  18. uniform float4 _MainTex_TexelSize;
  19. uniform float intensity;
  20. struct v2f {
  21. float4 pos : SV_POSITION;
  22. float2 uv : TEXCOORD0;
  23. };
  24. v2f vert( appdata_img v )
  25. {
  26. v2f o;
  27. o.pos = UnityObjectToClipPos (v.vertex);
  28. o.uv.xy = v.texcoord.xy;
  29. return o;
  30. }
  31. half4 frag (v2f i) : SV_Target
  32. {
  33. float4 hrDepth = tex2D(_HrDepthTex, i.uv);
  34. float4 lrDepth = tex2D(_LrDepthTex, i.uv);
  35. hrDepth.a = DecodeFloatRGBA(hrDepth);
  36. lrDepth.a = DecodeFloatRGBA(lrDepth);
  37. float4 color = tex2D(_MainTex, i.uv);
  38. return color * (1.0-abs(hrDepth.a-lrDepth.a)*intensity);
  39. }
  40. ENDCG
  41. }
  42. }
  43. Fallback off
  44. }