| 185 | } |
| 186 | |
| 187 | bool ReflectionsPass::setupResources() |
| 188 | { |
| 189 | // Wait for the assets |
| 190 | if (!_sphereModel->CanBeRendered() || !_boxModel->CanBeRendered() || !_preIntegratedGF->IsLoaded() || !_shader->IsLoaded()) |
| 191 | return true; |
| 192 | const auto shader = _shader->GetShader(); |
| 193 | CHECK_INVALID_SHADER_PASS_CB_SIZE(shader, 0, Data); |
| 194 | |
| 195 | // Create pipeline stages |
| 196 | GPUPipelineState::Description psDesc; |
| 197 | if (!_psProbe->IsValid()) |
| 198 | { |
| 199 | psDesc = GPUPipelineState::Description::DefaultNoDepth; |
| 200 | psDesc.BlendMode = BlendingMode::AlphaBlend; |
| 201 | psDesc.VS = shader->GetVS("VS_Model"); |
| 202 | psDesc.PS = shader->GetPS("PS_EnvProbe"); |
| 203 | psDesc.CullMode = CullMode::Normal; |
| 204 | psDesc.DepthEnable = true; |
| 205 | psDesc.DepthBoundsEnable = _depthBounds; |
| 206 | if (_psProbe->Init(psDesc)) |
| 207 | return true; |
| 208 | psDesc.DepthFunc = ComparisonFunc::Always; |
| 209 | psDesc.CullMode = CullMode::Inverted; |
| 210 | if (_psProbeInside->Init(psDesc)) |
| 211 | return true; |
| 212 | } |
| 213 | psDesc = GPUPipelineState::Description::DefaultFullscreenTriangle; |
| 214 | if (!_psCombinePass->IsValid()) |
| 215 | { |
| 216 | psDesc.BlendMode = BlendingMode::Add; |
| 217 | psDesc.BlendMode.RenderTargetWriteMask = BlendingMode::ColorWrite::RGB; |
| 218 | if (_depthBounds) |
| 219 | { |
| 220 | psDesc.DepthEnable = psDesc.DepthBoundsEnable = true; |
| 221 | psDesc.DepthWriteEnable = false; |
| 222 | } |
| 223 | psDesc.PS = shader->GetPS("PS_CombinePass"); |
| 224 | if (_psCombinePass->Init(psDesc)) |
| 225 | return true; |
| 226 | } |
| 227 | |
| 228 | return false; |
| 229 | } |
| 230 | |
| 231 | void ReflectionsPass::Dispose() |
| 232 | { |