I am trying to implement a custom effect for one of my animated models.
I've had the problem, though, that anything I rendered with my custom effect was overexposed, although lighting was at intensity 1.0.
While testing, I've found that the colors of the rendered result were always twice as bright as intended.
By analysing the render steps with PIX for Windows, I've realized that every object is rendered twice, with the second pass rendered additively.
I took a lucky guess and implemented a second pass into my effect, with the first pass returning only black as color. At that point I got the result I've expected.
What exactly is the reason for that? How does the render pipeline work there? What passes are expected from my effect and what exactly are their functions?
Hi Sandman,
It sounds like you are using forward rendering - in forward rendering the scene is rendered in layers with each layer applying a single light's contribution to the scene (see the Custom Effects - Forward Rendered article for details). There is also an ambient / Z-fill pass that optimizes per-pixel rendering for all other passes.
Make sure your shader uses SAS lighting bindings to receive lighting information from SunBurn. There's a great example of this in the Custom Effects example (the forward blend.fx), it shows how to define and use the provided lighting bindings.
Let me know if this helps!
Follow me on Twitter – development and personal tweetsAwesome XNA Videos – Lighting, Rendering, and game videos