Game Development Stack Exchange is a question and answer site for professional and independent game developers. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

Lets say I have got terrain effect, contains multitexturing, light. Now water effect. It must be different, but must be also affected by light. Other one, player effect, must also be affected by light, but doesn't share much stuff with others.

How all of these should be mixed together to create proper effect? Should I write multiple techniques in single effect file, or should I split it to as many as possibile and choose which are needed when rendering?

share|improve this question
up vote 3 down vote accepted

There are many ways to do it; you can write different techniques which stitch together many different shaders (you can use multiple passes to get what you want), you can write lots of pixel/vertex shaders and call lots of common functions and you can also write one massive pixel/vertex shader and use your fields to determine the flow through the algorithm (for example having a flag to determine if it should add lighting and water effects in the pixel shader). Not to mention the fact that you can apply lots of effects post process, even lighting (check out deferred rendering / deferred shading / deferred lighting, I guess deferred is the key word there). Post process effects involve rendering to a render target then running pixel shader passes on it like you would with a sprite.

However, if you want to just play around with a few different effects you can try rendering the object multiple times with different effects. To combine them all you have to do is render the first one normally and perform each subsequent render with blending turned on. It's not efficient at all, nor entirely accurate in all cases. But it's a good way to play around.

share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.