Sign in to follow this  
Mihulik

How to manage effects?

Recommended Posts

Hi, I'm relative new in 3D graphics programming and I'm confused how to manage effects. I want to give option to users that will use my api to add their own effects. I mean effect as combination of vertex/geometry/pixel shader and render states. My first (and absolutely wrong I think) idea was that I'd make a lot of "mega-über-shaders" that combine every possible combination of effects. For example "NormallMappingAmbientOcclusionDiffuseAndBumpMapping shader".:-D Of course, it's crap because there are so many possible combinations (and I'm not even talking about limited number of instructions in SM3). Further, users couldn't add their own effects because they'd have to rewrite every possible combination for their new effect. So, it's wrong. So, my second idea that could lead to goal is: One "normal" shader for one effect. In this case, I'd render scene several times with corresponding shaders. However, in this case I'd render scene too many times, wouldn't I? Suppose that I want to render scene that contains transparent and opaque objects with per-pixel lighting(normal mapping), diffuse texture and ambient occlusion. So render path would be something like: 1) render opaque objects with diffuse texture 2) same with transparent objects 3) normal mapping 4) ambient occlusion So I'd render scene four times. It's too many because there could be more effects, isn't it? How to manage this? I'd be very very thankful for your advices. Thank you!

Share this post


Link to post
Share on other sites
Hi !

My two rules:

- avoid multipass with too many passes
- avoid single-pass too many instruction

But IMHO it all depends on what your engine is supposed to handle (how many dynamic lights? Transparent/Opaque objects? SSAO? Complex Material system?)

reading your post (and supposing you're using a modern/recent GPU) I think that deferred approach maybe the best way to proceed.



Regards,
Mauro


http://www.breakinglass.com

[Edited by - mauro78 on December 27, 2009 5:47:09 AM]

Share this post


Link to post
Share on other sites
Note that some games do in fact auto-generate hundreds or thousands of shaders with different features enabled - it's not infeasible to take that approach, as long as its sufficiently automated

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this