In Ventuz, you are able to add and easily modify Dynamic Shadows. This page will explain how to create shadows and what to keep in mind while working with them.
First, enable your light sources in the scene to cast shadows on their respective Nodes. By default, all Objects in the Scene that are affected by its lighting will now cast and receive shadows. In Ventuz, this is done with the help of Shadow Maps that are rendered for each Light and then applied to all objects that receive shadows.
The Light Source Nodes are the starting point for creating dynamic shadows. You can cast shadows with every type of Light Source. As soon as you change the Property Group Shadows from None to Shadow Map, everything affected by that light will also cast and receive shadows.
Point Lights demand a lot of performance for Shadowing. This is because it needs to render one shadow map for each direction resulting in six extra rendering processes for each shadowing point light.
Directional Lights adjust their frustum size of the shadow map based on the maximum distance between the objects in your scene. The quality of the shadow map will be drastically affected by the size of your scene.
LightVolume can define the volume of within the Directional Light will cast shadows!
Amount will change the intensity of the shadow.
Resolution changes the size of the used Render Target for the Shadow Map. The higher the resolution the more detailed the results but the higher the performance and memory consumption.
Always keep the Resolution as low as possible as that may save a lot of performance.
DepthBias and SlopeBias change how the Shadow Map will be applied to the receiving objects in your scene. This can be used to remove artifacts (e.g. shadow acne) that appear through false self-shadowing of surfaces. This happens when the shader compares several depths against the same texel on the Shadow Map (see the Sphere on the left screenshot in the below table).
Depth Bias adds a Bias to that comparison to let it fail more often.
Slope Bias adjusts the depth bias based on the angle of the light hitting the surface. This reduces Shadow Acne even more on very flat angles. Most of the time you will need to adjust both values to get rid of these artifacts. It is trial and error for each light as too high values will prevent the shadow from rendering where the viewer would expect it (called peter panning).
No Bias | With Bias |
Too Much Bias |
---|---|---|
|
|
|
With the Select Property, you can use one of two different Groups for the shadow casting - shadows by this light will then only be cast by objects in the same group (see Shadow Casters).
Lastly, you have some Filtering Options to create better effects in exchange for performance. You can either sample 1, 4 or 8 times in the Filter property. The more samples you use, the smoother the result but the more performance it will take to sample from the shadow map. If using 4 or 8 samples you can also change the Anti Aliasing and Filter Scaling to adjust the result. The Anti Aliasing and Filter Scaling values are represented in Pixels. If you adjust the Anti Aliasing to have a size of 1 it means the Anti Aliasing will have a radius of 1 pixel - independent from the resolution, it will always be 1 pixel. The same goes for the Filter Scaling.
By default, all objects in the scene that are affected by shadow casting light will also cast and receive shadows. If this is not desirable or the shadowing is causing bottlenecks in performance, you can change which objects should cast or receive shadows for better results.
To exclude an object from casting shadows you can use the Shadow Filter Node. With its Condition property, you can change which pass the following objects should be rendered. Model Only will ignore them during the shadowing process so that they do not cast shadows. Shadow Only will ignore the model during the normal rendering so that they cast shadows but the model is not visible otherwise. Model and Shadow which is the default option will draw the objects both the model and the shadow.
To adjust which group of lights the following objects should cast shadows, you can use the Select property (see Light Sources).
To adjust the way the shadows of an object are cast you can use a Material Node and its Shadow Options Property Group. Change it from None to either Shadow Options or Shadow Options with Fade.
For shadow casters only, the Simple Caster Shader Property is of interest. The other options change the way an object receives shadows (see Shadow Receivers). With this property you can change whether or not to cast shadows in a simplified way. The Simple Caster Shader ignores the Alpha Channel of the surface. Vertices displaced by shaders are not processed; in exchange it saves some performance.
The effects can be seen below. In the first column you can see the results with simple shading while in the second column you see the results with normal shading. In the first row you see geometry with vertices displaced by a vertex noise shader and in the second row you see a simple rectangle with an alpha texture.
SimpleCasterShadow ON | SimpleCasterShadow OFF |
---|---|
|
|
|
|
Lastly, you can change the way shadows are received by objects using the Material Node. Like on shadow casters you need to turn the Shadow Options Property Group from None to Shadow Options or Shadow Options with Fade.
The Receive flag turns on and off whether or not to receive shadows. This can be turned off for each geometry that does not receive shadows and to save performance.
The FadeDiffuse, FadeSpecular and FadeAmbient affect how much each channel of the Material fades out the Material. By default, all of these are set to 1. If one of these is turned down, the shadow is not affected anymore if the channel is affected other than through the shadowing light. In the screenshots below you can see a Sphere that is casting a shadow onto a rectangle that was cast by the spotlight above it. The Rectangle is also lighted by a Directional Light which is affecting the Rectangle's Diffuse Channel. On the left you see that scene with a FadeDiffuse value of 1 and on the right you see the same scene with a FadeDiffuse of 0. As you can see, the shadow is not as intense on the left as on the right, because it is affected by the Diffuse Channel of the Rectangle.
FadeDiffuse = 1 | FadeDiffuse = 0 |
---|---|
|
|
The Directional Light can have a LightVolume enabled. The volume can help where a shadow map will be generated. This is extremely helpful if your scene is very large and you want toto focus on a specified area. This way, you don't need to increase the shadow map resolution and can save performance; This prevents the boundaries of your shadow map from changing if objects are moved outside of your scene. For example, the shadow map calculation for a directional light will always take the outer boundaries of the scene, whenever these change because an object moves, and therefore increases the scene boundaries as shown by the screenshot below, it will resize the shadow map area. The result is a larger shadow map that scales the pixels accordingly.
As long as the objects are inside of a reasonable area, the shadow map will have good results at a resolution of 256px. As soon as an object moves toward the edge of the scene, the shadow map will also resize or extend to match the outer boundaries of the scene. The resolution stays the same at 256px, but the projection size of the map increases.
To visualize what happens:
All Objects inside the scene boundaries | One Object is moving and changes the scene boundaries |
---|---|
|
|
The result is a very pixilated shadow map. The shadow map will change its scale/size based on the scene size. Whenever you would have a moving object, you will see that the shadow map will change and recalculate each frame.
No LightVolume used:
And here we have defined a LightVolume which is a bit smaller than the rectangular groundplane. On one hand the Shadow Map crops right the shadow and on the other hand it prevents the scale of the Shadow Map so you don't the scrambling pixels.
You can get a much better and a more precise shadow map by defining the LightVolume of the Directional Light Source. Changing the translation of the Directional Light Source to the area of interest. Simply add an Axis in front of the Directional Light Source and reposition it. Also enable the LightVolume and change its properties to define the volume for the shadow.