Crazy idea no. 2- an edge-detection stencil-buffer shadowmap
Moderator: Moderators
Crazy idea no. 2- an edge-detection stencil-buffer shadowmap
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.
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.
Re: Crazy idea no. 2- an edge-detection stencil-buffer shadowmap
Why do you think running that per unit would outperform a simple geometry render?
Re: Crazy idea no. 2- an edge-detection stencil-buffer shadowmap
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
Eitherway Im not quite sure what you mean by edge detection system with regards to this
-
- Posts: 1176
- Joined: 23 Aug 2007, 19:46
Re: Crazy idea no. 2- an edge-detection stencil-buffer shadowmap
The funny thing is that most people/engines struggle to get soft shadows in their games rather than sharp ones...
When talking about performance pretty much anything is faster than simple stencil shadows so go ahead please!

When talking about performance pretty much anything is faster than simple stencil shadows so go ahead please!

Re: Crazy idea no. 2- an edge-detection stencil-buffer shadowmap
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
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
-
- Posts: 1176
- Joined: 23 Aug 2007, 19:46
Re: Crazy idea no. 2- an edge-detection stencil-buffer shadowmap
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/
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/
Re: Crazy idea no. 2- an edge-detection stencil-buffer shadowmap
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.
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.
Re: Crazy idea no. 2- an edge-detection stencil-buffer shadowmap
<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>
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>
Re: Crazy idea no. 2- an edge-detection stencil-buffer shadowmap
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?
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?
Re: Crazy idea no. 2- an edge-detection stencil-buffer shadowmap
Interesting... it's like they're reading my mind:
http://developer.nvidia.com/object/doc_shadows.html
http://developer.nvidia.com/object/doc_shadows.html
- Tribulexrenamed
- Posts: 775
- Joined: 22 Apr 2008, 19:06
Re: Crazy idea no. 2- an edge-detection stencil-buffer shadowmap
Wear a tinfoil hat, it helps.
-
- Posts: 933
- Joined: 27 Feb 2006, 02:04
Re: Crazy idea no. 2- an edge-detection stencil-buffer shadowmap
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.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>