public ShadowMap(IColorBuffer sharedColorBuffer, int index) { _shadowMapResourceName = "ShadowMap" + index; CameraSliceFrustum = new ViewFrustum(); LightFrustum = new ViewFrustum(); RenderTarget = new RenderTarget(); RenderTarget.ColorBuffer.Add(sharedColorBuffer); RenderTarget.DepthStencilBuffer = new DepthStencilBuffer(sharedColorBuffer.Width, sharedColorBuffer.Height, 1, true); }
private void UpdateShadowMaps() { IColorBuffer colorBuffer = null; if ((_shadowCascades.Count > 0 && _shadowCascades[0].RenderTarget.DepthStencilBuffer.Width != this.ShadowMapSize) || _shadowCascades.Count == 0) { colorBuffer = new TextureColorBuffer(SharpDX.DXGI.Format.R8_UNorm, this.ShadowMapSize, this.ShadowMapSize, 1, false); _shadowCascades.Clear(); } else if (_shadowCascades.Count != this.NumShadowMaps) { colorBuffer = _shadowCascades[0].RenderTarget.ColorBuffer[0]; while (this.NumShadowMaps < _shadowCascades.Count) { _shadowCascades.RemoveAt(_shadowCascades.Count - 1); } } while (this.NumShadowMaps > _shadowCascades.Count) { _shadowCascades.Add(new ShadowMap(colorBuffer, _shadowCascades.Count)); } }