At the current stage (v1.4), only the first directional light can cast shadows. Shadows are disabled by default. To enabled shadows, set the DirectionalLight.CastShadow property to true

<DirectionalLight CastShadow="True" DiffuseColor="0.5, 0.5, 0.5" SpecularColor="1, 1, 1" Direction="-1, -1, -1" />


Not all objects can cast shadows. Models, primitives and surfaces are the built-in objects that can cast shadows. By default, models and primitives will cast shadows automatically while a surface won’t. This behavior can be adjusted though the Model.CastShadow, Primitive.CastShadow and Surface.CastShadow properties.

To receive the shadow, an object has to be assigned a material that supports the shadow mapping technique. A common way of doing this is to add the ShadowMapMaterialPart to a MaterialGroup:


<Surface Heightmap.Width="128" Heightmap.Height="128" Heightmap.Step="1" PatchSegmentCount="8" Transform.Position="-64, 0, -64" TextureTransform.Scale="0.2, 0.2">
        <DiffuseMaterialPart Texture="{ContentReference ../Textures/terrainTex}" />
        <ShadowMapMaterialPart />
        <DirectionalLightMaterialPart />


Shadow Map Quality

There are several ways to adjust the quality of the shadows. The most significant approach is to adjust the size of the shadow map. The default shadow map size on Windows is 2048, to adjust the size of the shadow map, manually set the Light.ShadowMap property:

<DirectionalLight CastShadow="True" Direction="-1, -1, -1" ShadowMap="{ShadowMap Size=4096}" />

Or increase the shadow map sample count by setting the ShadowMapMaterialPart.FilterSize property:

<Model Source="{ContentReference ../Models/Dude}" Transform.Position="-20, 0, 0" AnimationCullingEnabled="False">
            <SkinnedMaterialPart />
            <DiffuseMaterialPart />
            <SpecularMaterialPart />
            <ShadowMapMaterialPart FilerSize="5" />
            <DirectionalLightMaterialPart />



Note the above adjustment has a huge impact on the performance of the application.

Last edited Sep 30, 2012 at 3:13 AM by yufeih, version 6


No comments yet.