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

Method Prepare

Source/Engine/Graphics/RenderView.cpp:12–63  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

10#include "RenderTools.h"
11
12void RenderView::Prepare(RenderContext& renderContext)
13{
14 ASSERT(renderContext.List && renderContext.Buffers);
15
16 const float width = static_cast<float>(renderContext.Buffers->GetWidth());
17 const float height = static_cast<float>(renderContext.Buffers->GetHeight());
18
19 // Check if use TAA (need to modify the projection matrix)
20 Float2 taaJitter;
21 NonJitteredProjection = Projection;
22 IsTaaResolved = false;
23 if (renderContext.List->Setup.UseTemporalAAJitter)
24 {
25 // Move to the next frame
26 const int MaxSampleCount = 8;
27 if (++TaaFrameIndex >= MaxSampleCount)
28 TaaFrameIndex = 0;
29
30 // Calculate jitter
31 const float jitterSpread = renderContext.List->Settings.AntiAliasing.TAA_JitterSpread;
32 const float jitterX = (RenderTools::TemporalHalton(TaaFrameIndex + 1, 2) - 0.5f) * jitterSpread;
33 const float jitterY = (RenderTools::TemporalHalton(TaaFrameIndex + 1, 3) - 0.5f) * jitterSpread;
34 taaJitter = Float2(jitterX * 2.0f / width, jitterY * 2.0f / height);
35
36 // Modify projection matrix
37 if (IsOrthographicProjection())
38 {
39 // TODO: jitter otho matrix in a proper way
40 }
41 else
42 {
43 Projection.Values[2][0] += taaJitter.X;
44 Projection.Values[2][1] += taaJitter.Y;
45 }
46
47 // Update matrices
48 Matrix::Invert(Projection, IP);
49 Frustum.SetMatrix(View, Projection);
50 Frustum.GetInvMatrix(IVP);
51 CullingFrustum = Frustum;
52 }
53 else
54 {
55 TaaFrameIndex = 0;
56 taaJitter = Float2::Zero;
57 }
58
59 renderContext.List->Init(renderContext);
60 renderContext.LodProxyView = nullptr;
61
62 PrepareCache(renderContext, width, height, taaJitter);
63}
64
65void RenderView::PrepareCache(const RenderContext& renderContext, float width, float height, const Float2& temporalAAJitter, const RenderView* mainView)
66{

Callers 4

DrawSceneDepthMethod · 0.45
RenderInnerFunction · 0.45
RenderMethod · 0.45
RenderMethod · 0.45

Calls 7

Float2Class · 0.85
IsOrthographicProjectionFunction · 0.85
GetWidthMethod · 0.80
InvertFunction · 0.50
GetHeightMethod · 0.45
SetMatrixMethod · 0.45
InitMethod · 0.45

Tested by

no test coverage detected