::GTapex.com:: Realtime Fakery 102 : "Solid" glass

 
 
Faked Solid Glass
There's many ways to make car headlights, some work better than others. Back in the day when we couldnt afford polys the headlights were generally textured onto the front of the car with no 3D detail.
As the poly counts grew, so did the the detail that artist put into lights, but there was always/and to this day still is in some games, one visual problem on headlights particularily on older cars, that is the headlight glass itself had moulded refraction lines, and its this that give a certain amount of the headlights realism.

There a number of ways aroud this
1. Semi transparent texture of the actual headlight (usually a photo), allowing the viewer to see the 3D detail of the insided of the light, problem is the base texture of the glass is static so any shading, or detail will conflict with any inner headlight modelling

2. Moulded lines, textured onto the glass, now this kind of workss.. i've been doing this since 2002  as a way to get round the problem, since i never really liked the look of semi transparent textures...  but its a so/so solution

3. Modelled glass, apart from the obvious alpha sorting problems.... talk about poly wastage.

4. This techinque, which uses 2 alpha glass layers to fact the smooth outer surface of the headlight, as well as emulating the inner layers moulded lines through the use of a normal map.
downside of course being alpha's are always expensive, it's an extra drawcall and really only I seem to care about 
Examples of various ways to approach headlight glass.
Totally Transparent 2D Semi transparent Texture Alpha lines Faked double sided glass
Actually looks quite good ;P
The Texture Part
First thing you want to do is get a decent flat-on as possible image of the headlight your going to use as a base.
If you've got access to the car its always a plus since you can get the shot and res for a decent base. As with all textures if your doing it yourself, getting as far as possible and using a long focal length will give you less distorted picture (ie less perspective).

Once you've got your texture it's just a simple case of drawing over the lines in the glass in photoshop (on another layer). Its a lonely process... but hey.
Refraction lines on the glass Alpha Map - Used (used as heigh map)

The resultand lines will give you a black and white image like the one on the far left, this is not only works as the perfect alpha map for your glass, but also it doubles up as a height map for converting into a normal map.
Normal Map - NVIDIA Normal tools Normal Map - Crazy Bump
Once you've created you're heigh map, its easy enough to convert it into a normal map using a a variety of tools, not all results are the same though.

Some end use expermination is required ,e.g. Xoliulshader likes subtle bump maps, Racer needs a more extreme one for the effect to work.
The 3D part
The actual 3D bit is actually quite simple, all you need to do is put in your "inner" layer of glass behind the normal glass surface (offest by a few mm)

picture shows the above headlight exploded with the outerglass, innerglass and headlight housing seperated.
1. Outer layer is just a transparent glass material, no normal
2. Inner layer, the same but has a normal map applied. 

Things to watch out for in both the viewport shader & Racer (or any game for that matter) is alpha sorting. issues, which might need some jiggery pokery to get the right.
The Results
 
What you end up with is a closer real time approximation on how the refraction lines on the glass react to the light rather than being a static level of brightness, below are a series of screenshots from Racer where the lighting on the glass "ridges" changes as the car moves around the track. And much like real life when in direct sunlight the refraction lines are hightly visible, and barely visible when not lit.

The only caveat is that alpha's are expensive, soriting can be a problem  and its' an extra drawcall. So not a bad idea for real time rendering with the Xoliulshader for example, but it's probably best to keep this technique to the high LOD model, and swap to a simple alpha texture without the normal layer on LODs for the sake of a decentframe rate!