Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- Shader "Curved/CurvedAlphaWithLightning" {
- Properties {
- _Color("Color", COLOR) = (1, 1, 1, 1)
- _MainTex ("Base (RGB)", 2D) = "white" {}
- _QOffset ("Offset", Vector) = (0,0,0,0)
- _Dist ("Distance", Float) = 100.0
- _Alpha ("Alpha", Range(0.0,1.0)) = 1.0
- }
- SubShader {
- Tags {"Queue"="Transparent" "IgnoreProjector"="True" "RenderType"="Transparent" "LightMode"="ForwardBase"}
- LOD 100
- ZWrite On
- Blend SrcAlpha OneMinusSrcAlpha
- Pass
- {
- Lighting On
- CGPROGRAM
- // Upgrade NOTE: excluded shader from DX11; has structs without semantics (struct v2f members factor)
- //#pragma exclude_renderers d3d11
- #pragma vertex vert
- #pragma fragment frag
- #include "UnityCG.cginc"
- #include "UnityLightingCommon.cginc"
- half4 _Color;
- sampler2D _MainTex;
- float4 _QOffset;
- float _Dist;
- float _Alpha;
- uniform float4 _MainTex_ST;
- struct v2f
- {
- float4 pos : SV_POSITION;
- float2 uv : TEXCOORD0;
- float3 diffColor: COLOR0;
- };
- v2f vert (appdata_base v)
- {
- v2f o;
- float4 vPos = mul (UNITY_MATRIX_MV, v.vertex);
- float zOff = vPos.z/_Dist;
- vPos += _QOffset*zOff*zOff;
- o.pos = mul (UNITY_MATRIX_P, vPos);
- o.uv = TRANSFORM_TEX(v.texcoord, _MainTex);
- // This is lightning model
- half3 worldNormal = UnityObjectToWorldNormal(v.normal);
- float nl = max(0, dot(worldNormal, _WorldSpaceLightPos0.xyz));
- float hLambert = dot(nl*0.5 + 0.5, 2);
- o.diffColor = hLambert * _LightColor0;
- o.diffColor.rgb += ShadeSH9(float4(worldNormal,1));
- return o;
- }
- fixed4 frag (v2f i) : COLOR
- {
- //fixed4 color = tex2D(_MainTex, i.uv) * _Color;
- float4 color = tex2D(_MainTex, i.uv) * float4(_Color.r, _Color.g, _Color.b, _Alpha) * float4(i.diffColor,1);
- return color;
- }
- ENDCG
- }
- }
- //FallBack "Legacy Shaders/Transparent/VertexLit"
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement