Using default fragment shader with custom vertex one?

Started by
2 comments, last by Rasmadrak 15 years, 8 months ago
Good time of the day, Currently I am using the GL_EXT_draw_instanced together with the ability to bind the uniform to a buffer to draw geometry instances in my application. I am using custom vertex shader to transform the model using the matrices in the passed buffer. I also have to write my own fragment shader to shade polygons. Does that mean that I need to implement all the lightning equations? Or is there a way to use the "default" fragment shader to do the work for me? Something is telling me that I can't, because there is not way to modify the active normal, so I would need to pass the normal from vertex shader to fragment shader using a global. But maybe there is still a way that will save me time reinventing the wheel with implementing all the shading equations. Thanks in advance!
Advertisement
That is correct.
If you really need the "fixed functionality" You can look at 3Dlabs' ShaderGen(sorry couldn't find it on google).

Hope this helps.
Fixed pipe does lighting at the vertex stage so you have to do it yourself.
Sig: http://glhlib.sourceforge.net
an open source GLU replacement library. Much more modern than GLU.
float matrix[16], inverse_matrix[16];
glhLoadIdentityf2(matrix);
glhTranslatef2(matrix, 0.0, 0.0, 5.0);
glhRotateAboutXf2(matrix, angleInRadians);
glhScalef2(matrix, 1.0, 1.0, -1.0);
glhQuickInvertMatrixf2(matrix, inverse_matrix);
glUniformMatrix4fv(uniformLocation1, 1, FALSE, matrix);
glUniformMatrix4fv(uniformLocation2, 1, FALSE, inverse_matrix);
http://www.lighthouse3d.com/opengl/glsl/index.php?ogldir1

That site contains a lot of good (and effecient?) samples.
It's actually easy-peasey to re-implement the fixed functionality in shaders. :)

/Robert
"Game Maker For Life, probably never professional thou." =)

This topic is closed to new replies.

Advertisement