- Home /
Question by
qwert12345 · Feb 11, 2014 at 01:50 PM ·
shaderlightingcurve
How can I add lighting to curved shader?
I looking for solution for days, if anybody knows how can I add lighting to following shader:
Shader "Custom/Curved" {
Properties {
_MainTex ("Base (RGB)", 2D) = "white" {}
_QOffset ("Offset", Vector) = (0,0,0,0)
_Dist ("Distance", Float) = 100.0
} SubShader { Tags { "RenderType"="Opaque" } Pass { Lighting Off
CGPROGRAM
#pragma vertex vert
#pragma fragment frag
#include "UnityCG.cginc"
sampler2D _MainTex;
float4 _QOffset;
float _Dist;
uniform float4 _MainTex_ST;
struct v2f {
float4 pos : SV_POSITION;
float2 uv : TEXCOORD0;
};
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);
return o;
}
half4 frag (v2f i) : COLOR
{
return tex2D(_MainTex, i.uv);
}
ENDCG
}
}
FallBack "Mobil/Unlit"
}
Thanks!
Comment
Your answer
Follow this Question
Related Questions
Unity5 Any way to have a unlit no depth shader? 0 Answers
How To Replicate the Untitled Goose Game Art Style? 0 Answers
Masking shader with alpha Color 1 Answer
Inverted Normals in Player, correct in Editor? 1 Answer
Creating a lighting shader 0 Answers