leoaered
09-23-2012, 11:55 PM
I'm trying to send the model view projection matrix from the CPU side into my shader, but it's not working as expected. I have two objects loaded into my scene, without any transformations: 'box.wrl' and 'ground.osgb'.
1) Sending over the projection matrix seems to mess up the order of rendering.
uniform vec4 S1, S2, S3, S4;
void main()
{
gl_Position = mat4(S1, S2, S3, S4) * gl_ModelViewMatrix * gl_Vertex;
//gl_Position = ftransform();
}
When I pass in viz.MainWindow.getProjectionMatrix(), the scene looks OK, just the ground is rendered on top of the box. I don't really understand why, since if I use ftransform() or the inbuilt gl_ProjectionMatrix/gl_ModelViewProjectionMatrix the problem goes away. I also don't think there is a problem with the way I'm sending over the matrix, because I tried hardcoding the projection matrix into the vertex shader and had the same issue.
2) I can't get the view matrix to work, or I don't understand how to get it.
uniform vec4 S1, S2, S3, S4;
void main()
{
gl_Position = gl_ProjectionMatrix * mat4(S1, S2, S3, S4) * gl_Vertex;
//gl_Position = ftransform();
}
I tried passing viz.MainView.getMatrix() / viz.MainWindow.getMatrix() to no avail. The box doesn't show up properly. What am I missing? The model matrix should be identity because I didn't have any transforms on the objects.
*Sorry for the double post in Vizard 3.0 forum. I realized I posted on the wrong forum, and also have more useful information this time.
1) Sending over the projection matrix seems to mess up the order of rendering.
uniform vec4 S1, S2, S3, S4;
void main()
{
gl_Position = mat4(S1, S2, S3, S4) * gl_ModelViewMatrix * gl_Vertex;
//gl_Position = ftransform();
}
When I pass in viz.MainWindow.getProjectionMatrix(), the scene looks OK, just the ground is rendered on top of the box. I don't really understand why, since if I use ftransform() or the inbuilt gl_ProjectionMatrix/gl_ModelViewProjectionMatrix the problem goes away. I also don't think there is a problem with the way I'm sending over the matrix, because I tried hardcoding the projection matrix into the vertex shader and had the same issue.
2) I can't get the view matrix to work, or I don't understand how to get it.
uniform vec4 S1, S2, S3, S4;
void main()
{
gl_Position = gl_ProjectionMatrix * mat4(S1, S2, S3, S4) * gl_Vertex;
//gl_Position = ftransform();
}
I tried passing viz.MainView.getMatrix() / viz.MainWindow.getMatrix() to no avail. The box doesn't show up properly. What am I missing? The model matrix should be identity because I didn't have any transforms on the objects.
*Sorry for the double post in Vizard 3.0 forum. I realized I posted on the wrong forum, and also have more useful information this time.