Take the 2-minute tour ×
Game Development Stack Exchange is a question and answer site for professional and independent game developers. It's 100% free, no registration required.

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

1 Answer 1

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

 
discard

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.