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: 234
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: 5094
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: 1648
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
deetsay
icon/The Silents, Sp..
WVL/Xenon
MWR/Visdom
csabanw
Peacemaker/CENSOR/Hi..
Mike
MCM/ONSLAUGHT
Guests online: 102
Top Demos
1 Next Level  (9.7)
2 13:37  (9.7)
3 Mojo  (9.7)
4 Coma Light 13  (9.6)
5 Edge of Disgrace  (9.6)
6 What Is The Matrix 2  (9.6)
7 The Demo Coder  (9.6)
8 Uncensored  (9.6)
9 Comaland 100%  (9.6)
10 Wonderland XIV  (9.6)
Top onefile Demos
1 No Listen  (9.6)
2 Layers  (9.6)
3 Cubic Dream  (9.6)
4 Party Elk 2  (9.6)
5 Copper Booze  (9.6)
6 Dawnfall V1.1  (9.5)
7 Rainbow Connection  (9.5)
8 Onscreen 5k  (9.5)
9 Morph  (9.5)
10 Libertongo  (9.5)
Top Groups
1 Performers  (9.3)
2 Booze Design  (9.3)
3 Oxyron  (9.3)
4 Censor Design  (9.3)
5 Triad  (9.3)
Top Organizers
1 Burglar  (9.9)
2 Sixx  (9.8)
3 hedning  (9.7)
4 Irata  (9.7)
5 Tim  (9.7)

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