GeeXLab
Current version: 0.17.x
»GeeXLab homepage

FurMark
Current version: 1.19.1
»FurMark homepage
»FurMark 1.9.x Submissions

GPU Caps Viewer
Current version: 1.37.0.0
»GPU Caps Viewer homepage
»GPU DB Submissions

GPU Shark
Current version: 0.10.0.4
»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.2
»FluidMark homepage
»FluidMark 1.4.x Submissions

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

3D Graphics Search Engine:

The Geeks Of 3D

 
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





GeeXLab demos


GLSL - Mesh exploder


PhysX 3 cloth demo


Normal visualizer with GS


Compute Shaders test on Radeon


Raymarching in GLSL



Geeks3D latest news


Geeks3D forum news


Misc
»Texture DataPack #1
»Asus Silent Knight CPU Cooler
Page generated in 0.009788990020752 seconds.