Advertisement
Guest User

shader

a guest
Jul 15th, 2019
110
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.62 KB | None | 0 0
  1. Shader "Curved/CurvedAlpha" {
  2. Properties {
  3. _Color("Color", COLOR) = (1, 1, 1, 1)
  4. _MainTex ("Base (RGB)", 2D) = "white" {}
  5. _QOffset ("Offset", Vector) = (0,0,0,0)
  6. _Dist ("Distance", Float) = 100.0
  7. _Alpha ("Alpha", Range(0.0,1.0)) = 1.0
  8. }
  9. SubShader {
  10. Tags {"Queue"="Transparent" "IgnoreProjector"="True" "RenderType"="Transparent"}
  11. LOD 100
  12.  
  13. ZWrite On
  14. Blend SrcAlpha OneMinusSrcAlpha
  15.  
  16. Pass
  17. {
  18. Lighting Off
  19.  
  20. CGPROGRAM
  21. // Upgrade NOTE: excluded shader from DX11; has structs without semantics (struct v2f members factor)
  22. #pragma exclude_renderers d3d11
  23. #pragma vertex vert
  24. #pragma fragment frag
  25. #include "UnityCG.cginc"
  26.  
  27. half4 _Color;
  28. sampler2D _MainTex;
  29. float4 _QOffset;
  30. float _Dist;
  31. float _Alpha;
  32. uniform float4 _MainTex_ST;
  33.  
  34. struct v2f {
  35. float4 pos : SV_POSITION;
  36. float2 uv : TEXCOORD0;
  37. float4 factor: COLOR;
  38. };
  39.  
  40. v2f vert (appdata_base v)
  41. {
  42. v2f o;
  43. float4 vPos = mul (UNITY_MATRIX_MV, v.vertex);
  44. float zOff = vPos.z/_Dist;
  45. vPos += _QOffset*zOff*zOff;
  46. o.pos = mul (UNITY_MATRIX_P, vPos);
  47. o.uv = TRANSFORM_TEX(v.texcoord, _MainTex);
  48. float factor = max(0, dot(v.normal, float3(0,1,0)));
  49. o.factor = float4(factor,0,0,0);
  50. return o;
  51.  
  52. }
  53.  
  54.  
  55. fixed4 frag (v2f i) : COLOR
  56. {
  57. //fixed4 color = tex2D(_MainTex, i.uv) * _Color;
  58. return tex2D(_MainTex, i.uv) * float4(_Color.r, _Color.g, _Color.b, _Alpha) * i.factor.x;
  59. }
  60. ENDCG
  61. }
  62.  
  63. }
  64.  
  65. FallBack "Platogo/Unlit Texture Alpha"
  66. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement