Radioactive-Software Radioactive-Software
Forum to discuss Radioactive-Software Products
 
 FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

Shadowmaps
Goto page 1, 2  Next
 
This forum is locked: you cannot post, reply to, or edit topics.   This topic is locked: you cannot edit posts or make replies.    Radioactive-Software Forum Index -> Programming
View previous topic :: View next topic  
Author Message
rh
Guest





PostPosted: Sun Jun 11, 2006 1:42 pm    Post subject: Shadowmaps Reply with quote

hi, i am looking at this game some time and it looks very cool Cool

I am interested in how you have done the shadowmaps because i am doing an engine too Smile .
Do you use perspective shadow maps?
Is it one directional light(sun) or omnidirectional using a cubemap?

Would be nice if you can tell some details about it.

And of course : Keep up the great work Wink
Back to top
Guest






PostPosted: Sun Jun 18, 2006 5:09 am    Post subject: Reply with quote

*push* Very Happy
Back to top
dgreen
The One


Joined: 24 Sep 2005
Posts: 6811
Location: Raleigh, NC

PostPosted: Sun Jun 18, 2006 6:13 am    Post subject: Reply with quote

Hey there! Sorry I must have missed this thread.

I use a orthogonal projection matrix for the shadows (no perspective), it is one directional light.

Because the scenes are so large I had to use two shadow maps (local and global shadow maps). The global shadow map covers the entire city/scene and is 512x512 or 1024x1024 in resolution, depending on how fast the user's computer is. The local shadow map is 2048x2048 or 1024x1024 in size, again depending on the users computer.

The local shadow map is scaled/sized around the view frustum depending on the camera height and several other factors. As the camera gets closer to the ground, the local shadow map tightens up. This is to provide better resolution. Anything not covered with the local shadow map, will get taken care of by the global shadow map.

I divide my scene into render groups, based on the texture/material assigned to each triangle/object. Additionally each render group is broken up into two groups of triangles, based on which shadow map it belongs to. This way it's very easy to render the local shadow maps, and then the global shadow map.

I'm still going through and optimizing the code, but considering the size of the city and the 100s of visible actors/vehicles at any given time...I'm very happy with the performance. I make heavy use of LOD, and imposters to optimize the framerates as well. Getting alpha testing to work with assembly level shaders & shadow maps is not fun lol, if you need some help with that in the future, let me know.

Lets see what else....oh...I've been battling with some z-fighting artifacts regarding the shadow maps [mostly at sunset]...and I just solved that problem. I had an elaborate dynamic z-bias system setup to aleviate the problem...but it turns out that just reversing the culling order when rendering TO the shadow maps will resolve most of those issues. That only works if your geometry is closed though, so keep that in mind.

Well that's all I can think of right now, let me know if you have any more questions I'd be glad to answer them!

Thanks for following my project, I appreciate it!

- Dan
_________________
I run this place.
"Some muckety-muck architecture magazine was interviewing Will Wright about SimCity, and they asked
him a question something like "which ontological urban paridigm most influenced your design of the simulator,
the Exo-Hamiltonian Pattern Language Movement, or the Intra-Urban Deconstructionist Sub-Culture Hypothesis?"
He replied, "I just kind of optimized for game play."

Back to top
View user's profile Send private message Visit poster's website AIM Address
rh
Guest





PostPosted: Fri Jun 23, 2006 6:46 am    Post subject: Reply with quote

Thx for infos Smile

I have one more questions about your bloom/blur.
How have you done the blur? With a 3X3 matrix over the whole scene and have you done some adding to the color with different weights(more RG and less B may be)?
Back to top
dgreen
The One


Joined: 24 Sep 2005
Posts: 6811
Location: Raleigh, NC

PostPosted: Sat Jun 24, 2006 2:42 pm    Post subject: Reply with quote

Yup, that's how I do the blur. Actually I have a lot simpler one that just uses bilinear filtering, due to itteritive sampling of the scene...that's the low end blur though, and the one shown in these screenshots. I'm still working on a high blur/bloom, but I have to put that on hold right now.

- Dan
_________________
I run this place.
"Some muckety-muck architecture magazine was interviewing Will Wright about SimCity, and they asked
him a question something like "which ontological urban paridigm most influenced your design of the simulator,
the Exo-Hamiltonian Pattern Language Movement, or the Intra-Urban Deconstructionist Sub-Culture Hypothesis?"
He replied, "I just kind of optimized for game play."

Back to top
View user's profile Send private message Visit poster's website AIM Address
Mincetro
Forum Regular


Joined: 29 Nov 2005
Posts: 16

PostPosted: Sat Jun 24, 2006 8:09 pm    Post subject: Reply with quote

@rh - If you'd like to learn about methods for implementig bloom, I'd recommend this article by Harry Kalogirou.
_________________
"Whats are Quantum Mechanics?" "I don't know, somebody that repairs Quantums I guess"
Back to top
View user's profile Send private message Send e-mail
dgreen
The One


Joined: 24 Sep 2005
Posts: 6811
Location: Raleigh, NC

PostPosted: Sat Jun 24, 2006 8:42 pm    Post subject: Reply with quote

Cool. I've never seen that article before, that's exactly the type of bloom I'm going to do for the high end.

I'm going to add a brightpass as well, that should make it look a lot better than the current bloom. I'm also going to use a much better filter kernal. Yeaaaa.

- Dan
_________________
I run this place.
"Some muckety-muck architecture magazine was interviewing Will Wright about SimCity, and they asked
him a question something like "which ontological urban paridigm most influenced your design of the simulator,
the Exo-Hamiltonian Pattern Language Movement, or the Intra-Urban Deconstructionist Sub-Culture Hypothesis?"
He replied, "I just kind of optimized for game play."

Back to top
View user's profile Send private message Visit poster's website AIM Address
Mincetro
Forum Regular


Joined: 29 Nov 2005
Posts: 16

PostPosted: Sun Jun 25, 2006 9:53 pm    Post subject: Reply with quote

I was reading through that article a while ago and said "I NEED to learn how to add GLSL into torque!".
Then I tried it, got bored and played Riddick Wink
(I'm not that good a graphics programmer)
_________________
"Whats are Quantum Mechanics?" "I don't know, somebody that repairs Quantums I guess"
Back to top
View user's profile Send private message Send e-mail
Derek
Guest





PostPosted: Tue May 06, 2008 7:06 pm    Post subject: Reply with quote

Do you use NVIDIA's hardware PCF stuff?

Also what size area does the local shadowmap cover 100m? or does it vary?

How do you blend between the local and global shadowmap, is it done based on the texel value, say when it gets toward the edges it blends to the global map?

Do you always render the global shadowmap and if so is it a performance hit to render the entire city each time?
Back to top
warlord11030
Moris Family Mafia Don


Joined: 19 May 2007
Posts: 2777

PostPosted: Tue May 06, 2008 11:47 pm    Post subject: Reply with quote

I approve this message.
_________________
Ive ran my Family for a long time.. Years! The Moris Family operations are on...
-The Sims Online
-Urban Empires
-Secondlife
-There
-SAMP
www.rl-rpg.nl/forum/index.php
www.radioactive-software.com
Don Moris.
Back to top
View user's profile Send private message
rappen
Mini-Me


Joined: 22 Apr 2007
Posts: 6633
Location: Spijkenisse, Netherlands

PostPosted: Wed May 07, 2008 4:38 pm    Post subject: Reply with quote

dgreen wrote:
Yup, that's how I do the blur. Actually I have a lot simpler one that just uses bilinear filtering, due to itteritive sampling of the scene...that's the low end blur though, and the one shown in these screenshots. I'm still working on a high blur/bloom, but I have to put that on hold right now.

- Dan


Yea, exactly
_________________
Rappen Fo'shizzle my nizzle oh fo dizzle Razz

Back to top
View user's profile Send private message AIM Address MSN Messenger
dpadam450
Jehovah's Witness


Joined: 01 Jul 2008
Posts: 38
Location: Seattle

PostPosted: Mon Aug 25, 2008 9:13 pm    Post subject: Reply with quote

In your shader, how do you differentiate between local and global?

The only method I can think of would be to check if the fragment projects within bounds of the local shadow maps texture (texcoord between 0 and 1).
_________________
http://p-o-p-games.50webs.com/projects.html
Back to top
View user's profile Send private message AIM Address
dgreen
The One


Joined: 24 Sep 2005
Posts: 6811
Location: Raleigh, NC

PostPosted: Fri Aug 29, 2008 3:20 am    Post subject: Reply with quote

dpadam450 wrote:
In your shader, how do you differentiate between local and global?

The only method I can think of would be to check if the fragment projects within bounds of the local shadow maps texture (texcoord between 0 and 1).


I check the distance from the camrea to see if it's in range of the local shadow map [ distance is passed from the vertex shader, and is used for other things]. I use pcf 3x3 & a conditional for the soft shadows, based on the view distance with the 9 shadow map samples inside each if {}. Compiles under shader model 3.0

In the 1st fallback, I just sample both shadow maps and then do the conditional to decide which gets used. [ compiles under shader model 2.0]

2nd fallback is no shadows. Compiles under shader model 2.0 since DX doesn't support < SM 2.0 anymore

The minimum local shadow map sampling distance scales up, as the camera's height increases.

Hope that makes some sense heh
_________________
I run this place.
"Some muckety-muck architecture magazine was interviewing Will Wright about SimCity, and they asked
him a question something like "which ontological urban paridigm most influenced your design of the simulator,
the Exo-Hamiltonian Pattern Language Movement, or the Intra-Urban Deconstructionist Sub-Culture Hypothesis?"
He replied, "I just kind of optimized for game play."

Back to top
View user's profile Send private message Visit poster's website AIM Address
dpadam450
Jehovah's Witness


Joined: 01 Jul 2008
Posts: 38
Location: Seattle

PostPosted: Fri Aug 29, 2008 9:04 pm    Post subject: Reply with quote

You check simply for distance, but what about frustum? IE two framents on the ground have very similar distances from the local light, but one is inside the frustum of the local light and one is outside?
_________________
http://p-o-p-games.50webs.com/projects.html
Back to top
View user's profile Send private message AIM Address
dgreen
The One


Joined: 24 Sep 2005
Posts: 6811
Location: Raleigh, NC

PostPosted: Sun Aug 31, 2008 12:03 am    Post subject: Reply with quote

dpadam450 wrote:
You check simply for distance, but what about frustum? IE two framents on the ground have very similar distances from the local light, but one is inside the frustum of the local light and one is outside?


I have a buffer to account for that, and objects of a certain size always have their lowest lod rendered to fix that artifact.

The frustum also determines the center of the local shadow map
_________________
I run this place.
"Some muckety-muck architecture magazine was interviewing Will Wright about SimCity, and they asked
him a question something like "which ontological urban paridigm most influenced your design of the simulator,
the Exo-Hamiltonian Pattern Language Movement, or the Intra-Urban Deconstructionist Sub-Culture Hypothesis?"
He replied, "I just kind of optimized for game play."

Back to top
View user's profile Send private message Visit poster's website AIM Address
Display posts from previous:   
This forum is locked: you cannot post, reply to, or edit topics.   This topic is locked: you cannot edit posts or make replies.    Radioactive-Software Forum Index -> Programming All times are GMT - 5 Hours
Goto page 1, 2  Next
Page 1 of 2

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB © 2001, 2002 phpBB Group