Skip to main content
gamedev.net
🔒 Locked

Combining Shaders

Started by alirakiyan Sep 5, 2011 at 11:22 AM 0 replies 1.2k views
Original Post
alirakiyan
alirakiyan
hi

How can I combine two shaders? or draw an object with several independent shaders?

for example I wanna draw a shadowed ,bumped object

How can I Draw shadows without changing last object's shader?

undead
undead
"Combining" is maybe a bit too generic.

Some effects like shadowing require special actions to be taken in the rendering pipeline (i.e. rendering the scene from a light's pov then submit the result as a texture input) so in that case there's extra work to be done which isn't shader related.
Some post processing effects can be achieved with multiple passes, in general you can build a post-processing class ping-ponging between two buffers applying effects one after another. In theory that is usually done for specific effects using full screen quads, in practice none prevents you to draw a mesh and reuse the previous buffer output as a parameter for "combining" multiple effects. If the goal is just to combine effects (you don't take advantage of extra data available when post-processing) then performance-wise that isn't the best solution.

The solution that worked for me was to create small bits of HLSL code each performing a specific action/effect and then use .fx preprocessing capabilities to generate the appropriate shader permutation(s) at runtime. Even if this allows great flexibility, shader output won't be 100% as fast as it could and also you will need a system smart enough to identify and reuse the permutations you already generated.

Topic Locked

This topic has been locked by a moderator. New replies are not allowed.

Sign in to reply to this topic.