Some new effects
3:13 pm in Tesla Engine by Starnick
Thought I’d give the blog a spin for a change, since I’ve moved most of my updates to the twitter feed. Work on Tesla is a bit slow, but steady as I’m currently juggling three different projects. The past week I thought I’d take a break from the drudgery and actually do some cool graphics programming for a change! I’m also including these in the sample browser.
Glow Effect
This is an effect I’ve wanted to do for a while (especially after playing the X3 games), it’s essentially a bloom post-process effect. Instead of extracting the brightest parts of the scene however, you control how much geometry glow via a glow map. You render all your objects that self-illuminate to a render target, apply a gaussian blur filter and then composite that image with the final frame buffer contents. When rendering your objects normally, you also include the glow map to control the emissive lighting term (like a specular map, that way you can also tweak it with a material emissive parameter to change its intensity). That way your object looks right when the glow effect is applied to parts of it that are in darkness. Overall it’s a pretty cool effect, as these pictures can show.

This is the model from the glow sample. It actually came with an emissive map that I colorized to use in the effect.
Thick Wireframes
The second effect is a familiar topic: wireframe drawing. Drawing thick lines is actually a widely asked topic in the D3D world, since unlike OpenGL there’s no easy/fast way of doing it. So you tend to end up with very thin, hard to see wireframes that are badly aliased and fight with the solid model underneath (usually applying a depth bias to the wireframe helps, but care needs to be taken in making sure that bias isn’t too large). I found an interesting technique on the web the other day that deals with drawing nice thick and smooth wireframes over solid objects:
http://www2.imm.dtu.dk/~jab/Wireframe/
It’s really an interesting idea – essentially the technique has you draw wireframes as solid triangles where you switch from fill color to wire color depending on the distance to the triangle edges. So it’s actually a single-pass technique, although you can have a transparent fill color and blend it with the object (actually that’s what I do in the sample, to preserve lighting). As you can see in the image below, it’s a pretty stark difference. The downside is you need to replicate data, since each vertex needs to know the other two vertices in the triangle, although the technique can also be done using geometry shaders (in fact Nvidia has such an implement here). Another interesting perk of this technique is you have complete control how the wireframe is drawn, so you can have interesting effects like a dotted edge or remove the interior of the polygon to get a halo-ed line (see the original link for images!).

Left: Teapot rendered with this technique. Right: Teapot wireframe rendered the naive way (no depth bias however).
Last but not least…
Shadow mapping! I’ve put off bringing shadows to Tesla for a while now. I hope to implement some helper classes/shadow managers in setting up scenes that require shadow map generation really easy too.



