Copy Link
Add to Bookmark
Report

Bumpmapping

By Mikael Kalms (Scout / C-Lous)

atari's profile picture
Published in 
atari
 · 9 Jan 2021

Bump is essentially having individual XY-offsets in the envmap/phongmap for every pixel.


2d Bump


The simplest form requires one phongmap and one bumpmap. The phongmap is your usual phongtexture, and the bumpmap contains one word per pixel. The bumped 2D phong is drawn using this technique:

 for Y = 0 to scrheight 
{
for X = 0 to scrwidth
{
PhongX = X + Bump[X][Y][0]
PhongY = Y + Bump[X][Y][1]
C = Phong[PhongX][PhongY]
putpixel(X,Y,C)
}
}

An example of this kind of bump can be found in Orange's "The Sea Robot of Love" (PC, 64k at The Party V). Bump with picture can be seen in 3LE's "The Tribe" (first place at Icing '96). Picture/bump is accomplished by adding a pixelread and a shade table lookup to the innerloop.

Bump is a good addition to standard zoomrotators: have a look at C-Lous' "Kolor Remix" (Remedy '96) for an example of it.


3d Bump


(err... rather "2D polygon bump")

Don't settle with phong bump, go for the real thing! That is, phong bump texture... It does not take much more CPU time.
As the bump and the texture both are fixed on the surface of the 3D-obejct(s), they have the same UV coordinates, thus giving only a few more instructions for adding bump. This is a (slow) example of an inner loop:

 ; a0 = texture, a1 = phong, a2 = bump, a3 = shadetab, a4 = screen 
.pixel add.w tustep,d0
add.w tvstep,d1
add.w pustep,d2
add.w pvstep,d3
move.w pustep,d5
; Get UV offs in phong
lsr.w #8,d5
move.w pvstep,d4
move.b d5,d4
move.w tustep,d6
; Get UV offs in texture & bump
lsr.w #8,d6
move.w tvstep,d5
move.b d6,d5
add.w (a2,d5.w*2),d4
; Add the bump offs for current pixel
move.b (a1,d4.l),d4
; Get phong
lsl.w #8,d4
move.b (a0,d5.l),d4
; Get texture
move.b (a3,d4.l),(a4)+
; Write shaded pixel to screen
dbf d7,.pixel

The bump effect adds quite a bit of realism to normal phong texture.


Generating the bumpmap

It is tricky to get a good-looking bumpmap. One way (useful for 2D bump) is saying that the brighter a pixel is, the higher above the flat surface it is.
First convert the picture to grayscale using some program like PicCon.
Then the bump value can be calculated in this way:

 bump[X][Y][0] = (texture[X-1][Y] - texture[X+1][Y]) * scale 
bump[X][Y][1] = (texture[X][Y-1] - texture[X][Y+1]) * scale

Appropriate values for scale varies from texture to texture.

← previous
next →
loading
sending ...
New to Neperos ? Sign Up for free
download Neperos App from Google Play
install Neperos as PWA

Let's discover also

Recent Articles

Recent Comments

Neperos cookies
This website uses cookies to store your preferences and improve the service. Cookies authorization will allow me and / or my partners to process personal data such as browsing behaviour.

By pressing OK you agree to the Terms of Service and acknowledge the Privacy Policy

By pressing REJECT you will be able to continue to use Neperos (like read articles or write comments) but some important cookies will not be set. This may affect certain features and functions of the platform.
OK
REJECT