what the range of values i should get in case of orthographic camera, for x y and z ?
oVert.camSpacePosProj = (uTDMats[TDCameraIndex()].camProj * TDDeform(P)).xyz;
how would you change the projection matrix to always produce z values in range between 0 - 1
i will have to fit the z value between the near and far values i guess,
but - there is any documented or existing method in TD , before i dig bit more ?
or
How do i get the depth node matrix ?
meanwhile :
songho.ca/opengl/gl_projectionmatrix.html
thank you !
Barak
More info about the problem,
I think there is an issue with the orthographic projection not sure it work as it should .
why there are postive and negative numbers in camerasproj space ( z axis) ?
vertex shader :
oVert.camSpacePosProj = (uTDMats[TDCameraIndex()].camProj * worldSpacePos).xyz;
pixel shader:
I`m using case 3
[code]for (int i = 1; i < TD_NUM_COLOR_BUFFERS; i++)
{
switch (i)
{
default:
//Color RGB
oFragColor[i] = diffuseMapColor;
break;
case 1:
//PC world space
oFragColor[i] = TDOutputSwizzle( vec4(iVert.worldSpacePos, 1.0) );
break;
case 2:
//PC world camera space
oFragColor[i] = TDOutputSwizzle( vec4(iVert.camSpacePos.rgb,1.0) );
break;
case 3:
//PC camera after projection space
oFragColor[i] = TDOutputSwizzle( vec4(iVert.camSpacePosProj.rgb,1.0) );
break;
case 4:
//Normal camera space
oFragColor[i] = TDOutputSwizzle(vec4(camSpaceNorm.xyz, 1.0));
break;
case 5:
//alpha
oFragColor[i] = vec4(diffuseMapColor.a);
break;
}
}
}
[/code]
I guess the values are between -1 to 1 after the orthographic projection.
I get better results now.
OpenGL uses -1->1 for all three axii in post projection space. DirectX uses 0-1 for the Z axis, which may be where your confusion comes from.