Jump to content
Posted 19 January 2012 - 01:57 AM
Posted 19 January 2012 - 03:20 AM
Posted 19 January 2012 - 04:46 PM
Posted 20 January 2012 - 11:43 PM
On this car chase game (click for trailer) we used some really simple techniques like MJP mentions.
To use a frame from the video as an example:
[A] are MJP's "cards". We called this same technique "coronas" or "billboard sprites", it's been a common technique in games since forever.
Every frame, I found the location in front of each headlight and drew a rectangle there using additive blending, textured with a glow effect.
To get occlusion working, I drew them with depth-testing disabled (so they would overlap the scene), but hid the whole sprite if the centre was hidden. To implement this hiding/occlusion feature, when drawing the 'sprite' on the CPU, I projected their positions into screen space (by using the projection matrix) and passed this position in as a shader variable. Inside the shader, every pixel sampled the depth-buffer at this same location, and compared the sampled depth against the projected depth. If the sampled depth was closer, then every pixel output black colour instead of the texture colour.
[C] is just a regular bloom shader, which blurs the white headlight geometry a small amount.
[B] is the bloom results applied a second time, but using (1-texCoords) instead, which flips them over the screen to make a fake lens flare.