--------------------------------- DirectionalShadowData::Init Create the render target and texture
| 20 | // Create the render target and texture |
| 21 | // |
| 22 | void DirectionalShadowData::Init(ivec2 const resolution) |
| 23 | { |
| 24 | render::GraphicsSettings const& graphicsSettings = RenderingSystems::Instance()->GetGraphicsSettings(); |
| 25 | |
| 26 | I_GraphicsApiContext* const api = Viewport::GetCurrentApiContext(); |
| 27 | |
| 28 | //Calculate cascade distances |
| 29 | float distMult = graphicsSettings.CSMDrawDistance / powf(2.f, static_cast<float>(graphicsSettings.NumCascades - 1)); |
| 30 | |
| 31 | m_Cascades.clear(); |
| 32 | for (int32 cascadeIdx = 0; cascadeIdx < graphicsSettings.NumCascades; ++cascadeIdx) |
| 33 | { |
| 34 | CascadeData cascade; |
| 35 | |
| 36 | cascade.distance = static_cast<float>((cascadeIdx + 1) ^ 2) * distMult; |
| 37 | |
| 38 | // Create depth texture |
| 39 | cascade.texture = new TextureData(resolution, E_ColorFormat::Depth, E_ColorFormat::Depth, E_DataType::Float); |
| 40 | cascade.texture->Build(); |
| 41 | |
| 42 | TextureParameters params(false, true); |
| 43 | params.wrapS = E_TextureWrapMode::ClampToEdge; |
| 44 | params.wrapT = E_TextureWrapMode::ClampToEdge; |
| 45 | params.compareMode = E_TextureCompareMode::CompareRToTexture; |
| 46 | cascade.texture->SetParameters(params); |
| 47 | |
| 48 | // create render target |
| 49 | api->GenFramebuffers(1, &(cascade.fbo)); |
| 50 | api->BindFramebuffer(cascade.fbo); |
| 51 | api->LinkTextureToFboDepth(cascade.texture->GetLocation()); |
| 52 | //only depth components |
| 53 | api->SetDrawBufferCount(0); |
| 54 | api->SetReadBufferEnabled(false); |
| 55 | |
| 56 | api->BindFramebuffer(0); |
| 57 | |
| 58 | m_Cascades.push_back(cascade); |
| 59 | } |
| 60 | } |
| 61 | |
| 62 | //--------------------------------- |
| 63 | // DirectionalShadowData::Destroy |
nothing calls this directly
no test coverage detected