Dark Bit Factory & Gravity
PROGRAMMING => Purebasic => Topic started by: egons on May 28, 2012
-
hi!
help me to understand how to create bump light. I have an algo of texture generation.
next is i haven't idea how to build normal map, and next - how to implement bump light (PixPlant screenshot attached).
attach file - texture+normalmap+grayscale in bitmap
-
Here a some old NEHE conversions.
Perhaps its done with older version, so yu have to
solve it with the new PB Version, if yu have the new one.
I think for imageloading glaux is used, so yu ll have to implement yur
own bitmaploader.
Watch out for lesson 22.
http://forum.games-creators.org/showthread.php?t=4312
-
One way to build a bump map:
0. Bump maps are texture maps containing normals for each pixel.
1. Pretend white is 'high' and black is 'low'.
2. Create 8 normals to the neighbouring pixels...
\|/
-+-
/|\
...where x,z are fixed and y is the difference in brightness (-255 to 255) / 512.
3. Normalise each vector.
4. Add them together and normalise it again.
5. Convert this normal into the format needed for the bump map.
6. Repeat for each pixel.
-
Here a some old NEHE conversions.
Perhaps its done with older version, so yu have to
solve it with the new PB Version, if yu have the new one.
I think for imageloading glaux is used, so yu ll have to implement yur
own bitmaploader.
Watch out for lesson 22.
http://forum.games-creators.org/showthread.php?t=4312
lesson 22 doesn't looks like "bumpy", so i am not sure - is it works or not?
3. Normalise each vector.
4. Add them together and normalise it again.
how to add 8 vectors? and what is 'directions' of the normals?
http://www.paulsprojects.net/tutorials/simplebump/simplebump.html
this is a good, working example, but an author uses normal map(
-
There are 8 neighbouring pixels, they are at...
(-1,-1)
(-1,0)
(-1,1)
(0,-1)
(0,1)
(1,-1)
(1,0)
(1,1)
...relative to the pixel you are looking at.
Let's say the 'height' of these pixels is h0 to h7, and the height of the center pixel is c, then 8 normals could very roughly be
(-1,-1,c-h0)
(-1,0,c-h1)
(-1,1,c-h2)
(0,-1,c-h3)
(0,1,c-h4)
(1,-1,c-h5)
(1,0,c-h6)
(1,1,c-h7)
remembering to divide down the c-h'es by 512 because they are brightnesses.
Then you can normalise each vector by taking its length and dividing out,
so for each of the vectors above, (x,y,z)
length = sqrt(x^2 + y^2 + z^2)
nx = x/length
ny = y/length
nz = z/length
Then you can add together all the vectors (by adding the 8 nx, ny, nz values together) to get an average normal - let's make that (sx,sy,sz)
You can renormalise that
length = sqrt(sx^2 + sy^2 + sz^2)
rx = sx/length
ry = sy/length
rz = sz/length
Now you have a rough normal for your pixel (rx,ry,rz).
The final step is to encode that as pixel data in the bumpmap, and that depends on the format of the bumpmap.
Jim
-
well.. some normalmap generators confusing :skint:
better is to concentrate on bump light.
-
well, i've found solution at the BB site - building Normal Maps from Height Maps(Greyscale)
some borders sucks, but.
-
some experiments with lame maps.
looking for the light...
-
Nothing here... :(
blank screen
-
last one. stuck with lights :'(