cg question

Started by
7 comments, last by silvermace 19 years, 6 months ago
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
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?
well, I tried both.
I only update normals with that Model Matrix, so the object gets drawn correctly but not lightenend at all.
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....

void cgGLSetMatrixParameterArrayfr(CGparameter parameter,
long startIndex, long numberOfElements,
const float* array);
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.
"I am a donut! Ask not how many tris/batch, but rather how many batches/frame!" -- Matthias Wloka & Richard Huddy, (GDC, DirectX 9 Performance)

http://www.silvermace.com/ -- My personal website
yeah, that's what I did now.
still there's gotta be a way to pass your own matrix in a single call to the shader.
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
"I am a donut! Ask not how many tris/batch, but rather how many batches/frame!" -- Matthias Wloka & Richard Huddy, (GDC, DirectX 9 Performance)

http://www.silvermace.com/ -- My personal website

This topic is closed to new replies.

Advertisement