I have created the following animated shader which takes two textures.
How can I rewrite this to achieve the same effect with vertex lighting instead of pixel lighting? I believe that I need a vertex & fragment shader. I am very new to shader programming and this would greatly help me to understand how they work.
This shader currently runs very poorly on iPhone 4G due to per-pixel lighting.
Shader "Custom/Animated/Layer" {
Properties {
_Speed("Speed (XY)", Vector) = (1, 1, 0, 0)
_Color("Color", Color) = (1, 0, 0)
_MainTex ("Base (RGB)", 2D) = "white" {}
_LayerTex ("Layer (RGB)", 2D) = "bump" {}
}
SubShader {
CGPROGRAM
#pragma surface surf Lambert
sampler2D _MainTex;
sampler2D _LayerTex;
float4 _Color;
float4 _Speed;
struct Input {
float2 uv_MainTex;
float2 uv_LayerTex;
};
void surf(Input IN, inout SurfaceOutput o) {
float4 maintex = tex2D(_MainTex, IN.uv_MainTex);
float4 layertex = tex2D(_LayerTex, IN.uv_LayerTex + _Speed.xy * _Time.x);
o.Albedo = lerp(maintex, maintex * _Color * 2, layertex.r);
o.Alpha = maintex.a;
}
ENDCG
}
FallBack "VertexLit"
}
asked
Feb 06 '12 at 12:03 AM
numberkruncher
2.2k
●
37
●
46
●
59