| 118 | } |
| 119 | |
| 120 | void MaterialComplexityMaterialShader::Draw(RenderContext& renderContext, GPUContext* context, GPUTextureView* lightBuffer) |
| 121 | { |
| 122 | // Draw decals into Light buffer to include them into complexity drawing |
| 123 | auto& decals = renderContext.List->Decals; |
| 124 | auto boxModel = Content::LoadAsyncInternal<Model>(TEXT("Engine/Models/SimpleBox")); |
| 125 | auto& decalsWrapper = _wrappers[4]; |
| 126 | if (decals.HasItems() && boxModel && boxModel->CanBeRendered() && decalsWrapper.IsReady()) |
| 127 | { |
| 128 | PROFILE_GPU_CPU_NAMED("Decals"); |
| 129 | DrawCall drawCall; |
| 130 | MaterialBase::BindParameters bindParams(context, renderContext, drawCall); |
| 131 | bindParams.BindViewData(); |
| 132 | context->SetRenderTarget(lightBuffer); |
| 133 | for (int32 i = 0; i < decals.Count(); i++) |
| 134 | { |
| 135 | const RenderDecalData& decal = decals.Get()[i]; |
| 136 | drawCall.World = decal.World; |
| 137 | drawCall.ObjectPosition = drawCall.World.GetTranslation(); |
| 138 | drawCall.Material = decal.Material; |
| 139 | decalsWrapper.Bind(bindParams); |
| 140 | boxModel->Render(context); |
| 141 | } |
| 142 | context->ResetSR(); |
| 143 | } |
| 144 | |
| 145 | // Draw transparency into Light buffer to include it into complexity drawing |
| 146 | GPUTexture* depthBuffer = renderContext.Buffers->DepthBuffer; |
| 147 | GPUTextureView* readOnlyDepthBuffer = depthBuffer->View(); |
| 148 | if (EnumHasAnyFlags(depthBuffer->Flags(), GPUTextureFlags::ReadOnlyDepthView)) |
| 149 | readOnlyDepthBuffer = depthBuffer->ViewReadOnlyDepth(); |
| 150 | context->SetRenderTarget(readOnlyDepthBuffer, lightBuffer); |
| 151 | auto& distortionList = renderContext.List->DrawCallsLists[(int32)DrawCallsListType::Distortion]; |
| 152 | if (!distortionList.IsEmpty()) |
| 153 | { |
| 154 | PROFILE_GPU_CPU_NAMED("Distortion"); |
| 155 | renderContext.View.Pass = DrawPass::Distortion; |
| 156 | renderContext.List->ExecuteDrawCalls(renderContext, distortionList); |
| 157 | } |
| 158 | auto& forwardList = renderContext.List->DrawCallsLists[(int32)DrawCallsListType::Forward]; |
| 159 | if (!forwardList.IsEmpty()) |
| 160 | { |
| 161 | PROFILE_GPU_CPU_NAMED("Forward"); |
| 162 | renderContext.View.Pass = DrawPass::Forward; |
| 163 | renderContext.List->ExecuteDrawCalls(renderContext, forwardList); |
| 164 | } |
| 165 | |
| 166 | // Draw accumulated complexity into colors gradient |
| 167 | context->ResetRenderTarget(); |
| 168 | context->SetRenderTarget(renderContext.Task->GetOutputView()); |
| 169 | context->SetViewportAndScissors(renderContext.Task->GetOutputViewport()); |
| 170 | if (_shader && _shader->IsLoaded()) |
| 171 | { |
| 172 | if (!_ps) |
| 173 | { |
| 174 | _ps = GPUDevice::Instance->CreatePipelineState(); |
| 175 | auto psDesc = GPUPipelineState::Description::DefaultFullscreenTriangle; |
| 176 | psDesc.PS = _shader->GetShader()->GetPS("PS"); |
| 177 | _ps->Init(psDesc); |
no test coverage detected