Jump to content
  • Advertisement
Sign in to follow this  
nicknametooshort

Multiple Shaders in GLSL

This topic is 3500 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, My problem: 1. having multiple shaders (GLSL) in one program. 2. in that program i would have (lets say) 3 cubes. 3. i want the 3 different cubes to be affected by three different shaders. So far, i can only program multiple shaders into one program and all 3 cubes are affected by the 3 shaders. Question: Is it GLSL-possible to have the 3 different cubes (in the same program) to be affected by different vertex/fragment shader. if yes, how? my current solution for this right now is having three different programs with the different shaders attached to them. and toggling between the programs.

Share this post


Link to post
Share on other sites
Advertisement
Creating 3 different programs and switching between them is the correct way. A single program will perform the same render operations on all geometry it is used on.

You could technically use only one program and switch and relink the shader objects in it between the draw calls, but that would be just silly.

Share this post


Link to post
Share on other sites
[ You could technically use only one program and switch and relink the shader objects in it between the draw calls, but that would be just silly. ]


that is what i did previously... haha...

i thought so... there is no way 2 shaders can have 2 different impact on 2 different objects in the same program. =.="

thanks for the clarification tho...

Share this post


Link to post
Share on other sites
You could implement your three different shader all inside one shader. Then use a variable to branch your logic. That is what is done in the leadwerks game engine.

Share this post


Link to post
Share on other sites
Quote:
Original post by mmakrzem
You could implement your three different shader all inside one shader. Then use a variable to branch your logic. That is what is done in the leadwerks game engine.


Perhaps that's not a good idea. Perhaps it will reduce performance specially when used in the FS.

Share this post


Link to post
Share on other sites
Quote:
Original post by mmakrzem
You could implement your three different shader all inside one shader. Then use a variable to branch your logic. That is what is done in the leadwerks game engine.


I can't see what there is to gain by doing this though. The whole purpose of the ogl shader program abstraction is to simplify switching between shaders for different objects. Last thing you want to do is increase the complexity of your actual shader.

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.

GameDev.net is your game development community. Create an account for your GameDev Portfolio and participate in the largest developer community in the games industry.

Sign me up!