Alpha Bug.... Actually Useful?

Posted by Adventus on Feb. 19, 2007, 10:45 p.m.

Thats right boys/girls (and inbetweens…. dont want to descriminate now), Pheonix101 (AKA Adventus on GMC) has returned…. Although im willing to bet OpticalLiam is the only one who noticed my absence.

Ill get the boring stuff over first…. aka my life. This is my 2nd day at University (Australian National University) studying Bachelor of Engineering/Bachelor of Science and my lectures are completely packed…. its probably got something to do with the 80/75 % entrance score (i got 97%)…. so it'll probably start to thin out once they realise building shit actually requires maths.

Now to some slightly more interesting stuff (to me anyway…. i doubt most of you will care).

Today i was bored so i decided to see it i could modify L2S to use only 2 surfaces (it usually requires 3 full screen surfaces) whilst still potentially (i didnt bother with a few of them because i know they'll work) maintaining all its features…. z ordered shadows/overlays especially. This may sound pretty easy…. but it took me a good 2 hours to complete…. and im not incredibly stupid (nor smart i may add).

Anyway, The basic theory revolves around presuming that the shadow buffer requires only one colour channel. If we had access to DirectX we could simply use an 8bit greyscale surface…. but alas GM could not possibly be that easy. I discovered the trick was to render shadows to the light buffers alpha channel in conjunction with GMs alpha bug…. then mulitplying the light texture with the alpha channel.

At this point its all pretty straight forward, the real problem occurs when you want to render overlays in proper z order (meaning shadows cast with higher z's go over overlays of lower z). After plenty of screwing around i managed it but at the cost of having to redraw the light sprite and the overlay sprite.

Download: L2S_example

This method is slightly slower in terms of fill rate…. but if you need a game to work on limited spec computers (less than 32mb video memory anyway) it becomes more practical. Also realise that the download is not an engine, just an example.

Cheers,

PS: The white numbers above the shadow casters are their z values.

Comments

Kaz 17 years, 9 months ago

Is the mouse supposed to feel like its 100 tons? Because its moving like it. FPS is around 110.

Adventus 17 years, 9 months ago

You can change that easily, im just using it on a shite computer so i didnt notice its heaviness. Go to "obj_system" -> "end_step" and the last two arguments of "define_view" define the max scroll speed.

Kaz 17 years, 9 months ago

Ah, I though my computer was too slow for this. Which I was pretty sure wasn't the case since this is a new computer.

Adventus 17 years, 9 months ago

Pretty much all computers that can run GM games should be able to run this, i get about 50fps on an AMD sempron 2500+ (~1.7 GHz), Geforce 4 MX 32mb, 480mb RAM (…. well thats what it says in dxdiag).

Kaz 17 years, 9 months ago

Heh

2.0Ghz Intel Dual Core

256mb ATI Radeon x1400

1gb RAM

Xemrel 17 years, 9 months ago

Another plus to the alpha bug is that you can use it to explicitly set the alpha of a surface, or part of a surface to cut holes in the rendered image. ;)

OL 17 years, 9 months ago

Nice work, 250 FPS.

Graydon 17 years, 9 months ago

I also have the weird 480 ram.

DevonX 17 years, 9 months ago

My Comp Specs:

-384mb RAM

-32mb Video Memory (lol)

-Idk…

It gets about 25 fps with this.

My Aunt's Comp Specs: (I go to my aunts alot so here is her specs)

-2gb RAM

-1gb Video Memory

-OMG!!!!1

I havent tried this on that yet, but I'm sure it would get like 3000 fps, anything that allows max fps usually gets 3000. Her computer is amazing.

Adventus 17 years, 9 months ago

The real importance is not its relative speed, since normal L2S is theoretically faster, but the smaller vram dependancy. Still…. The only real reason i put it up was because i found it theoretically interesting.

Quote:
I also have the weird 480 ram.
Eh, I just realised its because the missing 32mb is allocated as video RAM…. you can never trust Nvidia/Ati.XD.

Quote:
-1gb Video Memory
I think she's gotta be running SLI/Crossfire to acheive 1GB of vram.

I might have a try at converting L3S to this method aswell, originally i thought it would be impossible (now i just think it'll be very hard) because i couldnt think of a way to do emboss bumpmapping…. but i may be able to manage it.