Advertisement Jump to content
Sign in to follow this  

rendering objects with multiple shaders

This topic is 4885 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
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, you agree to our community Guidelines, Terms of Use, and Privacy Policy. is your game development community. Create an account for your GameDev Portfolio and participate in the largest developer community in the games industry.

Sign me up!