MCPcopy Create free account
hub / github.com/FlaxEngine/FlaxEngine / Draw

Method Draw

Source/Engine/Renderer/Editor/MaterialComplexity.cpp:120–185  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

118}
119
120void 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);

Callers 15

RenderMethod · 0.45
RenderMethod · 0.45
RenderDebugMethod · 0.45
RenderMethod · 0.45
DrawCascadeActorsMethod · 0.45
RenderDebugMethod · 0.45
RenderAntiAliasingPassFunction · 0.45
RenderLightBufferFunction · 0.45
DrawActorsMethod · 0.45
RenderInnerFunction · 0.45
DrawLinearToSrgbMethod · 0.45

Calls 15

EnumHasAnyFlagsFunction · 0.85
BindViewDataMethod · 0.80
ExecuteDrawCallsMethod · 0.80
GetOutputViewMethod · 0.80
GetOutputViewportMethod · 0.80
HasItemsMethod · 0.45
IsReadyMethod · 0.45
SetRenderTargetMethod · 0.45
CountMethod · 0.45
GetMethod · 0.45
BindMethod · 0.45

Tested by

no test coverage detected