Soft Shadows with RenderDotCSince its introduction, RenderDotC has supported standard depth map shadows through the Shading Language shadow() function. Sometimes the user may want to get Soft Shadows with true penumbral effects like many raytracing renderers offer. RenderDotC now supports soft shadows through the use of several shadow maps and an extended shadow() call. The approach is actually very similar to raytracing, since it actually traces rays from the surface to points on an area lightsource. The difference is that instead of tracing rays through the actual scene geometry, it uses the shadow maps as a scene representation and traces rays through them. This provides high quality soft shadows without the cost of conventional raytracing and also inherits the typical advantages of shadow mapping:
The Area Light SourceThe Shading Language shadow() call now accepts the new parameter "source", followed by one, two, three or four Points in current space defining a point, line, triangle or bilinear patch respectively. This one is used as the origin of light for shadow computation.The "samples" switch in this case is used to set the number of rays traced from the surface element to different points on the light source. Higher numbers will reduce noise, but will lead to higer rendering times. Multiple Shadow MapsIt is possible, to get soft shadows out of one shadow map, but due to the lack of information you might get some artifacts, especially when the light source is near and big in respect to the object. In some cases you might get away with that, though. The important thing for shadow map generation is that all shadow maps cover all the objects which are supposed to cast shadows. It's not so important from where you generate your shadow maps, they don't even have to be anywehere near the actual light source. It's more important to cover all of the surfaces which will cast shadows.The illustration shows the concept of soft shadow generation via shadow maps. The two shadow maps are generated from two different positions on the light source and due to their different position they cover slightly different parts of the surface. Rays are traced from the surface point P to points on the lightsource you defined via "source". Three sample rays are shown in the picture and the ray to point x1 would be considered unoccluded if only the shadow map from location 1 would be given since the part that ray intersects is not covered by that shadow map. For this reason the modified shadow() call now accepts more than one texturemap. Several texturemaps are given as comma-sperated list: "shadow1.map,shadow2.map,shadow3.map..." Normal shadow maps are accepted, but you can speed up soft shadow rendering with the "minmax" switch for MakeShadow or the -Z (capital) switch when using texdc. An example .rib statement would be: MakeShadow "shadow.z" "shadow.shd" "minmax" [1] Gap BiasThe Gap Bias defines how different the depth values of adjacent pixels in the shadow map have to be, to be considered disconnected.Here is an example shader:
light arealight(color lightcolor = color(1,1,1); float intensity = 1; string maplist = ""; float numsamples = 1; point Pl1 = point "shader" (0, 0, 0); point Pl2 = point "shader" (1, 0, 0); point Pl3 = point "shader" (0, 1, 0); point Pl4 = point "shader" (1, 1, 0); float shadowbias = 0.001; float gapbias = 0.01) { varying float attenuation; /* Base illumination at average of light positions
*/
arealight.sl And here is an example RIB file to test the functionality:
Declare "minmax" "integer" Declare "Pl1" "uniform point" Declare "Pl2" "uniform point" Declare "Pl3" "uniform point" Declare "Pl4" "uniform point" Declare "maplist" "uniform string" Declare "shadowbias" "uniform float" Declare "gapbias" "uniform float" Declare "numsamples" "uniform float" Option "shadow" "bias" [0.6] FrameBegin 1
Identity # Second Soft Shadow Map image (upper right)
Identity # Third Soft Shadow Map image (lower left)
Identity MakeShadow "sphere1.z" "sphere1.shd" "minmax" [1]
Display "softshadows.tif" "file" "rgb"
softshadows.rib |