| 167 | } |
| 168 | |
| 169 | void Sky::ApplySky(GPUContext* context, RenderContext& renderContext, const Matrix& world) |
| 170 | { |
| 171 | // Get precomputed cache and bind it to the pipeline |
| 172 | AtmosphereCache cache; |
| 173 | if (!AtmospherePreCompute::GetCache(&cache)) |
| 174 | return; |
| 175 | context->BindSR(4, cache.Transmittance); |
| 176 | context->BindSR(5, cache.Irradiance); |
| 177 | context->BindSR(6, cache.Inscatter->ViewVolume()); |
| 178 | |
| 179 | // Setup constants data |
| 180 | Matrix m; |
| 181 | Data data; |
| 182 | Matrix::Multiply(world, renderContext.View.ViewProjection(), m); |
| 183 | Matrix::Transpose(m, data.WorldViewProjection); |
| 184 | Matrix::Transpose(renderContext.View.IVP, data.InvViewProjection); |
| 185 | GBufferPass::SetInputs(renderContext.View, data.GBuffer); |
| 186 | data.ViewOffset = renderContext.View.Origin + GetPosition(); |
| 187 | data.NoiseScale = renderContext.View.IsSingleFrame ? 0.01f : 0.03f; |
| 188 | InitConfig(data.Fog); |
| 189 | //data.Fog.AtmosphericFogSunPower *= SunLight ? SunLight->Brightness : 1.0f; |
| 190 | if (EnumHasNoneFlags(renderContext.View.Flags, ViewFlags::SpecularLight)) |
| 191 | { |
| 192 | // Hide sun disc if specular light is disabled |
| 193 | data.Fog.AtmosphericFogSunDiscScale = 0; |
| 194 | } |
| 195 | |
| 196 | // Bind pipeline |
| 197 | auto cb = _shader->GetShader()->GetCB(0); |
| 198 | context->UpdateCB(cb, &data); |
| 199 | context->BindCB(0, cb); |
| 200 | context->SetState(_psSky); |
| 201 | } |
| 202 | |
| 203 | void Sky::EndPlay() |
| 204 | { |
no test coverage detected