Hey guys,
So I’m trying my hand at Maya’s GLSL shader. I want to make a simple two tone shader that takes a light vector from a directional light, and displays a light texture on the lit side, and another shadow texture on the dark side.
I’m converting it from a CGFX shader I made a while ago. I had a pixel shader that looked like this:
float4 Toon (vert2pixel IN) : COLOR
{
float2 UV = IN.UV;
float3 normalDirection = normalize(IN.worldNormal);
float4 lightDirection = dot(normalDirection, -light1Dir);
if(lightDirection.r>=0){
float4 lightColor = tex2D(diffuseMapSampler, IN.UV);
return lightColor;
}
else
{
float4 darkColor = tex2D(shadowMapSampler, IN.UV);
return darkColor;
}
}
So I tried translating this part to my OGSFX shader in Maya:
GLSLShader PS
{
void main()
{
vec2 UV = out_uv;
vec3 normalDirection = normalize(out_worldNormal);
float lightDirection = dot(normalDirection, light0Dir);
if(lightDirection.r>=0){
out_color = texture2D(lightTextureSampler, psIn.texcoord);
}
else
{
out_color = texture2D(shadowTextureSampler, psIn.texcoord);
}
}
}
and I get this as an error code:
Failed to compile --> PIXEL SHADER <–
Errors:
0(224) : error C7505: OpenGL does not allow swizzles on scalar expressions
222: float lightDirection = dot(normalDirection, light0Dir);
223:
224: if(lightDirection.r>=0){
225: out_color = texture2D(lightTextureSampler, psIn.texcoord);
226: }
//
What do you guys think I’m missing?