Crazy idea no. 2- an edge-detection stencil-buffer shadowmap

Crazy idea no. 2- an edge-detection stencil-buffer shadowmap

Discuss Lua based Spring scripts (LuaUI widgets, mission scripts, gaia scripts, mod-rules scripts, scripted keybindings, etc...)

Moderator: Moderators

Post Reply
User avatar
Argh
Posts: 10920
Joined: 21 Feb 2005, 03:38

Crazy idea no. 2- an edge-detection stencil-buffer shadowmap

Post by Argh »

Basically, I've revamped the Blob Shadows a bit, and it works better (i.e., faster, and I'm thinking about minor stuff to make it a bit prettier), but I was thinking... why not go one further, and use an edge-detection system to make a shadowmap, per object?

I'm pretty sure that it would out-perform Spring's current shadowmap system by a large amount, so long as it didn't bother doing shadows for the terrain, and would look really sweet, because shadows could be really sharp.

Problem is, I have no idea how to perform the edge-detection to set up the mask. I'll try to find some source on this later on, I'm sure that this isn't anything that can't be done.
User avatar
lurker
Posts: 3842
Joined: 08 Jan 2007, 06:13

Re: Crazy idea no. 2- an edge-detection stencil-buffer shadowmap

Post by lurker »

Why do you think running that per unit would outperform a simple geometry render?
User avatar
AF
AI Developer
Posts: 20687
Joined: 14 Sep 2004, 11:32

Re: Crazy idea no. 2- an edge-detection stencil-buffer shadowmap

Post by AF »

I don't understand would you not have to regenerate your mask every time the unit or the camera or both moved? Units are 3d objects not 2d billboards.

Eitherway Im not quite sure what you mean by edge detection system with regards to this
[Krogoth86]
Posts: 1176
Joined: 23 Aug 2007, 19:46

Re: Crazy idea no. 2- an edge-detection stencil-buffer shadowmap

Post by [Krogoth86] »

The funny thing is that most people/engines struggle to get soft shadows in their games rather than sharp ones... :wink:

When talking about performance pretty much anything is faster than simple stencil shadows so go ahead please! :-)
User avatar
Argh
Posts: 10920
Joined: 21 Feb 2005, 03:38

Re: Crazy idea no. 2- an edge-detection stencil-buffer shadowmap

Post by Argh »

Er...

1. DoW uses sharp-edged shadows, which I'm pretty sure use this technique, or something like it. Performs well enough that even back then in 2004, they did it for all buildings. And the sharp-edged but accurate shadows look far better, and perform far better, than Spring's.

2. There are other techniques (and some working source) to consider. I just hadn't had time to look at the all of the alternatives:

http://www.punkuser.net/vsm/
http://iupiter.sourceforge.net/index.htm (Open Source code, no less)

For some more basic reading on the subject:

http://en.wikipedia.org/wiki/Shadow_volume
[Krogoth86]
Posts: 1176
Joined: 23 Aug 2007, 19:46

Re: Crazy idea no. 2- an edge-detection stencil-buffer shadowmap

Post by [Krogoth86] »

Well I don't know if this is a way that works for the Spring engine and I don't know if this would make sense for an RTS but you might want to try to do LiSPPSVSM (= "Light Space Perspective Parallel Split Variance Shadow Mapping") and try to exclude lots of the hard work that goes into making the shadows soft (as I said: when it's about shadows getting soft ones is a tough job)...

I'm no shader pro so I don't know if it's realistic but I've some literature for you. That LiSPPSVSM method is meant for big outdoor environments so it might just work:

1) Light Space Perspective Shadow Mapping:
http://www.cg.tuwien.ac.at/research/vr/ ... index.html

2) Parallel Split Shadow Mapping:
http://hax.fi/asko/PSSM.html

3a) Variance Shadow Mapping:
http://www.punkuser.net/vsm/

3b) Percentage Closer Filtering / Percentage Closer Soft Shadows:
http://www.cs.utah.edu/classes/cs5610/p ... -2005/lha/
User avatar
Argh
Posts: 10920
Joined: 21 Feb 2005, 03:38

Re: Crazy idea no. 2- an edge-detection stencil-buffer shadowmap

Post by Argh »

Hrmm. Took a look at that. Looks interesting, although I'm pretty dubious about how big of a deal it is that shadows are blurry in a RTS setting- speed is the main thing I'm looking for, Spring's shadow code is amazingly slow compared to a lot of stuff I've seen in the commercial world, and looks worse, too.

Haven't had time to really dig at the code and find the stuff that would need to be ported yet. And the code's not Open Source, so we'd need permission from the authors to distribute their algorithms.

There are a lot of interesting things on that website, though. One that I thought was particularly interesting was this:

Link.
User avatar
Cremuss
Posts: 364
Joined: 28 Oct 2006, 21:38

Re: Crazy idea no. 2- an edge-detection stencil-buffer shadowmap

Post by Cremuss »

<HS>
Maybe wait for the Doom 3 engine to take the shadow engine :-)
The source code is gonna be released 2009 if I remember well
</HS>
User avatar
Argh
Posts: 10920
Joined: 21 Feb 2005, 03:38

Re: Crazy idea no. 2- an edge-detection stencil-buffer shadowmap

Post by Argh »

Meh. Why wait, when this could just get solved? So far as I can tell, after doing some readings, there are several valid approaches to consider:

1. Use a bitmap shadowmap approach like what we're doing now, but use a single (small) bitmap per unit. Then you're only producing a shadow for a unit at a time- and even a 256 bitmap would look much sharper than a giant 4096 shadowmap using Spring's current method.

For terrain... use a much smaller size, or the same base size as units, and blur it with whatever method we're using now (yes, we have some sort of blurring being done, on purpose or no, use a 256 shadowmap, you'll see what I mean).

2. Use stencil-buffer approaches, using a very simple half-resolution heightmap as the basis for the mesh to project the stencil onto.

This would produce really accurate shadows. If you looked super-close from a low enough angle, you might be able to see that it wouldn't actually match the terrain geometry perfectly, but it really wouldn't be noticeable during a game.

From what I've read... this should run quite quickly, if implemented in GLSL, and it would be a massive improvement over what we've got now.



At any rate, I think that either approach ought to work a lot faster than what we have now, I just dunno how to do an edge-detection algorithm from the POV of the sun to make the mask for a stencil, or to take "snapshot" of the unit from the angle of the sun, using GL.UNIT to make that unit pure black or whatever against a pure white background, store the resulting image as a texture, then use that texture in a call to the blob-shadow code. If I knew how to make a screen-cap of something on the screen in Spring, I think I could figure out the rest of that approach merely by recycling some of the other stuff we have around here. Anybody have any ideas about that?
User avatar
Argh
Posts: 10920
Joined: 21 Feb 2005, 03:38

Re: Crazy idea no. 2- an edge-detection stencil-buffer shadowmap

Post by Argh »

Interesting... it's like they're reading my mind:

http://developer.nvidia.com/object/doc_shadows.html
User avatar
Tribulexrenamed
Posts: 775
Joined: 22 Apr 2008, 19:06

Re: Crazy idea no. 2- an edge-detection stencil-buffer shadowmap

Post by Tribulexrenamed »

Wear a tinfoil hat, it helps.
el_matarife
Posts: 933
Joined: 27 Feb 2006, 02:04

Re: Crazy idea no. 2- an edge-detection stencil-buffer shadowmap

Post by el_matarife »

Cremuss wrote:<HS>
Maybe wait for the Doom 3 engine to take the shadow engine :-)
The source code is gonna be released 2009 if I remember well
</HS>
Unlikely, since the new Wolfenstein game is going to use the Doom 3 aka iD Tech 4 engine and will be coming out sometime next year. I assume they'll wait at least 12 to 18 months after the last game using that engine is released, like they did with the Quake 3 aka iD Tech 3 engine. It took 6 years for iD Tech 3 to be open sourced, so I assume we can look forward to the iD Tech 4 engine being released under the GPL in 2010, probably mid August after Quakecon.
Post Reply

Return to “Lua Scripts”