diff options
Diffstat (limited to 'scene/resources')
-rw-r--r-- | scene/resources/particles_material.cpp | 25 | ||||
-rw-r--r-- | scene/resources/particles_material.h | 34 | ||||
-rw-r--r-- | scene/resources/style_box.cpp | 4 | ||||
-rw-r--r-- | scene/resources/style_box.h | 4 | ||||
-rw-r--r-- | scene/resources/visual_shader.cpp | 78 | ||||
-rw-r--r-- | scene/resources/visual_shader_nodes.cpp | 5 |
6 files changed, 114 insertions, 36 deletions
diff --git a/scene/resources/particles_material.cpp b/scene/resources/particles_material.cpp index 9c8b3875ad..91569e65d6 100644 --- a/scene/resources/particles_material.cpp +++ b/scene/resources/particles_material.cpp @@ -996,7 +996,7 @@ void ParticlesMaterial::set_emission_shape(EmissionShape p_shape) { _queue_shader_change(); } -void ParticlesMaterial::set_emission_sphere_radius(float p_radius) { +void ParticlesMaterial::set_emission_sphere_radius(real_t p_radius) { emission_sphere_radius = p_radius; RenderingServer::get_singleton()->material_set_param(_get_material(), shader_names->emission_sphere_radius, p_radius); } @@ -1035,17 +1035,17 @@ void ParticlesMaterial::set_emission_ring_axis(Vector3 p_axis) { RenderingServer::get_singleton()->material_set_param(_get_material(), shader_names->emission_ring_axis, p_axis); } -void ParticlesMaterial::set_emission_ring_height(float p_height) { +void ParticlesMaterial::set_emission_ring_height(real_t p_height) { emission_ring_height = p_height; RenderingServer::get_singleton()->material_set_param(_get_material(), shader_names->emission_ring_height, p_height); } -void ParticlesMaterial::set_emission_ring_radius(float p_radius) { +void ParticlesMaterial::set_emission_ring_radius(real_t p_radius) { emission_ring_radius = p_radius; RenderingServer::get_singleton()->material_set_param(_get_material(), shader_names->emission_ring_radius, p_radius); } -void ParticlesMaterial::set_emission_ring_inner_radius(float p_radius) { +void ParticlesMaterial::set_emission_ring_inner_radius(real_t p_radius) { emission_ring_inner_radius = p_radius; RenderingServer::get_singleton()->material_set_param(_get_material(), shader_names->emission_ring_inner_radius, p_radius); } @@ -1054,7 +1054,7 @@ ParticlesMaterial::EmissionShape ParticlesMaterial::get_emission_shape() const { return emission_shape; } -float ParticlesMaterial::get_emission_sphere_radius() const { +real_t ParticlesMaterial::get_emission_sphere_radius() const { return emission_sphere_radius; } @@ -1082,15 +1082,15 @@ Vector3 ParticlesMaterial::get_emission_ring_axis() const { return emission_ring_axis; } -float ParticlesMaterial::get_emission_ring_height() const { +real_t ParticlesMaterial::get_emission_ring_height() const { return emission_ring_height; } -float ParticlesMaterial::get_emission_ring_radius() const { +real_t ParticlesMaterial::get_emission_ring_radius() const { return emission_ring_radius; } -float ParticlesMaterial::get_emission_ring_inner_radius() const { +real_t ParticlesMaterial::get_emission_ring_inner_radius() const { return emission_ring_inner_radius; } @@ -1107,12 +1107,12 @@ Vector3 ParticlesMaterial::get_gravity() const { return gravity; } -void ParticlesMaterial::set_lifetime_randomness(float p_lifetime) { +void ParticlesMaterial::set_lifetime_randomness(double p_lifetime) { lifetime_randomness = p_lifetime; RenderingServer::get_singleton()->material_set_param(_get_material(), shader_names->lifetime_randomness, lifetime_randomness); } -float ParticlesMaterial::get_lifetime_randomness() const { +double ParticlesMaterial::get_lifetime_randomness() const { return lifetime_randomness; } @@ -1169,11 +1169,12 @@ ParticlesMaterial::SubEmitterMode ParticlesMaterial::get_sub_emitter_mode() cons return sub_emitter_mode; } -void ParticlesMaterial::set_sub_emitter_frequency(float p_frequency) { +void ParticlesMaterial::set_sub_emitter_frequency(double p_frequency) { sub_emitter_frequency = p_frequency; RenderingServer::get_singleton()->material_set_param(_get_material(), shader_names->sub_emitter_frequency, 1.0 / p_frequency); //pass delta instead of frequency, since its easier to compute } -float ParticlesMaterial::get_sub_emitter_frequency() const { + +double ParticlesMaterial::get_sub_emitter_frequency() const { return sub_emitter_frequency; } diff --git a/scene/resources/particles_material.h b/scene/resources/particles_material.h index 8b0b26a3d1..ac7a500f73 100644 --- a/scene/resources/particles_material.h +++ b/scene/resources/particles_material.h @@ -241,19 +241,19 @@ private: Ref<Texture2D> emission_normal_texture; Ref<Texture2D> emission_color_texture; Vector3 emission_ring_axis; - float emission_ring_height; - float emission_ring_radius; - float emission_ring_inner_radius; + real_t emission_ring_height; + real_t emission_ring_radius; + real_t emission_ring_inner_radius; int emission_point_count = 1; bool anim_loop; Vector3 gravity; - float lifetime_randomness; + double lifetime_randomness; SubEmitterMode sub_emitter_mode; - float sub_emitter_frequency; + double sub_emitter_frequency; int sub_emitter_amount_at_end; bool sub_emitter_keep_velocity; //do not save emission points here @@ -297,34 +297,34 @@ public: bool get_particle_flag(ParticleFlags p_particle_flag) const; void set_emission_shape(EmissionShape p_shape); - void set_emission_sphere_radius(float p_radius); + void set_emission_sphere_radius(real_t p_radius); void set_emission_box_extents(Vector3 p_extents); void set_emission_point_texture(const Ref<Texture2D> &p_points); void set_emission_normal_texture(const Ref<Texture2D> &p_normals); void set_emission_color_texture(const Ref<Texture2D> &p_colors); void set_emission_ring_axis(Vector3 p_axis); - void set_emission_ring_height(float p_height); - void set_emission_ring_radius(float p_radius); - void set_emission_ring_inner_radius(float p_radius); + void set_emission_ring_height(real_t p_height); + void set_emission_ring_radius(real_t p_radius); + void set_emission_ring_inner_radius(real_t p_radius); void set_emission_point_count(int p_count); EmissionShape get_emission_shape() const; - float get_emission_sphere_radius() const; + real_t get_emission_sphere_radius() const; Vector3 get_emission_box_extents() const; Ref<Texture2D> get_emission_point_texture() const; Ref<Texture2D> get_emission_normal_texture() const; Ref<Texture2D> get_emission_color_texture() const; Vector3 get_emission_ring_axis() const; - float get_emission_ring_height() const; - float get_emission_ring_radius() const; - float get_emission_ring_inner_radius() const; + real_t get_emission_ring_height() const; + real_t get_emission_ring_radius() const; + real_t get_emission_ring_inner_radius() const; int get_emission_point_count() const; void set_gravity(const Vector3 &p_gravity); Vector3 get_gravity() const; - void set_lifetime_randomness(float p_lifetime); - float get_lifetime_randomness() const; + void set_lifetime_randomness(double p_lifetime); + double get_lifetime_randomness() const; void set_attractor_interaction_enabled(bool p_enable); bool is_attractor_interaction_enabled() const; @@ -348,8 +348,8 @@ public: void set_sub_emitter_mode(SubEmitterMode p_sub_emitter_mode); SubEmitterMode get_sub_emitter_mode() const; - void set_sub_emitter_frequency(float p_frequency); - float get_sub_emitter_frequency() const; + void set_sub_emitter_frequency(double p_frequency); + double get_sub_emitter_frequency() const; void set_sub_emitter_amount_at_end(int p_amount); int get_sub_emitter_amount_at_end() const; diff --git a/scene/resources/style_box.cpp b/scene/resources/style_box.cpp index 7d5868e3a6..3381043d29 100644 --- a/scene/resources/style_box.cpp +++ b/scene/resources/style_box.cpp @@ -461,12 +461,12 @@ bool StyleBoxFlat::is_anti_aliased() const { return anti_aliased; } -void StyleBoxFlat::set_aa_size(const real_t &p_aa_size) { +void StyleBoxFlat::set_aa_size(const real_t p_aa_size) { aa_size = CLAMP(p_aa_size, 0.01, 10); emit_changed(); } -float StyleBoxFlat::get_aa_size() const { +real_t StyleBoxFlat::get_aa_size() const { return aa_size; } diff --git a/scene/resources/style_box.h b/scene/resources/style_box.h index 124521b915..a6cd5b7fb7 100644 --- a/scene/resources/style_box.h +++ b/scene/resources/style_box.h @@ -205,8 +205,8 @@ public: void set_anti_aliased(const bool &p_anti_aliased); bool is_anti_aliased() const; - void set_aa_size(const float &p_aa_size); - float get_aa_size() const; + void set_aa_size(const real_t p_aa_size); + real_t get_aa_size() const; virtual Size2 get_center_size() const override; diff --git a/scene/resources/visual_shader.cpp b/scene/resources/visual_shader.cpp index a6815da6f4..75dd7448e7 100644 --- a/scene/resources/visual_shader.cpp +++ b/scene/resources/visual_shader.cpp @@ -3081,10 +3081,84 @@ String VisualShaderNodeUniform::get_warning(Shader::Mode p_mode, VisualShader::T List<String> keyword_list; ShaderLanguage::get_keyword_list(&keyword_list); if (keyword_list.find(uniform_name)) { - return TTR("Uniform name cannot be equal to a shader keyword. Choose another name."); + return TTR("Shader keywords cannot be used as uniform names.\nChoose another name."); } if (!is_qualifier_supported(qualifier)) { - return "This uniform type does not support that qualifier."; + String qualifier_str; + switch (qualifier) { + case QUAL_NONE: + break; + case QUAL_GLOBAL: + qualifier_str = "global"; + break; + case QUAL_INSTANCE: + qualifier_str = "instance"; + break; + } + return vformat(TTR("This uniform type does not support the '%s' qualifier."), qualifier_str); + } else if (qualifier == Qualifier::QUAL_GLOBAL) { + RS::GlobalVariableType gvt = RS::get_singleton()->global_variable_get_type(uniform_name); + if (gvt == RS::GLOBAL_VAR_TYPE_MAX) { + return vformat(TTR("Global uniform '%s' does not exist.\nCreate it in the Project Settings."), uniform_name); + } + bool incompatible_type = false; + switch (gvt) { + case RS::GLOBAL_VAR_TYPE_FLOAT: { + if (!Object::cast_to<VisualShaderNodeFloatUniform>(this)) { + incompatible_type = true; + } + } break; + case RS::GLOBAL_VAR_TYPE_INT: { + if (!Object::cast_to<VisualShaderNodeIntUniform>(this)) { + incompatible_type = true; + } + } break; + case RS::GLOBAL_VAR_TYPE_BOOL: { + if (!Object::cast_to<VisualShaderNodeBooleanUniform>(this)) { + incompatible_type = true; + } + } break; + case RS::GLOBAL_VAR_TYPE_COLOR: { + if (!Object::cast_to<VisualShaderNodeColorUniform>(this)) { + incompatible_type = true; + } + } break; + case RS::GLOBAL_VAR_TYPE_VEC3: { + if (!Object::cast_to<VisualShaderNodeVec3Uniform>(this)) { + incompatible_type = true; + } + } break; + case RS::GLOBAL_VAR_TYPE_TRANSFORM: { + if (!Object::cast_to<VisualShaderNodeTransformUniform>(this)) { + incompatible_type = true; + } + } break; + case RS::GLOBAL_VAR_TYPE_SAMPLER2D: { + if (!Object::cast_to<VisualShaderNodeTextureUniform>(this)) { + incompatible_type = true; + } + } break; + case RS::GLOBAL_VAR_TYPE_SAMPLER3D: { + if (!Object::cast_to<VisualShaderNodeTexture3DUniform>(this)) { + incompatible_type = true; + } + } break; + case RS::GLOBAL_VAR_TYPE_SAMPLER2DARRAY: { + if (!Object::cast_to<VisualShaderNodeTexture2DArrayUniform>(this)) { + incompatible_type = true; + } + } break; + case RS::GLOBAL_VAR_TYPE_SAMPLERCUBE: { + if (!Object::cast_to<VisualShaderNodeCubemapUniform>(this)) { + incompatible_type = true; + } + } break; + default: + break; + } + if (incompatible_type) { + return vformat(TTR("Global uniform '%s' has an incompatible type for this kind of node.\nChange it in the Project Settings."), uniform_name); + } } return String(); diff --git a/scene/resources/visual_shader_nodes.cpp b/scene/resources/visual_shader_nodes.cpp index 6fd6fd8f3b..afe0bdfd5c 100644 --- a/scene/resources/visual_shader_nodes.cpp +++ b/scene/resources/visual_shader_nodes.cpp @@ -4575,7 +4575,10 @@ bool VisualShaderNodeTransformUniform::is_use_prop_slots() const { } bool VisualShaderNodeTransformUniform::is_qualifier_supported(Qualifier p_qual) const { - return true; // all qualifiers are supported + if (p_qual == Qualifier::QUAL_INSTANCE) { + return false; + } + return true; } bool VisualShaderNodeTransformUniform::is_convertible_to_constant() const { |