v8671

07-12-2011, 02:16 AM

Hi everybody, i am having hard times converting some code into opengl shaders since i am about to convert a big bulk of previous code into glsl.

My problem is the following:

when i pass the matrices ( sp?? ) in the vertex shader and do the computation like this :

gl_Position = (ProjectionMatrix * ViewMatrix * ModelMatrix) * in_Position ;

everything works fine

so my idea is to move the matrix calculation away from the vertex shader and perform the computation entirely on the cpu since the matrix doesn' changes trhough all the vertices sent to the graphics card

so i do something like this :

gl_Position = (ProjViewModelMatrix) * in_Position ;

the ProjViewModelMatrix is computed entirely on the CPU and i pass it trhough an uniform , the problem is that i get a blank screen if i use the simplest matrix possibile like this :

float s=1.0f

p[ 0]=s; p[ 1]=0; p[ 2]=0; p[ 3]=0;

p[ 4]=0; p[ 5]=s; p[ 6]=0; p[ 7]=0;

p[ 8]=0; p[ 9]=0; p[10]=s; p[11]=0;

p[12]=0; p[13]=0; p[14]=0; p[15]=1;

the model is drawn correctly but without a projection of course, but let's

perform a simple translation, this means that p[12]=x, p[13]=y,p[14]= z;

now, if i put a value different from 1 in the p[14] entry i get a blank screen

since the model is drawn away from the observer

how can i solve this problem ?

But better yet, how can i correctly perform computation to match the built in glsl matrix computations ?

i have looked around for tutorial but they always use the built in glsl matrix computations , i haven't seen anyone doing the computation on the cpu , at least not in a public forum or site.

Thanks for any suggestion i am driving nuts.

My problem is the following:

when i pass the matrices ( sp?? ) in the vertex shader and do the computation like this :

gl_Position = (ProjectionMatrix * ViewMatrix * ModelMatrix) * in_Position ;

everything works fine

so my idea is to move the matrix calculation away from the vertex shader and perform the computation entirely on the cpu since the matrix doesn' changes trhough all the vertices sent to the graphics card

so i do something like this :

gl_Position = (ProjViewModelMatrix) * in_Position ;

the ProjViewModelMatrix is computed entirely on the CPU and i pass it trhough an uniform , the problem is that i get a blank screen if i use the simplest matrix possibile like this :

float s=1.0f

p[ 0]=s; p[ 1]=0; p[ 2]=0; p[ 3]=0;

p[ 4]=0; p[ 5]=s; p[ 6]=0; p[ 7]=0;

p[ 8]=0; p[ 9]=0; p[10]=s; p[11]=0;

p[12]=0; p[13]=0; p[14]=0; p[15]=1;

the model is drawn correctly but without a projection of course, but let's

perform a simple translation, this means that p[12]=x, p[13]=y,p[14]= z;

now, if i put a value different from 1 in the p[14] entry i get a blank screen

since the model is drawn away from the observer

how can i solve this problem ?

But better yet, how can i correctly perform computation to match the built in glsl matrix computations ?

i have looked around for tutorial but they always use the built in glsl matrix computations , i haven't seen anyone doing the computation on the cpu , at least not in a public forum or site.

Thanks for any suggestion i am driving nuts.