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

Method BindViewData

Source/Engine/Graphics/Materials/MaterialShader.cpp:64–96  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

62GPUConstantBuffer* IMaterial::BindParameters::PerDrawConstants = nullptr;
63
64void IMaterial::BindParameters::BindViewData()
65{
66 // Lazy-init
67 if (!PerViewConstants)
68 {
69 PerViewConstants = GPUDevice::Instance->CreateConstantBuffer(sizeof(MaterialShaderDataPerView), TEXT("PerViewConstants"));
70 PerDrawConstants = GPUDevice::Instance->CreateConstantBuffer(sizeof(MaterialShaderDataPerDraw), TEXT("PerDrawConstants"));
71 }
72
73 // Setup data
74 const auto& view = RenderContext.View;
75 MaterialShaderDataPerView cb;
76 Matrix::Transpose(view.Frustum.GetMatrix(), cb.ViewProjectionMatrix);
77 Matrix::Transpose(view.View, cb.ViewMatrix);
78 Matrix::Transpose(view.PrevViewProjection, cb.PrevViewProjectionMatrix);
79 Matrix::Transpose(view.MainViewProjection, cb.MainViewProjectionMatrix);
80 cb.MainScreenSize = view.MainScreenSize;
81 cb.ViewPos = view.Position;
82 cb.ViewFar = view.Far;
83 cb.ViewDir = view.Direction;
84 cb.TimeParam = Time;
85 cb.ScaledTimeParam = ScaledTime;
86 cb.ViewInfo = view.ViewInfo;
87 cb.ScreenSize = view.ScreenSize;
88 cb.TemporalAAJitter = view.TemporalAAJitter;
89 cb.LargeWorldsChunkIndex = LargeWorlds::Enable ? (Float3)Int3(view.Origin / LargeWorlds::ChunkSize) : Float3::Zero;
90 cb.LargeWorldsChunkSize = LargeWorlds::ChunkSize;
91 cb.TestValue = Graphics::TestValue;
92
93 // Update constants
94 GPUContext->UpdateCB(PerViewConstants, &cb);
95 GPUContext->BindCB(1, PerViewConstants);
96}
97
98void IMaterial::BindParameters::BindDrawData()
99{

Callers 6

ExecuteDrawCallsMethod · 0.80
RenderMethod · 0.80
DrawDecalsMethod · 0.80
RenderMethod · 0.80
DrawMethod · 0.80
ApplySkyMethod · 0.80

Calls 6

Int3Class · 0.85
GetMatrixMethod · 0.80
TransposeFunction · 0.50
CreateConstantBufferMethod · 0.45
UpdateCBMethod · 0.45
BindCBMethod · 0.45

Tested by

no test coverage detected