diff options
Diffstat (limited to 'src/client/shadows/dynamicshadowsrender.cpp')
-rw-r--r-- | src/client/shadows/dynamicshadowsrender.cpp | 65 |
1 files changed, 28 insertions, 37 deletions
diff --git a/src/client/shadows/dynamicshadowsrender.cpp b/src/client/shadows/dynamicshadowsrender.cpp index e9b2053e3..ebdd1d2af 100644 --- a/src/client/shadows/dynamicshadowsrender.cpp +++ b/src/client/shadows/dynamicshadowsrender.cpp @@ -132,7 +132,7 @@ void ShadowRenderer::initialize() m_texture_format_color = m_shadow_map_texture_32bit ? video::ECOLOR_FORMAT::ECF_G32R32F : video::ECOLOR_FORMAT::ECF_G16R16F; - + m_shadows_enabled &= m_shadows_supported; } @@ -176,16 +176,15 @@ void ShadowRenderer::setShadowIntensity(float shadow_intensity) void ShadowRenderer::addNodeToShadowList( scene::ISceneNode *node, E_SHADOW_MODE shadowMode) { - if (!node) - return; m_shadow_node_array.emplace_back(node, shadowMode); + // node should never be ClientMap + assert(strcmp(node->getName(), "ClientMap") != 0); + node->setMaterialTexture(TEXTURE_LAYER_SHADOW, shadowMapTextureFinal); } void ShadowRenderer::removeNodeFromShadowList(scene::ISceneNode *node) { - if (!node) - return; node->setMaterialTexture(TEXTURE_LAYER_SHADOW, nullptr); for (auto it = m_shadow_node_array.begin(); it != m_shadow_node_array.end();) { if (it->node == node) { @@ -286,7 +285,7 @@ void ShadowRenderer::updateSMTextures() cb->PerspectiveBiasZ = getPerspectiveBiasZ(); cb->CameraPos = light.getFuturePlayerPos(); } - + // set the Render Target // right now we can only render in usual RTT, not // Depth texture is available in irrlicth maybe we @@ -349,7 +348,7 @@ void ShadowRenderer::update(video::ITexture *outputTarget) for (DirectionalLight &light : m_light_list) { // Static shader values for entities are set in updateSMTextures - // SM texture for entities is not updated incrementally and + // SM texture for entities is not updated incrementally and // must by updated using current player position. m_shadow_depth_entity_cb->CameraPos = light.getPlayerPos(); @@ -392,7 +391,7 @@ void ShadowRenderer::drawDebug() m_driver->draw2DImage(shadowMapClientMap, core::rect<s32>(0, 50 + 128, 128, 128 + 50 + 128), core::rect<s32>({0, 0}, shadowMapTextureFinal->getSize())); - + if (shadowMapTextureDynamicObjects) m_driver->draw2DImage(shadowMapTextureDynamicObjects, core::rect<s32>(0, 128 + 50 + 128, 128, @@ -429,39 +428,32 @@ void ShadowRenderer::renderShadowMap(video::ITexture *target, m_driver->setTransform(video::ETS_VIEW, light.getFutureViewMatrix()); m_driver->setTransform(video::ETS_PROJECTION, light.getFutureProjectionMatrix()); - // Operate on the client map - for (const auto &shadow_node : m_shadow_node_array) { - if (strcmp(shadow_node.node->getName(), "ClientMap") != 0) - continue; - - ClientMap *map_node = static_cast<ClientMap *>(shadow_node.node); + ClientMap &map_node = static_cast<ClientMap &>(m_client->getEnv().getMap()); - video::SMaterial material; - if (map_node->getMaterialCount() > 0) { - // we only want the first material, which is the one with the albedo info - material = map_node->getMaterial(0); - } + video::SMaterial material; + if (map_node.getMaterialCount() > 0) { + // we only want the first material, which is the one with the albedo info + material = map_node.getMaterial(0); + } - material.BackfaceCulling = false; - material.FrontfaceCulling = true; + material.BackfaceCulling = false; + material.FrontfaceCulling = true; - if (m_shadow_map_colored && pass != scene::ESNRP_SOLID) { - material.MaterialType = (video::E_MATERIAL_TYPE) depth_shader_trans; - } - else { - material.MaterialType = (video::E_MATERIAL_TYPE) depth_shader; - material.BlendOperation = video::EBO_MIN; - } + if (m_shadow_map_colored && pass != scene::ESNRP_SOLID) { + material.MaterialType = (video::E_MATERIAL_TYPE) depth_shader_trans; + } + else { + material.MaterialType = (video::E_MATERIAL_TYPE) depth_shader; + material.BlendOperation = video::EBO_MIN; + } - m_driver->setTransform(video::ETS_WORLD, - map_node->getAbsoluteTransformation()); + m_driver->setTransform(video::ETS_WORLD, + map_node.getAbsoluteTransformation()); - int frame = m_force_update_shadow_map ? 0 : m_current_frame; - int total_frames = m_force_update_shadow_map ? 1 : m_map_shadow_update_frames; + int frame = m_force_update_shadow_map ? 0 : m_current_frame; + int total_frames = m_force_update_shadow_map ? 1 : m_map_shadow_update_frames; - map_node->renderMapShadows(m_driver, material, pass, frame, total_frames); - break; - } + map_node.renderMapShadows(m_driver, material, pass, frame, total_frames); } void ShadowRenderer::renderShadowObjects( @@ -472,8 +464,7 @@ void ShadowRenderer::renderShadowObjects( for (const auto &shadow_node : m_shadow_node_array) { // we only take care of the shadow casters - if (shadow_node.shadowMode == ESM_RECEIVE || - strcmp(shadow_node.node->getName(), "ClientMap") == 0) + if (shadow_node.shadowMode == ESM_RECEIVE) continue; // render other objects |