Jump to content

  • Log In with Google      Sign In   
  • Create Account


Shadow map surface aspect ratio ?


Old topic!
Guest, the last post of this topic is over 60 days old and at this point you may not reply in this topic. If you wish to continue this conversation start a new topic.

  • You cannot reply to this topic
5 replies to this topic

#1 Norden   Members   -  Reputation: 107

Like
0Likes
Like

Posted 05 May 2013 - 02:49 AM

Hey there guys!
 
I've been fooling around with shadow mapping for quite some time, I've experimented a lot, implemented pcf, vsm, esm filtering, and got it working well now. However, one question still haunts me, and I havent been able to find a satisfying answer or discussion about it. Aspect ratio of the shadow map rendering surface.
 
I am talking about a simple scenario, one directional light, one shadow map for entire scene. I construct my orthogonal lightview projection matrix by creating a box to fit around my viewing frustum (as I believe is the standard approach). So obviously, the aspect ratio of the lightview projection matrix is the same as the one of my view matrix, which depends on screen resolution and is never 1:1 (16:9...etc...). So I believe, the shadows are more accurate if the aspect ratio of my offscreen shadowmap rendering surface would be like that, the same as screen aspect ratio ??? Please correct me if I am wrong?? 
 
Nonetheless, in vast majority of the samples and tutorials, the shadowmap size used is fixed, 1024x1024 for example, and not dependent on the frame buffer resolution at all. The interesting thing is that not in a single resource (and I checked MANY) there was not even a word about that, either used fixed square size, or the size of frame buffer. Furthermore, I checked how it is with some AAA games, and realised they were all using fixed square shadow map sizes, with quality settings either size of 1024^, 2048^ or 4096^, which seem like giant leaps to me... Would it not make more sense to have the size of shadow map for normal quality for example the same as frame buffer resolution, the lower quiality size*0.5 and higher quality size*1.5 ???
 
Are such sizes of shadow maps used only to be compatible with older hardware that doesnt support arbitrary rendering surface sizes? Or am I missing something really obvious here ?? smile.png
 
I hope anyone can shead some light on this matter for me!!!
 
Thanks a lot!

Edited by Norden, 05 May 2013 - 02:51 AM.


Sponsor:

#2 MichaelNIII   Members   -  Reputation: 195

Like
1Likes
Like

Posted 05 May 2013 - 03:08 AM

They use the powers of 2 because textures are automatically resized with blank space on non-power of 2 textures. So reducing the quality of the map in order to achieve a perticular resolution may cause very slight accuracy improvement on that resolution (I believe it might because of the removal of floating point accuracy) - but would slight drop when used on any other resolution because the image has less detail. this may change as more graphics cards are accepting non-power of two textures, but I believe will remain the norm even after that - until there is a large movement for an industry standard for highest resolution at which point they would switch over to whatever that may turn out to be.

#3 Norden   Members   -  Reputation: 107

Like
0Likes
Like

Posted 05 May 2013 - 03:27 AM

Hey, thanks for your answer.

 

So if i get it right: Let's say my screen res is 1024x768. If I create a sm of size 1024x768, there would be a minor accuracy gain, and a minor performance gain on gpus that support non power of two sizes and no performance gain on gpus that dont support non power of 2 sizes over a 1024x1024 sm ?

 

The size of sm is important for me to be as small as possible not only because the memory and bandwidth, but also because I am doing a 5x5 gaussian blur prefilter on shadow map, and since I am fragment shader bound, that does affect final performance.

 

Thanx!



#4 Hodgman   Moderators   -  Reputation: 29302

Like
1Likes
Like

Posted 05 May 2013 - 03:47 AM

When you project your shadow-map texture on to the world, you don't end up with each pixel on the screen using a unique shadow-map texel, or vice versa.

i.e. there is not a 1:1 relationship between screen pixels and shadow pixels.

So, this being the case, there's no reason at all to have shadow-map resolution be a ratio of the screen resolution.



#5 galop1n   Members   -  Reputation: 226

Like
1Likes
Like

Posted 05 May 2013 - 04:07 AM

We allocate power of two texture because it reduce somme padding that may occurs in the memory ( not so true now, specially with big surfaces, but an old habit ). After that, if i allocate some 2048x2048 shadow map surfaces for my pool, it does not mean i have to use all the texels, if i have a distant shadow that should projet on may be 10% of the screen, i may reserve a sub rectangle and scale and bias uvs.

 

It exist also a lot of technique to improve the texel ratio of the shadow map (warp the projection, refine the shadow frustum around the casters, ...), because as said by hogman, there is no a 1/1 match between a shadow map texel and the frame buffer pixels.



#6 Norden   Members   -  Reputation: 107

Like
0Likes
Like

Posted 05 May 2013 - 04:50 AM

I am still a bit confused tongue.png

 

I fully understand that sm texel to pixel relationship is never 1:1, but still, if sm ratio differs from screen size ratio, sm texel would be scaled more in one direction than other when projecting to screen, producing less acurate shadows. Or am I wrong?? I did a test of both versions, and some shadow details look more correct to me when sm ratio matches screen ratio.

 

In terms of performance and compatibility: suppose the quality of final result is about the same if my sm size is 2048x2048 and 2048x1500 (I am making up the numbers). Which one would be better to use(taking into account my gaussian blur pass on sm)? I am targeting gpu's that support at least SM3.

 

Thanks to all of you!


Edited by Norden, 05 May 2013 - 04:53 AM.





Old topic!
Guest, the last post of this topic is over 60 days old and at this point you may not reply in this topic. If you wish to continue this conversation start a new topic.



PARTNERS