Exemplo n.º 1
0
        private void SetupShadowShader(DrawState state)
        {
            ICamera shadowCamera = this.shadowMapTarget.Camera;

            //compute the view*projection matrix for the shadow map camera...

            Matrix view, projection, viewProjection;

            shadowCamera.GetViewMatrix(out view);
            shadowCamera.GetProjectionMatrix(out projection, this.shadowMapTarget.Size);

            Matrix.Multiply(ref view, ref projection, out viewProjection);

            //and the view direction
            Vector3 viewDirection;

            shadowCamera.GetCameraViewDirection(out viewDirection);


            //set the matrix and other constants in the shadow mapping shader instances
            Shader.ShadowShader      shader      = state.GetShader <Shader.ShadowShader>();
            Shader.ShadowShaderBlend shaderBlend = state.GetShader <Shader.ShadowShaderBlend>();

            //non-blending shader
            shader.ShadowMap = this.shadowMapTarget.GetTexture();
            shader.SetShadowMapProjection(ref viewProjection);
            shader.SetShadowViewDirection(ref viewDirection);

            //setup the same constants for the blending shader
            shaderBlend.ShadowMap = this.shadowMapTarget.GetTexture();
            shaderBlend.SetShadowMapProjection(ref viewProjection);
            shaderBlend.SetShadowViewDirection(ref viewDirection);
        }