Jump to content
  • Advertisement
Sign in to follow this  
Viper173

cg question

This topic is 5452 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

so far I passed my OpenGL model matrix to my VShader by 4 float4 parameters looking like this: cgGLSetParameter4f(Model1, M[1,1], M[1,2], M[1,3], M[1,4]); cgGLSetParameter4f(Model2, M[2,1], M[2,2], M[2,3], M[2,4]); cgGLSetParameter4f(Model3, M[3,1], M[3,2], M[3,3], M[3,4]); cgGLSetParameter4f(Model4, M[4,1], M[4,2], M[4,3], M[4,4]); I guess there's a better way to do that...using a float4x4 matrix. but what's the call? cgGLSetMatrixParameterArrayfr I thought but either I did it wrong or it is the wrong call. thanx

Share this post


Link to post
Share on other sites
Advertisement
Is your matrix in row-major or column-major order? cgGLSetMatrixParameterArrayfr is for row major order matrices wile the same function but with a c on the end is for column major order matrices.

What happens when you try to pass a matrix like this anyway? What about it doesn't work?

Share this post


Link to post
Share on other sites
well, I tried both.
I only update normals with that Model Matrix, so the object gets drawn correctly but not lightenend at all.

Share this post


Link to post
Share on other sites
the multiplications with that matrix in the shader are pretty messy anyways. But once I have the correct call it should work as before, right?

heres the call I used:

cgGLSetMatrixParameterArrayfc( ModelMatrix, 0, 16, @M);

I guess the 0 and 16 aren't correct....

Share this post


Link to post
Share on other sites
i may be missing something here, but if your just using the modelview matrix, why not use the matrix tracker functions??

matMV = cgGetNamedParameter(m_cgVertexProgId, "MatMV");
cgGLSetStateMatrixParameter(matMV, CG_GL_MODELVIEW_MATRIX, CG_GL_MATRIX_IDENTITY);
in your shader:
 void vs_main( uniform float4x4 MatMV, ... ) 

note that you can set the projection, modelviewproj to be tracked and also that you can (instead of CG_GL_MATRIX_IDENTITY) you can pass CG_GL_MATRIX_INVERSE_TRANSPOSE (normal matrix) etc. to all trackers.

Check out the Cg Doc's or <CG/cgGL.h> for more defs.

Share this post


Link to post
Share on other sites
AFAIK, there isn't one apart from what you started with, why not create a utility function to take care of this for you?

E-mail nVidia Developer relations, they are extremely patient and helpful.

Cheers,
Danu

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

GameDev.net is your game development community. Create an account for your GameDev Portfolio and participate in the largest developer community in the games industry.

Sign me up!