Remarks on GLSL archives implementation
2005 November 4
KIST IMRC
Jinwook Kim
You may need texture files for the examples below.
1. Normal mapping
Test simple normal mapping and parallax mapping.
- Per fragment lighting calculation requires positive shininess value of the material. But the default value is zero, which will result in an unfavorable shading.
- For parallax mapping, viewing direction should be transformed to the modelview space. But on ATI mobility X600, predefined uniform variable gl_ModelViewMatrixInverse works incorrectly. So it is calculated manually using glNormalMatrixInverse().
- A bump texture is assumed to contain a normal direction in RGB channel and a height value in alpha channel.
- I assume an uplifted height map. But bump texture "tile2Bump.dds" in the example contains subsided height map. Be careful about the elevation direction of a height map.
- To apply this scheme to arbitrary geometry, you should know not only normal direction but tangential and binormal directions per vertices. Here per vertex coordinate frames are assumed to be an identity matrix.
2. Shadow map
Test simple shadow mapping with or without percentage closer filter(PCF).
- Frame-buffer object is required. On ATI mobility X600, RTT on depth only frame-buffer fails when maximizing the window.
- To draw a shadow map which is inherently a texture with an internal format of GL_DEPTH_COMPONENT16, do not forget to set texture parameters GL_TEXTURE_COMPARE_MODE and GL_TEXTURE_MIN_FILTER to GL_COMPARE_R_TO_TEXTURE and GL_LINEAR, respectively.
- GL_DEPTH_COMPONENT24 and GL_DEPTH_COMPONENT32 are not working on ATI mobility X600.
- When using PCF, self shadowing artifacts are noticed when near and far plane setting is relatively big. It is conjectured to be a depth map precision problem.
3. Buffer reduction
Test a performance of buffer reduction on various conditions
- Requires a floating point texture and a frame-buffer object. Note that only a box filter (GL_NEAREST) for floating point textures works on ATI mobility X600.
- If the texture size is considerably small, direct read-back of a frame-buffer may be faster.
4. Depth corrected shadow map
At a fragment shader, write gl_FragDepth according to the transformed vertex position.
- Only for casting shadow on a bumpy surface, just shadow map lookup with a transformed vertex position is sufficient.
- Note that writing gl_FragDepth will disable the early z kill pass. Nothing comes free.
5. Texture viewer
Verify a texture file whether it works with the glsl_common framework.
- Supporting file formats: bmp, dds
- Supporting internal formats: GL_LUMINANCE8, GL_LUMINANCE16, GL_LUMINANCE8_ALPHA8, GL_LUMINANCE16_ALPHA16, GL_R3_G3_B2, GL_RGB8, GL_RGBA8, GL_RGBA16, GL_LUMINANCE32F_ARB, GL_LUMINANCE_ALPHA32F_ARB, GL_RGBA16F_ARB, GL_RGBA32F_ARB, GL_COMPRESSED_RGBA_S3TC_DXT1_EXT, GL_COMPRESSED_RGBA_S3TC_DXT3_EXT, GL_COMPRESSED_RGBA_S3TC_DXT5_EXT
- Supporting targets: GL_TEXTURE_2D, GL_TEXTURE_3D, GL_TEXTURE_CUBEMAP
- Can choose a background color using a HSL color picker.
- Note that automatic mipmap generation on a frame-buffer object does not work on ATI mobility X600.
- Luminance bar of HSL color picker is rendered using 1D texture which is generated using a frame-buffer object according to the current hue-saturation value. Note that render to 1D texture requires horizontally lengthy frame-buffer.
- Cubemap is rendered to a so called sky box. You can see a seam between cubemap faces with a default wrapping mode (GL_CLAMP). Another wrapping modes such as GL_MIRRORED_REPEAT or GL_CLAMP_TO_EDGE may help eliminating this artifact.
6. Displacement mapping
7. Soft shadow
Soft shadow by blurring the shadow map in a screen space. Compare the results with and without PCF and Gaussian blur.
- Change the Gaussian distribution radius to see how it affects on blurring effect.
- Blurring process may require floating point textures for accuracy. But using floating point texture at blurring passes will disable the interpolation of texture lookup. So an internal format of GL_RGB8 is used in this example.
- The bigger the Gaussian distribution radius, the more blurry the scene. But the final image can be darker.
- PCF with 5 samples seams work fine.
- If the blur map resolution is less or equal to the shadow map resolution, self shadowing artifact is found.
- If the predefined varying variable of gl_TexCoord[n] is assigned in a vertex shader but it is not used in a fragment shader, texture lookups may fail in ATI mobility X600.
