Jump to content
  • Advertisement
Sign in to follow this  
AverageJoeSSU

OpenGL Deferred Shading w/ Shaders in Cg

This topic is 3905 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

I am using the example in More OpenGL Game Programming to do Deferred Shading using Cg. I am noticing a lot of differences between GLSL and Cg. Things like gl_normalmatrix being the inverse transpose of the ModelView.... Anyone have experience in these differences? or an example of a deferred shading vshader and fshader? I have noticed the example in the book is far from complete, so any insight in the matter would be helpful. (Workflow, Parameters, OpenGL code, Shader code).

Share this post


Link to post
Share on other sites
Advertisement
Cg can't access OpenGL states directly. You should pass all essential states to uniform parameters. If you need ModelViewProjection, set uniform like "mvp". For all these matrix manipulations you can use function cgGLSetStateMatrixParameter from CgGL.

Share this post


Link to post
Share on other sites
Quote:
Original post by keltar
Cg can't access OpenGL states directly. You should pass all essential states to uniform parameters. If you need ModelViewProjection, set uniform like "mvp". For all these matrix manipulations you can use function cgGLSetStateMatrixParameter from CgGL.


It is not correct. Indeed, you can access quite a number of OpenGL states in Cg directly. The syntax for OpenGL states access is something like...

void your_cg_func(
//...
uniform float4x4 mvp : state.matrix.mvp,
uniform float4x4 me : state.matrix.texture,
uniform float4x4 mv : state.matrix.modelview[0]
){

}

For more details about what OpenGL states can be accessed in Cg directly, please
refer to Appendix B of Cg Users Manual in http://developer.nvidia.com/object/cg_toolkit.html.

Share this post


Link to post
Share on other sites
Indeed, it can be used with ARB-based profiles, but not in general case. It is profile-specific extention, and it works only with ARB-based profiles (arbvp1, vp40, gp4vp and so on). Sadly, I don't now how to do the same with glslv/glslf profiles.
Full list of glstates can be found in ARB_vertex_program and ARB_fragment_program specs.

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.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!