PDA

View Full Version : Shader Centric Projection Rejection



optimal.complex
02-05-2014, 02:08 AM
Is it reasonable for exploration purposes to construct a
projection matrix
within the vertex shader? My projection gets a rejection during rendering.
My projection matrix does not meet my expection during rendering. It does something. I just cannot tell what.
Am I missing some obvious pieces of the opengl picture?
I am trying to see how expressive the shader can be. So I am transforming there.


...elided
//cpp
glutInitContextVersion(4, 2); Show_GL_Error();
glutInitContextFlags(GLUT_CORE_PROFILE | GLUT_DEBUG);
glutInitContextProfile(GLUT_FORWARD_COMPATIBLE); //Show_GL_Error();

//vertex shader
mat4 perspective =
{
{(2 *near)/(right - left), 0,0,0},
{0, (2 * near)/(top-bottom), 0,0},
{2*(right+left)/(right-left),2*(top+bottom)/(top-bottom), -(far + near)/(far-near), -1},
{0,0,-(2*far*near)/(far-near),0}
};
...elided
this works for rotation
gl_Position = trans * scale * roty * vPosition;
..................
this gives me unexpected results
gl_Position = perspective * trans * scale * roty * vPosition;
...................
What does work
Viewing and rotating various meshes exported from Blender 3D.