Advertisement
Guest User

TheCurveShader

a guest
Jul 4th, 2014
251
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Scala 1.12 KB | None | 0 0
  1. Shader "Custom/Curved" {
  2.     Properties {
  3.         _MainTex ("Base (RGB)", 2D) = "white" {}
  4.         _QOffset ("Offset", Vector) = (0,0,0,0)
  5.         _Brightness ("Brightness", Float) = 0.0
  6.         _Dist ("Distance", Float) = 100.0
  7.     }
  8.    
  9.     SubShader {
  10.         Tags { "Queue" = "Transparent"}
  11.         Pass
  12.         {
  13.            
  14.             Blend SrcAlpha OneMinusSrcAlpha
  15.             CGPROGRAM
  16.             #pragma vertex vert
  17.             #pragma fragment frag
  18.             #include "UnityCG.cginc"
  19.  
  20.             sampler2D _MainTex;
  21.             float4 _QOffset;
  22.             float _Dist;
  23.             float _Brightness;
  24.            
  25.             struct v2f {
  26.                 float4 pos : SV_POSITION;
  27.                 float4 uv : TEXCOORD0;
  28.                 float3 viewDir : TEXCOORD1;
  29.                 fixed4 color : COLOR;
  30.             };
  31.  
  32.             v2f vert (appdata_full v)
  33.             {
  34.                v2f o;
  35.                float4 vPos = mul (UNITY_MATRIX_MV, v.vertex);
  36.                float zOff = vPos.z/_Dist;
  37.                vPos += _QOffset*zOff*zOff;
  38.                o.pos = mul (UNITY_MATRIX_P, vPos);
  39.                o.uv = v.texcoord;
  40.                return o;
  41.             }
  42.             half4 frag (v2f i) : COLOR0
  43.             {
  44.                 half4 col = tex2D(_MainTex, i.uv.xy);
  45.                 col *= UNITY_LIGHTMODEL_AMBIENT*_Brightness;
  46.                 return col;
  47.             }
  48.             ENDCG
  49.         }
  50.     }
  51.    
  52.     FallBack "Diffuse"
  53. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement