MCPcopy Create free account
hub / github.com/BohemiaInteractive/CWR / UpdateShadowMapLitState

Method UpdateShadowMapLitState

engine/PoseidonGL33/EngineGL33_Shaders.cpp:1032–1072  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1030}
1031
1032void EngineGL33::UpdateShadowMapLitState()
1033{
1034 // PS UBO: shadowCtl c2 {enable, 0, darkness, texelSize}; cascadeVP[4] c8-c23;
1035 // cascadeSplits c24 (per-tier select distance: a camera 3D radius for the first
1036 // omniCount omni tiers, a far eye-depth for frustum tiers); cascadeCtl c25
1037 // {count, fadeRange, biasBase, omniCount}; camFwd c26. Disabled default keeps
1038 // count 0 / darkness 1.0 (no change), so the gate is doubly safe.
1039 float ctl[4] = {0.0f, 0.0f, 1.0f, 0.0f};
1040 float splits[4] = {0.0f, 0.0f, 0.0f, 0.0f};
1041 float cascadeCtl[4] = {0.0f, 0.0f, 0.0f, 0.0f};
1042 float camFwd[4] = {0.0f, 0.0f, 1.0f, 0.0f};
1043 if (_shadowTuning.enabled && _shadowMapActive && _shadowMapTex && _shadowCascades > 0)
1044 {
1045 ctl[0] = 1.0f; // enable the per-fragment shadow test
1046 // Lit-colour multiplier where shadowed, faded toward 1.0 (no shadow) as the
1047 // sun sets: full darkness in daylight, none at night. _shadowSunFactor is 1
1048 // by day, 0 at night (Scene drives it from the sun's NightEffect).
1049 ctl[2] = 1.0f - _shadowSunFactor * (1.0f - _shadowTuning.darkness);
1050 ctl[3] = (_shadowMapRes > 0) ? (1.0f / static_cast<float>(_shadowMapRes)) : 0.0f; // PCF texel size
1051 cascadeCtl[0] = static_cast<float>(_shadowCascades);
1052 cascadeCtl[1] = _shadowTuning.fadeRange;
1053 cascadeCtl[2] = _shadowTuning.biasBase;
1054 cascadeCtl[3] = static_cast<float>(_shadowOmniCount); // leading omni (distance-selected) tiers
1055 for (int i = 0; i < _shadowCascades && i < 4; i++)
1056 {
1057 splits[i] = _shadowSplits[i];
1058 }
1059 camFwd[0] = _shadowCamFwd[0];
1060 camFwd[1] = _shadowCamFwd[1];
1061 camFwd[2] = _shadowCamFwd[2];
1062 memcpy(s_psShadow + 8 * 4, _shadowMapVP, sizeof(float) * 16 * _shadowCascades);
1063 GL33Bind::ActiveUnit(2);
1064 glBindTexture(GL_TEXTURE_2D_ARRAY, _shadowMapTex);
1065 GL33Bind::ActiveUnit(0);
1066 }
1067 memcpy(s_psShadow + 2 * 4, ctl, 16);
1068 memcpy(s_psShadow + 24 * 4, splits, 16);
1069 memcpy(s_psShadow + 25 * 4, cascadeCtl, 16);
1070 memcpy(s_psShadow + 26 * 4, camFwd, 16);
1071 FlushPSConstants();
1072}
1073
1074void EngineGL33::UploadVSViewConstants(const FrameState& frame)
1075{

Callers

nothing calls this directly

Calls 1

ActiveUnitFunction · 0.85

Tested by

no test coverage detected