Dark Bit Factory & Gravity

PROGRAMMING => Purebasic => Topic started by: egons on May 28, 2012

Title: Bump mapping - where to start?
Post 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
Title: Re: Bump mapping - where to start?
Post by: energy on May 28, 2012
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
Title: Re: Bump mapping - where to start?
Post by: Jim on May 28, 2012
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...
Code: [Select]
\|/
-+-
/|\
...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.
Title: Re: Bump mapping - where to start?
Post by: egons on May 28, 2012
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?

Quote
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(
Title: Re: Bump mapping - where to start?
Post by: Jim on May 28, 2012
There are 8 neighbouring pixels, they are at...
Code: [Select]
(-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
Code: [Select]
(-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)
Code: [Select]
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
Code: [Select]
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
Title: Re: Bump mapping - where to start?
Post by: egons on May 28, 2012
well.. some normalmap generators confusing :skint:
better is to concentrate on bump light.
Title: Re: Bump mapping - where to start?
Post by: egons on June 05, 2012
well, i've found solution at the BB site - building Normal Maps from Height Maps(Greyscale)
some borders sucks, but.
Title: Re: Bump mapping - where to start?
Post by: egons on June 13, 2012
some experiments with lame maps.
looking for the light...
Title: Re: Bump mapping - where to start?
Post by: jace_stknights on June 14, 2012
Nothing here...  :(
blank screen
Title: Re: Bump mapping - where to start?
Post by: egons on June 15, 2012
last one. stuck with lights :'(