Jump to content
  • Advertisement
Sign in to follow this  
MattHughes

multiple GLSL shaders (images!)

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

Hello, I'm starting to understand the basics of GLSL and have been toying around with it all afternoon. What I don't understand is how to specify which shader is being used on a certain object. For example, I have this colorful vertex shader: I also have this mediocre toon fragment shader: What would I do if I want the monkey to render with the toon shader, and the human with the colorful shader? Every tutorial that I've found has assumed that I want a shader to apply to the entire scene.

Share this post


Link to post
Share on other sites
Advertisement
You've got to render the two objects using two separate draw calls (which usually means the two objects will be in different vertex/index buffers).

Before each draw call you set up the appropriate shader.

Share this post


Link to post
Share on other sites
When you will render an object, the call sequence might look something like

for all objects;
glBindTexture(...) //Texture
glUseProgram(...) //Shader
glUniform4fv(....) //Uniforms
glBindBuffer(...) //VBO
glVertexPointer(...) //VBO offsets
glBindBuffer(...) //IBO
glDrawRangeElements(....)
repeat;

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.

Participate in the game development conversation and more when you create an account on GameDev.net!

Sign me up!