diff options
Diffstat (limited to 'scene')
-rw-r--r-- | scene/2d/collision_object_2d.cpp | 2 | ||||
-rw-r--r-- | scene/3d/collision_object.cpp | 2 | ||||
-rw-r--r-- | scene/main/scene_tree.cpp | 1 | ||||
-rw-r--r-- | scene/resources/material.cpp | 21 | ||||
-rw-r--r-- | scene/resources/material.h | 5 |
5 files changed, 29 insertions, 2 deletions
diff --git a/scene/2d/collision_object_2d.cpp b/scene/2d/collision_object_2d.cpp index ce56b85a9e..73e5dc6021 100644 --- a/scene/2d/collision_object_2d.cpp +++ b/scene/2d/collision_object_2d.cpp @@ -82,7 +82,7 @@ uint32_t CollisionObject2D::create_shape_owner(Object *p_owner) { uint32_t id; if (shapes.size() == 0) { - id = 1; + id = 0; } else { id = shapes.back()->key() + 1; } diff --git a/scene/3d/collision_object.cpp b/scene/3d/collision_object.cpp index 1c0633fba7..7b4770e435 100644 --- a/scene/3d/collision_object.cpp +++ b/scene/3d/collision_object.cpp @@ -161,7 +161,7 @@ uint32_t CollisionObject::create_shape_owner(Object *p_owner) { uint32_t id; if (shapes.size() == 0) { - id = 1; + id = 0; } else { id = shapes.back()->key() + 1; } diff --git a/scene/main/scene_tree.cpp b/scene/main/scene_tree.cpp index 4f62d88934..b020238cac 100644 --- a/scene/main/scene_tree.cpp +++ b/scene/main/scene_tree.cpp @@ -2216,6 +2216,7 @@ void SceneTree::_bind_methods() { BIND_ENUM_CONSTANT(STRETCH_ASPECT_KEEP); BIND_ENUM_CONSTANT(STRETCH_ASPECT_KEEP_WIDTH); BIND_ENUM_CONSTANT(STRETCH_ASPECT_KEEP_HEIGHT); + BIND_ENUM_CONSTANT(STRETCH_ASPECT_EXPAND); } SceneTree *SceneTree::singleton = NULL; diff --git a/scene/resources/material.cpp b/scene/resources/material.cpp index c6b434af44..da0f522ff3 100644 --- a/scene/resources/material.cpp +++ b/scene/resources/material.cpp @@ -268,6 +268,8 @@ void SpatialMaterial::init_shaders() { shader_names->grow = "grow"; + shader_names->ao_light_affect = "ao_light_affect"; + shader_names->proximity_fade_distance = "proximity_fade_distance"; shader_names->distance_fade_min = "distance_fade_min"; shader_names->distance_fade_max = "distance_fade_max"; @@ -462,6 +464,7 @@ void SpatialMaterial::_update_shader() { if (features[FEATURE_AMBIENT_OCCLUSION]) { code += "uniform sampler2D texture_ambient_occlusion : hint_white;\n"; code += "uniform vec4 ao_texture_channel;\n"; + code += "uniform float ao_light_affect;\n"; } if (features[FEATURE_DETAIL]) { @@ -796,6 +799,8 @@ void SpatialMaterial::_update_shader() { code += "\tAO = dot(texture(texture_ambient_occlusion,base_uv),ao_texture_channel);\n"; } } + + code += "\tAO_LIGHT_AFFECT = ao_light_affect;\n"; } if (features[FEATURE_SUBSURACE_SCATTERING]) { @@ -1012,6 +1017,16 @@ float SpatialMaterial::get_rim_tint() const { return rim_tint; } +void SpatialMaterial::set_ao_light_affect(float p_ao_light_affect) { + + ao_light_affect = p_ao_light_affect; + VS::get_singleton()->material_set_param(_get_material(), shader_names->ao_light_affect, p_ao_light_affect); +} +float SpatialMaterial::get_ao_light_affect() const { + + return ao_light_affect; +} + void SpatialMaterial::set_clearcoat(float p_clearcoat) { clearcoat = p_clearcoat; @@ -1745,6 +1760,9 @@ void SpatialMaterial::_bind_methods() { ClassDB::bind_method(D_METHOD("set_grow", "amount"), &SpatialMaterial::set_grow); ClassDB::bind_method(D_METHOD("get_grow"), &SpatialMaterial::get_grow); + ClassDB::bind_method(D_METHOD("set_ao_light_affect", "amount"), &SpatialMaterial::set_ao_light_affect); + ClassDB::bind_method(D_METHOD("get_ao_light_affect"), &SpatialMaterial::get_ao_light_affect); + ClassDB::bind_method(D_METHOD("set_alpha_scissor_threshold", "threshold"), &SpatialMaterial::set_alpha_scissor_threshold); ClassDB::bind_method(D_METHOD("get_alpha_scissor_threshold"), &SpatialMaterial::get_alpha_scissor_threshold); @@ -1853,6 +1871,7 @@ void SpatialMaterial::_bind_methods() { ADD_GROUP("Ambient Occlusion", "ao_"); ADD_PROPERTYI(PropertyInfo(Variant::BOOL, "ao_enabled"), "set_feature", "get_feature", FEATURE_AMBIENT_OCCLUSION); + ADD_PROPERTY(PropertyInfo(Variant::REAL, "ao_light_affect", PROPERTY_HINT_RANGE, "0,1,0.01"), "set_ao_light_affect", "get_ao_light_affect"); ADD_PROPERTYI(PropertyInfo(Variant::OBJECT, "ao_texture", PROPERTY_HINT_RESOURCE_TYPE, "Texture"), "set_texture", "get_texture", TEXTURE_AMBIENT_OCCLUSION); ADD_PROPERTYI(PropertyInfo(Variant::BOOL, "ao_on_uv2"), "set_flag", "get_flag", FLAG_AO_ON_UV2); ADD_PROPERTY(PropertyInfo(Variant::INT, "ao_texture_channel", PROPERTY_HINT_ENUM, "Red,Green,Blue,Alpha,Gray"), "set_ao_texture_channel", "get_ao_texture_channel"); @@ -2036,6 +2055,8 @@ SpatialMaterial::SpatialMaterial() set_distance_fade_min_distance(0); set_distance_fade_max_distance(10); + set_ao_light_affect(0.0); + set_metallic_texture_channel(TEXTURE_CHANNEL_RED); set_roughness_texture_channel(TEXTURE_CHANNEL_RED); set_ao_texture_channel(TEXTURE_CHANNEL_RED); diff --git a/scene/resources/material.h b/scene/resources/material.h index 721514f586..cf190f0921 100644 --- a/scene/resources/material.h +++ b/scene/resources/material.h @@ -315,6 +315,7 @@ private: StringName proximity_fade_distance; StringName distance_fade_min; StringName distance_fade_max; + StringName ao_light_affect; StringName metallic_texture_channel; StringName roughness_texture_channel; @@ -358,6 +359,7 @@ private: float point_size; float alpha_scissor_threshold; bool grow_enabled; + float ao_light_affect; float grow; int particles_anim_h_frames; int particles_anim_v_frames; @@ -443,6 +445,9 @@ public: void set_rim_tint(float p_rim_tint); float get_rim_tint() const; + void set_ao_light_affect(float p_ao_light_affect); + float get_ao_light_affect() const; + void set_clearcoat(float p_clearcoat); float get_clearcoat() const; |