shadow: Add shadow-cube-map-filter setting, disabled by default

Enabling this will enable the `FT_shadow` filter for cube maps, which doesn't work with Cg shaders (incl. shader generator) but does with custom GLSL shaders

This will be enabled by default once the shaderpipeline branch is merged

Fixes #1332
This commit is contained in:
rdb 2022-08-31 11:37:49 +02:00
parent 3e220e4fb4
commit 899cbb9fff
3 changed files with 16 additions and 2 deletions

View File

@ -463,6 +463,12 @@ ConfigVariableInt shadow_depth_bits
PRC_DESC("The minimum number of depth buffer bits requested when rendering "
"shadow maps. Set this to 32 for more depth resolution in shadow "
"maps."));
ConfigVariableBool shadow_cube_map_filter
("shadow-cube-map-filter", false,
PRC_DESC("If true, Panda enables hardware depth map comparison mode for "
"point lights, if supported. If false, does not. Keep this set to "
"false if you want the shader generator to work correctly for point "
"light shadows."));
ConfigVariableColor background_color
("background-color", "0.41 0.41 0.41 0.0",

View File

@ -103,6 +103,7 @@ extern EXPCL_PANDA_DISPLAY ConfigVariableInt accum_bits;
extern EXPCL_PANDA_DISPLAY ConfigVariableInt multisamples;
extern EXPCL_PANDA_DISPLAY ConfigVariableInt back_buffers;
extern EXPCL_PANDA_DISPLAY ConfigVariableInt shadow_depth_bits;
extern EXPCL_PANDA_DISPLAY ConfigVariableBool shadow_cube_map_filter;
extern EXPCL_PANDA_DISPLAY ConfigVariableDouble pixel_zoom;

View File

@ -3580,9 +3580,16 @@ get_dummy_shadow_map(Texture::TextureType texture_type) const {
dummy_cube->setup_cube_map(1, Texture::T_unsigned_byte, Texture::F_depth_component);
dummy_cube->set_clear_color(1);
// Note: cube map shadow filtering doesn't seem to work in Cg.
// That is why it is currently disabled by default, but it can be
// overridden in Config.prc for apps that have custom GLSL shaders.
if (shadow_cube_map_filter && get_supports_shadow_filter()) {
dummy_cube->set_minfilter(SamplerState::FT_shadow);
dummy_cube->set_magfilter(SamplerState::FT_shadow);
} else {
dummy_cube->set_minfilter(SamplerState::FT_linear);
dummy_cube->set_magfilter(SamplerState::FT_linear);
}
}
return dummy_cube;
}
}