Hi,
I am seeing some strange behavior while setting vec3/vec4 uniform from outside.
I am using vec3 uniform along with gl_TexCoord[0] to access texture3D for computing gradient. Uniforms are set from outside such that they have value in one index and rest are zero.
float zVal[3] = { 0.0, 0.0, 0.15}; // case 1
e.g glUniform3fv(location, 1, zVal);
and similar for xVal and yVal.
When uniforms are set as above then computed gradients are inorrect. I render normalized gradient as an image and it has lots of black spots and ‘un-evenness’.
But, if If I set zVal as
float zVal[3] = { 0.00001, 0.0, 0.15}; // case 2
then it works fine!
Also if I access specific component and create vec3 in shader for case (1) as vec3( 0.0, 0.0, zVal.z) then also it works fine. In this case assembly generated by compiler is different.
But for case 2, assembly generated is same as case 1 but still computations are incorrect.
Can anyone suggest what is going wrong here?
thanks
Ketan
Note:
!!ARBfp1.0
OPTION NV_fragment_program2;
cgc version 1.6.0000, build date Aug 11 2006 19:59:24
command line args:
#vendor NVIDIA Corporation
#version 1.6.0.0
#profile fp40
#program main
…
ADDR R0.xyz, fragment.texcoord[0], c[0];
ADDR R1.xyz, fragment.texcoord[0], -c[0];
TEX R0.w, R1, texture[0], 3D;
TEX R1.w, R0, texture[0], 3D;
ADDR R0.z, R1.w, -R0.w; // does central diff in X
…
for case 1 and case 2