Noise2DGen.shader 1.8 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667
  1. Shader "Hidden/VolumetricFog2/Noise2DGen" {
  2. Properties {
  3. _MainTex ("Texture", 2D) = "white" {}
  4. _Color ("Color", Color) = (1,1,1)
  5. }
  6. SubShader {
  7. ZTest Always Cull Off ZWrite Off
  8. Pass
  9. {
  10. CGPROGRAM
  11. #pragma vertex vert
  12. #pragma fragment frag
  13. #include "UnityCG.cginc"
  14. #include "Lighting.cginc"
  15. struct appdata {
  16. float4 vertex : POSITION;
  17. float2 uv : TEXCOORD0;
  18. };
  19. struct v2f {
  20. float4 vertex : SV_POSITION;
  21. float4 uv : TEXCOORD0;
  22. };
  23. sampler2D _MainTex;
  24. half3 _Color;
  25. half3 _SunDir;
  26. half3 _SpecularColor;
  27. half _SpecularIntensity;
  28. float _SpecularThreshold;
  29. v2f vert (appdata v) {
  30. v2f o;
  31. o.vertex = UnityObjectToClipPos(v.vertex);
  32. o.uv = float4(v.uv, 0, 0);
  33. return o;
  34. }
  35. half4 frag (v2f i) : SV_Target {
  36. half3 specularColor = _SpecularColor * ((1.0 + _SpecularIntensity) * _SpecularIntensity);
  37. half lcr = _Color.r * 0.5;
  38. half lcg = _Color.g * 0.5;
  39. half lcb = _Color.b * 0.5;
  40. half scr = specularColor.r * 0.5;
  41. half scg = specularColor.g * 0.5;
  42. half scb = specularColor.b * 0.5;
  43. half2 nlight = normalize(-_SunDir.xz) * 0.3;
  44. half a = tex2D(_MainTex, i.uv.xy).r;
  45. half an = tex2D(_MainTex, i.uv.xy + nlight).r;
  46. half r = saturate ((a - an) * _SpecularThreshold);
  47. half cor = lcr + scr * r;
  48. half cog = lcg + scg * r;
  49. half cob = lcb + scb * r;
  50. return half4(cor, cog, cob, a);
  51. }
  52. ENDCG
  53. }
  54. }
  55. }