Post news RSS Overview over Specter's rendering pipeline

In this post I will address some of the questions I got concerning the rendering and especially the lighting in Specter.

Posted by on

I will demonstrate the rendering process using this screenshot:

Final image...

1. Particle Rendering
All particles are rendered in additive blending mode. This allows for nice fire effects, which is the main application of particle systems in Specter. Effects like smoke or dust are hard to achieve this way, but until now we haven't had need for them.Due to the fact that I only want to apply the additive blending to the particles themselves and not to the scene I have to render them to a separate render target.I also render the depth of each pixel to a separate render target, which will later be used for a z-combine with the world render target.

Particle render target...
Particle depth buffer (not all that interesting because the particles are at maximum depth)...

2. World Rendering
The rest of the world is rendered in alpha blend mode, back-to-front, to a separate render target. That means all sprites have to be depth sorted first. This can get really expensive (at one point 25% of the time in each frame was spent on depth sorting). How I optimized that will be the theme of a later post.I again render the depth of each pixel to a depth buffer. The world depth buffer will be used for the z-combine with the particles, but also as input for the lighting shader.

World render target...

World depth target (lighter is farther away)...

3. Light Rendering
Before we combine the particle and the world render targets we first have to light the scene. Otherwise the particles would be dimmed as well and looking at how they are used for fire that would ruin the effect.The lighting system is one of the more complex systems in Specter and will get a separate post as well. It's based on a blog post by soolstyle, but heavily modified, optimized and in some aspects simplified.I render a quad for every light which is on screen, using the world depth buffer as input for a shader. In the shader I run a edge detection algorithm on the depth buffer to find ridges. The lights are rendered in additive mode. The lighting system supports point and spot lights at the moment.

Light buffer...

4. World/Light combine
To combine the lighting with the world I use a pixel shader that multiplies the two textures together and adds the ambient lighting. It get's tuned a little bit depending on how bright the scene is, but that's not too dramatic.

5. Particle/World combine
As mentioned earlier I combine the world and the particle render target using their depth buffers. This allows me to render particles behind parts of the world.Basically, I render the particle render target over the world render target. A shader takes the two depth buffers as input and discards any pixel where the particle depth is larger than the world depth.

6. Bloom filter
The next step is a full screen bloom effect, which helps to blow out some highlights.

7. Distortion
I'll write another post about distortion but until then you can have a look at this blog post by Eric Wheeler. I do almost exactly what he does.

That's it for now. As I said I'll go more in depth about some aspects in future news, so stay tuned!

Guest - - 695,657 comments

This comment is currently awaiting admin approval, join now to view.

Post a comment
Sign in or join with:

Only registered members can share their thoughts. So come on! Join the community today (totally free - or sign in with your social account on the right) and join in the conversation.