| 62 | GPUConstantBuffer* IMaterial::BindParameters::PerDrawConstants = nullptr; |
| 63 | |
| 64 | void 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 | |
| 98 | void IMaterial::BindParameters::BindDrawData() |
| 99 | { |
no test coverage detected