New shader
After doing the deferred lighting system we hit a content stall. We’re waiting on artwork to put in. So, during this time I toyed with some other lighting systems. One of the goals I’ve liked striving for is more artist control over the look of the application. What this means is that once I’ve finished coding it, an artist can sit down by themselves and manipulate the look as they want. If lighting parameters are bound up in code somewhere this makes it really difficult. After the jump, I’ll show you what I came up with to help with this problem.
First off, the models that appear in the images below are not ours. They were available online for free, but we will only be using them for demonstration purposes. They won’t appear in Bombs, or any other applications of ours. Thanks go to the original modelers.
Those screenshots show lighting that is based on 3 factors: The lighting condition (direction, distance, and color), the viewing angle, and the distance from the viewer. So, how is an artist given control over this? Using two textures, an artist can create a great many lighting effects. Here are the textures used to control the above images.
The top image shows the texture controlling the diffuse lighting, based on the direction to the light (x-axis) and the distance from the viewer (y-axis). The second texture lets artists define lighting effects that are view-dependent (rim lighting or shading, specularity, etc.) which depends on the direction of the viewer (x-axis) and distance from the viewer (y-axis).
Changing lighting behavior is fairly easy by modifying these textures. It isn’t instantly mastered. The textures do have a bit of a learning curve until you get a hang of how changes in the textures translate to changes in lighting behavior. However, it’s fairly obvious how these textures provide a lot of control for artists, and are easier to edit than parameters in code. Essentially each 2D texture is defining a function with two inputs, which output a result that is combined into the lighting equations. By changing the textures, an artist is actually changes the lighting equations themselves.
Here’s an example of two different textures.
You can see they are quite different. The top lighting texture has had all color removed and a more gentle slope introduced. This will give the objects a softer look. The bottom texture shows a rim darkening effect. Here are the results of using these textures.
We can achieve many varied looks using these two lighting textures (not to mention textures mapped to the object itself). The other benefit of this technique used with forward rendering (not deferred) is that each object can easily have its own custom lighting. Also, because the lighting equations are stored in textures, a simple texture fetch (tex2D) function computes view-independent and view-dependent lighting effects. The fewer instructions means we can handle more lights per pass than usual, meaning overall a scene will be able handle more lights with forward rendering than before (16, 32, maybe even 64 lights per object with modern cards that support Shader Model 3.0). With this, we may be able to achieve a many-light rendering system without the up-front cost of deferred rendering. This is still experimental and the deferred renderer is still in Bombs, but as the art content and style becomes more concrete we may move over to a system based around this shader. Stay tuned for more!
1 comment














Would you like to give me your email with which I can contact with you directly for some consultation? Thank you.