private bool RenderSceneToTexture()
        {
            // Set the render target to be the render to texture.
            RenderTexture.SetRenderTarget(D3D.DeviceContext);

            // Clear the render to texture.
            RenderTexture.ClearRenderTarget(D3D.DeviceContext, 0.0f, 0.0f, 0.0f, 1.0f);

            // Get the world matrix from the d3d object.
            Matrix worldMatrix = D3D.WorldMatrix;

            // Generate the light view matrix based on the light's position.
            Light.GenerateViewMatrix();

            // Get the view and orthographic matrices from the light object.
            Matrix lightViewMatrix  = Light.ViewMatrix;
            Matrix lightOrthoMatrix = Light.OrthoMatrix;

            // Translate to the position of the tree.
            Vector3 treePosition = TreeModel.GetPosition();

            Matrix.Translation(treePosition.X, treePosition.Y, treePosition.Z, out worldMatrix);

            // Render the tree trunk with the depth shader.
            TreeModel.RenderTrunk(D3D.DeviceContext);
            if (!DepthShader.Render(D3D.DeviceContext, TreeModel.TrunkIndexCount, worldMatrix, lightViewMatrix, lightOrthoMatrix))
            {
                return(false);
            }

            // Render the tree leaves using the depth transparency shader.
            TreeModel.RenderLeaves(D3D.DeviceContext);
            if (!TransparentDepthShader.Render(D3D.DeviceContext, TreeModel.LeafIndexCount, worldMatrix, lightViewMatrix, lightOrthoMatrix, TreeModel.LeafTexture.TextureResource))
            {
                return(false);
            }

            // Reset the world matrix.
            worldMatrix = D3D.WorldMatrix;

            // Translate to the position of the ground model.
            Vector3 groundPosition = GroundModel.GetPosition();

            Matrix.Translation(groundPosition.X, groundPosition.Y, groundPosition.Z, out worldMatrix);

            // Render the ground model with the depth shader.
            GroundModel.Render(D3D.DeviceContext);
            if (!DepthShader.Render(D3D.DeviceContext, GroundModel.IndexCount, worldMatrix, lightViewMatrix, lightOrthoMatrix))
            {
                return(false);
            }

            // Reset the render target back to the original back buffer and not the render to texture anymore.
            D3D.SetBackBufferRenderTarget();

            // Reset the viewport back to the original.
            D3D.ResetViewPort();

            return(true);
        }
        private bool Render()
        {
            // Clear the buffers to begin the scene.
            D3D.BeginScene(0.0f, 0.0f, 0.0f, 1.0f);

            // Generate the view matrix based on the camera's position.
            Camera.Render();

            // Get the world, view, and projection matrices from the camera and d3d objects.
            Matrix worldMatrix      = D3D.WorldMatrix;
            Matrix viewMatrix       = Camera.ViewMatrix;
            Matrix projectionMatrix = D3D.ProjectionMatrix;

            // Get the view and projection matrices from the view point object.
            Matrix viewMatrix2       = ViewPoint.ViewMatrix;
            Matrix projectionMatrix2 = ViewPoint.ProjectionMatrix;

            // Setup the translation for the ground model.
            Matrix.Translation(0.0f, 1.0f, 0.0f, out worldMatrix);

            // Render the ground model using the projection shader.
            GroundModel.Render(D3D.DeviceContext);
            if (!ProjectionShader.Render(D3D.DeviceContext, GroundModel.IndexCount, worldMatrix, viewMatrix, projectionMatrix, GroundModel.Texture.TextureResource, Light.AmbientColor, Light.DiffuseColour, Light.Position, viewMatrix2, projectionMatrix2, ProjectionTexture.TextureResource))
            {
                return(false);
            }

            // Reset the world matrix and setup the translation for the cube model.
            worldMatrix = D3D.WorldMatrix;
            Matrix.Translation(0.0f, 2.0f, 0.0f, out worldMatrix);

            // Render the cube model using the projection shader.
            CubeModel.Render(D3D.DeviceContext);
            if (!ProjectionShader.Render(D3D.DeviceContext, CubeModel.IndexCount, worldMatrix, viewMatrix, projectionMatrix, CubeModel.Texture.TextureResource, Light.AmbientColor, Light.DiffuseColour, Light.Position, viewMatrix2, projectionMatrix2, ProjectionTexture.TextureResource))
            {
                return(false);
            }

            // Present the rendered scene to the screen.
            D3D.EndScene();

            return(true);
        }
        private bool Render()
        {
            // Clear the scene.
            D3D.BeginScene(0.0f, 0.0f, 1.0f, 1.0f);

            // Generate the view matrix based on the camera's position.
            Camera.Render();

            // Get the world, view, projection, ortho, and base view matrices from the camera and Direct3D objects.
            Matrix worldMatrix      = D3D.WorldMatrix;
            Matrix viewCameraMatrix = Camera.ViewMatrix;
            Matrix projectionMatrix = D3D.ProjectionMatrix;
            Matrix orthoMatrix      = D3D.OrthoMatrix;
            Matrix baseViewMatrix   = Camera.BaseViewMatrix;

            // Render the ground model.
            GroundModel.Render(D3D.DeviceContext);
            ShaderManager.RenderTextureShader(D3D.DeviceContext, GroundModel.IndexCount, worldMatrix, viewCameraMatrix, projectionMatrix, GroundModel.ColourTexture.TextureResource);

            // Turn on the alpha-to-coverage blending.
            D3D.EnableSecondBlendState();

            // Render the foliage.
            Foliage.Render(D3D.DeviceContext);
            if (!ShaderManager.RenderFoliageShader(D3D.DeviceContext, Foliage.VertexCount, Foliage.InstanceCount, viewCameraMatrix, projectionMatrix, Foliage.Texture.TextureResource))
            {
                return(false);
            }

            // Turn off the alpha blending.
            D3D.TurnOffAlphaBlending();

            // Render the user interface.
            UserInterface.Render(D3D, ShaderManager, worldMatrix, baseViewMatrix, orthoMatrix);

            // Present the rendered scene to the screen.
            D3D.EndScene();

            return(true);
        }
        private bool RenderSceneToTexture2()
        {
            // Set the render target to be the render to texture.
            RenderTexture2.SetRenderTarget(D3D.DeviceContext);

            // Clear the render to texture.
            RenderTexture2.ClearRenderTarget(D3D.DeviceContext, 0.0f, 0.0f, 0.0f, 1.0f);

            // Generate the light view matrix based on the light's position.
            Light2.GenerateViewMatrix();

            // Get the world matrix from the d3d object.
            Matrix worldMareix = D3D.WorldMatrix;

            // Get the view and orthographic matrices from the light object.
            Matrix lightViewMatrix  = Light2.ViewMatrix;
            Matrix lightOrthoMatrix = Light2.ProjectionMatrix;

            // Setup the translation matrix for the cube model.
            Vector3 cubePosition = CubeModel.GetPosition();

            Matrix.Translation(cubePosition.X, cubePosition.Y, cubePosition.Z, out worldMareix);

            // Render the cube model with the depth shader.
            CubeModel.Render(D3D.DeviceContext);
            if (!DepthShader.Render(D3D.DeviceContext, CubeModel.IndexCount, worldMareix, lightViewMatrix, lightOrthoMatrix))
            {
                return(false);
            }

            // Reset the world matrix.
            worldMareix = D3D.WorldMatrix;

            // Setup the translation matrix for the sphere model.
            Vector3 spherePosition = SphereModel.GetPosition();

            Matrix.Translation(spherePosition.X, spherePosition.Y, spherePosition.Z, out worldMareix);

            // Render the sphere model with the depth shader.
            SphereModel.Render(D3D.DeviceContext);
            if (!DepthShader.Render(D3D.DeviceContext, SphereModel.IndexCount, worldMareix, lightViewMatrix, lightOrthoMatrix))
            {
                return(false);
            }

            // Reset the world matrix.
            worldMareix = D3D.WorldMatrix;

            // Setup the translation matrix for the ground model.
            Vector3 groundPosition = GroundModel.GetPosition();

            Matrix.Translation(groundPosition.X, groundPosition.Y, groundPosition.Z, out worldMareix);

            // Render the ground model with the depth shader.
            GroundModel.Render(D3D.DeviceContext);
            if (!DepthShader.Render(D3D.DeviceContext, GroundModel.IndexCount, worldMareix, lightViewMatrix, lightOrthoMatrix))
            {
                return(false);
            }

            // Reset the render target back to the original back buffer and not the render to texture anymore.
            D3D.SetBackBufferRenderTarget();

            // Reset the viewport back to the original.
            D3D.ResetViewPort();

            return(true);
        }
        public bool Render()
        {
            // First render the scene to a texture.
            if (!RenderSceneToTexture())
            {
                return(false);
            }

            // Render the scene to texture again but use the second light's view point.
            if (!RenderSceneToTexture2())
            {
                return(false);
            }

            // Clear the buffers to begin the scene.
            D3D.BeginScene(0.0f, 0.0f, 0.0f, 1.0f);

            // Generate the view matrix based on the camera's position.
            Camera.Render();

            // Generate the light view matrix based on the light's position.
            Light.GenerateViewMatrix();

            // Do the same for the second light.
            Light2.GenerateViewMatrix();

            // Get the world, view, and projection matrices from the camera and d3d objects.
            Matrix viewMatrix       = Camera.ViewMatrix;
            Matrix worldMatrix      = D3D.WorldMatrix;
            Matrix projectionMatrix = D3D.ProjectionMatrix;

            // Get the light's view and projection matrices from the light object.
            Matrix lightViewMatrix       = Light.ViewMatrix;
            Matrix lightProjectionMatrix = Light.ProjectionMatrix;

            // Do the same for the second light.
            Matrix lightViewMatrix2       = Light2.ViewMatrix;
            Matrix lightProjectionMatrix2 = Light2.ProjectionMatrix;

            // Setup the translation matrix for the cube model.
            Vector3 cubePosition = CubeModel.GetPosition();

            Matrix.Translation(cubePosition.X, cubePosition.Y, cubePosition.Z, out worldMatrix);

            // Put the cube model vertex and index buffers on the graphics pipeline to prepare them for drawing.
            CubeModel.Render(D3D.DeviceContext);

            // Render the model using the shadow shader.
            if (!ShadowShader.Render(D3D.DeviceContext, CubeModel.IndexCount, worldMatrix, viewMatrix, projectionMatrix, lightViewMatrix, lightProjectionMatrix, CubeModel.Texture.TextureResource, RenderTexture.ShaderResourceView, Light.Position, Light.AmbientColor, Light.DiffuseColour, lightViewMatrix2, lightProjectionMatrix2, RenderTexture2.ShaderResourceView, Light2.Position, Light2.DiffuseColour))
            {
                return(false);
            }

            // Reset the world matrix.
            worldMatrix = D3D.WorldMatrix;

            // Setup the translation matrix for the sphere model.
            Vector3 spherePosition = SphereModel.GetPosition();

            Matrix.Translation(spherePosition.X, spherePosition.Y, spherePosition.Z, out worldMatrix);

            // Put the model vertex and index buffers on the graphics pipeline to prepare them for drawing.
            SphereModel.Render(D3D.DeviceContext);
            if (!ShadowShader.Render(D3D.DeviceContext, SphereModel.IndexCount, worldMatrix, viewMatrix, projectionMatrix, lightViewMatrix, lightProjectionMatrix, SphereModel.Texture.TextureResource, RenderTexture.ShaderResourceView, Light.Position, Light.AmbientColor, Light.DiffuseColour, lightViewMatrix2, lightProjectionMatrix2, RenderTexture2.ShaderResourceView, Light2.Position, Light2.DiffuseColour))
            {
                return(false);
            }

            // Reset the world matrix.
            worldMatrix = D3D.WorldMatrix;

            // Setup the translation matrix for the ground model.
            Vector3 groundPosition = GroundModel.GetPosition();

            Matrix.Translation(groundPosition.X, groundPosition.Y, groundPosition.Z, out worldMatrix);

            // Render the ground model using the shadow shader.
            GroundModel.Render(D3D.DeviceContext);
            if (!ShadowShader.Render(D3D.DeviceContext, GroundModel.IndexCount, worldMatrix, viewMatrix, projectionMatrix, lightViewMatrix, lightProjectionMatrix, GroundModel.Texture.TextureResource, RenderTexture.ShaderResourceView, Light.Position, Light.AmbientColor, Light.DiffuseColour, lightViewMatrix2, lightProjectionMatrix2, RenderTexture2.ShaderResourceView, Light2.Position, Light2.DiffuseColour))
            {
                return(false);
            }

            // Present the rendered scene to the screen.
            D3D.EndScene();

            return(true);
        }
Esempio n. 6
0
        private bool RenderScene()
        {
            // Generate the view matrix based on the camera position.
            Camera.Render();

            // Get the world, view, and projection matrices from camera and d3d objects.
            var viewMatrix       = Camera.ViewMatrix;
            var worldMatrix      = D3D.WorldMatrix;
            var projectionMatrix = D3D.ProjectionMatrix;

            #region Render Ground Model
            // Translate to where the ground model will be rendered.
            Matrix.Translation(0f, 1f, 0f, out worldMatrix);

            // Put the ground model vertex and index buffers on the graphics pipeline to prepare them for drawing.
            GroundModel.Render(D3D.DeviceContext);

            // Render the ground model using the light shader.
            if (!LightShader.Render(D3D.DeviceContext, GroundModel.IndexCount, worldMatrix, viewMatrix, projectionMatrix, GroundModel.TextureCollection.Select(item => item.TextureResource).First(), Light.Direction, Light.AmbientColor, Light.DiffuseColour, Camera.GetPosition(), Light.SpecularColor, Light.SpecularPower))
            {
                return(false);
            }
            #endregion

            // Reset the world matrix.
            worldMatrix = D3D.WorldMatrix;

            #region Render Wall Model
            // Translate to where the ground model will be rendered.
            Matrix.Translation(0f, 6f, 8f, out worldMatrix);

            // Put the wall model vertex and index buffers on the graphics pipeline to prepare them for drawing.
            WallModel.Render(D3D.DeviceContext);

            // Render the wall model using the light shader.
            if (!LightShader.Render(D3D.DeviceContext, WallModel.IndexCount, worldMatrix, viewMatrix, projectionMatrix, WallModel.TextureCollection.Select(item => item.TextureResource).First(), Light.Direction, Light.AmbientColor, Light.DiffuseColour, Camera.GetPosition(), Light.SpecularColor, Light.SpecularPower))
            {
                return(false);
            }
            #endregion

            // Reset the world matrix.
            worldMatrix = D3D.WorldMatrix;

            #region Render Bath Model
            // Translate to where the bath model will be rendered.
            Matrix.Translation(0f, 2f, 0f, out worldMatrix);

            // Put the bath model vertex and index buffers on the graphics pipeline to prepare them for drawing.
            BathModel.Render(D3D.DeviceContext);

            // Render the bath model using the light shader.
            if (!LightShader.Render(D3D.DeviceContext, BathModel.IndexCount, worldMatrix, viewMatrix, projectionMatrix, BathModel.TextureCollection.Select(item => item.TextureResource).First(), Light.Direction, Light.AmbientColor, Light.DiffuseColour, Camera.GetPosition(), Light.SpecularColor, Light.SpecularPower))
            {
                return(false);
            }
            #endregion

            // Reset the world matrix.
            worldMatrix = D3D.WorldMatrix;

            #region Render Water Model
            // Get the camera reflection view matrix.
            var reflectionMatrix = Camera.ReflectionViewMatrix;

            // Translate to where the water model will be rendered.
            Matrix.Translation(0f, WaterHeight, 0f, out worldMatrix);

            // Put the water model vertex and index buffers on the graphics pipeline to prepare them for drawing.
            WaterModel.Render(D3D.DeviceContext);

            // Render the bath model using the light shader.
            if (!WaterShader.Render(D3D.DeviceContext, WaterModel.IndexCount, worldMatrix, viewMatrix, projectionMatrix, reflectionMatrix, RenderReflectionTexture.ShaderResourceView, RenderRefractionTexture.ShaderResourceView, WaterModel.TextureCollection.Select(item => item.TextureResource).First(), WaterTranslation, 0.1f)) // was 0.01f for scale originally.
            {
                return(false);
            }
            #endregion

            return(true);
        }
Esempio n. 7
0
        private bool RenderBlackAndWhiteShadows()
        {
            // Set the render target to be the render to texture.
            BlackWhiteRenderTexture.SetRenderTarget(D3D.DeviceContext);

            // Clear the render to texture.
            BlackWhiteRenderTexture.ClearRenderTarget(D3D.DeviceContext, 0.0f, 0.0f, 0.0f, 1.0f);

            // Generate the view matrix based on the camera's position.
            Camera.Render();

            // Generate the light view matrix based on the light's position.
            Light.GenerateViewMatrix();

            // Get the world, view, and projection matrices from the camera and d3d objects.
            Matrix cameraViewMatrix = Camera.ViewMatrix;
            Matrix worldMatrix      = D3D.WorldMatrix;
            Matrix projectionMatrix = D3D.ProjectionMatrix;

            // Get the light's view and projection matrices from the light object.
            Matrix lightViewMatrix       = Light.ViewMatrix;
            Matrix lightProjectionMatrix = Light.ProjectionMatrix;

            // Setup the translation matrix for the cube model.
            Vector3 cubePosition = CubeModel.GetPosition();

            Matrix.Translation(cubePosition.X, cubePosition.Y, cubePosition.Z, out worldMatrix);

            // Render the cube model using the shadow shader.
            CubeModel.Render(D3D.DeviceContext);
            if (!ShadowShader.Render(D3D.DeviceContext, CubeModel.IndexCount, worldMatrix, cameraViewMatrix, projectionMatrix, lightViewMatrix, lightProjectionMatrix, RenderTexture.ShaderResourceView, Light.Position))
            {
                return(false);
            }

            // Reset the world matrix.
            worldMatrix = D3D.WorldMatrix;

            // Setup the translation matrix for the sphere model.
            Vector3 spherePosition = SphereModel.GetPosition();

            Matrix.Translation(spherePosition.X, spherePosition.Y, spherePosition.Z, out worldMatrix);

            // Render the sphere model using the shadow shader.
            SphereModel.Render(D3D.DeviceContext);
            if (!ShadowShader.Render(D3D.DeviceContext, SphereModel.IndexCount, worldMatrix, cameraViewMatrix, projectionMatrix, lightViewMatrix, lightProjectionMatrix, RenderTexture.ShaderResourceView, Light.Position))
            {
                return(false);
            }

            // Reset the world matrix.
            worldMatrix = D3D.WorldMatrix;

            // Setup the translation matrix for the ground model.
            Vector3 groundPosition = GroundModel.GetPosition();

            Matrix.Translation(groundPosition.X, groundPosition.Y, groundPosition.Z, out worldMatrix);

            // Render the ground model using the shadow shader.
            GroundModel.Render(D3D.DeviceContext);
            if (!ShadowShader.Render(D3D.DeviceContext, SphereModel.IndexCount, worldMatrix, cameraViewMatrix, projectionMatrix, lightViewMatrix, lightProjectionMatrix, RenderTexture.ShaderResourceView, Light.Position))
            {
                return(false);
            }

            // Reset the render target back to the original back buffer and not the render to texture anymore.
            D3D.SetBackBufferRenderTarget();

            // Reset the viewport back to the original.
            D3D.ResetViewPort();

            return(true);
        }
Esempio n. 8
0
        public bool Render()
        {
            // First render the scene to a texture.
            if (!RenderSceneToTexture())
            {
                return(false);
            }

            // Next render the shadowed scene in black and white.
            if (!RenderBlackAndWhiteShadows())
            {
                return(false);
            }

            // Then down sample the black and white scene texture.
            if (!DownSampleTexture())
            {
                return(false);
            }

            // Perform a horizontal blur on the down sampled texture.
            if (!RenderHorizontalBlurToTexture())
            {
                return(false);
            }

            // Now perform a vertical blur on the texture.
            if (!RenderVerticalBlurToTexture())
            {
                return(false);
            }

            // Finally up sample the final blurred render to texture that can now be used in the soft shadow shader.
            if (!UpSampleTexture())
            {
                return(false);
            }

            // Clear the buffers to begin the scene.
            D3D.BeginScene(0.0f, 0.0f, 0.0f, 1.0f);

            // Generate the view matrix based on the camera's position.
            Camera.Render();

            // Get the world, view, and projection matrices from the camera and d3d objects.
            Matrix viewMatrix       = Camera.ViewMatrix;
            Matrix worldMatrix      = D3D.WorldMatrix;
            Matrix projectionMatrix = D3D.ProjectionMatrix;

            // Setup the translation matrix for the cube model.
            Vector3 cubePosition = CubeModel.GetPosition();

            Matrix.Translation(cubePosition.X, cubePosition.Y, cubePosition.Z, out worldMatrix);

            // Render the cube model using the soft shadow shader.
            CubeModel.Render(D3D.DeviceContext);
            if (!SoftShadowShader.Render(D3D.DeviceContext, CubeModel.IndexCount, worldMatrix, viewMatrix, projectionMatrix, CubeModel.Texture.TextureResource, UpSampleTexure.ShaderResourceView, Light.Position, Light.AmbientColor, Light.DiffuseColour))
            {
                return(false);
            }

            // Reset the world matrix.
            worldMatrix = D3D.WorldMatrix;

            // Setup the translation matrix for the sphere model.
            Vector3 spherePosition = SphereModel.GetPosition();

            Matrix.Translation(spherePosition.X, spherePosition.Y, spherePosition.Z, out worldMatrix);

            // Render the sphere model using the soft shadow shader.
            SphereModel.Render(D3D.DeviceContext);
            if (!SoftShadowShader.Render(D3D.DeviceContext, SphereModel.IndexCount, worldMatrix, viewMatrix, projectionMatrix, SphereModel.Texture.TextureResource, UpSampleTexure.ShaderResourceView, Light.Position, Light.AmbientColor, Light.DiffuseColour))
            {
                return(false);
            }

            // Reset the world matrix.
            worldMatrix = D3D.WorldMatrix;

            // Setup the translation matrix for the ground model.
            Vector3 groundPosition = GroundModel.GetPosition();

            Matrix.Translation(groundPosition.X, groundPosition.Y, groundPosition.Z, out worldMatrix);

            // Render the ground model using the shadow shader.
            GroundModel.Render(D3D.DeviceContext);
            if (!SoftShadowShader.Render(D3D.DeviceContext, GroundModel.IndexCount, worldMatrix, viewMatrix, projectionMatrix, GroundModel.Texture.TextureResource, UpSampleTexure.ShaderResourceView, Light.Position, Light.AmbientColor, Light.DiffuseColour))
            {
                return(false);
            }

            // Present the rendered scene to the screen.
            D3D.EndScene();

            return(true);
        }
        private bool Render()
        {
            // Render the depth of the scene to a texture.
            if (!RenderSceneToTexture())
            {
                return(false);
            }

            // Clear the scene to Grey
            D3D.BeginScene(0.0f, 0.5f, 0.8f, 1.0f);

            // Generate the view matrix based on the camera's position.
            Camera.Render();

            // Generate the light view matrix based on the light's position.
            Light.GenerateViewMatrix();

            // Get the matrices from the camera and d3d objects.
            Matrix viewCameraMatrix = Camera.ViewMatrix;
            Matrix worldMatrix      = D3D.WorldMatrix;
            Matrix projectionMatrix = D3D.ProjectionMatrix;

            // Get the light's view and projection matrices from the light object.
            Matrix lightViewMatrix  = Light.ViewMatrix;
            Matrix lightOrthoMatrix = Light.OrthoMatrix;

            // Set the light color attributes.
            Light.SetDiffuseColor(1.0f, 1.0f, 1.0f, 1.0f);
            Light.SetAmbientColor(0.15f, 0.15f, 0.15f, 1.0f);

            // Translate to the position of the ground model.
            Vector3 groundPosition = GroundModel.GetPosition();

            Matrix.Translation(groundPosition.X, groundPosition.Y, groundPosition.Z, out worldMatrix);

            // Render the ground model using the shadow shader.
            GroundModel.Render(D3D.DeviceContext);
            if (!ShadowShader.Render(D3D.DeviceContext, GroundModel.IndexCount, worldMatrix, viewCameraMatrix, projectionMatrix, lightViewMatrix, lightOrthoMatrix, GroundModel.Texture.TextureResource, RenderTexture.ShaderResourceView, Light.Direction, Light.AmbientColor, Light.DiffuseColour))
            {
                return(false);
            }

            // Reset the world matrix.
            worldMatrix = D3D.WorldMatrix;

            // Translate to the position of the tree model.
            Vector3 treePosition = TreeModel.GetPosition();

            Matrix.Translation(treePosition.X, treePosition.Y, treePosition.Z, out worldMatrix);

            // Render the tree trunk.
            TreeModel.RenderTrunk(D3D.DeviceContext);
            if (!ShadowShader.Render(D3D.DeviceContext, TreeModel.TrunkIndexCount, worldMatrix, viewCameraMatrix, projectionMatrix, lightViewMatrix, lightOrthoMatrix, TreeModel.TrunkTexture.TextureResource, RenderTexture.ShaderResourceView, Light.Direction, Light.AmbientColor, Light.DiffuseColour))
            {
                return(false);
            }

            // Enable blending and
            D3D.TurnOnAlphaBlending();

            // Render the tree leaves.
            TreeModel.RenderLeaves(D3D.DeviceContext);
            if (!ShadowShader.Render(D3D.DeviceContext, TreeModel.LeafIndexCount, worldMatrix, viewCameraMatrix, projectionMatrix, lightViewMatrix, lightOrthoMatrix, TreeModel.LeafTexture.TextureResource, RenderTexture.ShaderResourceView, Light.Direction, Light.AmbientColor, Light.DiffuseColour))
            {
                return(false);
            }

            // Turn off Alpha Blending.
            D3D.TurnOffAlphaBlending();

            // Reset the world matrix.
            worldMatrix = D3D.WorldMatrix;

            // Present the rendered scene to the screen.
            D3D.EndScene();

            return(true);
        }