Hard Light Productions Forums

Modding, Mission Design, and Coding => FS2 Open Coding - The Source Code Project (SCP) => Topic started by: Swifty on November 13, 2013, 02:18:20 pm

Title: Variance Shadow Maps (Soft shadows) WIP
Post by: Swifty on November 13, 2013, 02:18:20 pm
In between job interviews I've been doing some clean up in the rendering code. I decided to add soft shadows using Valathil's shadow mapping as a base.

There's a bit of a performance cost unfortunately but I think my performance improvements in go_faster_and_prettier still gets us a net gain in performance to allow something like this. And there's a possibility of more optimizations to the graphics code that's still to be done.

(http://i.imgur.com/NCa3htG.jpg)

(http://i.imgur.com/9Ja1zIL.jpg)

(http://i.imgur.com/KUjtgnC.jpg)

(http://i.imgur.com/4jYdnaL.jpg)

(http://i.imgur.com/COQAEEt.png)

(http://i.imgur.com/Cavfj7n.png)

(http://i.imgur.com/6d7RSob.png)
Title: Re: Variance Shadow Maps (Soft shadows) WIP
Post by: MatthTheGeek on November 13, 2013, 02:22:24 pm
sheeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeet
Title: Re: Variance Shadow Maps (Soft shadows) WIP
Post by: Rodo on November 13, 2013, 02:32:31 pm
Looks way too cool to complain about minium performance hits. :yes:
Title: Re: Variance Shadow Maps (Soft shadows) WIP
Post by: Scourge of Ages on November 13, 2013, 02:39:09 pm
Oh my~
Title: Re: Variance Shadow Maps (Soft shadows) WIP
Post by: The Dagger on November 13, 2013, 03:01:05 pm
It makes me really happy when super-cool stuff comes out of the blue like this. It made my day. Thanks Swifty! :yes:
Title: Re: Variance Shadow Maps (Soft shadows) WIP
Post by: Solatar on November 13, 2013, 03:38:11 pm
Awesome.  One more reason for me to buy a new computer sometime that can actually run FSO with the shader pipeline active. :yes:
Title: Re: Variance Shadow Maps (Soft shadows) WIP
Post by: The E on November 13, 2013, 04:33:54 pm
oh my
Title: Re: Variance Shadow Maps (Soft shadows) WIP
Post by: CommanderDJ on November 13, 2013, 05:15:39 pm
whaaaaaaaaaaaaaaaaaaaaaaaat
Title: Re: Variance Shadow Maps (Soft shadows) WIP
Post by: Kobrar44 on November 13, 2013, 07:32:15 pm
I wonder if the shadow acne is completely gone by now?
Title: Re: Variance Shadow Maps (Soft shadows) WIP
Post by: Mongoose on November 13, 2013, 07:46:37 pm
How did...what is...bwuh...*brain melts*

(you know I think I posted about this same exact thing back when Valathil originally unveiled his shadow builds)
Title: Re: Variance Shadow Maps (Soft shadows) WIP
Post by: StarSlayer on November 13, 2013, 08:10:45 pm
(http://segafans.com/wp-content/uploads/2013/08/mother-of-god.jpg)
Title: Re: Variance Shadow Maps (Soft shadows) WIP
Post by: X3N0-Life-Form on November 13, 2013, 08:16:58 pm
Oh my ...
Title: Re: Variance Shadow Maps (Soft shadows) WIP
Post by: Fury on November 14, 2013, 12:04:45 am
Swifty, I love you.
Title: Re: Variance Shadow Maps (Soft shadows) WIP
Post by: Luis Dias on November 14, 2013, 04:02:11 am
INCREDIBRUUU :D

no but really that's awesome.

So.... when is this thing actually coming to the main trunk already?!?!
Title: Re: Variance Shadow Maps (Soft shadows) WIP
Post by: TwentyPercentCooler on November 14, 2013, 08:32:06 pm
I love HLP's wizards. It's like walking into a room and a crazy guy with a shotgun pops out from behind the couch and shoots you in the face, except that instead of the shot being made of lead, it's made of awesome.
Title: Re: Variance Shadow Maps (Soft shadows) WIP
Post by: z64555 on November 16, 2013, 07:00:44 am
I love HLP's wizards. It's like walking into a room and a crazy guy with a shotgun pops out from behind the couch and shoots you in the face, except that instead of the shot being made of lead, it's made of awesome.

quoted for truth.  :yes:  :yes:
Title: Re: Variance Shadow Maps (Soft shadows) WIP
Post by: Flaser on November 25, 2013, 04:34:24 am
Can mod makers parameterize how shadows are applied? (Possibly on a per mission basis) This would be great to simulate the difference say... between fighting in hard vacuum (hard shadows) vs nebulas or atmospheres.

(Note: let's not get bogged down in physics. The whole premise of a space combat dogfighting game is ridiculous and it only works because it rides on a tsunami made of awesome driven by the rule of cool...
I only ask since it's nice for modders to have better control of the aesthetics).
Title: Re: Variance Shadow Maps (Soft shadows) WIP
Post by: Oddgrim on November 30, 2013, 07:45:08 pm
Good stuff, hopes to see more of this. I'd love to have this in my client :p
Title: Re: Variance Shadow Maps (Soft shadows) WIP
Post by: Swifty on December 02, 2013, 10:11:04 pm
Can mod makers parameterize how shadows are applied? (Possibly on a per mission basis) This would be great to simulate the difference say... between fighting in hard vacuum (hard shadows) vs nebulas or atmospheres.

(Note: let's not get bogged down in physics. The whole premise of a space combat dogfighting game is ridiculous and it only works because it rides on a tsunami made of awesome driven by the rule of cool...
I only ask since it's nice for modders to have better control of the aesthetics).
No, it's not possible. The whole point of soft shadows is to basically cover up any details lost when rendering to a shadow map. Sorry.
Title: Re: Variance Shadow Maps (Soft shadows) WIP
Post by: Luis Dias on December 03, 2013, 05:13:20 am
Yes, his point was whether he could (or not) have access to some blur parameter of sorts. Like 0 = w/out blur, 1 = your version, 2 = double blur, 3,4 = triple, for times the blur (dense nebulas).
Title: Re: Variance Shadow Maps (Soft shadows) WIP
Post by: --Steve-O-- on December 15, 2013, 01:23:21 am
I love HLP's wizards. It's like walking into a room and a crazy guy with a shotgun pops out from behind the couch and shoots you in the face, except that instead of the shot being made of lead, it's made of awesome.

quoted again for great justice

that shizz is funny yo
Title: Re: Variance Shadow Maps (Soft shadows) WIP
Post by: Bryan See on February 16, 2014, 09:18:47 am
Swifty, how's your variance soft shadow maps going on? I'd like to see it committed to main trunk very soon.
Title: Re: Variance Shadow Maps (Soft shadows) WIP
Post by: Swifty on March 03, 2014, 01:03:03 am
Well it's probably not something I'd immediately commit to trunk. I rewrote a lot of model rendering code so it'll probably be more prudent to do some bug testing. You'll probably start seeing it in the Test Builds section very soon.
Title: Re: Variance Shadow Maps (Soft shadows) WIP
Post by: SypheDMar on March 07, 2014, 05:43:07 pm
Remember when our coders said that this was impossible?

 :pimp:
Title: Re: Variance Shadow Maps (Soft shadows) WIP
Post by: Zacam on March 07, 2014, 06:56:00 pm
Under the constraints of the previous times that it was brought up, it was. The engine didn't have any sort of framework for delivering this.

That started changing once Taylor introduced the shader pipeline and we got folks like Hery, The E, Valathil and Swifty involved into iterating on it. Because then it went from being impossible to plausible. Hell, it even took Triple-A a while to get into figuring out how to make it possible.

There's obviously still a good amount of progress to be made, especially in terms of making it something that will perform well. But we'll get there.
Title: Re: Variance Shadow Maps (Soft shadows) WIP
Post by: SypheDMar on March 07, 2014, 09:03:39 pm
We've done the impossible, and that makes us mighty shows how far we've gone. We couldn't have imagined this years ago, but it's becoming a reality.

Y'all make dreams come true.
Title: Re: Variance Shadow Maps (Soft shadows) WIP
Post by: Swifty on April 06, 2014, 05:28:59 am
So, the technique I've implemented has been using something called variance shadow maps. Long story short, this let's us prefilter the shadow maps using a separable filter like gaussian blur to get the softness we need.

Data from testing is showing that the gaussian blur is hitting people's machines really hard. That's due the number of texture fetches required to implement gaussian blur. I'm using four shadow maps for four different cascades, all 1024x1024. So 2048x2048 texels times 5 texel fetches for the vertical pass times 5 texel fetches for the horizontal pass... That's a lot of texture fetches. It also doesn't help that variance shadow mapping requires fatter floating point textures so we also take on a texture bandwidth hit.

So, I think I'm going to ditch the variance shadow mapping technique now that I discovered cheaper ways to sample shadow maps with the filter sizes we need without sacrificing quality and reducing the frametime footprint.
Title: Re: Variance Shadow Maps (Soft shadows) WIP
Post by: Bobboau on April 07, 2014, 10:03:52 pm
so, just a small tangent, is the fixed function pipeline supported anymore at all? or is it as deprecated as the non-htl code?
Title: Re: Variance Shadow Maps (Soft shadows) WIP
Post by: Swifty on April 08, 2014, 12:01:47 am
Fixed function should still work even with how I refactor the model render functions. If it doesn't, it's a bug. A big bug.