rendering objects with multiple shaders

Started by
0 comments, last by sirob 18 years, 7 months ago
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.
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...
Sirob Yes.» - status: Work-O-Rama.

This topic is closed to new replies.

Advertisement