Current version: 0.45.1
>GeeXLab homepage

Current version: 1.30.0
>FurMark homepage

GPU Caps Viewer
Current version:
>GPU Caps Viewer homepage

GPU Shark
Current version:
>GPU Shark homepage

>JeGX's HackLab

Geeks3D's Articles
>GPU Memory Speed Demystified

>Multi-Threading Programming Resources

>GeForce and Radeon OpenCL Overview

>How to Get your Multi-core CPU Busy at 100%

>How To Make a VGA Dummy Plug

>Night Vision Post Processing Filter

PhysX FluidMark
Current version: 1.5.4
>FluidMark homepage

Current version: 0.3.0
>TessMark homepage

Current version: 0.3.0
>ShaderToyMark homepage
>ShaderToyMark Scores

Current Version: 1.23.0
>Libraries and Plugins
>Online Help - Reference Guide
>Codes Samples
The Art of Texturing Using The OpenGL Shading Language

By Jerome Guinot aka 'JeGX' - jegx [at] ozone3d (dot) net

Initial draft: April 15, 2006

[ Index ]

Introduction | Page 2 | Page 3 | Page 4 | Page 5 | Page 6 | Page 7 | Page 8 | Conclusion

�Next Page

5 - Special Textures

5.1 - Gloss Maps

A gloss map is a texture that encodes reflectivity areas. The following picture shows such a texture:

Gloss Map
Fig. 15 - an example of gloss map

The white encodes high reflectivity areas and the black those with low reflectivity. The following image, from the DEMO_Gloss_Map.xml demo shows the use of this gloss maps:

Gloss Mapping
Fig. 16 - the DEMO_Gloss_Map.xml demo

The following GLSL code is the one of the pixel shader of the DEMO_Gloss_Map.xml demo:

uniform samplerCube cubeMap;
uniform sampler2D colorMap;
uniform sampler2D glossMap;

void main (void)
	vec4 output_color;
	// Perform a simple 2D texture look up.
	vec4 base_color = texture2D(colorMap, gl_TexCoord[0].st * 2.0).rgba;
	// Do a gloss map look up and compute the reflectivity.
	vec3 gloss_color = texture2D(glossMap, gl_TexCoord[0].st).rgb;
	float reflectivity = 0.30*gloss_color.r + 
			0.59*gloss_color.g + 

	// Perform a cube map look up.
	vec4 cube_color = textureCube(cubeMap, gl_TexCoord[1].xyz).rgba;

	// Write the final pixel.
	gl_FragColor = base_color + (cube_color*reflectivity);

This pixel shader is an altered version of the CEM one. The reflectivity factor is calculated from the relation used to convert a color into a gray value. Thus, you can use color gloss map if you want.

5.2 - Alpha Maps

An alpha map is a binary texture in the meaning it contains information that allows all or nothing based choices. Alpha maps are usually used for tests at the pixel level (alpha-testing) in order to know if a pixel is either fully opaque or fully transparent. In this last case, the pixel is not sent to the framebuffer, saving a little of fillrate.

There is a handy keyword in GLSL to prevent a fragment (pixel in processing in the OpenGL terminology) to update the framebuffer: discard. According to the OpenGL implementations, the instructions that follow the discard keyword can or can not be executed but in all cases the framebuffer will not be updated. discard is available in the pixel shader only.

The following image shows the alpha map used in the DEMO_Alpha_Map.xml demo:

Alpha Map
Fig. 17 - an example of alpha map

Alpha Mapping
Fig. 18 - the DEMO_Alpha_Map.xml demo

Below, a piece of code that shows the use of the discard keyword:

uniform sampler2D colorMap;
uniform sampler2D alphaMap;

void main (void)
	vec4 alpha_color = texture2D(alphaMap, gl_TexCoord[0].xy);

	gl_FragColor  = texture2D(colorMap, gl_TexCoord[0].xy);

[ Index ]

Introduction | Page 2 | Page 3 | Page 4 | Page 5 | Page 6 | Page 7 | Page 8 | Conclusion

�Next Page

GeeXLab demos

GLSL - Mesh exploder

PhysX 3 cloth demo

Normal visualizer with GS

Compute Shaders test on Radeon

Raymarching in GLSL

>Texture DataPack #1
>Asus Silent Knight CPU Cooler
Page generated in 0.0028538703918457 seconds.