Blitz Stencil Shadow System v0.89 alpha

Community Forums/Showcase/Blitz Stencil Shadow System v0.89 alpha

Braincell(Posted 2006) [#1]
Here is the Blitz stencil shadow system version 0.89 in alpha state.

I am not publishing any docs at the moment, but rest assured they will (probably) be there soon, and they'll be very comprehensive.

I'm releasing this as i see there is recently enthusiasm about stencil shadow systems and its something im lacking at the moment. I have found out that making code for building and updating shadow volumes is 90% of a stencil shadow system. This has been done fully, and all that remains to be done on this system for it to get into version 1.0 is to get propper control of ZFail and ZPass, that is when to go into each mode. Right now the system would work propperly if the Render (in this alpha case the Render_F) function was replaced with a ZFail one, as right now its a ZPass render without any checks or switches for ZFail. It can probably be done in a few hours but ... i'm just not up for it at the moment. Also the first function posted by Tom (and others 1 year ago) was ZFail so you can find it somewhere on the forums, plug it into Render_F(), and see what happens. So i hope someone will be helping out in finishing this. I have first started on such a system a year ago and have worked actively on it for about 3 months, including 3 complete rewrites. The code is fully commented and i tried to make it tidy so that it can be an opensource project for the community. I beleive that my method is the fastes achievable method for updating shadow volumes in blitz with its limited set of functions for controling mesh shapes. The advantage of the system is that it creates volumes with a mathematically absolute minimum number of quads (aka triangles or polygons) that are needed, because the bottle neck is by far moving the verts of shadow volumes to update it's shape every frame.

Here are some shots from 0.89



This is what you get with a ZPass render. It isn't right:



DOWNLOAD 660kb
(Includes source, exe, media, userlibs)

PS
I'll write more tomorrow, i dont have time now. Enjoy.


Ross C(Posted 2006) [#2]
checking it now...


Ross C(Posted 2006) [#3]
It looks very promising man! keep up the good work and make some cash out this. Very excellent addition to blitz if it gets completed!


Braincell(Posted 2006) [#4]
Cash?? It was always meant to be free and it always will. I earn enough with my 3d modelling. :)

I'll just reupload a small fix with resetting CameraClsMode between rendermodes which caused the screen to be uncleared if you pressed Enter more than twice to change the mode.


Mustang(Posted 2006) [#5]
Cool - good shadow system is one of three remaining big features I'd like to get, others being tangent space normal maps and DXTC.

I do have Sswift's excellent shadow system but it has it's on issues that comes from how it's done and designed. I'd prefer stencils even if they are slitghly too sharp to my taste and somewhat FPS eaters... but all shadow routines are.

Tom showed blurred shdows in the recent thread but that would need BRL support and persipiration and so far they have not done other than bug fixes, so I'm guessing Tom won't get what he wants either.


t3K|Mac(Posted 2006) [#6]
it looks VERY promising, braincell. you definately have to finish this one...


Matty(Posted 2006) [#7]
Could not get test 2 to work. Simply get an MAV (when you do a peekbyte at line 1109 of the library file.)

Test 1 works, Test 3 works - in blitz3d, not the exe.

Also cannot get the exe to perform any of the tests regardless of where I put the dll (I tried it in the same directory as the exe as well as in the userlibs directory of blitz3d).


degac(Posted 2006) [#8]
well done Len/BrainCell (or what else... :D)


Filax(Posted 2006) [#9]
It looks very promising Braincell ! thanks to share.


Ross C(Posted 2006) [#10]
The .dll will probably need to go into the system directory of windows to work with the .exe i think.


Braincell(Posted 2006) [#11]
Thanks for the nice comments.

The point here is that anyone can and SHOULD build up on top of this. The volumes are there, so it shouldnt be hard. Tho i cant promise too much cooperation.

About testobject2, i dont know why that happens, it works here and we all have the same file. Maybe different blitz version? No clue. But line 1109? That is very weird :P i especially have no clue how that could happen. About the exe, yea i get the same problem, so just ignore the exe. :)


OJay(Posted 2006) [#12]
ah finally, cant believe my eyes ;D

all samples run fine over here, though no shadows are drawn correctly...let me have a look at this...


Matty(Posted 2006) [#13]
@Braincell / Lenn - if it helps I am using blitz3d version 1.90 (I really don't want to upgrade to anything beyond that after all the issues that arose from the later versions - just in case they still have problems)


Braincell(Posted 2006) [#14]
Yea OJay, this is a release just to show that volumes are being built propperly.

Also, dont try using your own meshes just yet, there is a bug with loading meshes that i didnt fix yet, so some will not work.


Stevie G(Posted 2006) [#15]
Good work Lenn. Are you going to continue with this until it's in a usable form?


Ruz(Posted 2006) [#16]
nice one man. work all night and day to get it finished:)


bytecode77(Posted 2006) [#17]
how can i make 2 casters casting a volume?
if i put in 2 casters, only one casts a volume(a very corrupted one)


Braincell(Posted 2006) [#18]
Ruz, i'm not sure i will work on it at all, let alone day and night... very funny ... i mean... sorry :(

Devils, i dunno. If you wanna work on the system, then i can try fix this easily (its just some testing code thats left in there that i need to comment and its fixed). But first we need just 1 volume to cast shadows correctly.


Ruz(Posted 2006) [#19]
aww shame. me wants nice shadows on everyhting:)


Stevie G(Posted 2006) [#20]
@ Lenn,

I've been waiting on this for a looong time so I'm a little disappointed that you don't seem to have the enthusiasm to continue on what is essentially an incomplete system. I guess at least you made the effort to begin with so kudos to you.

I don't know the first thing about stencil shadows so hopefully someone will pick this one up.

Cheers
Stevie


Braincell(Posted 2006) [#21]
No i didnt say i quit completely, but that chances of me finishing it are simply "unkown" to me. I change opinion from day to day. Yesterday i promised myself to finish it, and i was going to work on it, today i forgot about it, i just... dont...know..... :)

But yea, i kinda completely stopped caring about this "community" and coding in general, cos 3d art is so fun, not that i dislike anyone here. And that was one of the main motivations when i started out, now it isnt really there. I couldnt care less if you had shadows in your project, or if you were disappointed with me, but i want to finish it because i feel like an idiot having invested so much time into it for nothing.


Pongo(Posted 2006) [#22]
For what it's worth, I hope you are able to continue (or at least pass it along to someone who can)

Having nice shadows is something just about everyone here could use, and I'm pretty sure a lot of others have been anxiously waiting to see this like I have. Now seeing that demo makes it feel that much closer.


jfk EO-11110(Posted 2006) [#23]
>> or if you were disappointed with me <<

Of course absolutely NOT. Keep up the good work. Continue whenever you want.


bytecode77(Posted 2006) [#24]
i have tried to make a system, and thats it:

http://patrick-sch.de/bleibdafuerimmer/StencilShadowSystem.zip

but the problem is, that you can't see much of the shadows!


Mustang(Posted 2006) [#25]
I'd welcome stencils with open arms because I'm so bad at coding... I too hope that either braincell or someone else finishes this so that it's fully usable chunk of code. I really could use this in my projetcs.


Ross C(Posted 2006) [#26]
I wish fredborg would release his source :o) Or sell it :o)


bytecode77(Posted 2006) [#27]
see my shadow system... there is a little bug, but may someone can fix it?!


Dreamora(Posted 2006) [#28]
Ross: That would be of not much use.
His realtime shadow code is in the codearchivs somewhere (yes he did one. he also did this funny batman light projection source thing).
Gile[s] shadow would be useless as it takes hundred and tousand times longer to render the same thing with shadow because the way it does it ;-)


Stevie G(Posted 2006) [#29]
Dreamora, I think Ross is talking about Fredborg's stencil shadow system ... where he used that beethoven mesh ... maybe you missed it but it was the best looking one so far ;)

Stevie


Stevie G(Posted 2006) [#30]
Oh and Devils Child .. I get a MAV when running the demo. Does any one know which version of Blitz allowed dx7 low level access ... I'm still on 1.87 so this is probably the reason?

Stevie


n8r2k(Posted 2006) [#31]
yay free


jfk EO-11110(Posted 2006) [#32]
funny I found "carmack_shadow.bb" on my harddrive, written by Lenn some time ago. It's working nicely with the dx7test dll. Only the shadow volume creation function isn't really helpful since it creates 6 triangles for every caster triangle.
Creating such a volume is really easy, but may be too slow for real world usage.

Combining this with my experiments on ICU volume creation my be an idea.


Braincell(Posted 2006) [#33]
What you see here is exactly the same as in the carmack_shadow.bb file I made. But volumes are built differently here and we need a different technique than just simple ZPass, or maybe we dont, blabla....


jfk EO-11110(Posted 2006) [#34]
As it was said, zpass or carmack reverse may work nicely and isn't the problem, it's the fast and correct shadow volume creation that is needed and it seems to be real tricky.

as far as I see the bottle neck of it is the calculation of the visibility of potential edge tris, because a test must be performed to see if the tris is obscured by any other tris, thus you have to check every triangle against all other triangles. That's why linepicks are so slow.


Braincell(Posted 2006) [#35]
And whats wrong with the volume building in this system? Have you downloaded it and tried it? Have you read when i said that only volume building works here, and that i'm aware this is 90% of the work the system needs, and that someone should be able to finish it easily? Well you sound like you know the stuff, finish it, or tell me why the volume building technique here is bad.


bytecode77(Posted 2006) [#36]
here is a technique i prefere to use:
http://www.blitzbasic.com/Community/posts.php?topic=58767

the code is modifyed by ME!!!
the code of dare devil is a little bit messy, but i made a potentional volume creation out of it :)
have fun...


Steven Noyce(Posted 2006) [#37]
I have seen many volume creation programs and think I slightly understand how they work, but I am totaly lost in how you get the ground (or whatever) to turn grey when inside the volume.

Would someone mind posting a simple program that uses like a plane for the ground and a cone for the shadow volume that turns the intersecting parts grey, like a round shadow?


OJay(Posted 2006) [#38]
well...you know, this is exactly what stencilshadows are about... o_O


jfk EO-11110(Posted 2006) [#39]
braincell, I didn't mean to say anything against you. I have spent some days a few weeks ago and my attemp failed, so I stopped.

Blitznerd - every pixel that will be rendered will count the number of hits on the outside surface of the volume and on the inside surface of the volume. if the numbers are the same then the ray went trough the volume. If the number differs, the ray hit the ground etc before it left the volume, therefor the pixel is in the shadow.

It would be way to slow to do this in Blitz code, it's done with a number of special renderworld commands on the direc3d level. Have a look at Braincells Demo Source.