Author Topic: Bump mapping - where to start?  (Read 2514 times)

0 Members and 1 Guest are viewing this topic.

Offline egons

  • C= 64
  • **
  • Posts: 31
  • Karma: 0
    • View Profile
Bump mapping - where to start?
« 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

Offline energy

  • Amiga 1200
  • ****
  • Posts: 280
  • Karma: 25
    • View Profile
Re: Bump mapping - where to start?
« Reply #1 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
coding: jwasm,masm
hobby: www.scd2003.de

Offline Jim

  • Founder Member
  • DBF Aficionado
  • ********
  • Posts: 5301
  • Karma: 402
    • View Profile
Re: Bump mapping - where to start?
« Reply #2 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.
« Last Edit: May 28, 2012 by Jim »
Challenge Trophies Won:

Offline egons

  • C= 64
  • **
  • Posts: 31
  • Karma: 0
    • View Profile
Re: Bump mapping - where to start?
« Reply #3 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(

Offline Jim

  • Founder Member
  • DBF Aficionado
  • ********
  • Posts: 5301
  • Karma: 402
    • View Profile
Re: Bump mapping - where to start?
« Reply #4 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
Challenge Trophies Won:

Offline egons

  • C= 64
  • **
  • Posts: 31
  • Karma: 0
    • View Profile
Re: Bump mapping - where to start?
« Reply #5 on: May 28, 2012 »
well.. some normalmap generators confusing :skint:
better is to concentrate on bump light.

Offline egons

  • C= 64
  • **
  • Posts: 31
  • Karma: 0
    • View Profile
Re: Bump mapping - where to start?
« Reply #6 on: June 05, 2012 »
well, i've found solution at the BB site - building Normal Maps from Height Maps(Greyscale)
some borders sucks, but.

Offline egons

  • C= 64
  • **
  • Posts: 31
  • Karma: 0
    • View Profile
Re: Bump mapping - where to start?
« Reply #7 on: June 13, 2012 »
some experiments with lame maps.
looking for the light...

Offline jace_stknights

  • Amiga 1200
  • ****
  • Posts: 399
  • Karma: 32
  • PEEK & POKE are not MOVEM!
    • View Profile
    • ST Knights WebSite
Re: Bump mapping - where to start?
« Reply #8 on: June 14, 2012 »
Nothing here...  :(
blank screen
Challenge Trophies Won:

Offline egons

  • C= 64
  • **
  • Posts: 31
  • Karma: 0
    • View Profile
Re: Bump mapping - where to start?
« Reply #9 on: June 15, 2012 »
last one. stuck with lights :'(