Hi,
I have the following opengl c++ code:
glBegin(GL_QUADS);
float beta = tan((fov*M_PI/180.0f)/2.0f); //find height
float alpha = beta*aspect; //find width
glTexCoord4f(eye[0], eye[1], eye[2], 0);
// upper left corner
glColor4f(-alpha*T[0] - beta*B[0] + N[0],
-alpha*T[1] - beta*B[1] + N[1],
-alpha*T[2] - beta*B[2] + N[2], 0);
glVertex2f(-1, -1);
// upper right corner
glColor4f( alpha*T[0] - beta*B[0] + N[0],
alpha*T[1] - beta*B[1] + N[1],
alpha*T[2] - beta*B[2] + N[2], 0);
glVertex2f( 1, -1);
// lower right corner
glColor4f( alpha*T[0] + beta*B[0] + N[0],
alpha*T[1] + beta*B[1] + N[1],
alpha*T[2] + beta*B[2] + N[2], 0);
glVertex2f( 1, 1);
// lower left corner
glColor4f(-alpha*T[0] + beta*B[0] + N[0],
-alpha*T[1] + beta*B[1] + N[1],
-alpha*T[2] + beta*B[2] + N[2], 0);
glVertex2f(-1, 1);
glEnd();
This is a full screen quad and I know how to implement it with jME. The colors I can set with Quad.setColorBuffer. But, I don't understand how to translate glTexCoord4f(eye[0], eye[1], eye[2], 0); to jME. There is a cg vertex shader with this code:
void main(float4 position : POSITION,
float4 rayOrigin : TEXCOORD0,
float4 rayDirection : COLOR,
out float4 pos : POSITION,
out float4 rO : TEXCOORD0,
out float4 rD : TEXCOORD1,
uniform float4x4 modelViewProj)
{
// compute screen space position of quad corners
pos = mul( glstate.matrix.mvp, position);
// pass ray origins and directions to fragment shader
rO = rayOrigin;
rD = rayDirection;
}
void main()
{
gl_TexCoord[0] = gl_MultiTexCoord0;
gl_Position = ftransform();
gl_TexCoord[1] = gl_Color;
}
Could you help me with glTexCoord4f(eye[0], eye[1], eye[2], 0);, please? The full code, you can find at http://graphics.cs.uiuc.edu/svn/kcrane/web/src/qjuliagpu_src.zip.
Best,
Andreas