Log inRegister an accountBrowse CSDbHelp & documentationFacts & StatisticsThe forumsAvailable RSS-feeds on CSDbSupport CSDb Commodore 64 Scene Database
You are not logged in - nap
CSDb User Forums


Forums > C64 Coding > Bumpmapping
2010-01-21 15:47
Shadow
Account closed

Registered: Apr 2002
Posts: 355
Bumpmapping

Yeah, I feel like a total retard, but I can't figure out how the really fast bumpmappers seen in many C64 demos (well, at least in the second half of the nineties) works.
I've written some bumpmappers for other systems, but looking at some C64 code, it seems it is possible to take the smart precalcing of stuff yet another step that I'm missing.
Since I'm guessing we are past the "only lamers rip"-phase now that we've entered the 2010s, I did the sneaky thing and peeked at some code in a couple of demos, and it seemed like this is the way to do it:

ldy #PRECALCULATED_CONSTANT_FOR_X1Y1
lda (PRECALCULATED_ZP_PTR_FOR_X1Y1),y
ldy #PRECALCULATED_CONSTANT_FOR_X2Y1
ora (PRECALCULATED_ZP_PTR_FOR_X2Y1),y
sta screen

ldy #PRECALCULATED_CONSTANT_FOR_X3Y1
lda (PRECALCULATED_ZP_PTR_FOR_X3Y1),y
ldy #PRECALCULATED_CONSTANT_FOR_X4Y1
ora (PRECALCULATED_ZP_PTR_FOR_X4Y1),y
sta screen


.. repeat unrolled code


ZP seems to be filled each frame with freshly calculated pointers to the "graphics data", ie. in a zoom4 mode it is high or low-nibble colors depending on if it is x1 or x2 etc.

In my world, a bumpmapper is
A) A set of precalced X normals
B) A set of precalced Y normals
C) An x-position for the light
D) An y-position for the light
E) An 'environment/light' graphics

But I can't quite come up with how to combine A-E into the constansts, and how to arrange the data.

I'm assuming the recalcing of the ZP-ptr table is updating the light position at least.

2010-01-21 15:56
Dano

Registered: Jul 2004
Posts: 226
i think that heavily depends on precalculated colortables, so you just read out the colorvalue, index the new color via a bumpvalue (i.e. like $04 normal color, $03 darker, %05 lighter), and the resulting value is the new color. for each color you prepare colortables for lighter and darker values, so that give give you a decent quick lookup.
2010-01-21 16:21
Shadow
Account closed

Registered: Apr 2002
Posts: 355
Yes, "colored" bump could be done via a colortable loookup as that, however, this is not the issue here, rather how to actually calculate the "bump" value.
2010-01-21 18:21
Oswald

Registered: Apr 2002
Posts: 5017
lda heightmap+actx(+acty..)
sec
sbc heightmap+actx+1
clc
adc #somevaluetokeepitabovezero
sta xdiff

lda heightmap+acty
sec
sbc heightmap+acty+1
clc
adc #somevaluetokeepitabovezero
sta ydiff


spedcode:

ldy #actx1+xdiff1
lda ((acty1+ydiff1*2)),y
ldy #actx2+xdiff2
lda ((acty2+ydiff2*2)),y
sta scr

2010-01-22 10:35
Shadow
Account closed

Registered: Apr 2002
Posts: 355
Thanks Oswald, it makes perfect sense now!
Then the ZP-pointers are updated dynamically to do the moving of the light in both X and Y direction, and voila, fast bumpmapping. Nice!
2010-01-25 07:56
Frantic

Registered: Mar 2003
Posts: 1627
Don't forget to write it up and put it on codebase when you're done. ;)

http://codebase64.org/doku.php?id=base:demo_programming
RefreshSubscribe to this thread:

You need to be logged in to post in the forum.

Search the forum:
Search   for   in  
All times are CET.
Search CSDb
Advanced
Users Online
Apollyon/ALD
t0m3000/ibex-crew
hedning/G★P
Røly/Mayday!
kbs/Pht/Lxt
Didi/Laxity
Freeze/Blazon
Guests online: 185
Top Demos
1 Next Level  (9.8)
2 Mojo  (9.7)
3 Coma Light 13  (9.7)
4 Edge of Disgrace  (9.6)
5 Comaland 100%  (9.6)
6 No Bounds  (9.6)
7 Uncensored  (9.6)
8 Wonderland XIV  (9.6)
9 Memento Mori  (9.6)
10 Bromance  (9.5)
Top onefile Demos
1 It's More Fun to Com..  (9.7)
2 Party Elk 2  (9.7)
3 Cubic Dream  (9.6)
4 Copper Booze  (9.5)
5 TRSAC, Gabber & Pebe..  (9.5)
6 Rainbow Connection  (9.5)
7 Wafer Demo  (9.5)
8 Dawnfall V1.1  (9.5)
9 Quadrants  (9.5)
10 Daah, Those Acid Pil..  (9.5)
Top Groups
1 Oxyron  (9.3)
2 Nostalgia  (9.3)
3 Booze Design  (9.3)
4 Censor Design  (9.3)
5 Crest  (9.3)
Top NTSC-Fixers
1 Pudwerx  (10)
2 Booze  (9.7)
3 Stormbringer  (9.7)
4 Fungus  (9.6)
5 Grim Reaper  (9.3)

Home - Disclaimer
Copyright © No Name 2001-2024
Page generated in: 0.039 sec.