public void Clear() { Macros.Clear(); Definitions.Clear(); Raws.Clear(); Inclusion = ImmutableStack <bool> .Nil; CurrentOffset = 0; pastOffsets.Clear(); }
/// <summary> /// Function called to initialize the effect. /// </summary> /// <remarks>Applications must implement this method to ensure that any required resources are created, and configured for the effect.</remarks> protected override void OnInitialize() { var globalData = new GlobalEffectData { CameraPosition = DX.Vector3.Zero, FlipYNormal = 0 }; _globalData = GorgonConstantBufferView.CreateConstantBuffer(Graphics, ref globalData, "Global deferred light effect data.", ResourceUsage.Default); _lightData = GorgonConstantBufferView.CreateConstantBuffer(Graphics, new GorgonConstantBufferInfo("Deferred Lighting Light Data Buffer") { SizeInBytes = Unsafe.SizeOf <PointLightData>(), Usage = ResourceUsage.Dynamic }); Macros.Add(new GorgonShaderMacro("DEFERRED_LIGHTING")); _vertexDeferShader = CompileShader <GorgonVertexShader>(Resources.Lighting, "GorgonVertexLightingShader"); _vertexDeferShaderState = VertexShaderBuilder.Shader(_vertexDeferShader) .Build(); _pixelDeferShader = CompileShader <GorgonPixelShader>(Resources.Lighting, "GorgonPixelShaderDeferred"); _pixelDeferShaderState = PixelShaderBuilder.Shader(_pixelDeferShader) .SamplerState(_diffuseFilter, 0) .SamplerState(_normalFilter, 1) .SamplerState(_specularFilter, 2) .Build(); Macros.Clear(); Macros.Add(new GorgonShaderMacro("LIGHTS")); _vertexLitShader = CompileShader <GorgonVertexShader>(Resources.Lighting, "GorgonVertexLitShader"); _vertexLitShaderState = VertexShaderBuilder.Shader(_vertexLitShader) .Build(); _pixelLitShader = CompileShader <GorgonPixelShader>(Resources.Lighting, "GorgonPixelShaderLighting"); _pixelLitShaderState = PixelShaderBuilder.Shader(_pixelLitShader) .ConstantBuffer(_lightData, 1) .ConstantBuffer(_globalData, 2) .SamplerState(_diffuseFilter, 0) .SamplerState(_normalFilter, 1) .SamplerState(_specularFilter, 2) .Build(); // Rebuild our states for the new pixel shaders. _lightingState = BatchStateBuilder.PixelShaderState(_pixelLitShaderState) .VertexShaderState(_vertexLitShaderState) .BlendState(GorgonBlendState.Additive) .Build(); }