I have a very strange bug with my stereo manager I hadn't noticed with previous versions of ogre. (It does not work with ogre 1.4.7)
Let's say I have this very simple anaglyph material :
Code: Select all
fragment_program Anaglyph_fp cg
{
source anaglyph.cg
profiles ps_2_0 arbfp1
entry_point Anaglyph_fp
}
material TestAnaglyph
{
technique
{
pass
{
fragment_program_ref Anaglyph_fp
{
}
texture_unit
{
tex_coord_set 0
texture 10points.png
}
texture_unit
{
tex_coord_set 0
texture ogrelogo-small.jpg
}
}
}
}
Code: Select all
float4 Anaglyph_fp
(
in float2 texCoord: TEXCOORD0,
uniform sampler2D LeftTex : register(s0),
uniform sampler2D RightTex : register(s1)
) : COLOR
{
float4 left = tex2D(LeftTex, texCoord);
float4 right = tex2D(RightTex, texCoord);
return float4(left.r, right.g, right.b, 1); // does not work
// return left * float4(1,0,0,1) + right * float4(0,1,1,1); // works
// return float4(left.r, right.g, right.b, left.r); // works
}

There is no error in the log and I'm sure the shader is executed because if I change the texture coordinates in the shader, the changes are visible.
More strangely, if i replace the last line with return left * float4(1,0,0,1) + right * float4(0,1,1,1); or return float4(left.r, right.g, right.b, left.r);, it works fine :

if I change the components used in float4(left.r, right.g, right.b, left.r);, sometimes it shows a mix between the two images (what I want) but sometimes it only shows only one of the two images.
I tried this on a 8800GTX and a 7900GS and the shader worked before.
Did something changed in the Cg compiler with newer versions of ogre ? Is this a bug of the cg compiler or some sort of optimization ? Have you any idea ?
Thanks