mirror of
https://github.com/Relintai/pandemonium_engine.git
synced 2024-12-22 11:56:49 +01:00
Adding back lightmaps pt2.
This commit is contained in:
parent
98cbf1026a
commit
62fdccce25
@ -498,6 +498,7 @@ public:
|
||||
void light_set_negative(RID p_light, bool p_enable) {}
|
||||
void light_set_cull_mask(RID p_light, uint32_t p_mask) {}
|
||||
void light_set_reverse_cull_face_mode(RID p_light, bool p_enabled) {}
|
||||
void light_set_bake_mode(RID p_light, RS::LightBakeMode p_bake_mode) {}
|
||||
|
||||
void light_omni_set_shadow_mode(RID p_light, RS::LightOmniShadowMode p_mode) {}
|
||||
void light_omni_set_shadow_detail(RID p_light, RS::LightOmniShadowDetail p_detail) {}
|
||||
@ -517,6 +518,7 @@ public:
|
||||
AABB light_get_aabb(RID p_light) const { return AABB(); }
|
||||
float light_get_param(RID p_light, RS::LightParam p_param) { return 0.0; }
|
||||
Color light_get_color(RID p_light) { return Color(); }
|
||||
RS::LightBakeMode light_get_bake_mode(RID p_light) { return RS::LightBakeMode::LIGHT_BAKE_DISABLED; }
|
||||
uint64_t light_get_version(RID p_light) const { return 0; }
|
||||
|
||||
/* PROBE API */
|
||||
|
@ -2350,8 +2350,8 @@ void RasterizerSceneGLES2::_render_render_list(RenderList::Element **p_elements,
|
||||
|
||||
if (!unshaded && e->light_index < RenderList::MAX_LIGHTS) {
|
||||
light = render_light_instances[e->light_index];
|
||||
if ((e->instance->layer_mask & light->light_ptr->cull_mask) == 0) {
|
||||
light = nullptr; // Don't use this light, it is culled
|
||||
if ((e->instance->baked_light && light->light_ptr->bake_mode == RS::LIGHT_BAKE_ALL) || (e->instance->layer_mask & light->light_ptr->cull_mask) == 0) {
|
||||
light = nullptr; // Don't use this light, it is culled or already included in the lightmap
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -4255,6 +4255,7 @@ RID RasterizerStorageGLES2::light_create(RS::LightType p_type) {
|
||||
light->directional_blend_splits = false;
|
||||
light->directional_range_mode = RS::LIGHT_DIRECTIONAL_SHADOW_DEPTH_RANGE_STABLE;
|
||||
light->reverse_cull = false;
|
||||
light->bake_mode = RS::LIGHT_BAKE_INDIRECT;
|
||||
light->version = 0;
|
||||
|
||||
return light_owner.make_rid(light);
|
||||
@ -4342,6 +4343,16 @@ void RasterizerStorageGLES2::light_set_reverse_cull_face_mode(RID p_light, bool
|
||||
light->instance_change_notify(true, false);
|
||||
}
|
||||
|
||||
void RasterizerStorageGLES2::light_set_bake_mode(RID p_light, RS::LightBakeMode p_bake_mode) {
|
||||
Light *light = light_owner.getornull(p_light);
|
||||
ERR_FAIL_COND(!light);
|
||||
|
||||
light->bake_mode = p_bake_mode;
|
||||
|
||||
light->version++;
|
||||
light->instance_change_notify(true, false);
|
||||
}
|
||||
|
||||
void RasterizerStorageGLES2::light_omni_set_shadow_mode(RID p_light, RS::LightOmniShadowMode p_mode) {
|
||||
Light *light = light_owner.getornull(p_light);
|
||||
ERR_FAIL_COND(!light);
|
||||
@ -4437,6 +4448,13 @@ Color RasterizerStorageGLES2::light_get_color(RID p_light) {
|
||||
return light->color;
|
||||
}
|
||||
|
||||
RS::LightBakeMode RasterizerStorageGLES2::light_get_bake_mode(RID p_light) {
|
||||
Light *light = light_owner.getornull(p_light);
|
||||
ERR_FAIL_COND_V(!light, RS::LightBakeMode::LIGHT_BAKE_DISABLED);
|
||||
|
||||
return light->bake_mode;
|
||||
}
|
||||
|
||||
bool RasterizerStorageGLES2::light_has_shadow(RID p_light) const {
|
||||
Light *light = light_owner.getornull(p_light);
|
||||
ERR_FAIL_COND_V(!light, false);
|
||||
|
@ -956,6 +956,7 @@ public:
|
||||
|
||||
uint32_t cull_mask;
|
||||
|
||||
RS::LightBakeMode bake_mode;
|
||||
RS::LightOmniShadowMode omni_shadow_mode;
|
||||
RS::LightOmniShadowDetail omni_shadow_detail;
|
||||
|
||||
@ -979,6 +980,7 @@ public:
|
||||
virtual void light_set_negative(RID p_light, bool p_enable);
|
||||
virtual void light_set_cull_mask(RID p_light, uint32_t p_mask);
|
||||
virtual void light_set_reverse_cull_face_mode(RID p_light, bool p_enabled);
|
||||
virtual void light_set_bake_mode(RID p_light, RS::LightBakeMode p_bake_mode);
|
||||
|
||||
virtual void light_omni_set_shadow_mode(RID p_light, RS::LightOmniShadowMode p_mode);
|
||||
virtual void light_omni_set_shadow_detail(RID p_light, RS::LightOmniShadowDetail p_detail);
|
||||
@ -998,6 +1000,7 @@ public:
|
||||
virtual RS::LightType light_get_type(RID p_light) const;
|
||||
virtual float light_get_param(RID p_light, RS::LightParam p_param);
|
||||
virtual Color light_get_color(RID p_light);
|
||||
virtual RS::LightBakeMode light_get_bake_mode(RID p_light);
|
||||
|
||||
virtual AABB light_get_aabb(RID p_light) const;
|
||||
virtual uint64_t light_get_version(RID p_light) const;
|
||||
|
@ -135,6 +135,16 @@ PoolVector<Face3> Light::get_faces(uint32_t p_usage_flags) const {
|
||||
return PoolVector<Face3>();
|
||||
}
|
||||
|
||||
void Light::set_bake_mode(BakeMode p_mode) {
|
||||
bake_mode = p_mode;
|
||||
RS::get_singleton()->light_set_bake_mode(light, RS::LightBakeMode(bake_mode));
|
||||
_change_notify();
|
||||
}
|
||||
|
||||
Light::BakeMode Light::get_bake_mode() const {
|
||||
return bake_mode;
|
||||
}
|
||||
|
||||
void Light::owner_changed_notify() {
|
||||
// For cases where owner changes _after_ entering tree (as example, editor editing).
|
||||
_update_visibility();
|
||||
@ -189,6 +199,10 @@ void Light::_validate_property(PropertyInfo &property) const {
|
||||
if (RenderingServer::get_singleton()->is_low_end() && property.name == "shadow_contact") {
|
||||
property.usage = PROPERTY_USAGE_NOEDITOR | PROPERTY_USAGE_INTERNAL;
|
||||
}
|
||||
|
||||
if (bake_mode != BAKE_ALL && property.name == "light_size") {
|
||||
property.usage = PROPERTY_USAGE_NOEDITOR | PROPERTY_USAGE_INTERNAL;
|
||||
}
|
||||
}
|
||||
|
||||
void Light::_bind_methods() {
|
||||
@ -216,6 +230,9 @@ void Light::_bind_methods() {
|
||||
ClassDB::bind_method(D_METHOD("set_shadow_color", "shadow_color"), &Light::set_shadow_color);
|
||||
ClassDB::bind_method(D_METHOD("get_shadow_color"), &Light::get_shadow_color);
|
||||
|
||||
ClassDB::bind_method(D_METHOD("set_bake_mode", "bake_mode"), &Light::set_bake_mode);
|
||||
ClassDB::bind_method(D_METHOD("get_bake_mode"), &Light::get_bake_mode);
|
||||
|
||||
ADD_GROUP("Light", "light_");
|
||||
ADD_PROPERTY(PropertyInfo(Variant::COLOR, "light_color", PROPERTY_HINT_COLOR_NO_ALPHA), "set_color", "get_color");
|
||||
ADD_PROPERTYI(PropertyInfo(Variant::REAL, "light_energy", PROPERTY_HINT_RANGE, "0,16,0.001,or_greater"), "set_param", "get_param", PARAM_ENERGY);
|
||||
@ -223,6 +240,7 @@ void Light::_bind_methods() {
|
||||
ADD_PROPERTYI(PropertyInfo(Variant::REAL, "light_size", PROPERTY_HINT_RANGE, "0,1,0.001,or_greater"), "set_param", "get_param", PARAM_SIZE);
|
||||
ADD_PROPERTY(PropertyInfo(Variant::BOOL, "light_negative"), "set_negative", "is_negative");
|
||||
ADD_PROPERTYI(PropertyInfo(Variant::REAL, "light_specular", PROPERTY_HINT_RANGE, "0,16,0.001,or_greater"), "set_param", "get_param", PARAM_SPECULAR);
|
||||
ADD_PROPERTY(PropertyInfo(Variant::INT, "light_bake_mode", PROPERTY_HINT_ENUM, "Disable,Indirect Only,All (Direct + Indirect)"), "set_bake_mode", "get_bake_mode");
|
||||
ADD_PROPERTY(PropertyInfo(Variant::INT, "light_cull_mask", PROPERTY_HINT_LAYERS_3D_RENDER), "set_cull_mask", "get_cull_mask");
|
||||
ADD_GROUP("Shadow", "shadow_");
|
||||
ADD_PROPERTY(PropertyInfo(Variant::BOOL, "shadow_enabled"), "set_shadow", "has_shadow");
|
||||
@ -251,6 +269,10 @@ void Light::_bind_methods() {
|
||||
BIND_ENUM_CONSTANT(PARAM_SHADOW_BIAS);
|
||||
BIND_ENUM_CONSTANT(PARAM_SHADOW_BIAS_SPLIT_SCALE);
|
||||
BIND_ENUM_CONSTANT(PARAM_MAX);
|
||||
|
||||
BIND_ENUM_CONSTANT(BAKE_DISABLED);
|
||||
BIND_ENUM_CONSTANT(BAKE_INDIRECT);
|
||||
BIND_ENUM_CONSTANT(BAKE_ALL);
|
||||
}
|
||||
|
||||
Light::Light(RenderingServer::LightType p_type) {
|
||||
@ -272,6 +294,7 @@ Light::Light(RenderingServer::LightType p_type) {
|
||||
RS::get_singleton()->instance_set_base(get_instance(), light);
|
||||
|
||||
reverse_cull = false;
|
||||
bake_mode = BAKE_INDIRECT;
|
||||
|
||||
editor_only = false;
|
||||
set_color(Color(1, 1, 1, 1));
|
||||
|
@ -60,6 +60,12 @@ public:
|
||||
PARAM_MAX = RS::LIGHT_PARAM_MAX
|
||||
};
|
||||
|
||||
enum BakeMode {
|
||||
BAKE_DISABLED,
|
||||
BAKE_INDIRECT,
|
||||
BAKE_ALL
|
||||
};
|
||||
|
||||
private:
|
||||
Color color;
|
||||
float param[PARAM_MAX];
|
||||
@ -71,6 +77,7 @@ private:
|
||||
RS::LightType type;
|
||||
bool editor_only;
|
||||
void _update_visibility();
|
||||
BakeMode bake_mode;
|
||||
|
||||
// bind helpers
|
||||
|
||||
@ -112,6 +119,9 @@ public:
|
||||
void set_shadow_reverse_cull_face(bool p_enable);
|
||||
bool get_shadow_reverse_cull_face() const;
|
||||
|
||||
void set_bake_mode(BakeMode p_mode);
|
||||
BakeMode get_bake_mode() const;
|
||||
|
||||
virtual AABB get_aabb() const;
|
||||
virtual PoolVector<Face3> get_faces(uint32_t p_usage_flags) const;
|
||||
|
||||
@ -120,6 +130,7 @@ public:
|
||||
};
|
||||
|
||||
VARIANT_ENUM_CAST(Light::Param);
|
||||
VARIANT_ENUM_CAST(Light::BakeMode);
|
||||
|
||||
class DirectionalLight : public Light {
|
||||
GDCLASS(DirectionalLight, Light);
|
||||
|
@ -261,7 +261,7 @@ void GeometryInstance::set_generate_lightmap(bool p_enabled) {
|
||||
generate_lightmap = p_enabled;
|
||||
}
|
||||
|
||||
bool GeometryInstance::get_generate_lightmap() {
|
||||
bool GeometryInstance::get_generate_lightmap() const {
|
||||
return generate_lightmap;
|
||||
}
|
||||
|
||||
|
@ -140,7 +140,7 @@ public:
|
||||
ShadowCastingSetting get_cast_shadows_setting() const;
|
||||
|
||||
void set_generate_lightmap(bool p_enabled);
|
||||
bool get_generate_lightmap();
|
||||
bool get_generate_lightmap() const;
|
||||
|
||||
void set_lightmap_scale(LightmapScale p_scale);
|
||||
LightmapScale get_lightmap_scale() const;
|
||||
|
@ -185,6 +185,9 @@ SceneStringNames::SceneStringNames() {
|
||||
_im_update = StaticCString::create("_im_update");
|
||||
_queue_update = StaticCString::create("_queue_update");
|
||||
|
||||
baked_light_changed = StaticCString::create("baked_light_changed");
|
||||
_baked_light_changed = StaticCString::create("_baked_light_changed");
|
||||
|
||||
_mouse_enter = StaticCString::create("_mouse_enter");
|
||||
_mouse_exit = StaticCString::create("_mouse_exit");
|
||||
|
||||
|
@ -194,6 +194,9 @@ public:
|
||||
StringName _im_update;
|
||||
StringName _queue_update;
|
||||
|
||||
StringName baked_light_changed;
|
||||
StringName _baked_light_changed;
|
||||
|
||||
StringName _mouse_enter;
|
||||
StringName _mouse_exit;
|
||||
|
||||
|
@ -239,7 +239,7 @@ bool MergingTool::is_mergeable_with(const MeshInstance &p_mi, const MeshInstance
|
||||
if (p_mi.get_material_override() != p_other.get_material_override()) {
|
||||
return false;
|
||||
}
|
||||
/*
|
||||
|
||||
if (p_mi.get_flag(GeometryInstance::FLAG_USE_BAKED_LIGHT) != p_other.get_flag(GeometryInstance::FLAG_USE_BAKED_LIGHT)) {
|
||||
return false;
|
||||
}
|
||||
@ -249,7 +249,7 @@ bool MergingTool::is_mergeable_with(const MeshInstance &p_mi, const MeshInstance
|
||||
if (p_mi.get_lightmap_scale() != p_other.get_lightmap_scale()) {
|
||||
return false;
|
||||
}
|
||||
*/
|
||||
|
||||
|
||||
if (p_check_surface_material_match) {
|
||||
Ref<Mesh> rmesh_a = p_mi.get_mesh();
|
||||
@ -1038,7 +1038,7 @@ void MergingTool::_copy_geometry_instance_settings(const GeometryInstance &p_sou
|
||||
r_dest.set_material_overlay(p_source.get_material_overlay());
|
||||
r_dest.set_material_override(p_source.get_material_override());
|
||||
r_dest.set_cast_shadows_setting(p_source.get_cast_shadows_setting());
|
||||
//r_dest.set_flag(GeometryInstance::FLAG_USE_BAKED_LIGHT, p_source.get_flag(GeometryInstance::FLAG_USE_BAKED_LIGHT));
|
||||
r_dest.set_flag(GeometryInstance::FLAG_USE_BAKED_LIGHT, p_source.get_flag(GeometryInstance::FLAG_USE_BAKED_LIGHT));
|
||||
|
||||
r_dest.set_portal_mode(p_source.get_portal_mode());
|
||||
r_dest.set_include_in_bound(p_source.get_include_in_bound());
|
||||
|
@ -339,6 +339,7 @@ public:
|
||||
virtual void mesh_clear(RID p_mesh) = 0;
|
||||
|
||||
/* MULTIMESH API */
|
||||
|
||||
struct MMInterpolator {
|
||||
RS::MultimeshTransformFormat _transform_format = RS::MULTIMESH_TRANSFORM_3D;
|
||||
RS::MultimeshColorFormat _color_format = RS::MULTIMESH_COLOR_NONE;
|
||||
@ -462,6 +463,7 @@ public:
|
||||
virtual void light_set_negative(RID p_light, bool p_enable) = 0;
|
||||
virtual void light_set_cull_mask(RID p_light, uint32_t p_mask) = 0;
|
||||
virtual void light_set_reverse_cull_face_mode(RID p_light, bool p_enabled) = 0;
|
||||
virtual void light_set_bake_mode(RID p_light, RS::LightBakeMode p_bake_mode) = 0;
|
||||
|
||||
virtual void light_omni_set_shadow_mode(RID p_light, RS::LightOmniShadowMode p_mode) = 0;
|
||||
virtual void light_omni_set_shadow_detail(RID p_light, RS::LightOmniShadowDetail p_detail) = 0;
|
||||
@ -481,6 +483,7 @@ public:
|
||||
virtual AABB light_get_aabb(RID p_light) const = 0;
|
||||
virtual float light_get_param(RID p_light, RS::LightParam p_param) = 0;
|
||||
virtual Color light_get_color(RID p_light) = 0;
|
||||
virtual RS::LightBakeMode light_get_bake_mode(RID p_light) = 0;
|
||||
virtual uint64_t light_get_version(RID p_light) const = 0;
|
||||
|
||||
/* PROBE API */
|
||||
@ -581,6 +584,7 @@ public:
|
||||
virtual void canvas_light_occluder_set_polylines(RID p_occluder, const PoolVector<Vector2> &p_lines) = 0;
|
||||
|
||||
/* INTERPOLATION */
|
||||
|
||||
struct InterpolationData {
|
||||
void notify_free_multimesh(RID p_rid);
|
||||
LocalVector<RID> multimesh_interpolate_update_list;
|
||||
|
@ -333,6 +333,7 @@ public:
|
||||
BIND2(light_set_negative, RID, bool)
|
||||
BIND2(light_set_cull_mask, RID, uint32_t)
|
||||
BIND2(light_set_reverse_cull_face_mode, RID, bool)
|
||||
BIND2(light_set_bake_mode, RID, LightBakeMode)
|
||||
|
||||
BIND2(light_omni_set_shadow_mode, RID, LightOmniShadowMode)
|
||||
BIND2(light_omni_set_shadow_detail, RID, LightOmniShadowDetail)
|
||||
|
@ -1727,6 +1727,10 @@ void RenderingServerScene::instance_geometry_set_flag(RID p_instance, RS::Instan
|
||||
ERR_FAIL_COND(!instance);
|
||||
|
||||
switch (p_flags) {
|
||||
case RS::INSTANCE_FLAG_USE_BAKED_LIGHT: {
|
||||
instance->baked_light = p_enabled;
|
||||
|
||||
} break;
|
||||
case RS::INSTANCE_FLAG_DRAW_NEXT_FRAME_IF_VISIBLE: {
|
||||
instance->redraw_if_visible = p_enabled;
|
||||
|
||||
|
@ -466,6 +466,7 @@ public:
|
||||
|
||||
List<PairInfo> geometries;
|
||||
|
||||
Instance *baked_light;
|
||||
int32_t previous_room_id_hint;
|
||||
|
||||
private:
|
||||
@ -519,6 +520,7 @@ public:
|
||||
|
||||
D = nullptr;
|
||||
last_version = 0;
|
||||
baked_light = nullptr;
|
||||
previous_room_id_hint = -1;
|
||||
}
|
||||
};
|
||||
|
@ -257,6 +257,7 @@ public:
|
||||
FUNC2(light_set_negative, RID, bool)
|
||||
FUNC2(light_set_cull_mask, RID, uint32_t)
|
||||
FUNC2(light_set_reverse_cull_face_mode, RID, bool)
|
||||
FUNC2(light_set_bake_mode, RID, LightBakeMode)
|
||||
|
||||
FUNC2(light_omni_set_shadow_mode, RID, LightOmniShadowMode)
|
||||
FUNC2(light_omni_set_shadow_detail, RID, LightOmniShadowDetail)
|
||||
|
@ -2001,6 +2001,7 @@ void RenderingServer::_bind_methods() {
|
||||
ClassDB::bind_method(D_METHOD("light_set_negative", "light", "enable"), &RenderingServer::light_set_negative);
|
||||
ClassDB::bind_method(D_METHOD("light_set_cull_mask", "light", "mask"), &RenderingServer::light_set_cull_mask);
|
||||
ClassDB::bind_method(D_METHOD("light_set_reverse_cull_face_mode", "light", "enabled"), &RenderingServer::light_set_reverse_cull_face_mode);
|
||||
ClassDB::bind_method(D_METHOD("light_set_bake_mode", "light", "bake_mode"), &RenderingServer::light_set_bake_mode);
|
||||
|
||||
ClassDB::bind_method(D_METHOD("light_omni_set_shadow_mode", "light", "mode"), &RenderingServer::light_omni_set_shadow_mode);
|
||||
ClassDB::bind_method(D_METHOD("light_omni_set_shadow_detail", "light", "detail"), &RenderingServer::light_omni_set_shadow_detail);
|
||||
@ -2357,6 +2358,10 @@ void RenderingServer::_bind_methods() {
|
||||
BIND_ENUM_CONSTANT(LIGHT_PARAM_SHADOW_BIAS_SPLIT_SCALE);
|
||||
BIND_ENUM_CONSTANT(LIGHT_PARAM_MAX);
|
||||
|
||||
BIND_ENUM_CONSTANT(LIGHT_BAKE_DISABLED);
|
||||
BIND_ENUM_CONSTANT(LIGHT_BAKE_INDIRECT);
|
||||
BIND_ENUM_CONSTANT(LIGHT_BAKE_ALL);
|
||||
|
||||
BIND_ENUM_CONSTANT(LIGHT_OMNI_SHADOW_DUAL_PARABOLOID);
|
||||
BIND_ENUM_CONSTANT(LIGHT_OMNI_SHADOW_CUBE);
|
||||
BIND_ENUM_CONSTANT(LIGHT_OMNI_SHADOW_DETAIL_VERTICAL);
|
||||
|
@ -468,6 +468,15 @@ public:
|
||||
virtual void light_set_cull_mask(RID p_light, uint32_t p_mask) = 0;
|
||||
virtual void light_set_reverse_cull_face_mode(RID p_light, bool p_enabled) = 0;
|
||||
|
||||
// bake mode
|
||||
enum LightBakeMode {
|
||||
LIGHT_BAKE_DISABLED,
|
||||
LIGHT_BAKE_INDIRECT,
|
||||
LIGHT_BAKE_ALL
|
||||
};
|
||||
|
||||
virtual void light_set_bake_mode(RID p_light, LightBakeMode p_bake_mode) = 0;
|
||||
|
||||
// omni light
|
||||
enum LightOmniShadowMode {
|
||||
LIGHT_OMNI_SHADOW_DUAL_PARABOLOID,
|
||||
@ -1178,6 +1187,7 @@ VARIANT_ENUM_CAST(RenderingServer::Features);
|
||||
VARIANT_ENUM_CAST(RenderingServer::MultimeshTransformFormat);
|
||||
VARIANT_ENUM_CAST(RenderingServer::MultimeshColorFormat);
|
||||
VARIANT_ENUM_CAST(RenderingServer::MultimeshCustomDataFormat);
|
||||
VARIANT_ENUM_CAST(RenderingServer::LightBakeMode);
|
||||
VARIANT_ENUM_CAST(RenderingServer::MultimeshPhysicsInterpolationQuality);
|
||||
VARIANT_ENUM_CAST(RenderingServer::LightOmniShadowMode);
|
||||
VARIANT_ENUM_CAST(RenderingServer::LightOmniShadowDetail);
|
||||
|
Loading…
Reference in New Issue
Block a user