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

Method DrawFog

Source/Engine/Level/Actors/ExponentialHeightFog.cpp:189–216  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

187 });
188
189void ExponentialHeightFog::DrawFog(GPUContext* context, RenderContext& renderContext, GPUTextureView* output)
190{
191 PROFILE_GPU_CPU("Exponential Height Fog");
192 auto volumetricFogTexture = renderContext.List->Fog.VolumetricFogTexture;
193 bool useVolumetricFog = volumetricFogTexture != nullptr;
194
195 // Setup shader inputs
196 Data data;
197 GBufferPass::SetInputs(renderContext.View, data.GBuffer);
198 data.ExponentialHeightFog = renderContext.List->Fog.ExponentialHeightFogData;
199 data.VolumetricFog = renderContext.List->Fog.VolumetricFogData;
200 data.TemporalAAJitter = renderContext.View.TemporalAAJitter;
201 auto cb = _shader->GetShader()->GetCB(0);
202 ASSERT_LOW_LAYER(cb->GetSize() == sizeof(Data));
203 context->UpdateCB(cb, &data);
204 context->BindCB(0, cb);
205 context->BindSR(0, renderContext.Buffers->DepthBuffer);
206 context->BindSR(1, volumetricFogTexture);
207
208 // TODO: instead of rendering fullscreen triangle, draw quad transformed at the fog start distance (also it could use early depth discard)
209 // TODO: or use DepthBounds to limit the fog rendering to the distance range
210
211 // Draw fog
212 const int32 psIndex = (useVolumetricFog ? 1 : 0);
213 context->SetState(_psFog.Get(psIndex));
214 context->SetRenderTarget(output);
215 context->DrawFullscreenTriangle();
216}
217
218void ExponentialHeightFog::OnEnable()
219{

Callers

nothing calls this directly

Calls 9

GetShaderMethod · 0.45
GetSizeMethod · 0.45
UpdateCBMethod · 0.45
BindCBMethod · 0.45
BindSRMethod · 0.45
SetStateMethod · 0.45
GetMethod · 0.45
SetRenderTargetMethod · 0.45

Tested by

no test coverage detected