me-main #1

Merged
Nate Rupsis merged 123 commits from me-main into main 2023-02-13 18:39:11 +01:00
6 changed files with 29 additions and 4 deletions
Showing only changes of commit 94d280fc3f - Show all commits

View File

@ -469,6 +469,11 @@ class RENDER_PT_eevee_next_shadows(RenderButtonsPanel, Panel):
def poll(cls, context):
return (context.engine in cls.COMPAT_ENGINES)
def draw_header(self, context):
scene = context.scene
props = scene.eevee
self.layout.prop(props, "use_shadows", text="")
def draw(self, context):
layout = self.layout
layout.use_property_split = True

View File

@ -3913,6 +3913,7 @@ void blo_do_versions_300(FileData *fd, Library * /*lib*/, Main *bmain)
{
if (!DNA_struct_elem_find(fd->filesdna, "SceneEEVEE", "int", "shadow_pool_size")) {
LISTBASE_FOREACH (Scene *, scene, &bmain->scenes) {
scene->eevee.flag |= SCE_EEVEE_SHADOW_ENABLED;
scene->eevee.shadow_pool_size = 512;
scene->r.simplify_shadows = 1.0f;
scene->r.simplify_shadows_render = 1.0f;

View File

@ -632,8 +632,18 @@ ShadowModule::ShadowModule(Instance &inst) : inst_(inst)
void ShadowModule::init()
{
::Scene &scene = *inst_.scene;
shadow_page_len_ = clamp_i(
scene.eevee.shadow_pool_size * 4, SHADOW_PAGE_PER_ROW, SHADOW_MAX_PAGE);
bool enabled = (scene.eevee.flag & SCE_EEVEE_SHADOW_ENABLED) != 0;
if (assign_if_different(enabled_, enabled)) {
inst_.sampling.reset();
/* Force light reset. */
for (Light &light : inst_.lights.light_map_.values()) {
light.initialized = false;
}
}
int pool_size = enabled_ ? scene.eevee.shadow_pool_size : 0;
shadow_page_len_ = clamp_i(pool_size * 4, SHADOW_PAGE_PER_ROW, SHADOW_MAX_PAGE);
float simplify_shadows = 1.0f;
if (scene.r.mode & R_SIMPLIFY) {
simplify_shadows = inst_.is_viewport() ? scene.r.simplify_shadows :
@ -670,7 +680,7 @@ void ShadowModule::init()
statistics_buf_.current().read();
ShadowStatistics stats = statistics_buf_.current();
if (stats.page_used_count > shadow_page_len_) {
if (stats.page_used_count > shadow_page_len_ && enabled_) {
std::stringstream ss;
ss << "Error: Shadow buffer full, may result in missing shadows and lower performance. ("
<< stats.page_used_count << " / " << shadow_page_len_ << ")\n";
@ -761,7 +771,7 @@ void ShadowModule::end_sync()
{
/* Delete unused shadows first to release tilemaps that could be reused for new lights. */
for (Light &light : inst_.lights.light_map_.values()) {
if (!light.used) {
if (!light.used || !enabled_) {
light.shadow_discard_safe(*this);
}
else if (light.directional != nullptr) {

View File

@ -281,6 +281,8 @@ class ShadowModule {
float lod_bias_ = 0.0f;
/** Maximum number of allocated pages. Maximum value is SHADOW_MAX_TILEMAP. */
int shadow_page_len_ = SHADOW_MAX_TILEMAP;
/** Global switch. */
bool enabled_ = true;
public:
ShadowModule(Instance &inst);

View File

@ -2706,6 +2706,7 @@ enum {
SCE_EEVEE_OVERSCAN = (1 << 21),
SCE_EEVEE_DOF_HQ_SLIGHT_FOCUS = (1 << 22),
SCE_EEVEE_DOF_JITTER = (1 << 23),
SCE_EEVEE_SHADOW_ENABLED = (1 << 24),
};
/** #SceneEEVEE.shadow_method */

View File

@ -7757,6 +7757,12 @@ static void rna_def_scene_eevee(BlenderRNA *brna)
RNA_def_property_update(prop, NC_SCENE | ND_RENDER_OPTIONS, NULL);
/* Shadows */
prop = RNA_def_property(srna, "use_shadows", PROP_BOOLEAN, PROP_NONE);
RNA_def_property_boolean_sdna(prop, NULL, "flag", SCE_EEVEE_SHADOW_ENABLED);
RNA_def_property_ui_text(prop, "Shadows", "Enable shadow casting from lights");
RNA_def_property_override_flag(prop, PROPOVERRIDE_OVERRIDABLE_LIBRARY);
RNA_def_property_update(prop, NC_SCENE | ND_RENDER_OPTIONS, NULL);
prop = RNA_def_property(srna, "shadow_cube_size", PROP_ENUM, PROP_NONE);
RNA_def_property_enum_items(prop, eevee_shadow_size_items);
RNA_def_property_ui_text(