The render is correct until I rotate one of the model 180deg around Y-axis using setRotation(..). Then the shading on the rotated model is flipped as if the light was rotated as well.
I'm using irrCg to implement shader. The only matrix I pass to shader is ETS_PROJECTION * ETS_VIEW * ETS_WORLD, which transforms vertex position to clip plane position.
I have tried passing different matrices like inverse/transpose of ETS_WORLD but still have issue as mentioned. I have a feeling that somehow I miss passing some matrices.
Anyone having this issue?
These are screenshots
Normal shading

Rotated shading

This is the Cg vertex prog, which is from irrCg example, LightingFrag.cg
Code: Select all
void main_v( float4 position : POSITION,
float3 normal : NORMAL,
out float4 oPosition : POSITION,
out float3 objectPos: TEXCOORD0,
out float3 oNormal: TEXCOORD1,
uniform float4x4 modelViewProj)
{
oPosition = mul(modelViewProj, position);
objectPos = position.xyz;
oNormal = normal;
}