GeeXLab
Current version: 0.45.1
>GeeXLab homepage

FurMark
Current version: 1.30.0
>FurMark homepage

GPU Caps Viewer
Current version: 1.55.0.0
>GPU Caps Viewer homepage

GPU Shark
Current version: 0.26.0.0
>GPU Shark homepage


Blogs
>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

TessMark
Current version: 0.3.0
>TessMark homepage

ShaderToyMark
Current version: 0.3.0
>ShaderToyMark homepage
>ShaderToyMark Scores

Demoniak3D
Current Version: 1.23.0
>Demoniak3D
>Download
>Libraries and Plugins
>Demos
>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



3 - MultiTexturing

multitexturing is the ability of a 3D engine and more precisely of a 3D graphics board to render several textures in a single pass (i.e in the same time). In OpenGL, this is possible since the 1.3 revision and today almost all graphics controllers are able to perform multitexturing with at least 2 textures.

Multitexturing is fundamental in modern 3D applications and we find it almost everywhere:

  • light-mapping: use of a second texture that contains the shadow and lighting of the scene
  • bump-mapping: use of a texture that contains the relief of a surface
  • gpgpu: several textures that hold mathematic or physic data and that are used in complex scientific simulations (fractals, fluid mechanics, advanced particle system, etc.)
  • and of course, the countless effects based on the use of several textures (reflection, water surface, alpha maps and other gloss-maps, hdr, soft-shadows, etc.)

At the GLSL level, multitexturing is very simple since it is enough to add as many texture samplers as you need. The following shader, from the DEMO_Multi_Texturing.xml demo, shows the use of 4 textures: the base map (or color map) and three lightmaps (red, green and blue maps):

[Vertex_Shader]

void main()
{	
	gl_TexCoord[0] = gl_MultiTexCoord0;
	gl_Position = ftransform();		
}

[Pixel_Shader]

uniform sampler2D colorMap;
uniform sampler2D redMap;
uniform sampler2D greenMap;
uniform sampler2D blueMap;

void main (void)
{
	vec4 color_map = texture2D( colorMap, gl_TexCoord[0].st);
	vec4 red_map = texture2D( redMap, gl_TexCoord[0].st);
	vec4 green_map = texture2D( greenMap, gl_TexCoord[0].st);
	vec4 blue_map = texture2D( blueMap, gl_TexCoord[0].st);
	
	gl_FragColor = color_map + 
			red_map*0.7 + 
			green_map*0.41 + 
			blue_map*0.89;
}

The result is visible in the figure 4:


Multi-Texturing
Fig. 4 - the DEMO_Multi_Texturing.xml demo

This example shows us one of the biggest advantages of the use of shaders for multitexturing compared to the fixed functions: the ability to combine (or mix) as we wish the different texture units.





[ 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



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