Light Textures and Falloff Images: Difference between revisions

From The DarkMod Wiki
Jump to navigationJump to search
(wiki formatting)
Line 3: Line 3:
While I am still getting this article in shape. Whatever notion I have on this topic was conveyed to me by the following members:
While I am still getting this article in shape. Whatever notion I have on this topic was conveyed to me by the following members:


plasticman
* plasticman
 
* Rich_is_Bored
Rich_is_Bored


==Introduction==
==Introduction==
Line 24: Line 23:




http://www.mahalo.com/how-to-learn-texture-baking-in-blender
* http://www.mahalo.com/how-to-learn-texture-baking-in-blender
 
* http://www.ambiera.com/irredit/index.html
 
* http://irrlicht.sourceforge.net/
http://www.ambiera.com/irredit/index.html
 
http://irrlicht.sourceforge.net/


==Step 1 Planning==
==Step 1 Planning==
Line 51: Line 47:
with a black layer and save this merged image as a TGA texture.
with a black layer and save this merged image as a TGA texture.


http://www.tankedup-imaging.com/gimp/layers.html
* http://www.tankedup-imaging.com/gimp/layers.html




Line 84: Line 80:
In this folder, create the following sub-directories:
In this folder, create the following sub-directories:


Materials
* Materials
 
* Lights
Lights


Place your new textures into the Lights directory.
Place your new textures into the Lights directory.
Line 92: Line 87:
Open a text editor like Notepad++ or Wordpad and create document using this as a template:
Open a text editor like Notepad++ or Wordpad and create document using this as a template:


 
<pre>
lights/My_Custom_Light1
lights/My_Custom_Light1
{
{


lightFalloffImage makeIntensity( lights/My_Custom_Light1_Z.tga )
  lightFalloffImage makeIntensity( lights/My_Custom_Light1_Z.tga )


{
  {  
 
  forceHighQuality
forceHighQuality
  map gfx/lights/My_Custom_Light1_XY.tga
 
  zeroClamp
map gfx/lights/My_Custom_Light1_XY.tga
  }
 
zeroClamp
 
}


}
}
</pre>


Save this document and change the extension from ".txt" to ".mtr" and copy it to your new Materials directory.
Save this document and change the extension from ".txt" to ".mtr" and copy it to your new Materials directory.
Line 133: Line 124:




 
<pre>
lights/aa_1_sky1
lights/aa_1_sky1
{
lightFalloffImage makeIntensity( gfx/lights/1_sky1_z.tga )
{
{
 
  lightFalloffImage makeIntensity( gfx/lights/1_sky1_z.tga )
forceHighQuality
  {
 
  forceHighQuality
map gfx/lights/1_sky1_xy.tga
  map gfx/lights/1_sky1_xy.tga
 
  red Parm0 * 2
red Parm0 * 2
  green Parm1 * 2
 
  blue Parm2 * 2
green Parm1 * 2
  zeroClamp
 
  }
blue Parm2 * 2
 
zeroClamp
 
}
 
}
}
</pre>


==Example Ambient Light Shader==
==Example Ambient Light Shader==
Line 162: Line 143:
(from Strombine)
(from Strombine)


 
<pre>
lights/aa_1_amb1
lights/aa_1_amb1
{
ambientLight
lightFalloffImage makeIntensity( gfx/lights/xrampup.tga )
{
{
 
  ambientLight
forceHighQuality
  lightFalloffImage makeIntensity( gfx/lights/xrampup.tga )
 
  {
map gfx/lights/1_amb1_xy.tga
  forceHighQuality
 
  map gfx/lights/1_amb1_xy.tga
colored
  colored
 
  // zeroClamp
// zeroClamp
  }
 
}
 
}
}
</pre>


==TDM Examples==
==TDM Examples==
Line 195: Line 167:
==Links and References==
==Links and References==


Light Baking Thread:
* Light Baking Thread: http://modetwo.net/darkmod/index.php?/topic/11416-light-baking/
 
* Another Light Baking Thread: http://modetwo.net/darkmod/index.php?/topic/4751-lightmaps-in-doom-3-engine-a-hybrid-approach-to-real-time-lighting
http://modetwo.net/darkmod/index.php?/topic/11416-light-baking/
* Strombine: http://www.lunaran.com/page.php?id=165
 
* Strombine at Quake3world: http://www.quake3world.com/forum/viewtopic.php?t=29872
Another Light Baking Thread:
* Kabits Outdoor lighting (references a similar approach) http://www.katsbits.com/tutorials/idtech/dynamic-outdoor-lighting-techniques.php
 
http://modetwo.net/darkmod/index.php?/topic/4751-lightmaps-in-doom-3-engine-a-hybrid-approach-to-real-time-lighting
 
Strombine:
 
http://www.lunaran.com/page.php?id=165
 
Strombine at Quake3world:
 
http://www.quake3world.com/forum/viewtopic.php?t=29872
 
Kabits Outdoor lighting (references a similar approach)
 
http://www.katsbits.com/tutorials/idtech/dynamic-outdoor-lighting-techniques.php

Revision as of 18:21, 18 August 2010

Credits

While I am still getting this article in shape. Whatever notion I have on this topic was conveyed to me by the following members:

  • plasticman
  • Rich_is_Bored

Introduction

While The Dark Mod comes with a rich library of Light Shaders and Textures there are times when mappers may wish to customize the look of lighting further. Light Textures can be used for basic light painting tricks like projecting window-pane light on a floor to advanced uses like simulating the look of a baked light-map.

Lunaran (Matthew Breit) did an in depth look at the performance aspects of Light Shaders in Id Tech 4 and found that there is no performance loss for applying falloff Images and light texture to all the lights on your map. He used this new-found insight to develop a technique for making the most of light textures. Essentially he took screen-shots from specific views of his map where light volumes affected the geometry in a predictable way and then painted light textures that conform to the contours of the space and surfaces shown in the screen-shots.

Lunaran's method involves not only shaped projected and omni lights but also a shaped ambient (that is the deluxe method). Even without shaping the ambient a couple of custom-textured point lights can give you much richer lighting that the standard squares and circles that are commonly used.

To help you understand how these textures work you should imagine the silly flashlight mods for Doom 3 that cause your flashlight to show a pattern (like Bart Simpson's face or a Heart) on the surface that you shine the light on. Instead of shining these types of silly images, we are going to shine images that make the lighting look better by pretending to do stuff that real light does like bouncing of the ground or a wall.

As you have probably guessed, since this is a real light it DOES affect the Light Gem.

(The Light Gem impact may be reduced via a falloff Image that confines the light close to the surface (mostly black with a small strip of illumination)??? Tests pending...)

If someone has advanced knowledge, they could bake light-bounces to a UV mapped texture of a Model created from exported brush-work and then unwrap the texture and copy a portion of it into an image editor to be saved as a light texture as well. This tutorial is just for an artistic-style "winging-it" approach.


Step 1 Planning

Once you have your map or map section built you will need to decide what lights will be direct and where you might want bounced light or moonlight to hit your geometry. If you have placed lights all over the place to approximate these bounced effects then you will need to pare-down some lights.

Step 2 Screen-Shots

Whether you decide to use the deluxe method with a shaped ambient or just a couple of custom lights (here and there) unless you have a perfect memory for proportions, screen-shots will help you design the light texture and falloff texture.

If you decide to use the deluxe version shaped ambient, a top-view view of your map would probably be the best option.

For Lunaran's Projected light example, he shows a side-view screen that has an easy to predict light pattern (like a light waterfall).

If you have a good eye and want to create a show-piece look for some building (etc) you could use a straight view shot and use that to make a very detailed light texture that would be projected straight at the front view surface. I would caution, however, against using sharp contrast and instead make sure that every adjustment is a smooth gradient. The normal maps and geometry will do the rest of the work to create the details.


Load your screen-shot into your preferred image editor Photoshop, Gimp (etc) and create a new layer. Paint the lighting as desired to the new layer. Merge this layer with a black layer and save this merged image as a TGA texture.


Example 1: Create a Layer

LT Part1.JPG

Example 2: Airbrush Artwork

LT Part2.JPG

Example 3: Finished Texture (Bucket-Fill, Smudge Tool, Gaussian Blur)

Complete Light Texture.JPG


You will be doing this twice: Once for the Z-Axis (direction of the light projecting from the source), the other for the XY direction (the surface that the light hits).


I will recommend that you include "Z" and "XY" in the names of the textures so that you can easily distinguish them for the material light shader.


Example Z-Direction Texture: My_Custom_Light1_Z.tga

Example XY-Direction Texture: My_Custom_Light1_XY.tga

Step 3 Material Definitions

If you haven't already done so, please create a separate folder for your map files. In this folder, create the following sub-directories:

  • Materials
  • Lights

Place your new textures into the Lights directory.

Open a text editor like Notepad++ or Wordpad and create document using this as a template:

lights/My_Custom_Light1
{

  lightFalloffImage makeIntensity( lights/My_Custom_Light1_Z.tga )

  { 
  forceHighQuality
  map gfx/lights/My_Custom_Light1_XY.tga
  zeroClamp
  }

}

Save this document and change the extension from ".txt" to ".mtr" and copy it to your new Materials directory.


Step 4 Dark Radiant Light Definitions

1) Select an existing light or create a new light

2) The Light Inspector should list the new Light Texture based on it's specification in the Materials directory

3) Apply the Light Texture and review it's properties in the Entity Inspector pane

Step 5 Resize the Light

Try to maneuver to where you created your original screen-shot.

Position the light and light texture so that it matches the orientation that you used in your screen-shot plan image.

Example Light Shader

(from Strombine)


lights/aa_1_sky1
{
  lightFalloffImage makeIntensity( gfx/lights/1_sky1_z.tga )
  {
  forceHighQuality
  map gfx/lights/1_sky1_xy.tga
  red Parm0 * 2
  green Parm1 * 2
  blue Parm2 * 2
  zeroClamp
  }
}

Example Ambient Light Shader

(from Strombine)

lights/aa_1_amb1
{
  ambientLight
  lightFalloffImage makeIntensity( gfx/lights/xrampup.tga )
  {
  forceHighQuality
  map gfx/lights/1_amb1_xy.tga
  colored
  // zeroClamp
  }
}

TDM Examples

Look in tdm_textures_base01

tdm_light_shadows

tdm_light_textures

Links and References