forked from blender/blender
me-main #1
@ -469,6 +469,11 @@ class RENDER_PT_eevee_next_shadows(RenderButtonsPanel, Panel):
|
|||||||
def poll(cls, context):
|
def poll(cls, context):
|
||||||
return (context.engine in cls.COMPAT_ENGINES)
|
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):
|
def draw(self, context):
|
||||||
layout = self.layout
|
layout = self.layout
|
||||||
layout.use_property_split = True
|
layout.use_property_split = True
|
||||||
|
@ -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")) {
|
if (!DNA_struct_elem_find(fd->filesdna, "SceneEEVEE", "int", "shadow_pool_size")) {
|
||||||
LISTBASE_FOREACH (Scene *, scene, &bmain->scenes) {
|
LISTBASE_FOREACH (Scene *, scene, &bmain->scenes) {
|
||||||
|
scene->eevee.flag |= SCE_EEVEE_SHADOW_ENABLED;
|
||||||
scene->eevee.shadow_pool_size = 512;
|
scene->eevee.shadow_pool_size = 512;
|
||||||
scene->r.simplify_shadows = 1.0f;
|
scene->r.simplify_shadows = 1.0f;
|
||||||
scene->r.simplify_shadows_render = 1.0f;
|
scene->r.simplify_shadows_render = 1.0f;
|
||||||
|
@ -632,8 +632,18 @@ ShadowModule::ShadowModule(Instance &inst) : inst_(inst)
|
|||||||
void ShadowModule::init()
|
void ShadowModule::init()
|
||||||
{
|
{
|
||||||
::Scene &scene = *inst_.scene;
|
::Scene &scene = *inst_.scene;
|
||||||
shadow_page_len_ = clamp_i(
|
bool enabled = (scene.eevee.flag & SCE_EEVEE_SHADOW_ENABLED) != 0;
|
||||||
scene.eevee.shadow_pool_size * 4, SHADOW_PAGE_PER_ROW, SHADOW_MAX_PAGE);
|
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;
|
float simplify_shadows = 1.0f;
|
||||||
if (scene.r.mode & R_SIMPLIFY) {
|
if (scene.r.mode & R_SIMPLIFY) {
|
||||||
simplify_shadows = inst_.is_viewport() ? scene.r.simplify_shadows :
|
simplify_shadows = inst_.is_viewport() ? scene.r.simplify_shadows :
|
||||||
@ -670,7 +680,7 @@ void ShadowModule::init()
|
|||||||
statistics_buf_.current().read();
|
statistics_buf_.current().read();
|
||||||
ShadowStatistics stats = statistics_buf_.current();
|
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;
|
std::stringstream ss;
|
||||||
ss << "Error: Shadow buffer full, may result in missing shadows and lower performance. ("
|
ss << "Error: Shadow buffer full, may result in missing shadows and lower performance. ("
|
||||||
<< stats.page_used_count << " / " << shadow_page_len_ << ")\n";
|
<< 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. */
|
/* Delete unused shadows first to release tilemaps that could be reused for new lights. */
|
||||||
for (Light &light : inst_.lights.light_map_.values()) {
|
for (Light &light : inst_.lights.light_map_.values()) {
|
||||||
if (!light.used) {
|
if (!light.used || !enabled_) {
|
||||||
light.shadow_discard_safe(*this);
|
light.shadow_discard_safe(*this);
|
||||||
}
|
}
|
||||||
else if (light.directional != nullptr) {
|
else if (light.directional != nullptr) {
|
||||||
|
@ -281,6 +281,8 @@ class ShadowModule {
|
|||||||
float lod_bias_ = 0.0f;
|
float lod_bias_ = 0.0f;
|
||||||
/** Maximum number of allocated pages. Maximum value is SHADOW_MAX_TILEMAP. */
|
/** Maximum number of allocated pages. Maximum value is SHADOW_MAX_TILEMAP. */
|
||||||
int shadow_page_len_ = SHADOW_MAX_TILEMAP;
|
int shadow_page_len_ = SHADOW_MAX_TILEMAP;
|
||||||
|
/** Global switch. */
|
||||||
|
bool enabled_ = true;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
ShadowModule(Instance &inst);
|
ShadowModule(Instance &inst);
|
||||||
|
@ -2706,6 +2706,7 @@ enum {
|
|||||||
SCE_EEVEE_OVERSCAN = (1 << 21),
|
SCE_EEVEE_OVERSCAN = (1 << 21),
|
||||||
SCE_EEVEE_DOF_HQ_SLIGHT_FOCUS = (1 << 22),
|
SCE_EEVEE_DOF_HQ_SLIGHT_FOCUS = (1 << 22),
|
||||||
SCE_EEVEE_DOF_JITTER = (1 << 23),
|
SCE_EEVEE_DOF_JITTER = (1 << 23),
|
||||||
|
SCE_EEVEE_SHADOW_ENABLED = (1 << 24),
|
||||||
};
|
};
|
||||||
|
|
||||||
/** #SceneEEVEE.shadow_method */
|
/** #SceneEEVEE.shadow_method */
|
||||||
|
@ -7757,6 +7757,12 @@ static void rna_def_scene_eevee(BlenderRNA *brna)
|
|||||||
RNA_def_property_update(prop, NC_SCENE | ND_RENDER_OPTIONS, NULL);
|
RNA_def_property_update(prop, NC_SCENE | ND_RENDER_OPTIONS, NULL);
|
||||||
|
|
||||||
/* Shadows */
|
/* 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);
|
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_enum_items(prop, eevee_shadow_size_items);
|
||||||
RNA_def_property_ui_text(
|
RNA_def_property_ui_text(
|
||||||
|
Loading…
Reference in New Issue
Block a user