Search Home Members Contacts
About Us
Products
Downloads
Community
Support
Pages: [1] 2 3 4
  Print  
Author Topic: Shadow-Mapping Directional Lights  (Read 13249 times)
Zaknafein
Customers
Community Member
*****
Posts: 2670


WWW
« on: October 03, 2006, 11:53:58 PM »

Since BlindSide has worked hard on making Cubic Shadow Mapping work (that is, point lights), I've concentrated my efforts on making directional lights work.

I've started to work on this at the beginning of this week, and I'm starting to get pretty nice results...
To follow the development, I invite you to check this blog post once in a while : all my implemented features and planned features are listed.
I also posted tonight a comparision of all shadow filtering mode I've implemented yet with the same viewpoint and same shadowmap resolution... the FPS is a good indiction of the performance of each one as well.

http://www.zaknafein.hjcrusaders.com/?p=12

Some development screenshots (both using Scaled 4x4 PCF w/ Jittering) :

Logged

zaknafein.
>> the instruction limit : my blog & samples repository! <<
Shaedo
Customers
Community Member
*****
Posts: 68


WWW
« Reply #1 on: October 04, 2006, 03:53:10 AM »

Wow, great shots! Looks like you and BlindSide have got shadowmapping nailed down great.
Logged
Waterman
Customers
Community Member
*****
Posts: 1141


« Reply #2 on: October 04, 2006, 10:32:36 AM »

Very cool :-)

I grabbed two interesting ones from your blog text:
Quote

1. Offline static shadow computation : For static lights, there might be a way to pre-calculate shadow maps. I seriously don’t know how, because of the nature of texture projection (everything depends on the view), but I’ll see into that…

2. Redo the landscape shader : I won’t release anything until I have it working on a landscape. It was the goal to begin with. But to allow that, I need to re-do the splatting shader, and find out how projections would work on landscape chunks…

Re. 1; yes everything that removes real-time render is good. And with directional light, one could assume that it's pretty static (e.g. the sun). And if it moves, it's always possible to re-calculate the shadow map.

Why does it depend on the view ("...everything depends on the view") as long as you cover as much as needed in the shadow map? Basically it should be possible to even render the shadow map for a limited part of the scene and even so, while moving around the scene camera, get shadows - only to a limited part...? If the address goes outside the depth map, assume no shadows.

Re. 2; yes, this is of course what i  am interested in. I was about to attack this part, but i'll wait a bit as you are on it. But why redo the landscape shader? Why not just enter the shadowmap into the shadow layer of the built-in landscape shader? And update it at certain intervals. This would be less expensive.
Logged

Things should be described as simply as possible - but not simpler [A. Einstein]
Zaknafein
Customers
Community Member
*****
Posts: 2670


WWW
« Reply #3 on: October 04, 2006, 11:05:21 AM »

Thanks to both of you Smiley

Quote from: "Waterman"
Why does it depend on the view ("...everything depends on the view") as long as you cover as much as needed in the shadow map? Basically it should be possible to even render the shadow map for a limited part of the scene and even so, while moving around the scene camera, get shadows - only to a limited part...?

If you optimize things depending on where the camera is and where it looks at, then you can't really pre-cache shadows... you have to render a view-specific depth map everytime the camera moves... right?

Quote from: "Waterman"
If the address goes outside the depth map, assume no shadows.

Right now I'm having problems because of that -- I use CLAMP addressing, which clamps the depth to the depthmap extremities, and the clamped depth is usually smaller than the viewed depth... which ends up in shadows.
I think the only way to fix this is add four ugly if()'s...

Quote from: "Waterman"
But why redo the landscape shader? Why not just enter the shadowmap into the shadow layer of the built-in landscape shader? And update it at certain intervals. This would be less expensive.

You're right, I hadn't really thought about that. But does the shadow layer work when you use splatting? Anyway if not, it could be a "shadow splat" that's expanded on top of all the others.
Logged

zaknafein.
>> the instruction limit : my blog & samples repository! <<
Waterman
Customers
Community Member
*****
Posts: 1141


« Reply #4 on: October 04, 2006, 01:22:08 PM »

Quote from: "Zaknafein"
If you optimize things depending on where the camera is and where it looks at, then you can't really pre-cache shadows... you have to render a view-specific depth map everytime the camera moves... right?

Admitted, for indoor scenes this would involve grids and paging in 3 dimensions. Too tricky. But for landscapes ... (see below).

Quote from: "Zaknafein"
But does the shadow layer work when you use splatting? Anyway if not, it could be a "shadow splat" that's expanded on top of all the others.

I was thinking of yet another trick by Sylvain: Landscape.SetCustomLightmap(int32 iLightmapTexture, int32 iChunkID)

Lights, shadows...? :-)
Logged

Things should be described as simply as possible - but not simpler [A. Einstein]
Waterman
Customers
Community Member
*****
Posts: 1141


« Reply #5 on: October 04, 2006, 01:26:02 PM »

Didn't notice this earlier, your blog name: "The instruction limit"

* Hehe *
Logged

Things should be described as simply as possible - but not simpler [A. Einstein]
Zaknafein
Customers
Community Member
*****
Posts: 2670


WWW
« Reply #6 on: October 04, 2006, 03:53:00 PM »

Quote from: "Waterman"
I was thinking of yet another trick by Sylvain: Landscape.SetCustomLightmap(int32 iLightmapTexture, int32 iChunkID)

Lights, shadows...? :-)

Hehe, that's what I had in mind when I said "shadow layer" too. I've seen an example (AGT's 3rd person demo) which uses this lightmap to render the landscape self-shadows...
But I'm not entirely sure this works with splatting enabled. I'll make my tests...
Logged

zaknafein.
>> the instruction limit : my blog & samples repository! <<
Zaknafein
Customers
Community Member
*****
Posts: 2670


WWW
« Reply #7 on: October 11, 2006, 12:46:41 AM »

A bit of an update, I got Variance Shadow Maps with gaussian filtering to work. It's not 100% functional yet (some artifacts...) but it looks like a very good solution!
More info and comparision shots in the blog post.

7x7 gaussian blurred Variance Shadow Maps with hardware filtering


9x9 gaussian blurred VSM w/ hardware filtering
Logged

zaknafein.
>> the instruction limit : my blog & samples repository! <<
Zaknafein
Customers
Community Member
*****
Posts: 2670


WWW
« Reply #8 on: November 02, 2006, 08:46:07 PM »

I'm still working on this... Smiley

Here's the first WIP shot of shadowmapping on a landscape! Notice that the landscape self-shadows too... Cheesy
Edit : And then another shot with "transparent" shadowmapping... Not actually full alphablending, but alpha testing at 50%.


Logged

zaknafein.
>> the instruction limit : my blog & samples repository! <<
pizzayoyo
Customers
Community Member
*****
Posts: 1320


WWW
« Reply #9 on: November 02, 2006, 10:04:57 PM »

:O Really nice work here Cheesy

I can see the performance is way better than using stencils, and I will definitely be using this when you release it.

Love the tree shading btw.
Logged

JohnB
Customers
Community Member
*****
Posts: 174


« Reply #10 on: November 02, 2006, 11:10:52 PM »

Wow - that looks awsome... of course so does everything else you do.  Cheesy

John B.
Logged
patrickrho
Customers
Community Member
*****
Posts: 116


« Reply #11 on: November 03, 2006, 12:36:51 AM »

wow

looking forward to it!
Logged

Henry David Thoreau: Quotes on Vision
I would give all the wealth of the world, and all the deeds of all the heroes, for one true vision.
Zaknafein
Customers
Community Member
*****
Posts: 2670


WWW
« Reply #12 on: November 03, 2006, 02:03:32 AM »

Thanks Cheesy
As always, details about what's working, what's not working, and how I did it in the blog post @ http://www.zaknafein.hjcrusaders.com/?p=12#more-12
Logged

zaknafein.
>> the instruction limit : my blog & samples repository! <<
Raine
Customers
Community Member
*****
Posts: 1189


« Reply #13 on: November 03, 2006, 02:41:18 AM »

whoa.
Logged

AGT
Customers
Community Member
*****
Posts: 476


WWW
« Reply #14 on: November 03, 2006, 05:58:36 AM »

Quote
Edit : And then another shot with "transparent" shadowmapping... Not actually full alphablending, but alpha testing at 50%.

Wow :shock:  You've got to be kinding me. I never expected to see this one without using any Landscape premade lightmap.
Zak, that's great! I don't know what else to say!
Logged

patrickrho
Customers
Community Member
*****
Posts: 116


« Reply #15 on: November 03, 2006, 01:58:34 PM »

so does this mean that it would be so much faster than stencils?
Logged

Henry David Thoreau: Quotes on Vision
I would give all the wealth of the world, and all the deeds of all the heroes, for one true vision.
Zaknafein
Customers
Community Member
*****
Posts: 2670


WWW
« Reply #16 on: November 03, 2006, 03:00:05 PM »

It's hard to tell right now since my implementation is NOWHERE as flexible as TV's stencil shadows, and I haven't compared the performance yet. The performance mostly depends on the shadowmap and depthmap sizes, something that you can't change with stencils.
But :
- Soft shadows are a lot easier to achieve with shadowmapping than stencil shadows
- Alpha-tested shadows is not possible with stencils, and easy in shadowmapping
- Self-shadows are glitchy with stencils, and work well with shadowmapping
Logged

zaknafein.
>> the instruction limit : my blog & samples repository! <<
sgrippa
Customers
Community Member
*****
Posts: 232


« Reply #17 on: November 03, 2006, 04:46:02 PM »

I can't wait to see a demo if you'll decide to release it...  Cheesy
Usually your demos are masterpieces of good programming and I'd love in particular this one since I'm developing a little modification to treemagik meshes (using billboards vs static geometry); I'd love to see good shadows castewd trought leaves planes.

One quick question : are the shadows casted to meshes too (I mean, is the landscape the only receiver or they can be any geometry in the world) ?
Logged

Programming today is a race between software engineers striving to build bigger and better idiot-proof programs, and the Universe trying to produce bigger and better idiots. So far, the Universe is winning. (Rich Cook)
Zaknafein
Customers
Community Member
*****
Posts: 2670


WWW
« Reply #18 on: November 03, 2006, 04:59:39 PM »

Quote
masterpieces of good programming

*cough* Let's not get carried away... But thanks alot. Cheesy

Quote
are the shadows casted to meshes too

Not right now, but it's certainly doable. The main problem is that mesh shadow-mapping implies a custom shader, there is no "CustomLightmap" or splatting for meshes. I already managed it, but it's annoying because it strips off much of TV's normal functionality.
Logged

zaknafein.
>> the instruction limit : my blog & samples repository! <<
sgrippa
Customers
Community Member
*****
Posts: 232


« Reply #19 on: November 03, 2006, 07:49:29 PM »

I see, anyway casting shadows on meshes is relevant only with objects moving and in this case it may be more practical to use stencils.
Eventually I will place my trees and meshes wisely to achieve the best result.

Waiting for your demo  :lol:
Logged

Programming today is a race between software engineers striving to build bigger and better idiot-proof programs, and the Universe trying to produce bigger and better idiots. So far, the Universe is winning. (Rich Cook)
Pages: [1] 2 3 4
  Print  
 
Jump to:  

Powered by SMF 1.1.3 | SMF © 2006-2007, Simple Machines LLC
Seo4Smf v0.2 © Webmaster's Talks