MCPcopy Create free account
hub / github.com/Illation/ETEngine / Init

Method Init

Engine/source/EtRendering/GraphicsTypes/DirectionalShadowData.cpp:22–60  ·  view source on GitHub ↗

--------------------------------- DirectionalShadowData::Init Create the render target and texture

Source from the content-addressed store, hash-verified

20// Create the render target and texture
21//
22void 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

Callers

nothing calls this directly

Calls 8

BuildMethod · 0.80
SetParametersMethod · 0.80
GenFramebuffersMethod · 0.80
BindFramebufferMethod · 0.80
LinkTextureToFboDepthMethod · 0.80
SetDrawBufferCountMethod · 0.80
SetReadBufferEnabledMethod · 0.80
GetLocationMethod · 0.45

Tested by

no test coverage detected