multiple GLSL shaders (images!)
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.
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.
Before each draw call you set up the appropriate shader.
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;
for all objects;
glBindTexture(...) //Texture
glUseProgram(...) //Shader
glUniform4fv(....) //Uniforms
glBindBuffer(...) //VBO
glVertexPointer(...) //VBO offsets
glBindBuffer(...) //IBO
glDrawRangeElements(....)
repeat;
This topic is closed to new replies.
Advertisement
Popular Topics
Advertisement