Shadowmap Scaling

Shadowmap Scaling

Discuss the source code and development of Spring Engine in general from a technical point of view. Patches go here too.

Moderator: Moderators

Post Reply
User avatar
Argh
Posts: 10920
Joined: 21 Feb 2005, 03:38

Shadowmap Scaling

Post by Argh »

Stupid question, but I thought I'd bring it up. Why isn't the shadowmap's projection area based on, and clipped by, the viewpane, so that it scales with the distance of the camera from the map?

It seems to me that even 512 shadows could look pretty good if they were being projected based on the camera, instead of being applied globally to the entire map.
User avatar
jcnossen
Former Engine Dev
Posts: 2440
Joined: 05 Jun 2005, 19:13

Post by jcnossen »

it already uses the camera projection to increase detail near the camera. You notice it pretty well I think, especially when using 1024 resolution, but its probably not optimal yeah.
trepan
Former Engine Dev
Posts: 1200
Joined: 17 Nov 2005, 00:52

Post by trepan »

On a related note, the /shadows command was recently
modified to allow the specificion of the shadowmap size:

Code: Select all

/shadows [<0|1> [mapsize]]
User avatar
Argh
Posts: 10920
Joined: 21 Feb 2005, 03:38

Post by Argh »

@JC:

I'd have to vote that it's not scaling quite right. When the camera is very near to the ground, we should be seeing very exact shadows, but we're not. I think that the code that is using this needs to take distance from the ground Y into account.

@trepan:

What's going to happen if I specify anything but 1024 or 2048, though? Nothing? Or can I actually raise/lower this to new power-of-two sizes for comparison studies as to performance hits?
User avatar
kujeger
Posts: 91
Joined: 07 Oct 2004, 14:46

Post by kujeger »

Argh wrote:@JC:

I'd have to vote that it's not scaling quite right. When the camera is very near to the ground, we should be seeing very exact shadows, but we're not. I think that the code that is using this needs to take distance from the ground Y into account.

@trepan:

What's going to happen if I specify anything but 1024 or 2048, though? Nothing? Or can I actually raise/lower this to new power-of-two sizes for comparison studies as to performance hits?
I've tried it at 512, 256 and 128; worked fine (albeit ugly). Don't know about not power-of-two, though.
User avatar
Argh
Posts: 10920
Joined: 21 Feb 2005, 03:38

Post by Argh »

I've got a crazy idea:

Instead of using one shadowmap, which is attached to the camera and kept at a fixed angle relative to the sun, why not use two? One low-rez, which is kept far enough away from the camera to cover the entire battlefield, for distant shadows, and one that's much closer but higher rez, so that shadows up close are nice and sharp? We could then subtract the second one's area from the first, and end up with sharp shadows in the foreground and fuzzy ones in the distance... and if they were fuzzed out by distance from the POV, then the transition would look ok.

Just a thought.
User avatar
kujeger
Posts: 91
Joined: 07 Oct 2004, 14:46

Post by kujeger »

Wouldn't it kill performance to draw all the shadows twice?
User avatar
Argh
Posts: 10920
Joined: 21 Feb 2005, 03:38

Post by Argh »

No, because it scales off the size of the shadowmap. If the large-scale map is, say, 256^2, and the small-scale map is 1024^2, then we're talking about a total map that's far less than 2048^2, but should look noticeably better. Then, for lower-end users, they could use 512^2 / 128^2, and achieve an acceptable compromise between speed and beauty. I get 80+ FPS with 1024 shadows on, so I very much doubt that adding a second shadow calc for a much smaller area would slow things down a great deal. I just like the idea of a better tradeoff- with a smaller size, I suspect that most users could have shadows on, and at lower screen resolutions, it'd look very good, even with lower-end machines. Just my thought on this, of course- it's a crazy idea, but I thought it might be worth a thought.
User avatar
AF
AI Developer
Posts: 20687
Joined: 14 Sep 2004, 11:32

Post by AF »

I get 80+ FPS with 1024 shadows on, so I very much doubt that adding a second shadow calc for a much smaller area would slow things down a great deal.
You can run nanoblobz with shadows on and dynamic water, whereas 9/10 people cant play it on minimum settings for longer than 15 minutes without huge clunk clunk lag. You have a GF7900 right? Its better than the vast majority of spring players.

My framerates drops to an average of 10-20 fps with shadows turned on. I would like it if I could have very low resolution shadow maps, as itd look better even if I could see pixelation (theres a picture of a monkeylord in supcom where you can clearly see the pixels very large underneath it from the shadows, odd for a magazine preview screenshot in a review)
User avatar
jcnossen
Former Engine Dev
Posts: 2440
Joined: 05 Jun 2005, 19:13

Post by jcnossen »

Spring is limited by cpu when you have a decent card. Multiple passes cost a lot of FPS the way it is done.
Post Reply

Return to “Engine”