Jump to content
  • Advertisement
Sign in to follow this  
FunkyMonkey

rendering objects with multiple shaders

This topic is 4816 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

hey hey everyone, I'm back for more help. I'm trying to render a scene using multiple shader effects on objects. Currently, I'm trying out diffuse lighting and an exponential fog effect. Both work great by themselves, but when I do multiple rendering passes the last effect used overwrites all the previous ones. I was wondering if this is what usually happens, or if there is something that I must do in order to prevent this. I tried putting everything into one .fx file and doing multiple passes within the technique, I ended up with the same results. Any help/suggestions would be great.

Share this post


Link to post
Share on other sites
Advertisement
Hi FunkyMonkey,

Well, first off, yes, normally, when you draw two things, one over the other, the second overwrites the first.

If you want to combine two effect, you'll need to figure out what exactly it is you want to do. One option would be alphablending the two resulting images, from each effect into one image. This, in your case, wouldn't work well at all.

The second more fitting option would be to write a single effect that does both things in one pass (could be more, but start off with just one). To do this, you're going to have to figure out what each effect is doing, and how you would go about combining them.

Most likely, the diffuse lighting effect uses some kind of math to calculate a per-vertex color. The fog effect is most likely performing either vertex or pixel based fog, depending on the (exp of the) distance from the camera.
Off the top of my head, what you're probably going to have to do is write one effect that would first calculate the base diffuse color, and then apply the fog to it, in the same method the original effect does. The final outcome would both apply diffuse lighting and fog when you render.

Hope this helps...

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.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!