• Welcome to SC4 Devotion Forum Archives.

Look into the Shadow

Started by SimFox, June 11, 2008, 02:47:57 AM

Previous topic - Next topic

0 Members and 1 Guest are viewing this topic.

SimFox

Introduction:


I'll be moving to here some of the tutorials/overview articles I've had in my Forces of Light and the Geometry of the Shadows thread on Simtropolis. Given the stability of the later and the fact that crowd here is clearly more technically m,indeed and growth oriented I think it would be better place for them.
So, first subject will be SHADOWS and different ways to create them.

First one is is a brief tour into the types of shadows available in GMAX/MAX. Light and shadow are of paramount importance as they define what we see. Sadly both are much overlooked by aspiring BATers, who tend to go for "textures" and some such. Not that those are unimportant, but no texture will save the day if you shadows are all over the place, the wrong place...
So here we go:


This is to a degree relevant to all those using GMAX as well, since it gives you choice of ray traced shadows and those generated with shadow maps.
All renderings were made with MAX and numbers given are for MAX as well, but I believe it will hold for GMAX too.


SHADOW MAPS


Let's start with shadow maps. These work as textures and as such they could become HUGE drain on memory. If you keep them at small default values you'll get something amorphous with fringed borders and often odd splotches.

Shadow Map's saving grace is the fact that they're rather easy on CPU. But in today's world where CPU speed had gone loooong way Shadow Maps hold little if any benefit anymore.

Memory is presently also cheap. But if you want your shadow maps equal in quality ray traced shadows you may realize that limit is set by your OS. X86 version of Windows can handle only so much and can allocate to one given process even less.


RAY TRACED SHADOWS



Ray traced shadows work by tracing rays of light source (no surprise here). Process is very CPU intensive, but produces accurate shadow line. Calculations can be speed up by process called Quadtree. I'll show you effect of this on speed of render later on.


AREA SHADOWS (not available on GMAX)


Area shadows are, in fact a subdivision of Raytraced shadow and are SLOWEST of all. Speed and look of area shadows depends on your choice of the shape of the light source and the size you assign to it. The smaller it is the more area shadows will look like regular ray traced shadows.

In reality ALL shadows are Area Shadows. But given the burden they place on CPUs they are often substituted by regular ray traced ones when small and very far away light sources (like the Sun) are emulated.


EXAMPLES


To illustrate that brief info and to show quality vs. time effect here are few renderings of common teapot. All renders are done with default Scanline render. And none have any GI what-so-ever. I'll write about that subject later.

Notice:


  • All pictures are PNG files. I will not use JPG as compression may interfere with picture itself, making comparison pointless. If you can not see then – damp IE and get yourself Firefox!
  • All following is true for Scanline renderer (default option in MAX). Second rendering engine that comes with MAX – Mental Ray has it's own peculiarities and not considered here.

Let start with Shadow Map, the way BAT creates it:


This is with default black as a Shadow color. This sort of shadows may be seen on Moon but not on Earth! I will go in to more detail why on next show-and-tell about GI. But MAX has nice little trick – absolutely cheat one, but sweet none the less: you can change shadow color and give them much more natural look:


you can clearly see what is wrong with this type of shadows. This result you get with default value of 512 for the shadow map size. At this size your memory usage for rendering this scene is about 2,5Mb. And quality you can see from the picture. Render time is 1 sec.

Here is for a comparison how same scene looks with Ray traced shadow:


this is done with default settings for this particular shadow type. Render time is 21 sec. Memory usage is little under 1 Mb.

With Shadow Map Increasing map size leads to better quality , but also higher memory usage.
With map size of 4096 Shadow mapped shadow is still far away from quality of Ray traced one:


but memory usage rises to 67Mb.

Raising Shadow Map size to 8192 brings us to some approximation of the quality of ray traced shadow


but it requires whopping 264Mb of memory!!! And this is PER light source!

Reading all this you may ask 'Why is any of this important? Why should I care?' Well this sloppy nature of Shadow Maps is the reason for that peculiar situation when Roof junk appears to float in mid air in stead of being firmly put on the roof. Decorative elements on walls look like they are meters apart from those, or at all placed at the different height then in reality.


Max Quadtree Depth Parameter.
In Ray Traced Shadow parameters you'll find dial for Max Quadtree Depth. This is used to speed up calculations of Ray traced shadows. It is as I gather some sort of interpolation method. Default value is 7. Dialing it down to 1 will increase render time to 12min 25sec – 745sec !!! But dialing this up to 10 – max value – will bring render timer back to the same 2 sec as with shadow map. Theoretically quality and precision of shadow may suffer, however on our teapot result is indistinguishable.
Quadtree 1


Quadtree 10


So we have best of both worlds – speed of Shadow map and memory consumption of a ray trace.


Area Shadows.
Area Shadows produce effect commonly seen in real world – shadows borders get more blur and washed out the farther the shadow is from the point of origin. In fact all shadows we see around us are Area Shadows.
Amount of this effect depends in MAX on size and shape of the light source. For sun it would be natural to chose sphere or a disk.

Area shadow of a sphere of size of 10 with other settings on default will produce this image at 27sec. Memory usage is 2mb


Dialing size down to 5x5x5m makes shadow border more defined and reduce render time to 20 sec.


Changing shape of light source to the disk. Affect shadows quite a bit:


Boarders of the shadow are much more blurred then with Sphere, but this blur is coming with significant noise. Render time is 12 sec. To fix this noise we can dial up Shadow Integrity value from default 2 to 5. Doing so gives us this result:

At the same time render time goes from 12 sec to 50 sec.

You can experiment with other light source shapes and quality settings to get the feel how Area Shadows work


Although Area Shadows may look nice I believe one can skip them on a slower machine or larger structures because:

  • Sun (on a clear day) produce rather sharp, well defined shadows. When seen from the distances approximate of those in Simcity (even at zoom5) area effect is a minor one. Nice if it is there, but if that means days of render time I doubt it is worth it.
  • Shadow degradation in real world doesn't depend on the distance – in space for instance it never happens. But on the nature of the environments surrounding shadow and surface on which shadow is cast. More rough and bumpy this surface is, the more degradation you'll see. Reflective qualities of surroundings will also contribute to the process the more light is bounced around the faster shadow will degrade. Algorithms in Area shadow just some sort of approximation of an average environment.