My Account


RSS
oZone3D.Net RSS Feeds»RSS 2.0 Feeds

Blogs
»The Geeks Of 3D
»Demoniak3D Blog
»JeGX's Infamous Lab

Sponsors

Modul8: real time video mixing and compositing


Link to Us

oZone3D.Net 100% Realtime 3D

»All Links

Search
Google
Web
oZone3D.Net

Web Partners

www.benchmarkhq.ru
www.tdt3d.com
www.steph3d.net
www.g-truc.net
www.worldpcspecs.com


Banners Exchange

cgindia.blogspot.com
grapejuice.c.la
www.game-lab.com
www.cooki3d.org


Links Exchange

»CYGAD's 3DXtra
 
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







Language:


Demoniak3D
Current Version: 1.23.0
»Demoniak3D
»Download
»Libraries and Plugins
»Demos
»Online Help - Reference Guide
»Codes Samples


GPU Caps Viewer
Current Version: 1.4.2
»GPU Caps Viewer
»GPU DB Submissions


FurMark
Current Version: 1.3.0
»FurMark
»Benchmark Submissions
Page generated in 0.067195177078247 seconds.