Jump to content
  • Advertisement
Sign in to follow this  
Lord_Evil

GLSL and low level shaders

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

Hi, I'm working on integrating shaders into my engine, but there's a question: Can GLSL shaders (i.e. shader objects and program objects) be used concurrently with low level extensions? The purpose is to use GLSL as much as possible but provide support for low level shaders for fallback / performance reasons. My ShaderManager class will handle parameters, so it would be able to deal with named and indexed parameters. Thanks for your help.

Share this post


Link to post
Share on other sites
Advertisement
Quote:
Original post by Lord_Evil
Can GLSL shaders (i.e. shader objects and program objects) be used concurrently with low level extensions?

Depends what you mean by 'low level extensions' and 'concurrently'.

If you want to write a GLSL path and a fallback fixed function path that'll work fine (assuming that only one path is actually rendering at any one time). Some extensions are ignored when you switch to using shaders, some aren't.

Share this post


Link to post
Share on other sites
Well I mean using a GLSL program object in one render pass and using low level shaders (GL_ARB_vertex_program etc.) in another pass.

Does binding the low level shaders unbind the program object?

When shaders and/or glsl aren't available, fixed function fallback passes will be used. The ShaderManager will be online anyway but report that shaders aren't available for use.

Share this post


Link to post
Share on other sites
If you will use both, you need to disable one and also unbind before using the other.

Like glDisable(GL_VERTEX_PROGRAM_ARB)
glDisable(GL_FRAGMENT_PROGRAM_ARB)
glBindProgramARB(GL_VERTEX_PROGRAM_ARB, 0);
glBindProgramARB(GL_FRAGMENT_PROGRAM_ARB, 0);

glUseProgram(MyShader);


and then

glUseProgram(0);

glEnable(GL_VERTEX_PROGRAM_ARB)
glEnable(GL_FRAGMENT_PROGRAM_ARB)
glBindProgramARB(GL_VERTEX_PROGRAM_ARB, MyVertex);
glBindProgramARB(GL_FRAGMENT_PROGRAM_ARB, MyFrag);

and I suggest you test on all hw and drivers.

Share this post


Link to post
Share on other sites
Quote:
Original post by OrangyTang
Quote:
Original post by Lord_Evil
Can GLSL shaders (i.e. shader objects and program objects) be used concurrently with low level extensions?

Depends what you mean by 'low level extensions' and 'concurrently'.

If you want to write a GLSL path and a fallback fixed function path that'll work fine (assuming that only one path is actually rendering at any one time). Some extensions are ignored when you switch to using shaders, some aren't.


That's because shaders override of some of the pipeline. Vertex shader takes some of it and fragment shader takes control of some other.
Things like blending will work as usual. Alpha testing works as usual, Stencil, depth, etc.

Share this post


Link to post
Share on other sites
So, in order to use high level shaders and low level programs together, would you suggest using CG?

Afaik, CG compiles highlevel and lowlevel shaders. Ok, in CG they're all high level, but in terms of profiles you have 'low level' profiles and 'high level' profiles. But you wouldn't have to worry about whether GLSL is supported or not (as long as you're using only basic instructions).

Share this post


Link to post
Share on other sites
Cg provides profiles. It used to be ARB_vp/fp, NV stuff
Now they added GLSL support, which I assume means you can convert Cg code to GLSL.
I don't know what happens if you want to use multiple profiles.

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!