How about some more advanced texturing? May 17, 2006
Posted by winden in coding, demoscene.trackback
So, I recall sometime about 8 years ago, Ryan/Centolos told me that he had added support for texture + RGB interpolation to his 3dfx renderer, and was bitching about the fact that, while adding the support to the software renderer was possible, it would probably take a big hit on the speed due to the need to interpolate another 3 values per-pixel…
Fast forward a couple of years later, and you’d find me bored one day when I remembered this conversation and, like any bored amiga coder would do, started to think… RGB interpolation, if PC can do it, why not on amiga?… I already had a routine which interpolated 4 texture coords and had released it on synthesis (the tex+bump+env+shade rotozoomer), and recalled that registers were a bit short so didn’t realize at first how to cram not 4 but 7 interpolators into the inner loop, but luckily I had just started to work near home so every day I had a full hour of emptiness to fill with arguments about this optimisation
I recall this took one or two weeks, but finally I managed to cram all the crap into the registers…
; ; texture + bump + environment + shadetable + additive RGB texturer ; ; interpolated RGB values are added after modulating ; the texture color with the environment, so I'm not ; too sure this is really of any help for visual effects, ; but anyhow... ; ; pending: if (when) i get a 060, attempt to ; better utilise the dual pipelines ; ; d0 JJjjVVvv a0 DJdjDVdv ; d1 IIiiUUuu a1 DIdiDUdu ; d2 RRrrBBbb a2 DRdrDBdb ; d3 ccGGgg-- a3 01DGdg-- ; d4 a4 TT00DJDI texture.b + 0.b + bump.w ; d5 a5 EE environment.b ; d6 a6 RRGGBB-- screen.l ; d7 a7 RRGGBB-- shader.w .xloop move.l #$ff00ff00,d4 move.l #$00ff0000,d5 move.l d4,d6 move.l d4,d7 and.l d0,d6 ; d6 = JJ--VV-- and.l d1,d7 ; d7 = II--UU-- and.l d2,d4 ; d4 = RR--BB-- and.l d3,d5 ; d5 = --GG---- lsr.l #8,d7 or.l d6,d7 ; d7 = JJIIVVUU or.l d5,d4 ; d4 = RRGGBB-- move.l (a4,d7.w*4),d6 ; d6 = TT--DJDI swap d7 ; d7 = ----JJII add.w d6,d7 ; d7 = ----JJII + bump swap d6 ; d6 = ----TT-- move.b (a5,d7.w),d6 ; d6 = ----TTEE add.l (a7,d6.l*4),d4 ; d4 = RRGGBB-- move.l d4,(a6)+ add.l a0,d0 add.l a1,d1 add.l a2,d2 add.l a3,d3 bcc .xloop
This was done after I had stopped making any productions, so it has sit unused for some years… but lately I’ve been thinking about normal mapping for amiga and the though of having to interpol the normal for the per-pixel lighting calculation reminded me of this one…
ps. notice that this routine doesn’t need any memory accesses besides the texture ones. keeping the deltas on the stack would free 3 registers, so it would definitely be possible to interpolate even more values ;)
Comments»
No comments yet — be the first.