Mapping:HowTo:Realistic Windows

From Custom Map Makers Wiki
Revision as of 04:58, 24 August 2011 by Pickles (talk | contribs)
Jump to: navigation, search

Creating realistic windows in Urban Terror is fairly easy, but little complex and requires some work. What we will need is:

  1. Window texture modified into Special version of this texture with alpha channel
  2. Special image for creating reflection itself
  3. Shader for getting all this things to work


Let start with finding a good window texture - I like this one:

Realisticwindows3.jpg

Now we have to create a special version of our texture using alpha channel. These areas will be casting reflection. We only want the glass part to make a reflection, not the window frame. We can do it in GIMP or any other professional image editor. I'll use GIMP.

Chessboard means that part of the image is 100% transparent

Just take the image of the window, add an alpha channel, select all the glass parts and hit the delete key. Now it looks like the glass is gone but it's not! It's just 100% transparent. Save as .tga and that's it for the texture. The "transparent areas" will react with shader - that's why we need them - to point out which parts of the window we want to shine.

Now that we have our window texture with glass areas covered with alpha channel it's to the reflection image.


REFLECTION

Reflection image can be easily created by making a screenshot in game of the area the window "sees". Scale it down to 128x128 pixels (you won't need higher resolution) and convert into black and white. As an example:


Realisticwindows4.jpg


It looks weird, but it will only be used to simulate reflection.

SHADER

Simplest shader You can use is that:

textures/your_map/window
{
  {
    map textures/your_map/window.tga  [adds the window texture without paying attention to alpha. You will see the glass part of the windows, too]
  }
  {
    map textures/your_map/reflectionimage.tga [adds reflection over the whole image]
    tcgen environment
    blendFunc GL_ONE GL_ONE    
  }
  {
    map textures/your_map/window.tga  [adds the window texture again on top of everything but this time with alpha. This means your window frame will be pasted over the reflection but the glass part is 100% transparent, so you will still see the reflection here.]
    blendFunc GL_SRC_ALPHA GL_ONE_MINUS_SRC_ALPHA
  }
  {
    map $lightmap  [adds light and shadows]
    blendfunc GL_DST_COLOR GL_SRC_COLOR
  }
}


BRUSHWORK


That's the simplest part of the job. Create Brush, select one face, apply texture with shader (you will recognize it by white outline), fit it and compile!



After that You will get window with reflection, instead of non-shiny, dull texture.


Realisticwindows2.jpg