///////////////////////////////////////////////////////////////////////////////////////////// // Commandbuffer helpers ///////////////////////////////////////////////////////////////////////////////////////////// /// <summary> /// Set a specific keyword for the pixelshader /// </summary> /// <param name="keyword"></param> /// <param name="enable"></param> private void SetKeyword(MaterialKeywords keyword, bool enable) { //For now disable check if da keyword is already set //to make sure the cmd is always correctly setuped //if(_shaderKeywords[(int)keyword].enabled != enable) { PipelineExtensions.SetKeyword(_shaderKeywords[(int)keyword].name, enable); _shaderKeywords[(int)keyword].enabled = enable; } }
/// <summary> /// This cleans up the final render step /// </summary> internal void AfterCompositeCleanup() { _bloomUpsampleBuffer.ClearTemporary(_commandBuffer, 0, _renderPipeline); DisableDebugKeywords(); DisableRenderKeywords(); if (_renderPipeline == RenderPipeline.Legacy) { PipelineExtensions.SetKeyword(_shaderKeywords[(int)MaterialKeywords.LegacyBlit].name, false); } }
///////////////////////////////////////////////////////////////////////////////////////////// // Commandbuffer helpers ///////////////////////////////////////////////////////////////////////////////////////////// /// <summary> /// Set a specific keyword for the pixelshader /// </summary> /// <param name="keyword"></param> /// <param name="enable"></param> private void SetKeyword(MaterialKeywords keyword, bool enable) { //For now disable check if a keyword is already set //to make sure the cmd is always correctly setuped //if(_shaderKeywords[(int)keyword].enabled != enable) { if (_renderPipeline == RenderPipeline.SRP) { _commandBuffer.SetKeyword(_shaderKeywords[(int)keyword].name, enable); } else { PipelineExtensions.SetKeyword(_shaderKeywords[(int)keyword].name, enable); } _shaderKeywords[(int)keyword].enabled = enable; } }
/// <summary> /// Precomposite of the glow map /// </summary> private void Composite() { BeginProfileSample(PipelineProperties.CommandBufferProperties.sampleComposite); int renderpass; switch (_settings.debugView) { case DebugView.RawBloom: _renderKeywordsBundle.Add(MaterialKeywords.DebugRawBloom); renderpass = (int)ShaderRenderPass.Debug; break; case DebugView.Bloom: _renderKeywordsBundle.Add(MaterialKeywords.DebugBloom); renderpass = (int)ShaderRenderPass.Debug; break; case DebugView.Composite: if (_useLensSurface) { _renderKeywordsBundle.Add(MaterialKeywords.LensSurface); } _renderKeywordsBundle.Add(MaterialKeywords.DebugComposite); renderpass = (int)ShaderRenderPass.Debug; break; default: if (_useLensSurface) { _renderKeywordsBundle.Add(MaterialKeywords.LensSurface); } renderpass = (int)ShaderRenderPass.Composite; break; } PrepareDraw ( renderpass, _sourceContext[0].renderDimension ); if (_settings.workflow == Workflow.Selective && (_settings.debugView == DebugView.RawBloom)) { SetTexture(PipelineProperties.ShaderProperties.sourceTex, sourceFrameBuffer.renderTexture, true); } else { SetTexture(PipelineProperties.ShaderProperties.sourceTex, sourceFrameBuffer, true); SetTexture(PipelineProperties.ShaderProperties.bloomTex, _bloomUpsampleBuffer.renderTargets[0], true); } if (_useLensSurface) { SetTexture(PipelineProperties.ShaderProperties.lensSurfaceDirtTex, _settings.lensSurfaceDirtTexture ? _settings.lensSurfaceDirtTexture : _resources.lensSurfaceDirtTextureDefault, true); SetTexture(PipelineProperties.ShaderProperties.lensSurfaceDiffractionTex, _settings.lensSurfaceDiffractionTexture ? _settings.lensSurfaceDiffractionTexture : _resources.lensSurfaceDiffractionTextureDefault, true); } //Dont draw when using legacy render pipeline if (_renderPipeline == RenderPipeline.SRP) { _renderTargetsBundle.Add(_destinationFrameBuffer); Draw(); AfterCompositeCleanup(); } else { PipelineExtensions.SetKeyword(_shaderKeywords[(int)MaterialKeywords.LegacyBlit].name, true); _renderTargetsBundle.Clear(); } EndProfileSample(PipelineProperties.CommandBufferProperties.sampleComposite); }