bumpmapping in fragment shader

Started by
15 comments, last by MARS_999 17 years, 6 months ago
Quote:Original post by optic2000
Check out Irrlicht's soure code. There is a decent implementation in there and it is easy to read.


id rather not put my time on implementing this... if there is a seperate program that can do it... which i hope there is... dont want to waste time or code space since im getting near my deadline for my project...
Advertisement
The "easiest" thing to do is:

1. Download a tool (like ATI's bump map generator) or plugin for a graphics program like photoshop.
http://www.ati.com/developer/sdk/radeonSDK/html/Tools/ToolsPlugIns.html

2. Create and export a normal map for your texture.

3. Load the textures into your OpenGL program.

4. Pass the textures to your fragment shader (where you should have the code to handle this).


is there a program that can create clalculate the tangents aswell?
ok ive replaced the normalmpa calcualtions in my code with the ati bump map generator texture which i load and send to the fragment shader...

uniform sampler2D normals;uniform float angle;void main(){		vec3 Normal = normalize(normalize(texture2D(normals, gl_TexCoord[0].st).rgb)*2.0-1.0);	vec3 LightDir = vec3(-cos(angle*0.01745329), -sin(angle*0.01745329), 0.0);	float brightnes = dot(LightDir, Normal);		gl_FragColor = vec4(1.0, 1.0, 1.0, 1.0)*brightnes ;}


but it doesnt work as it should for some reason.. no matter what angle i use i always get the same lighting...?
how can i compute Tangent-vector ?
Honestly, through all of the stuff I looked through for that stupid tangent space calculation, it turns out that using your surface normal as your tangent works fine.
Quote:Original post by adawg1414
Honestly, through all of the stuff I looked through for that stupid tangent space calculation, it turns out that using your surface normal as your tangent works fine.


WHAT? Not possible if you are doing it correct. The tangent is perpendicular to the normal as is the bitangent. But where this happens is what needs to be calculated.

This topic is closed to new replies.

Advertisement