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



6 - Texture Warping

Texture warping takes place in the many effects we can apply to a texture in order to achieve a very cool result. The principle of warping is to perturb texture coordinates to create a deformation of the final image.

The following image shows us an example of texture warping:


Texture Warping
Fig. 19 - the DEMO_Texture_Warping.xml demo

There are several methods to warp texture coordinates. We will use the one based on a normal map. This normal map has been created from texture filled with Perlin noise using the nVidia plugin for Photoshop:


Texture Warping - Perlin Noise
Fig. 20 - the noise texture

This technique based on a GLSL shader to warp the texture coordinates is powerful because we act at the texel level. That means it is not necessary to have a dense mesh to create this effect.

The following shader, coming from the DEMO_Texture_Warping.xml demo, shows the texture warping:

[Vertex_Shader]

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

[Pixel_Shader]

uniform sampler2D colorMap;
uniform sampler2D noiseMap;
uniform float timer;

void main (void)
{
	vec3 noiseVec;
	vec2 displacement;
	float scaledTimer;

	displacement = gl_TexCoord[0].st;

	scaledTimer = timer*0.1;

	displacement.x += scaledTimer;
	displacement.y -= scaledTimer;

	noiseVec = normalize(texture2D(noiseMap, displacement.xy).xyz;
	noiseVec = (noiseVec * 2.0 - 1.0) * 0.035;
	
	gl_FragColor = texture2D(colorMap, gl_TexCoord[0].st + noiseVec.xy);
}

The uniform variable timer contains the elapsed time in seconds. Thanks to this elapsed time, we create a texture coordinate set displacement that allows us to fetch a value noiseVec in the noise texture. This vector noiseVec is then added to the base texture coordinates gl_TexCoord[0].st + noiseVec.xy in order to look the perturbed value up in the base map.





[ 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.10098886489868 seconds.