diff options
69 files changed, 854 insertions, 376 deletions
diff --git a/core/image.cpp b/core/image.cpp index 76f21a25de..6ab8bb6d46 100644 --- a/core/image.cpp +++ b/core/image.cpp @@ -1325,19 +1325,19 @@ void Image::create(const char **p_xpm) { line++; } } -#define DETECT_ALPHA_MAX_TRESHOLD 254 -#define DETECT_ALPHA_MIN_TRESHOLD 2 - -#define DETECT_ALPHA(m_value) \ - { \ - uint8_t value = m_value; \ - if (value < DETECT_ALPHA_MIN_TRESHOLD) \ - bit = true; \ - else if (value < DETECT_ALPHA_MAX_TRESHOLD) { \ - \ - detected = true; \ - break; \ - } \ +#define DETECT_ALPHA_MAX_THRESHOLD 254 +#define DETECT_ALPHA_MIN_THRESHOLD 2 + +#define DETECT_ALPHA(m_value) \ + { \ + uint8_t value = m_value; \ + if (value < DETECT_ALPHA_MIN_THRESHOLD) \ + bit = true; \ + else if (value < DETECT_ALPHA_MAX_THRESHOLD) { \ + \ + detected = true; \ + break; \ + } \ } #define DETECT_NON_ALPHA(m_value) \ @@ -1673,7 +1673,7 @@ void Image::blit_rect_mask(const Ref<Image> &p_src, const Ref<Image> &p_mask, co const uint8_t *src_data_ptr = rp.ptr(); int pixel_size = get_format_pixel_size(format); - + Ref<Image> msk = p_mask; msk->lock(); @@ -1683,7 +1683,7 @@ void Image::blit_rect_mask(const Ref<Image> &p_src, const Ref<Image> &p_mask, co int src_x = clipped_src_rect.position.x + j; int src_y = clipped_src_rect.position.y + i; - + if (msk->get_pixel(src_x, src_y).a != 0) { int dst_x = dest_rect.position.x + j; @@ -2434,7 +2434,7 @@ void Image::fix_alpha_edges() { unsigned char *data_ptr = wp.ptr(); const int max_radius = 4; - const int alpha_treshold = 20; + const int alpha_threshold = 20; const int max_dist = 0x7FFFFFFF; for (int i = 0; i < height; i++) { @@ -2443,7 +2443,7 @@ void Image::fix_alpha_edges() { const uint8_t *rptr = &srcptr[(i * width + j) * 4]; uint8_t *wptr = &data_ptr[(i * width + j) * 4]; - if (rptr[3] >= alpha_treshold) + if (rptr[3] >= alpha_threshold) continue; int closest_dist = max_dist; @@ -2465,7 +2465,7 @@ void Image::fix_alpha_edges() { const uint8_t *rp = &srcptr[(k * width + l) << 2]; - if (rp[3] < alpha_treshold) + if (rp[3] < alpha_threshold) continue; closest_color[0] = rp[0]; diff --git a/core/math/face3.cpp b/core/math/face3.cpp index 5b66e1999a..0e292500bf 100644 --- a/core/math/face3.cpp +++ b/core/math/face3.cpp @@ -272,8 +272,8 @@ void Face3::project_range(const Vector3 &p_normal, const Transform &p_transform, void Face3::get_support(const Vector3 &p_normal, const Transform &p_transform, Vector3 *p_vertices, int *p_count, int p_max) const { -#define _FACE_IS_VALID_SUPPORT_TRESHOLD 0.98 -#define _EDGE_IS_VALID_SUPPORT_TRESHOLD 0.05 +#define _FACE_IS_VALID_SUPPORT_THRESHOLD 0.98 +#define _EDGE_IS_VALID_SUPPORT_THRESHOLD 0.05 if (p_max <= 0) return; @@ -281,7 +281,7 @@ void Face3::get_support(const Vector3 &p_normal, const Transform &p_transform, V Vector3 n = p_transform.basis.xform_inv(p_normal); /** TEST FACE AS SUPPORT **/ - if (get_plane().normal.dot(n) > _FACE_IS_VALID_SUPPORT_TRESHOLD) { + if (get_plane().normal.dot(n) > _FACE_IS_VALID_SUPPORT_THRESHOLD) { *p_count = MIN(3, p_max); @@ -318,7 +318,7 @@ void Face3::get_support(const Vector3 &p_normal, const Transform &p_transform, V // check if edge is valid as a support real_t dot = (vertex[i] - vertex[(i + 1) % 3]).normalized().dot(n); dot = ABS(dot); - if (dot < _EDGE_IS_VALID_SUPPORT_TRESHOLD) { + if (dot < _EDGE_IS_VALID_SUPPORT_THRESHOLD) { *p_count = MIN(2, p_max); diff --git a/core/sort.h b/core/sort.h index a45eb8865a..06c427f61e 100644 --- a/core/sort.h +++ b/core/sort.h @@ -46,7 +46,7 @@ class SortArray { enum { - INTROSORT_TRESHOLD = 16 + INTROSORT_THRESHOLD = 16 }; public: @@ -180,7 +180,7 @@ public: inline void introsort(int p_first, int p_last, T *p_array, int p_max_depth) const { - while (p_last - p_first > INTROSORT_TRESHOLD) { + while (p_last - p_first > INTROSORT_THRESHOLD) { if (p_max_depth == 0) { partial_sort(p_first, p_last, p_last, p_array); @@ -273,9 +273,9 @@ public: inline void final_insertion_sort(int p_first, int p_last, T *p_array) const { - if (p_last - p_first > INTROSORT_TRESHOLD) { - insertion_sort(p_first, p_first + INTROSORT_TRESHOLD, p_array); - unguarded_insertion_sort(p_first + INTROSORT_TRESHOLD, p_last, p_array); + if (p_last - p_first > INTROSORT_THRESHOLD) { + insertion_sort(p_first, p_first + INTROSORT_THRESHOLD, p_array); + unguarded_insertion_sort(p_first + INTROSORT_THRESHOLD, p_last, p_array); } else { insertion_sort(p_first, p_last, p_array); diff --git a/drivers/gles2/rasterizer_gles2.cpp b/drivers/gles2/rasterizer_gles2.cpp index 3c543365f0..25c0f8925d 100644 --- a/drivers/gles2/rasterizer_gles2.cpp +++ b/drivers/gles2/rasterizer_gles2.cpp @@ -4199,7 +4199,7 @@ void RasterizerGLES2::set_camera(const Transform &p_world, const CameraMatrix &p void RasterizerGLES2::add_light(RID p_light_instance) { -#define LIGHT_FADE_TRESHOLD 0.05 +#define LIGHT_FADE_THRESHOLD 0.05 ERR_FAIL_COND(light_instance_count >= MAX_SCENE_LIGHTS); @@ -6481,7 +6481,7 @@ void RasterizerGLES2::_process_glow_bloom() { copy_shader.bind(); copy_shader.set_uniform(CopyShaderGLES2::BLOOM, float(current_env->fx_param[VS::ENV_FX_PARAM_GLOW_BLOOM])); - copy_shader.set_uniform(CopyShaderGLES2::BLOOM_TRESHOLD, float(current_env->fx_param[VS::ENV_FX_PARAM_GLOW_BLOOM_TRESHOLD])); + copy_shader.set_uniform(CopyShaderGLES2::BLOOM_THRESHOLD, float(current_env->fx_param[VS::ENV_FX_PARAM_GLOW_BLOOM_THRESHOLD])); glUniform1i(copy_shader.get_uniform_location(CopyShaderGLES2::SOURCE), 0); if (current_vd && current_env->fx_enabled[VS::ENV_FX_HDR]) { @@ -6491,7 +6491,7 @@ void RasterizerGLES2::_process_glow_bloom() { copy_shader.set_uniform(CopyShaderGLES2::TONEMAP_EXPOSURE, float(current_env->fx_param[VS::ENV_FX_PARAM_HDR_EXPOSURE])); copy_shader.set_uniform(CopyShaderGLES2::TONEMAP_WHITE, float(current_env->fx_param[VS::ENV_FX_PARAM_HDR_WHITE])); //copy_shader.set_uniform(CopyShaderGLES2::TONEMAP_WHITE,1.0); - copy_shader.set_uniform(CopyShaderGLES2::HDR_GLOW_TRESHOLD, float(current_env->fx_param[VS::ENV_FX_PARAM_HDR_GLOW_TRESHOLD])); + copy_shader.set_uniform(CopyShaderGLES2::HDR_GLOW_THRESHOLD, float(current_env->fx_param[VS::ENV_FX_PARAM_HDR_GLOW_THRESHOLD])); copy_shader.set_uniform(CopyShaderGLES2::HDR_GLOW_SCALE, float(current_env->fx_param[VS::ENV_FX_PARAM_HDR_GLOW_SCALE])); glActiveTexture(GL_TEXTURE0); diff --git a/drivers/gles2/rasterizer_gles2.h b/drivers/gles2/rasterizer_gles2.h index e6b76a4e92..e86d3ba298 100644 --- a/drivers/gles2/rasterizer_gles2.h +++ b/drivers/gles2/rasterizer_gles2.h @@ -689,14 +689,14 @@ class RasterizerGLES2 : public Rasterizer { fx_param[VS::ENV_FX_PARAM_GLOW_BLUR_STRENGTH] = 1.0; fx_param[VS::ENV_FX_PARAM_GLOW_BLUR_BLEND_MODE] = 0; fx_param[VS::ENV_FX_PARAM_GLOW_BLOOM] = 0.0; - fx_param[VS::ENV_FX_PARAM_GLOW_BLOOM_TRESHOLD] = 0.5; + fx_param[VS::ENV_FX_PARAM_GLOW_BLOOM_THRESHOLD] = 0.5; fx_param[VS::ENV_FX_PARAM_DOF_BLUR_PASSES] = 1; fx_param[VS::ENV_FX_PARAM_DOF_BLUR_BEGIN] = 100.0; fx_param[VS::ENV_FX_PARAM_DOF_BLUR_RANGE] = 10.0; fx_param[VS::ENV_FX_PARAM_HDR_TONEMAPPER] = VS::ENV_FX_HDR_TONE_MAPPER_LINEAR; fx_param[VS::ENV_FX_PARAM_HDR_EXPOSURE] = 0.4; fx_param[VS::ENV_FX_PARAM_HDR_WHITE] = 1.0; - fx_param[VS::ENV_FX_PARAM_HDR_GLOW_TRESHOLD] = 0.95; + fx_param[VS::ENV_FX_PARAM_HDR_GLOW_THRESHOLD] = 0.95; fx_param[VS::ENV_FX_PARAM_HDR_GLOW_SCALE] = 0.2; fx_param[VS::ENV_FX_PARAM_HDR_MIN_LUMINANCE] = 0.4; fx_param[VS::ENV_FX_PARAM_HDR_MAX_LUMINANCE] = 8.0; diff --git a/drivers/gles2/shaders/copy.glsl b/drivers/gles2/shaders/copy.glsl index 3f060cb97f..23680ffe91 100644 --- a/drivers/gles2/shaders/copy.glsl +++ b/drivers/gles2/shaders/copy.glsl @@ -87,7 +87,7 @@ uniform sampler2D glow_source; #if defined(USE_HDR) && defined(USE_GLOW_COPY) -uniform highp float hdr_glow_treshold; +uniform highp float hdr_glow_threshold; uniform highp float hdr_glow_scale; #endif @@ -107,7 +107,7 @@ uniform vec3 bcs; #ifdef USE_GLOW_COPY uniform float bloom; -uniform float bloom_treshold; +uniform float bloom_threshold; #endif @@ -374,11 +374,11 @@ void main() { #ifdef USE_GLOW_COPY - highp vec3 glowcol = color.rgb*color.a+step(bloom_treshold,dot(vec3(0.3333,0.3333,0.3333),color.rgb))*bloom*color.rgb; + highp vec3 glowcol = color.rgb*color.a+step(bloom_threshold,dot(vec3(0.3333,0.3333,0.3333),color.rgb))*bloom*color.rgb; #ifdef USE_HDR highp float collum = max(color.r,max(color.g,color.b)); - glowcol+=color.rgb*max(collum-hdr_glow_treshold,0.0)*hdr_glow_scale; + glowcol+=color.rgb*max(collum-hdr_glow_threshold,0.0)*hdr_glow_scale; #endif color.rgb=glowcol; color.a=0.0; @@ -500,7 +500,7 @@ void main() { //lum_accum=exp(lum_accum); -#ifdef USE_8BIT_HDR +#ifdef USE_8BIT_HDR highp float vd_lum = dot(texture2D( source_vd_lum, vec2(0.0) ), _multcv ); lum_accum = clamp( vd_lum + (lum_accum-vd_lum)*hdr_time_delta*hdr_exp_adj_speed,min_luminance*(1.0/LUM_RANGE),max_luminance*(1.0/LUM_RANGE)); @@ -555,4 +555,3 @@ void main() { #endif } - diff --git a/drivers/gles3/rasterizer_scene_gles3.cpp b/drivers/gles3/rasterizer_scene_gles3.cpp index 3b3ce73264..e8c6502bf4 100644 --- a/drivers/gles3/rasterizer_scene_gles3.cpp +++ b/drivers/gles3/rasterizer_scene_gles3.cpp @@ -869,7 +869,7 @@ void RasterizerSceneGLES3::environment_set_dof_blur_near(RID p_env, bool p_enabl env->dof_blur_near_amount = p_amount; env->dof_blur_near_quality = p_quality; } -void RasterizerSceneGLES3::environment_set_glow(RID p_env, bool p_enable, int p_level_flags, float p_intensity, float p_strength, float p_bloom_treshold, VS::EnvironmentGlowBlendMode p_blend_mode, float p_hdr_bleed_treshold, float p_hdr_bleed_scale, bool p_bicubic_upscale) { +void RasterizerSceneGLES3::environment_set_glow(RID p_env, bool p_enable, int p_level_flags, float p_intensity, float p_strength, float p_bloom_threshold, VS::EnvironmentGlowBlendMode p_blend_mode, float p_hdr_bleed_threshold, float p_hdr_bleed_scale, bool p_bicubic_upscale) { Environment *env = environment_owner.getornull(p_env); ERR_FAIL_COND(!env); @@ -878,9 +878,9 @@ void RasterizerSceneGLES3::environment_set_glow(RID p_env, bool p_enable, int p_ env->glow_levels = p_level_flags; env->glow_intensity = p_intensity; env->glow_strength = p_strength; - env->glow_bloom = p_bloom_treshold; + env->glow_bloom = p_bloom_threshold; env->glow_blend_mode = p_blend_mode; - env->glow_hdr_bleed_treshold = p_hdr_bleed_treshold; + env->glow_hdr_bleed_threshold = p_hdr_bleed_threshold; env->glow_hdr_bleed_scale = p_hdr_bleed_scale; env->glow_bicubic_upscale = p_bicubic_upscale; } @@ -1879,6 +1879,7 @@ void RasterizerSceneGLES3::_render_list(RenderList::Element **p_elements, int p_ glBindBufferBase(GL_UNIFORM_BUFFER, 0, state.scene_ubo); //bind globals ubo + bool use_radiance_map = false; if (!p_shadow && !p_directional_add) { glBindBufferBase(GL_UNIFORM_BUFFER, 2, state.env_radiance_ubo); //bind environment radiance info @@ -1892,6 +1893,7 @@ void RasterizerSceneGLES3::_render_list(RenderList::Element **p_elements, int p_ state.scene_shader.set_conditional(SceneShaderGLES3::USE_RADIANCE_MAP, true); state.scene_shader.set_conditional(SceneShaderGLES3::USE_RADIANCE_MAP_ARRAY, storage->config.use_texture_array_environment); + use_radiance_map = true; } else { state.scene_shader.set_conditional(SceneShaderGLES3::USE_RADIANCE_MAP, false); state.scene_shader.set_conditional(SceneShaderGLES3::USE_RADIANCE_MAP_ARRAY, false); @@ -1966,6 +1968,7 @@ void RasterizerSceneGLES3::_render_list(RenderList::Element **p_elements, int p_ state.scene_shader.set_conditional(SceneShaderGLES3::SHADOW_MODE_PCF_5, false); state.scene_shader.set_conditional(SceneShaderGLES3::SHADOW_MODE_PCF_13, false); state.scene_shader.set_conditional(SceneShaderGLES3::USE_GI_PROBES, false); + state.scene_shader.set_conditional(SceneShaderGLES3::USE_RADIANCE_MAP, false); //state.scene_shader.set_conditional(SceneShaderGLES3::SHADELESS,true); } else { @@ -1981,6 +1984,7 @@ void RasterizerSceneGLES3::_render_list(RenderList::Element **p_elements, int p_ state.scene_shader.set_conditional(SceneShaderGLES3::LIGHT_USE_PSSM_BLEND, false); state.scene_shader.set_conditional(SceneShaderGLES3::SHADOW_MODE_PCF_5, shadow_filter_mode == SHADOW_FILTER_PCF5); state.scene_shader.set_conditional(SceneShaderGLES3::SHADOW_MODE_PCF_13, shadow_filter_mode == SHADOW_FILTER_PCF13); + state.scene_shader.set_conditional(SceneShaderGLES3::USE_RADIANCE_MAP, use_radiance_map); if (p_directional_add || (directional_light && (e->sort_key & SORT_KEY_NO_DIRECTIONAL_FLAG) == 0)) { state.scene_shader.set_conditional(SceneShaderGLES3::USE_LIGHT_DIRECTIONAL, true); @@ -2163,7 +2167,19 @@ void RasterizerSceneGLES3::_add_geometry(RasterizerStorageGLES3::Geometry *p_geo ERR_FAIL_COND(!m); - bool has_base_alpha = (m->shader->spatial.uses_alpha || m->shader->spatial.uses_screen_texture); + _add_geometry_with_material(p_geometry, p_instance, p_owner, m, p_shadow); + + while (m->next_pass.is_valid()) { + m = storage->material_owner.getornull(m->next_pass); + if (!m) + break; + _add_geometry_with_material(p_geometry, p_instance, p_owner, m, p_shadow); + } +} + +void RasterizerSceneGLES3::_add_geometry_with_material(RasterizerStorageGLES3::Geometry *p_geometry, InstanceBase *p_instance, RasterizerStorageGLES3::GeometryOwner *p_owner, RasterizerStorageGLES3::Material *m, bool p_shadow) { + + bool has_base_alpha = (m->shader->spatial.uses_alpha || m->shader->spatial.uses_screen_texture || m->shader->spatial.unshaded); bool has_blend_alpha = m->shader->spatial.blend_mode != RasterizerStorageGLES3::Shader::Spatial::BLEND_MODE_MIX || m->shader->spatial.ontop; bool has_alpha = has_base_alpha || has_blend_alpha; bool shadow = false; @@ -3703,7 +3719,7 @@ void RasterizerSceneGLES3::_post_process(Environment *env, const CameraMatrix &p glBindTexture(GL_TEXTURE_2D, storage->frame.current_rt->exposure.color); state.effect_blur_shader.set_uniform(EffectBlurShaderGLES3::GLOW_BLOOM, env->glow_bloom); - state.effect_blur_shader.set_uniform(EffectBlurShaderGLES3::GLOW_HDR_TRESHOLD, env->glow_hdr_bleed_treshold); + state.effect_blur_shader.set_uniform(EffectBlurShaderGLES3::GLOW_HDR_THRESHOLD, env->glow_hdr_bleed_threshold); state.effect_blur_shader.set_uniform(EffectBlurShaderGLES3::GLOW_HDR_SCALE, env->glow_hdr_bleed_scale); } else { diff --git a/drivers/gles3/rasterizer_scene_gles3.h b/drivers/gles3/rasterizer_scene_gles3.h index 5f0db446a9..37bbd60797 100644 --- a/drivers/gles3/rasterizer_scene_gles3.h +++ b/drivers/gles3/rasterizer_scene_gles3.h @@ -381,7 +381,7 @@ public: float glow_strength; float glow_bloom; VS::EnvironmentGlowBlendMode glow_blend_mode; - float glow_hdr_bleed_treshold; + float glow_hdr_bleed_threshold; float glow_hdr_bleed_scale; bool glow_bicubic_upscale; @@ -467,7 +467,7 @@ public: glow_strength = 1.0; glow_bloom = 0.0; glow_blend_mode = VS::GLOW_BLEND_MODE_SOFTLIGHT; - glow_hdr_bleed_treshold = 1.0; + glow_hdr_bleed_threshold = 1.0; glow_hdr_bleed_scale = 2.0; glow_bicubic_upscale = false; @@ -522,7 +522,7 @@ public: virtual void environment_set_dof_blur_near(RID p_env, bool p_enable, float p_distance, float p_transition, float p_far_amount, VS::EnvironmentDOFBlurQuality p_quality); virtual void environment_set_dof_blur_far(RID p_env, bool p_enable, float p_distance, float p_transition, float p_far_amount, VS::EnvironmentDOFBlurQuality p_quality); - virtual void environment_set_glow(RID p_env, bool p_enable, int p_level_flags, float p_intensity, float p_strength, float p_bloom_treshold, VS::EnvironmentGlowBlendMode p_blend_mode, float p_hdr_bleed_treshold, float p_hdr_bleed_scale, bool p_bicubic_upscale); + virtual void environment_set_glow(RID p_env, bool p_enable, int p_level_flags, float p_intensity, float p_strength, float p_bloom_threshold, VS::EnvironmentGlowBlendMode p_blend_mode, float p_hdr_bleed_threshold, float p_hdr_bleed_scale, bool p_bicubic_upscale); virtual void environment_set_fog(RID p_env, bool p_enable, float p_begin, float p_end, RID p_gradient_texture); virtual void environment_set_ssr(RID p_env, bool p_enable, int p_max_steps, float p_fade_in, float p_fade_out, float p_depth_tolerance, bool p_roughness); @@ -769,6 +769,8 @@ public: _FORCE_INLINE_ void _add_geometry(RasterizerStorageGLES3::Geometry *p_geometry, InstanceBase *p_instance, RasterizerStorageGLES3::GeometryOwner *p_owner, int p_material, bool p_shadow); + _FORCE_INLINE_ void _add_geometry_with_material(RasterizerStorageGLES3::Geometry *p_geometry, InstanceBase *p_instance, RasterizerStorageGLES3::GeometryOwner *p_owner, RasterizerStorageGLES3::Material *p_material, bool p_shadow); + void _draw_sky(RasterizerStorageGLES3::Sky *p_sky, const CameraMatrix &p_projection, const Transform &p_transform, bool p_vflip, float p_scale, float p_energy); void _setup_environment(Environment *env, const CameraMatrix &p_cam_projection, const Transform &p_cam_transform); diff --git a/drivers/gles3/rasterizer_storage_gles3.cpp b/drivers/gles3/rasterizer_storage_gles3.cpp index 036ff58719..14fb36f3b0 100644 --- a/drivers/gles3/rasterizer_storage_gles3.cpp +++ b/drivers/gles3/rasterizer_storage_gles3.cpp @@ -1870,6 +1870,14 @@ void RasterizerStorageGLES3::material_set_line_width(RID p_material, float p_wid material->line_width = p_width; } +void RasterizerStorageGLES3::material_set_next_pass(RID p_material, RID p_next_material) { + + Material *material = material_owner.get(p_material); + ERR_FAIL_COND(!material); + + material->next_pass = p_next_material; +} + bool RasterizerStorageGLES3::material_is_animated(RID p_material) { Material *material = material_owner.get(p_material); @@ -1878,7 +1886,11 @@ bool RasterizerStorageGLES3::material_is_animated(RID p_material) { _update_material(material); } - return material->is_animated_cache; + bool animated = material->is_animated_cache; + if (!animated && material->next_pass.is_valid()) { + animated = material_is_animated(material->next_pass); + } + return animated; } bool RasterizerStorageGLES3::material_casts_shadows(RID p_material) { @@ -1888,7 +1900,13 @@ bool RasterizerStorageGLES3::material_casts_shadows(RID p_material) { _update_material(material); } - return material->can_cast_shadow_cache; + bool casts_shadows = material->can_cast_shadow_cache; + + if (!casts_shadows && material->next_pass.is_valid()) { + casts_shadows = material_casts_shadows(material->next_pass); + } + + return casts_shadows; } void RasterizerStorageGLES3::material_add_instance_owner(RID p_material, RasterizerScene::InstanceBase *p_instance) { diff --git a/drivers/gles3/rasterizer_storage_gles3.h b/drivers/gles3/rasterizer_storage_gles3.h index d317d27656..183db534ac 100644 --- a/drivers/gles3/rasterizer_storage_gles3.h +++ b/drivers/gles3/rasterizer_storage_gles3.h @@ -496,6 +496,8 @@ public: Vector<RID> textures; float line_width; + RID next_pass; + uint32_t index; uint64_t last_pass; @@ -533,6 +535,7 @@ public: virtual Variant material_get_param(RID p_material, const StringName &p_param) const; virtual void material_set_line_width(RID p_material, float p_width); + virtual void material_set_next_pass(RID p_material, RID p_next_material); virtual bool material_is_animated(RID p_material); virtual bool material_casts_shadows(RID p_material); diff --git a/drivers/gles3/shader_compiler_gles3.cpp b/drivers/gles3/shader_compiler_gles3.cpp index 6c568714f8..206f270f68 100644 --- a/drivers/gles3/shader_compiler_gles3.cpp +++ b/drivers/gles3/shader_compiler_gles3.cpp @@ -304,6 +304,7 @@ String ShaderCompilerGLES3::_dump_node_code(SL::Node *p_node, int p_level, Gener uniform_sizes.resize(max_uniforms); uniform_alignments.resize(max_uniforms); uniform_defines.resize(max_uniforms); + bool uses_uniforms = false; for (Map<StringName, SL::ShaderNode::Uniform>::Element *E = pnode->uniforms.front(); E; E = E->next()) { @@ -323,9 +324,10 @@ String ShaderCompilerGLES3::_dump_node_code(SL::Node *p_node, int p_level, Gener r_gen_code.texture_uniforms[E->get().texture_order] = _mkid(E->key()); r_gen_code.texture_hints[E->get().texture_order] = E->get().hint; } else { - if (r_gen_code.uniforms.empty()) { + if (!uses_uniforms) { r_gen_code.defines.push_back(String("#define USE_MATERIAL\n").ascii()); + uses_uniforms = true; } uniform_defines[E->get().order] = ucode; uniform_sizes[E->get().order] = _get_datatype_size(E->get().type); @@ -651,6 +653,14 @@ Error ShaderCompilerGLES3::compile(VS::ShaderMode p_mode, const String &p_code, _dump_node_code(parser.get_shader(), 1, r_gen_code, *p_actions, actions[p_mode]); + if (r_gen_code.uniform_total_size) { //uniforms used? + int md = sizeof(float) * 4; + if (r_gen_code.uniform_total_size % md) { + r_gen_code.uniform_total_size += md - (r_gen_code.uniform_total_size % md); + } + r_gen_code.uniform_total_size += md; //pad just in case + } + return OK; } @@ -700,7 +710,7 @@ ShaderCompilerGLES3::ShaderCompilerGLES3() { actions[VS::SHADER_CANVAS_ITEM].usage_defines["NORMALMAP"] = "#define NORMALMAP_USED\n"; actions[VS::SHADER_CANVAS_ITEM].usage_defines["SHADOW_COLOR"] = "#define SHADOW_COLOR_USED\n"; - actions[VS::SHADER_CANVAS_ITEM].render_mode_defines["skip_transform"] = "#define SKIP_TRANSFORM_USED\n"; + actions[VS::SHADER_CANVAS_ITEM].render_mode_defines["skip_vertex_transform"] = "#define SKIP_TRANSFORM_USED\n"; /** SPATIAL SHADER **/ @@ -775,11 +785,18 @@ ShaderCompilerGLES3::ShaderCompilerGLES3() { actions[VS::SHADER_SPATIAL].renames["SSS_STRENGTH"] = "sss_strength"; - actions[VS::SHADER_SPATIAL].render_mode_defines["skip_default_transform"] = "#define SKIP_TRANSFORM_USED\n"; + actions[VS::SHADER_SPATIAL].render_mode_defines["skip_vertex_transform"] = "#define SKIP_TRANSFORM_USED\n"; + actions[VS::SHADER_SPATIAL].render_mode_defines["world_vertex_coords"] = "#define VERTEX_WORLD_COORDS_USED\n"; actions[VS::SHADER_SPATIAL].render_mode_defines["diffuse_burley"] = "#define DIFFUSE_BURLEY\n"; actions[VS::SHADER_SPATIAL].render_mode_defines["diffuse_oren_nayar"] = "#define DIFFUSE_OREN_NAYAR\n"; actions[VS::SHADER_SPATIAL].render_mode_defines["diffuse_half_lambert"] = "#define DIFFUSE_HALF_LAMBERT\n"; + actions[VS::SHADER_SPATIAL].render_mode_defines["diffuse_toon"] = "#define DIFFUSE_TOON\n"; + + actions[VS::SHADER_SPATIAL].render_mode_defines["specular_blinn"] = "#define SPECULAR_BLINN\n"; + actions[VS::SHADER_SPATIAL].render_mode_defines["specular_phong"] = "#define SPECULAR_PHONG\n"; + actions[VS::SHADER_SPATIAL].render_mode_defines["specular_toon"] = "#define SPECULAR_TOON\n"; + actions[VS::SHADER_SPATIAL].render_mode_defines["specular_disabled"] = "#define SPECULAR_DISABLED\n"; /* PARTICLES SHADER */ diff --git a/drivers/gles3/shader_gles3.cpp b/drivers/gles3/shader_gles3.cpp index c821acadf5..33a7c9a22f 100644 --- a/drivers/gles3/shader_gles3.cpp +++ b/drivers/gles3/shader_gles3.cpp @@ -416,7 +416,8 @@ ShaderGLES3::Version *ShaderGLES3::get_current_version() { strings.push_back(fragment_code4.get_data()); #ifdef DEBUG_SHADER - DEBUG_PRINT("\nFragment Code:\n\n" + String(code_string.get_data())); + DEBUG_PRINT("\nFragment Globals:\n\n" + String(code_globals.get_data())); + DEBUG_PRINT("\nFragment Code:\n\n" + String(code_string2.get_data())); for (int i = 0; i < strings.size(); i++) { //print_line("frag strings "+itos(i)+":"+String(strings[i])); diff --git a/drivers/gles3/shaders/cubemap_filter.glsl b/drivers/gles3/shaders/cubemap_filter.glsl index 10a803cafe..393ef2892a 100644 --- a/drivers/gles3/shaders/cubemap_filter.glsl +++ b/drivers/gles3/shaders/cubemap_filter.glsl @@ -204,7 +204,9 @@ vec4 textureDualParaboloidArray(vec3 normal) { vec3 norm = normalize(normal); norm.xy/=1.0+abs(norm.z); norm.xy=norm.xy * vec2(0.5,0.25) + vec2(0.5,0.25); - norm.y+=max(0.0,sign(-norm.z))*0.5; + if (norm.z<0) { + norm.y=0.5-norm.y+0.5; + } return textureLod(source_dual_paraboloid_array, vec3(norm.xy, float(source_array_index) ), 0.0); } diff --git a/drivers/gles3/shaders/effect_blur.glsl b/drivers/gles3/shaders/effect_blur.glsl index 8ca8e21f11..2550335174 100644 --- a/drivers/gles3/shaders/effect_blur.glsl +++ b/drivers/gles3/shaders/effect_blur.glsl @@ -14,7 +14,7 @@ uniform vec4 blur_section; void main() { - uv_interp = uv_in; + uv_interp = uv_in; gl_Position = vertex_attrib; #ifdef USE_BLUR_SECTION @@ -99,7 +99,7 @@ uniform highp float auto_exposure_grey; #endif uniform float glow_bloom; -uniform float glow_hdr_treshold; +uniform float glow_hdr_threshold; uniform float glow_hdr_scale; #endif @@ -262,7 +262,7 @@ void main() { frag_color*=exposure; float luminance = max(frag_color.r,max(frag_color.g,frag_color.b)); - float feedback = max( smoothstep(glow_hdr_treshold,glow_hdr_treshold+glow_hdr_scale,luminance), glow_bloom ); + float feedback = max( smoothstep(glow_hdr_threshold,glow_hdr_threshold+glow_hdr_scale,luminance), glow_bloom ); frag_color *= feedback; @@ -285,4 +285,3 @@ void main() { } - diff --git a/drivers/gles3/shaders/scene.glsl b/drivers/gles3/shaders/scene.glsl index 29623a6296..6fbfeeff6c 100644 --- a/drivers/gles3/shaders/scene.glsl +++ b/drivers/gles3/shaders/scene.glsl @@ -275,6 +275,19 @@ void main() { highp mat4 modelview = camera_inverse_matrix * world_matrix; highp mat4 local_projection = projection_matrix; +//using world coordinates +#if !defined(SKIP_TRANSFORM_USED) && defined(VERTEX_WORLD_COORDS_USED) + + vertex = world_matrix * vertex; + normal = normalize((world_matrix * vec4(normal,0.0)).xyz); + +#if defined(ENABLE_TANGENT_INTERP) || defined(ENABLE_NORMALMAP) || defined(LIGHT_USE_ANISOTROPY) + + tangent = normalize((world_matrix * vec4(tangent,0.0)).xyz); + binormal = normalize((world_matrix * vec4(binormal,0.0)).xyz); +#endif +#endif + //defines that make writing custom shaders easier #define projection_matrix local_projection #define world_transform world_matrix @@ -286,29 +299,42 @@ VERTEX_SHADER_CODE - -#if !defined(SKIP_TRANSFORM_USED) +//using local coordinates (default) +#if !defined(SKIP_TRANSFORM_USED) && !defined(VERTEX_WORLD_COORDS_USED) vertex = modelview * vertex; normal = normalize((modelview * vec4(normal,0.0)).xyz); + +#if defined(ENABLE_TANGENT_INTERP) || defined(ENABLE_NORMALMAP) || defined(LIGHT_USE_ANISOTROPY) + + tangent = normalize((modelview * vec4(tangent,0.0)).xyz); + binormal = normalize((modelview * vec4(binormal,0.0)).xyz); +#endif #endif +//using world coordinates +#if !defined(SKIP_TRANSFORM_USED) && defined(VERTEX_WORLD_COORDS_USED) - vertex_interp = vertex.xyz; - normal_interp = normal; + vertex = camera_inverse_matrix * vertex; + normal = normalize((camera_inverse_matrix * vec4(normal,0.0)).xyz); #if defined(ENABLE_TANGENT_INTERP) || defined(ENABLE_NORMALMAP) || defined(LIGHT_USE_ANISOTROPY) -#if !defined(SKIP_TRANSFORM_USED) + tangent = normalize((camera_inverse_matrix * vec4(tangent,0.0)).xyz); + binormal = normalize((camera_inverse_matrix * vec4(binormal,0.0)).xyz); +#endif +#endif - tangent = normalize((modelview * vec4(tangent,0.0)).xyz); - binormal = normalize((modelview * vec4(binormal,0.0)).xyz); + vertex_interp = vertex.xyz; + normal_interp = normal; -#endif + +#if defined(ENABLE_TANGENT_INTERP) || defined(ENABLE_NORMALMAP) || defined(LIGHT_USE_ANISOTROPY) tangent_interp = tangent; binormal_interp = binormal; #endif + #ifdef RENDER_DEPTH @@ -749,6 +775,10 @@ LIGHT_SHADER_CODE diffuse += diffuse_color * max(0.0, NdotL) * (A + vec3(B) * s / t) / M_PI; } +#elif defined(DIFFUSE_TOON) + + diffuse += smoothstep(-roughness,max(roughness,0.01),dot(N,L)) * light_color * diffuse_color; + #elif defined(DIFFUSE_BURLEY) { @@ -779,6 +809,37 @@ LIGHT_SHADER_CODE if (roughness > 0.0) { + + // D + +#if defined(SPECULAR_BLINN) + + vec3 H = normalize(V + L); + float dotNH = max(dot(N,H), 0.0 ); + float intensity = pow( dotNH, (1.0-roughness) * 256.0); + specular += light_color * intensity * specular_blob_intensity; + +#elif defined(SPECULAR_PHONG) + + vec3 R = normalize(-reflect(L,N)); + float dotNV = max(0.0,dot(R,V)); + float intensity = pow( dotNV, (1.0-roughness) * 256.0); + specular += light_color * intensity * specular_blob_intensity; + +#elif defined(SPECULAR_TOON) + + vec3 R = normalize(-reflect(L,N)); + float dotNV = dot(R,V); + float mid = 1.0-roughness; + mid*=mid; + float intensity = smoothstep(mid-roughness*0.5,mid+roughness*0.5,dotNV) * mid; + diffuse += light_color * intensity * specular_blob_intensity; //write to diffuse, as in toon shading you generally want no reflection + +#elif defined(SPECULAR_DISABLED) + //none.. + +#else + // shlick+ggx as default float alpha = roughness * roughness; vec3 H = normalize(V + L); @@ -786,7 +847,6 @@ LIGHT_SHADER_CODE float dotNH = max(dot(N,H), 0.0 ); float dotLH = max(dot(L,H), 0.0 ); - // D #if defined(LIGHT_USE_ANISOTROPY) float aspect = sqrt(1.0-anisotropy*0.9); @@ -818,6 +878,7 @@ LIGHT_SHADER_CODE float speci = dotNL * D * F * vis; specular += speci * light_color * specular_blob_intensity; +#endif #if defined(LIGHT_USE_CLEARCOAT) float Dr = GTR1(dotNH, mix(.1,.001,clearcoat_gloss)); @@ -908,7 +969,7 @@ vec3 light_transmittance(float translucency,vec3 light_vec, vec3 normal, vec3 po } #endif -void light_process_omni(int idx, vec3 vertex, vec3 eye_vec,vec3 normal,vec3 binormal, vec3 tangent, vec3 albedo, float roughness, float rim, float rim_tint, float clearcoat, float clearcoat_gloss,float anisotropy,inout vec3 diffuse_light, inout vec3 specular_light) { +void light_process_omni(int idx, vec3 vertex, vec3 eye_vec,vec3 normal,vec3 binormal, vec3 tangent, vec3 albedo, float roughness, float rim, float rim_tint, float clearcoat, float clearcoat_gloss,float anisotropy,float p_blob_intensity,inout vec3 diffuse_light, inout vec3 specular_light) { vec3 light_rel_vec = omni_lights[idx].light_pos_inv_radius.xyz-vertex; float light_length = length( light_rel_vec ); @@ -959,11 +1020,11 @@ void light_process_omni(int idx, vec3 vertex, vec3 eye_vec,vec3 normal,vec3 bino light_attenuation*=mix(omni_lights[idx].shadow_color_contact.rgb,vec3(1.0),shadow); } - light_compute(normal,normalize(light_rel_vec),eye_vec,binormal,tangent,omni_lights[idx].light_color_energy.rgb*light_attenuation,albedo,omni_lights[idx].light_params.z,roughness,rim,rim_tint,clearcoat,clearcoat_gloss,anisotropy,diffuse_light,specular_light); + light_compute(normal,normalize(light_rel_vec),eye_vec,binormal,tangent,omni_lights[idx].light_color_energy.rgb*light_attenuation,albedo,omni_lights[idx].light_params.z*p_blob_intensity,roughness,rim,rim_tint,clearcoat,clearcoat_gloss,anisotropy,diffuse_light,specular_light); } -void light_process_spot(int idx, vec3 vertex, vec3 eye_vec, vec3 normal, vec3 binormal, vec3 tangent,vec3 albedo, float roughness, float rim,float rim_tint, float clearcoat, float clearcoat_gloss,float anisotropy, inout vec3 diffuse_light, inout vec3 specular_light) { +void light_process_spot(int idx, vec3 vertex, vec3 eye_vec, vec3 normal, vec3 binormal, vec3 tangent,vec3 albedo, float roughness, float rim,float rim_tint, float clearcoat, float clearcoat_gloss,float anisotropy,float p_blob_intensity, inout vec3 diffuse_light, inout vec3 specular_light) { vec3 light_rel_vec = spot_lights[idx].light_pos_inv_radius.xyz-vertex; float light_length = length( light_rel_vec ); @@ -992,7 +1053,7 @@ void light_process_spot(int idx, vec3 vertex, vec3 eye_vec, vec3 normal, vec3 bi light_attenuation*=mix(spot_lights[idx].shadow_color_contact.rgb,vec3(1.0),shadow); } - light_compute(normal,normalize(light_rel_vec),eye_vec,binormal,tangent,spot_lights[idx].light_color_energy.rgb*light_attenuation,albedo,spot_lights[idx].light_params.z,roughness,rim,rim_tint,clearcoat,clearcoat_gloss,anisotropy,diffuse_light,specular_light); + light_compute(normal,normalize(light_rel_vec),eye_vec,binormal,tangent,spot_lights[idx].light_color_energy.rgb*light_attenuation,albedo,spot_lights[idx].light_params.z*p_blob_intensity,roughness,rim,rim_tint,clearcoat,clearcoat_gloss,anisotropy,diffuse_light,specular_light); } @@ -1451,6 +1512,11 @@ FRAGMENT_SHADER_CODE ambient_light*=ambient_energy; + float specular_blob_intensity=1.0; +#if defined(SPECULAR_TOON) + specular_blob_intensity*=specular * 2.0; +#endif + #ifdef USE_LIGHT_DIRECTIONAL vec3 light_attenuation=vec3(1.0); @@ -1590,7 +1656,7 @@ FRAGMENT_SHADER_CODE #endif //LIGHT_DIRECTIONAL_SHADOW - light_compute(normal,-light_direction_attenuation.xyz,eye_vec,binormal,tangent,light_color_energy.rgb*light_attenuation,albedo,light_params.z,roughness,rim,rim_tint,clearcoat,clearcoat_gloss,anisotropy,diffuse_light,specular_light); + light_compute(normal,-light_direction_attenuation.xyz,eye_vec,binormal,tangent,light_color_energy.rgb*light_attenuation,albedo,light_params.z*specular_blob_intensity,roughness,rim,rim_tint,clearcoat,clearcoat_gloss,anisotropy,diffuse_light,specular_light); #endif //#USE_LIGHT_DIRECTIONAL @@ -1606,8 +1672,6 @@ FRAGMENT_SHADER_CODE highp vec4 reflection_accum = vec4(0.0,0.0,0.0,0.0); highp vec4 ambient_accum = vec4(0.0,0.0,0.0,0.0); - - for(int i=0;i<reflection_count;i++) { reflection_process(reflection_indices[i],vertex,normal,binormal,tangent,roughness,anisotropy,ambient_light,specular_light,reflection_accum,ambient_accum); } @@ -1620,11 +1684,11 @@ FRAGMENT_SHADER_CODE } for(int i=0;i<omni_light_count;i++) { - light_process_omni(omni_light_indices[i],vertex,eye_vec,normal,binormal,tangent,albedo,roughness,rim,rim_tint,clearcoat,clearcoat_gloss,anisotropy,diffuse_light,specular_light); + light_process_omni(omni_light_indices[i],vertex,eye_vec,normal,binormal,tangent,albedo,roughness,rim,rim_tint,clearcoat,clearcoat_gloss,anisotropy,specular_blob_intensity,diffuse_light,specular_light); } for(int i=0;i<spot_light_count;i++) { - light_process_spot(spot_light_indices[i],vertex,eye_vec,normal,binormal,tangent,albedo,roughness,rim,rim_tint,clearcoat,clearcoat_gloss,anisotropy,diffuse_light,specular_light); + light_process_spot(spot_light_indices[i],vertex,eye_vec,normal,binormal,tangent,albedo,roughness,rim,rim_tint,clearcoat,clearcoat_gloss,anisotropy,specular_blob_intensity,diffuse_light,specular_light); } @@ -1656,11 +1720,15 @@ FRAGMENT_SHADER_CODE diffuse_light=mix(diffuse_light,vec3(0.0),metallic); ambient_light=mix(ambient_light,vec3(0.0),metallic); { + +#if defined(DIFFUSE_TOON) + //simplify for toon, as + specular_light *= specular * metallic * albedo * 2.0; +#else //brdf approximation (Lazarov 2013) float ndotv = clamp(dot(normal,eye_vec),0.0,1.0); - + vec3 dielectric = vec3(0.034) * specular * 2.0; //energy conservation - vec3 dielectric = vec3(0.034) * 0.5 * 2.0; vec3 f0 = mix(dielectric, albedo, metallic); const vec4 c0 = vec4(-1.0, -0.0275, -0.572, 0.022); const vec4 c1 = vec4( 1.0, 0.0425, 1.04, -0.04); @@ -1669,6 +1737,8 @@ FRAGMENT_SHADER_CODE vec2 brdf = vec2( -1.04, 1.04 ) * a004 + r.zw; specular_light *= min(1.0,50.0 * f0.g) * brdf.y + brdf.x * f0; +#endif + } if (fog_color_enabled.a > 0.5) { diff --git a/editor/editor_node.cpp b/editor/editor_node.cpp index 1df991ab24..a83906ddf3 100644 --- a/editor/editor_node.cpp +++ b/editor/editor_node.cpp @@ -2753,6 +2753,8 @@ int EditorNode::_next_unsaved_scene() { for (int i = 0; i < editor_data.get_edited_scene_count(); i++) { + if (!editor_data.get_edited_scene_root(i)) + continue; int current = editor_data.get_edited_scene(); bool unsaved = (i == current) ? saved_version != editor_data.get_undo_redo().get_version() : editor_data.get_scene_version(i) != 0; if (unsaved) { @@ -4383,6 +4385,10 @@ void EditorNode::_scene_tab_closed(int p_tab) { current_option = SCENE_TAB_CLOSE; tab_closing = p_tab; Node *scene = editor_data.get_edited_scene_root(p_tab); + if (!scene) { + _discard_changes(); + return; + } bool unsaved = (p_tab == editor_data.get_edited_scene()) ? saved_version != editor_data.get_undo_redo().get_version() : @@ -6105,6 +6111,7 @@ EditorNode::EditorNode() { hbc->add_child(logo); Label *about_text = memnew(Label); + about_text->set_v_size_flags(Control::SIZE_SHRINK_CENTER); about_text->set_text(VERSION_FULL_NAME + String::utf8("\n\u00A9 2007-2017 Juan Linietsky, Ariel Manzur.\n\u00A9 2014-2017 ") + TTR("Godot Engine contributors") + "\n"); hbc->add_child(about_text); diff --git a/editor/editor_themes.cpp b/editor/editor_themes.cpp index 7e453a01c6..5b8f41e75f 100644 --- a/editor/editor_themes.cpp +++ b/editor/editor_themes.cpp @@ -117,9 +117,9 @@ Ref<Theme> create_editor_theme() { contrast = 0.25; } break; case 3: { // Arc - highlight_color = Color::html("#68a7f2"); - base_color = Color::html("#434a59"); - contrast = 0.2; + highlight_color = Color::html("#5294e2"); + base_color = Color::html("#383c4a"); + contrast = 0.25; } break; } @@ -260,7 +260,7 @@ Ref<Theme> create_editor_theme() { Ref<StyleBoxFlat> style_tree_focus = make_flat_stylebox(HIGHLIGHT_COLOR_DARK, 2, 2, 2, 2); theme->set_stylebox("selected_focus", "Tree", style_tree_focus); - Ref<StyleBoxFlat> style_tree_selected = make_flat_stylebox(light_color_1, 2, 2, 2, 2); + Ref<StyleBoxFlat> style_tree_selected = make_flat_stylebox(HIGHLIGHT_COLOR_DARK, 2, 2, 2, 2); theme->set_stylebox("selected", "Tree", style_tree_selected); Ref<StyleBoxFlat> style_tree_cursor = make_flat_stylebox(HIGHLIGHT_COLOR_DARK, 4, 4, 4, 4); @@ -275,10 +275,10 @@ Ref<Theme> create_editor_theme() { theme->set_stylebox("title_button_hover", "Tree", style_tree_title); theme->set_stylebox("title_button_pressed", "Tree", style_tree_title); - theme->set_color("prop_category", "Editor", dark_color_3); - theme->set_color("prop_section", "Editor", dark_color_1); - theme->set_color("prop_subsection", "Editor", dark_color_2); - theme->set_color("fg_selected", "Editor", Color::html("ffbd8e8e")); + theme->set_color("prop_category", "Editor", dark_color_1.linear_interpolate(Color(1, 1, 1, 1), 0.12)); + theme->set_color("prop_section", "Editor", dark_color_1.linear_interpolate(Color(1, 1, 1, 1), 0.09)); + theme->set_color("prop_subsection", "Editor", dark_color_1.linear_interpolate(Color(1, 1, 1, 1), 0.06)); + theme->set_color("fg_selected", "Editor", HIGHLIGHT_COLOR_DARK); theme->set_color("fg_error", "Editor", Color::html("ffbd8e8e")); theme->set_color("drop_position_color", "Tree", highlight_color); diff --git a/editor/plugins/collision_polygon_2d_editor_plugin.cpp b/editor/plugins/collision_polygon_2d_editor_plugin.cpp index 43abea0131..abee3ead71 100644 --- a/editor/plugins/collision_polygon_2d_editor_plugin.cpp +++ b/editor/plugins/collision_polygon_2d_editor_plugin.cpp @@ -112,7 +112,7 @@ bool CollisionPolygon2DEditor::forward_gui_input(const Ref<InputEvent> &p_event) Vector<Vector2> poly = node->get_polygon(); //first check if a point is to be added (segment split) - real_t grab_treshold = EDITOR_DEF("editors/poly_editor/point_grab_radius", 8); + real_t grab_threshold = EDITOR_DEF("editors/poly_editor/point_grab_radius", 8); switch (mode) { @@ -131,7 +131,7 @@ bool CollisionPolygon2DEditor::forward_gui_input(const Ref<InputEvent> &p_event) return true; } else { - if (wip.size() > 1 && xform.xform(wip[0]).distance_to(gpoint) < grab_treshold) { + if (wip.size() > 1 && xform.xform(wip[0]).distance_to(gpoint) < grab_threshold) { //wip closed _wip_close(); @@ -185,7 +185,7 @@ bool CollisionPolygon2DEditor::forward_gui_input(const Ref<InputEvent> &p_event) continue; //not valid to reuse point real_t d = cp.distance_to(gpoint); - if (d < closest_dist && d < grab_treshold) { + if (d < closest_dist && d < grab_threshold) { closest_dist = d; closest_pos = cp; closest_idx = i; @@ -214,7 +214,7 @@ bool CollisionPolygon2DEditor::forward_gui_input(const Ref<InputEvent> &p_event) Vector2 cp = xform.xform(poly[i]); real_t d = cp.distance_to(gpoint); - if (d < closest_dist && d < grab_treshold) { + if (d < closest_dist && d < grab_threshold) { closest_dist = d; closest_pos = cp; closest_idx = i; @@ -259,7 +259,7 @@ bool CollisionPolygon2DEditor::forward_gui_input(const Ref<InputEvent> &p_event) Vector2 cp = xform.xform(poly[i]); real_t d = cp.distance_to(gpoint); - if (d < closest_dist && d < grab_treshold) { + if (d < closest_dist && d < grab_threshold) { closest_dist = d; closest_pos = cp; closest_idx = i; diff --git a/editor/plugins/light_occluder_2d_editor_plugin.cpp b/editor/plugins/light_occluder_2d_editor_plugin.cpp index 09021446dc..a7a20e71fe 100644 --- a/editor/plugins/light_occluder_2d_editor_plugin.cpp +++ b/editor/plugins/light_occluder_2d_editor_plugin.cpp @@ -126,7 +126,7 @@ bool LightOccluder2DEditor::forward_gui_input(const Ref<InputEvent> &p_event) { Vector<Vector2> poly = Variant(node->get_occluder_polygon()->get_polygon()); //first check if a point is to be added (segment split) - real_t grab_treshold = EDITOR_DEF("editors/poly_editor/point_grab_radius", 8); + real_t grab_threshold = EDITOR_DEF("editors/poly_editor/point_grab_radius", 8); switch (mode) { @@ -145,12 +145,12 @@ bool LightOccluder2DEditor::forward_gui_input(const Ref<InputEvent> &p_event) { return true; } else { - if (wip.size() > 1 && xform.xform(wip[0]).distance_to(gpoint) < grab_treshold) { + if (wip.size() > 1 && xform.xform(wip[0]).distance_to(gpoint) < grab_threshold) { //wip closed _wip_close(true); return true; - } else if (wip.size() > 1 && xform.xform(wip[wip.size() - 1]).distance_to(gpoint) < grab_treshold) { + } else if (wip.size() > 1 && xform.xform(wip[wip.size() - 1]).distance_to(gpoint) < grab_threshold) { //wip closed _wip_close(false); return true; @@ -204,7 +204,7 @@ bool LightOccluder2DEditor::forward_gui_input(const Ref<InputEvent> &p_event) { continue; //not valid to reuse point real_t d = cp.distance_to(gpoint); - if (d < closest_dist && d < grab_treshold) { + if (d < closest_dist && d < grab_threshold) { closest_dist = d; closest_pos = cp; closest_idx = i; @@ -233,7 +233,7 @@ bool LightOccluder2DEditor::forward_gui_input(const Ref<InputEvent> &p_event) { Vector2 cp = xform.xform(poly[i]); real_t d = cp.distance_to(gpoint); - if (d < closest_dist && d < grab_treshold) { + if (d < closest_dist && d < grab_threshold) { closest_dist = d; closest_pos = cp; closest_idx = i; @@ -278,7 +278,7 @@ bool LightOccluder2DEditor::forward_gui_input(const Ref<InputEvent> &p_event) { Vector2 cp = xform.xform(poly[i]); real_t d = cp.distance_to(gpoint); - if (d < closest_dist && d < grab_treshold) { + if (d < closest_dist && d < grab_threshold) { closest_dist = d; closest_pos = cp; closest_idx = i; diff --git a/editor/plugins/line_2d_editor_plugin.cpp b/editor/plugins/line_2d_editor_plugin.cpp index 76906a5b93..4a7ad74fbe 100644 --- a/editor/plugins/line_2d_editor_plugin.cpp +++ b/editor/plugins/line_2d_editor_plugin.cpp @@ -62,12 +62,12 @@ Vector2 Line2DEditor::mouse_to_local_pos(Vector2 gpoint, bool alt) { int Line2DEditor::get_point_index_at(Vector2 gpos) { ERR_FAIL_COND_V(node == 0, -1); - real_t grab_treshold = EDITOR_DEF("editors/poly_editor/point_grab_radius", 8); + real_t grab_threshold = EDITOR_DEF("editors/poly_editor/point_grab_radius", 8); Transform2D xform = canvas_item_editor->get_canvas_transform() * node->get_global_transform(); for (int i = 0; i < node->get_point_count(); ++i) { Point2 p = xform.xform(node->get_point_pos(i)); - if (gpos.distance_to(p) < grab_treshold) { + if (gpos.distance_to(p) < grab_threshold) { return i; } } diff --git a/editor/plugins/navigation_polygon_editor_plugin.cpp b/editor/plugins/navigation_polygon_editor_plugin.cpp index 1457b28ed1..725e57fe0b 100644 --- a/editor/plugins/navigation_polygon_editor_plugin.cpp +++ b/editor/plugins/navigation_polygon_editor_plugin.cpp @@ -140,7 +140,7 @@ bool NavigationPolygonEditor::forward_gui_input(const Ref<InputEvent> &p_event) cpoint = node->get_global_transform().affine_inverse().xform(cpoint); //first check if a point is to be added (segment split) - real_t grab_treshold = EDITOR_DEF("editors/poly_editor/point_grab_radius", 8); + real_t grab_threshold = EDITOR_DEF("editors/poly_editor/point_grab_radius", 8); switch (mode) { @@ -160,7 +160,7 @@ bool NavigationPolygonEditor::forward_gui_input(const Ref<InputEvent> &p_event) return true; } else { - if (wip.size() > 1 && xform.xform(wip[0]).distance_to(gpoint) < grab_treshold) { + if (wip.size() > 1 && xform.xform(wip[0]).distance_to(gpoint) < grab_threshold) { //wip closed _wip_close(); @@ -211,7 +211,7 @@ bool NavigationPolygonEditor::forward_gui_input(const Ref<InputEvent> &p_event) continue; //not valid to reuse point real_t d = cp.distance_to(gpoint); - if (d < closest_dist && d < grab_treshold) { + if (d < closest_dist && d < grab_threshold) { closest_dist = d; closest_outline = j; closest_pos = cp; @@ -252,7 +252,7 @@ bool NavigationPolygonEditor::forward_gui_input(const Ref<InputEvent> &p_event) Vector2 cp = xform.xform(poly[i]); real_t d = cp.distance_to(gpoint); - if (d < closest_dist && d < grab_treshold) { + if (d < closest_dist && d < grab_threshold) { closest_dist = d; closest_pos = cp; closest_outline = j; @@ -312,7 +312,7 @@ bool NavigationPolygonEditor::forward_gui_input(const Ref<InputEvent> &p_event) Vector2 cp = xform.xform(poly[i]); real_t d = cp.distance_to(gpoint); - if (d < closest_dist && d < grab_treshold) { + if (d < closest_dist && d < grab_threshold) { closest_dist = d; closest_pos = cp; closest_outline = j; diff --git a/editor/plugins/polygon_2d_editor_plugin.cpp b/editor/plugins/polygon_2d_editor_plugin.cpp index dd13ca0e63..24ccdcd445 100644 --- a/editor/plugins/polygon_2d_editor_plugin.cpp +++ b/editor/plugins/polygon_2d_editor_plugin.cpp @@ -220,7 +220,7 @@ bool Polygon2DEditor::forward_gui_input(const Ref<InputEvent> &p_event) { Vector<Vector2> poly = Variant(node->get_polygon()); //first check if a point is to be added (segment split) - real_t grab_treshold = EDITOR_DEF("editors/poly_editor/point_grab_radius", 8); + real_t grab_threshold = EDITOR_DEF("editors/poly_editor/point_grab_radius", 8); switch (mode) { @@ -239,7 +239,7 @@ bool Polygon2DEditor::forward_gui_input(const Ref<InputEvent> &p_event) { return true; } else { - if (wip.size() > 1 && xform.xform(wip[0] + node->get_offset()).distance_to(gpoint) < grab_treshold) { + if (wip.size() > 1 && xform.xform(wip[0] + node->get_offset()).distance_to(gpoint) < grab_threshold) { //wip closed _wip_close(); @@ -293,7 +293,7 @@ bool Polygon2DEditor::forward_gui_input(const Ref<InputEvent> &p_event) { continue; //not valid to reuse point real_t d = cp.distance_to(gpoint); - if (d < closest_dist && d < grab_treshold) { + if (d < closest_dist && d < grab_threshold) { closest_dist = d; closest_pos = cp; closest_idx = i; @@ -322,7 +322,7 @@ bool Polygon2DEditor::forward_gui_input(const Ref<InputEvent> &p_event) { Vector2 cp = xform.xform(poly[i] + node->get_offset()); real_t d = cp.distance_to(gpoint); - if (d < closest_dist && d < grab_treshold) { + if (d < closest_dist && d < grab_threshold) { closest_dist = d; closest_pos = cp; closest_idx = i; @@ -367,7 +367,7 @@ bool Polygon2DEditor::forward_gui_input(const Ref<InputEvent> &p_event) { Vector2 cp = xform.xform(poly[i] + node->get_offset()); real_t d = cp.distance_to(gpoint); - if (d < closest_dist && d < grab_treshold) { + if (d < closest_dist && d < grab_threshold) { closest_dist = d; closest_pos = cp; closest_idx = i; diff --git a/editor/plugins/script_editor_plugin.cpp b/editor/plugins/script_editor_plugin.cpp index aedc96d20e..dc2eddda39 100644 --- a/editor/plugins/script_editor_plugin.cpp +++ b/editor/plugins/script_editor_plugin.cpp @@ -876,6 +876,9 @@ void ScriptEditor::_menu_option(int p_option) { bool debug_with_external_editor = !debug_menu->get_popup()->is_item_checked(debug_menu->get_popup()->get_item_index(DEBUG_WITH_EXTERNAL_EDITOR)); debugger->set_debug_with_external_editor(debug_with_external_editor); debug_menu->get_popup()->set_item_checked(debug_menu->get_popup()->get_item_index(DEBUG_WITH_EXTERNAL_EDITOR), debug_with_external_editor); + } break; + case TOGGLE_SCRIPTS_PANEL: { + list_split->set_visible(!list_split->is_visible()); } } @@ -2235,6 +2238,8 @@ ScriptEditor::ScriptEditor(EditorNode *p_editor) { file_menu->get_popup()->add_shortcut(ED_SHORTCUT("script_editor/close_docs", TTR("Close Docs")), CLOSE_DOCS); file_menu->get_popup()->add_shortcut(ED_SHORTCUT("script_editor/close_file", TTR("Close"), KEY_MASK_CMD | KEY_W), FILE_CLOSE); file_menu->get_popup()->add_shortcut(ED_SHORTCUT("script_editor/close_all", TTR("Close All")), CLOSE_ALL); + file_menu->get_popup()->add_separator(); + file_menu->get_popup()->add_shortcut(ED_SHORTCUT("script_editor/toggle_scripts_panel", TTR("Toggle Scripts Panel"), KEY_MASK_CMD | KEY_BACKSLASH), TOGGLE_SCRIPTS_PANEL); file_menu->get_popup()->connect("id_pressed", this, "_menu_option"); script_search_menu = memnew(MenuButton); diff --git a/editor/plugins/script_editor_plugin.h b/editor/plugins/script_editor_plugin.h index da8248a1a7..7f17365931 100644 --- a/editor/plugins/script_editor_plugin.h +++ b/editor/plugins/script_editor_plugin.h @@ -134,6 +134,7 @@ class ScriptEditor : public VBoxContainer { FILE_CLOSE, CLOSE_DOCS, CLOSE_ALL, + TOGGLE_SCRIPTS_PANEL, FILE_TOOL_RELOAD, FILE_TOOL_RELOAD_SOFT, DEBUG_NEXT, diff --git a/editor/property_editor.cpp b/editor/property_editor.cpp index ad9b3607e9..8a9fd2cde5 100644 --- a/editor/property_editor.cpp +++ b/editor/property_editor.cpp @@ -4462,7 +4462,7 @@ class SectionedPropertyEditorFilter : public Object { continue; if (sp == -1) { - pi.name = "Global/" + pi.name; + pi.name = "global/" + pi.name; } if (pi.name.begins_with(section + "/")) { diff --git a/platform/iphone/export/export.cpp b/platform/iphone/export/export.cpp index ec8470518a..0960ec8791 100644 --- a/platform/iphone/export/export.cpp +++ b/platform/iphone/export/export.cpp @@ -260,10 +260,12 @@ Error EditorExportPlatformIOS::export_project(const Ref<EditorExportPreset> &p_p f->close(); memdelete(f); +#ifdef OSX_ENABLED if (is_execute) { // we need execute rights on this file chmod(file.utf8().get_data(), 0755); } +#endif } ret = unzGoToNextFile(src_pkg_zip); diff --git a/platform/windows/os_windows.cpp b/platform/windows/os_windows.cpp index e94529dd94..2daf580c0d 100644 --- a/platform/windows/os_windows.cpp +++ b/platform/windows/os_windows.cpp @@ -1410,28 +1410,21 @@ void OS_Windows::set_window_size(const Size2 p_size) { return; } - RECT crect; - GetClientRect(hWnd, &crect); + int w = p_size.width; + int h = p_size.height; RECT rect; GetWindowRect(hWnd, &rect); - int dx = (rect.right - rect.left) - (crect.right - crect.left); - int dy = (rect.bottom - rect.top) - (crect.bottom - crect.top); - rect.right = rect.left + p_size.width + dx; - rect.bottom = rect.top + p_size.height + dy; + if (video_mode.borderless_window == false) { + RECT crect; + GetClientRect(hWnd, &crect); - //print_line("PRE: "+itos(rect.left)+","+itos(rect.top)+","+itos(rect.right-rect.left)+","+itos(rect.bottom-rect.top)); - - /*if (video_mode.resizable) { - AdjustWindowRect(&rect, WS_OVERLAPPEDWINDOW, FALSE); - } else { - AdjustWindowRect(&rect, WS_CAPTION | WS_POPUPWINDOW, FALSE); - }*/ - - //print_line("POST: "+itos(rect.left)+","+itos(rect.top)+","+itos(rect.right-rect.left)+","+itos(rect.bottom-rect.top)); + w += (rect.right - rect.left) - (crect.right - crect.left); + h += (rect.bottom - rect.top) - (crect.bottom - crect.top); + } - MoveWindow(hWnd, rect.left, rect.top, rect.right - rect.left, rect.bottom - rect.top, TRUE); + MoveWindow(hWnd, rect.left, rect.top, w, h, TRUE); } void OS_Windows::set_window_fullscreen(bool p_enabled) { @@ -1451,21 +1444,18 @@ void OS_Windows::set_window_fullscreen(bool p_enabled) { Point2 pos = get_screen_position(cs); Size2 size = get_screen_size(cs); - /* r.left = pos.x; - r.top = pos.y; - r.bottom = pos.y+size.y; - r.right = pos.x+size.x; -*/ - SetWindowLongPtr(hWnd, GWL_STYLE, - WS_SYSMENU | WS_POPUP | WS_CLIPCHILDREN | WS_CLIPSIBLINGS | WS_VISIBLE); - MoveWindow(hWnd, pos.x, pos.y, size.width, size.height, TRUE); - video_mode.fullscreen = true; + _update_window_style(false); + + MoveWindow(hWnd, pos.x, pos.y, size.width, size.height, TRUE); + } else { RECT rect; + video_mode.fullscreen = false; + if (pre_fs_valid) { rect = pre_fs_rect; } else { @@ -1475,35 +1465,12 @@ void OS_Windows::set_window_fullscreen(bool p_enabled) { rect.bottom = video_mode.height; } - if (video_mode.resizable) { - - SetWindowLongPtr(hWnd, GWL_STYLE, WS_OVERLAPPEDWINDOW | WS_VISIBLE); - //AdjustWindowRect(&rect, WS_OVERLAPPEDWINDOW, FALSE); - MoveWindow(hWnd, rect.left, rect.top, rect.right - rect.left, rect.bottom - rect.top, TRUE); - } else { + _update_window_style(false); - SetWindowLongPtr(hWnd, GWL_STYLE, WS_CAPTION | WS_POPUPWINDOW | WS_VISIBLE); - //AdjustWindowRect(&rect, WS_CAPTION | WS_POPUPWINDOW, FALSE); - MoveWindow(hWnd, rect.left, rect.top, rect.right - rect.left, rect.bottom - rect.top, TRUE); - } + MoveWindow(hWnd, rect.left, rect.top, rect.right - rect.left, rect.bottom - rect.top, TRUE); - video_mode.fullscreen = false; pre_fs_valid = true; - /* - DWORD dwExStyle=WS_EX_APPWINDOW | WS_EX_WINDOWEDGE; - DWORD dwStyle=WS_OVERLAPPEDWINDOW; - if (!video_mode.resizable) { - dwStyle &= ~WS_THICKFRAME; - dwStyle &= ~WS_MAXIMIZEBOX; - } - AdjustWindowRectEx(&pre_fs_rect, dwStyle, FALSE, dwExStyle); - video_mode.fullscreen=false; - video_mode.width=pre_fs_rect.right-pre_fs_rect.left; - video_mode.height=pre_fs_rect.bottom-pre_fs_rect.top; -*/ } - - //MoveWindow(hWnd,r.left,r.top,p_size.x,p_size.y,TRUE); } bool OS_Windows::is_window_fullscreen() const { @@ -1513,30 +1480,10 @@ void OS_Windows::set_window_resizable(bool p_enabled) { if (video_mode.resizable == p_enabled) return; - /* - GetWindowRect(hWnd,&pre_fs_rect); - DWORD dwExStyle=WS_EX_APPWINDOW | WS_EX_WINDOWEDGE; - DWORD dwStyle=WS_OVERLAPPEDWINDOW; - if (!p_enabled) { - dwStyle &= ~WS_THICKFRAME; - dwStyle &= ~WS_MAXIMIZEBOX; - } - AdjustWindowRectEx(&pre_fs_rect, dwStyle, FALSE, dwExStyle); - */ - - if (!video_mode.fullscreen) { - if (p_enabled) { - SetWindowLongPtr(hWnd, GWL_STYLE, WS_OVERLAPPEDWINDOW | WS_VISIBLE); - } else { - SetWindowLongPtr(hWnd, GWL_STYLE, WS_CAPTION | WS_MINIMIZEBOX | WS_POPUPWINDOW | WS_VISIBLE); - } - - RECT rect; - GetWindowRect(hWnd, &rect); - MoveWindow(hWnd, rect.left, rect.top, rect.right - rect.left, rect.bottom - rect.top, TRUE); - } video_mode.resizable = p_enabled; + + _update_window_style(); } bool OS_Windows::is_window_resizable() const { @@ -1576,13 +1523,36 @@ bool OS_Windows::is_window_maximized() const { } void OS_Windows::set_borderless_window(int p_borderless) { + if (video_mode.borderless_window == p_borderless) + return; + video_mode.borderless_window = p_borderless; + + _update_window_style(); } bool OS_Windows::get_borderless_window() { return video_mode.borderless_window; } +void OS_Windows::_update_window_style(bool repaint) { + if (video_mode.fullscreen || video_mode.borderless_window) { + SetWindowLongPtr(hWnd, GWL_STYLE, WS_SYSMENU | WS_POPUP | WS_CLIPCHILDREN | WS_CLIPSIBLINGS | WS_VISIBLE); + } else { + if (video_mode.resizable) { + SetWindowLongPtr(hWnd, GWL_STYLE, WS_OVERLAPPEDWINDOW | WS_VISIBLE); + } else { + SetWindowLongPtr(hWnd, GWL_STYLE, WS_CAPTION | WS_MINIMIZEBOX | WS_POPUPWINDOW | WS_VISIBLE); + } + } + + if (repaint) { + RECT rect; + GetWindowRect(hWnd, &rect); + MoveWindow(hWnd, rect.left, rect.top, rect.right - rect.left, rect.bottom - rect.top, TRUE); + } +} + Error OS_Windows::open_dynamic_library(const String p_path, void *&p_library_handle) { p_library_handle = (void *)LoadLibrary(p_path.utf8().get_data()); if (!p_library_handle) { diff --git a/platform/windows/os_windows.h b/platform/windows/os_windows.h index 6cbdd58830..835141145f 100644 --- a/platform/windows/os_windows.h +++ b/platform/windows/os_windows.h @@ -133,6 +133,8 @@ class OS_Windows : public OS { void _drag_event(int p_x, int p_y, int idx); void _touch_event(bool p_pressed, int p_x, int p_y, int idx); + void _update_window_style(bool repaint = true); + // functions used by main to initialize/deintialize the OS protected: virtual int get_video_driver_count() const; diff --git a/platform/x11/os_x11.cpp b/platform/x11/os_x11.cpp index f2754cc180..790182794e 100644 --- a/platform/x11/os_x11.cpp +++ b/platform/x11/os_x11.cpp @@ -1260,7 +1260,7 @@ void OS_X11::handle_key_event(XKeyEvent *p_event, bool p_echo) { // Echo characters in X11 are a keyrelease and a keypress // one after the other with the (almot) same timestamp. // To detect them, i use XPeekEvent and check that their - // difference in time is below a treshold. + // difference in time is below a threshold. if (xkeyevent->type != KeyPress) { @@ -1272,7 +1272,7 @@ void OS_X11::handle_key_event(XKeyEvent *p_event, bool p_echo) { XEvent peek_event; XPeekEvent(x11_display, &peek_event); - // I'm using a treshold of 5 msecs, + // I'm using a threshold of 5 msecs, // since sometimes there seems to be a little // jitter. I'm still not convinced that all this approach // is correct, but the xorg developers are diff --git a/scene/2d/area_2d.cpp b/scene/2d/area_2d.cpp index db22a38cec..841e2ef7d3 100644 --- a/scene/2d/area_2d.cpp +++ b/scene/2d/area_2d.cpp @@ -331,7 +331,10 @@ void Area2D::_clear_monitoring() { Object *obj = ObjectDB::get_instance(E->key()); Node *node = obj ? obj->cast_to<Node>() : NULL; - ERR_CONTINUE(!node); + + if (!node) //node may have been deleted in previous frame or at other legiminate point + continue; + //ERR_CONTINUE(!node); node->disconnect(SceneStringNames::get_singleton()->tree_entered, this, SceneStringNames::get_singleton()->_body_enter_tree); node->disconnect(SceneStringNames::get_singleton()->tree_exited, this, SceneStringNames::get_singleton()->_body_exit_tree); @@ -359,7 +362,7 @@ void Area2D::_clear_monitoring() { Object *obj = ObjectDB::get_instance(E->key()); Node *node = obj ? obj->cast_to<Node>() : NULL; - if (!node) //node may have been deleted in previous frame, this should not be an error + if (!node) //node may have been deleted in previous frame or at other legiminate point continue; //ERR_CONTINUE(!node); diff --git a/scene/3d/area.cpp b/scene/3d/area.cpp index 39a4e926b2..c62a866d8d 100644 --- a/scene/3d/area.cpp +++ b/scene/3d/area.cpp @@ -227,7 +227,11 @@ void Area::_clear_monitoring() { Object *obj = ObjectDB::get_instance(E->key()); Node *node = obj ? obj->cast_to<Node>() : NULL; - ERR_CONTINUE(!node); + + if (!node) //node may have been deleted in previous frame or at other legiminate point + continue; + //ERR_CONTINUE(!node); + if (!E->get().in_tree) continue; @@ -253,7 +257,11 @@ void Area::_clear_monitoring() { Object *obj = ObjectDB::get_instance(E->key()); Node *node = obj ? obj->cast_to<Node>() : NULL; - ERR_CONTINUE(!node); + + if (!node) //node may have been deleted in previous frame or at other legiminate point + continue; + //ERR_CONTINUE(!node); + if (!E->get().in_tree) continue; diff --git a/scene/gui/rich_text_label.cpp b/scene/gui/rich_text_label.cpp index 78ede6e494..c6b8398736 100644 --- a/scene/gui/rich_text_label.cpp +++ b/scene/gui/rich_text_label.cpp @@ -1822,12 +1822,37 @@ String RichTextLabel::get_text() { return text; } +void RichTextLabel::set_text(const String &p_string) { + clear(); + add_text(p_string); +} + +void RichTextLabel::set_percent_visible(float p_percent) { + + if (p_percent < 0 || p_percent >= 1) { + + visible_characters = -1; + percent_visible = 1; + + } else { + + visible_characters = get_total_character_count() * p_percent; + percent_visible = p_percent; + } + update(); +} + +float RichTextLabel::get_percent_visible() const { + return percent_visible; +} + void RichTextLabel::_bind_methods() { ClassDB::bind_method(D_METHOD("_gui_input"), &RichTextLabel::_gui_input); ClassDB::bind_method(D_METHOD("_scroll_changed"), &RichTextLabel::_scroll_changed); ClassDB::bind_method(D_METHOD("get_text"), &RichTextLabel::get_text); ClassDB::bind_method(D_METHOD("add_text", "text"), &RichTextLabel::add_text); + ClassDB::bind_method(D_METHOD("set_text", "text"), &RichTextLabel::set_text); ClassDB::bind_method(D_METHOD("add_image", "image:Texture"), &RichTextLabel::add_image); ClassDB::bind_method(D_METHOD("newline"), &RichTextLabel::add_newline); ClassDB::bind_method(D_METHOD("remove_line"), &RichTextLabel::remove_line); @@ -1873,6 +1898,9 @@ void RichTextLabel::_bind_methods() { ClassDB::bind_method(D_METHOD("set_visible_characters", "amount"), &RichTextLabel::set_visible_characters); ClassDB::bind_method(D_METHOD("get_visible_characters"), &RichTextLabel::get_visible_characters); + ClassDB::bind_method(D_METHOD("set_percent_visible", "percent_visible"), &RichTextLabel::set_percent_visible); + ClassDB::bind_method(D_METHOD("get_percent_visible"), &RichTextLabel::get_percent_visible); + ClassDB::bind_method(D_METHOD("get_total_character_count"), &RichTextLabel::get_total_character_count); ClassDB::bind_method(D_METHOD("set_use_bbcode", "enable"), &RichTextLabel::set_use_bbcode); @@ -1881,7 +1909,9 @@ void RichTextLabel::_bind_methods() { ADD_GROUP("BBCode", "bbcode_"); ADD_PROPERTY(PropertyInfo(Variant::BOOL, "bbcode_enabled"), "set_use_bbcode", "is_using_bbcode"); ADD_PROPERTY(PropertyInfo(Variant::STRING, "bbcode_text", PROPERTY_HINT_MULTILINE_TEXT), "set_bbcode", "get_bbcode"); + ADD_PROPERTY(PropertyInfo(Variant::INT, "visible_characters", PROPERTY_HINT_RANGE, "-1,128000,1"), "set_visible_characters", "get_visible_characters"); + ADD_PROPERTY(PropertyInfo(Variant::REAL, "percent_visible", PROPERTY_HINT_RANGE, "0,1,0.001"), "set_percent_visible", "get_percent_visible"); ADD_SIGNAL(MethodInfo("meta_clicked", PropertyInfo(Variant::NIL, "meta"))); @@ -1914,7 +1944,6 @@ void RichTextLabel::set_visible_characters(int p_visible) { } int RichTextLabel::get_visible_characters() const { - return visible_characters; } int RichTextLabel::get_total_character_count() const { @@ -1964,11 +1993,11 @@ RichTextLabel::RichTextLabel() { selection.enabled = false; visible_characters = -1; + percent_visible = 1; set_clip_contents(true); } RichTextLabel::~RichTextLabel() { - memdelete(main); } diff --git a/scene/gui/rich_text_label.h b/scene/gui/rich_text_label.h index eedb7e54db..409a8f6b3f 100644 --- a/scene/gui/rich_text_label.h +++ b/scene/gui/rich_text_label.h @@ -258,6 +258,7 @@ private: Selection selection; int visible_characters; + float percent_visible; void _process_line(ItemFrame *p_frame, const Vector2 &p_ofs, int &y, int p_width, int p_line, ProcessMode p_mode, const Ref<Font> &p_base_font, const Color &p_base_color, const Point2i &p_click_pos = Point2i(), Item **r_click_item = NULL, int *r_click_char = NULL, bool *r_outside = NULL, int p_char_count = 0); void _find_click(ItemFrame *p_frame, const Point2i &p_click, Item **r_click_item = NULL, int *r_click_char = NULL, bool *r_outside = NULL); @@ -340,10 +341,15 @@ public: void set_bbcode(const String &p_bbcode); String get_bbcode() const; + void set_text(const String &p_string); + void set_visible_characters(int p_visible); int get_visible_characters() const; int get_total_character_count() const; + void set_percent_visible(float p_percent); + float get_percent_visible() const; + RichTextLabel(); ~RichTextLabel(); }; diff --git a/scene/main/viewport.cpp b/scene/main/viewport.cpp index 3a9968d126..4fb4e02148 100644 --- a/scene/main/viewport.cpp +++ b/scene/main/viewport.cpp @@ -2352,7 +2352,7 @@ void Viewport::unhandled_input(const Ref<InputEvent> &p_event) { if (physics_object_picking && !get_tree()->input_handled) { - if (p_event->cast_to<InputEventMouseButton>() || p_event->cast_to<InputEventMouseMotion>() || p_event->cast_to<InputEventScreenDrag>() || p_event->cast_to<InputEventScreenTouch>()) { + if (Input::get_singleton()->get_mouse_mode() != Input::MOUSE_MODE_CAPTURED && (p_event->cast_to<InputEventMouseButton>() || p_event->cast_to<InputEventMouseMotion>() || p_event->cast_to<InputEventScreenDrag>() || p_event->cast_to<InputEventScreenTouch>())) { physics_picking_events.push_back(p_event); } } diff --git a/scene/resources/environment.cpp b/scene/resources/environment.cpp index b9dc428c2d..33e62e3a00 100644 --- a/scene/resources/environment.cpp +++ b/scene/resources/environment.cpp @@ -471,7 +471,7 @@ bool Environment::is_ssao_blur_enabled() const { void Environment::set_glow_enabled(bool p_enabled) { glow_enabled = p_enabled; - VS::get_singleton()->environment_set_glow(environment, glow_enabled, glow_levels, glow_intensity, glow_strength, glow_bloom, VS::EnvironmentGlowBlendMode(glow_blend_mode), glow_hdr_bleed_treshold, glow_hdr_bleed_treshold, glow_bicubic_upscale); + VS::get_singleton()->environment_set_glow(environment, glow_enabled, glow_levels, glow_intensity, glow_strength, glow_bloom, VS::EnvironmentGlowBlendMode(glow_blend_mode), glow_hdr_bleed_threshold, glow_hdr_bleed_threshold, glow_bicubic_upscale); _change_notify(); } @@ -489,7 +489,7 @@ void Environment::set_glow_level(int p_level, bool p_enabled) { else glow_levels &= ~(1 << p_level); - VS::get_singleton()->environment_set_glow(environment, glow_enabled, glow_levels, glow_intensity, glow_strength, glow_bloom, VS::EnvironmentGlowBlendMode(glow_blend_mode), glow_hdr_bleed_treshold, glow_hdr_bleed_treshold, glow_bicubic_upscale); + VS::get_singleton()->environment_set_glow(environment, glow_enabled, glow_levels, glow_intensity, glow_strength, glow_bloom, VS::EnvironmentGlowBlendMode(glow_blend_mode), glow_hdr_bleed_threshold, glow_hdr_bleed_threshold, glow_bicubic_upscale); } bool Environment::is_glow_level_enabled(int p_level) const { @@ -502,7 +502,7 @@ void Environment::set_glow_intensity(float p_intensity) { glow_intensity = p_intensity; - VS::get_singleton()->environment_set_glow(environment, glow_enabled, glow_levels, glow_intensity, glow_strength, glow_bloom, VS::EnvironmentGlowBlendMode(glow_blend_mode), glow_hdr_bleed_treshold, glow_hdr_bleed_treshold, glow_bicubic_upscale); + VS::get_singleton()->environment_set_glow(environment, glow_enabled, glow_levels, glow_intensity, glow_strength, glow_bloom, VS::EnvironmentGlowBlendMode(glow_blend_mode), glow_hdr_bleed_threshold, glow_hdr_bleed_threshold, glow_bicubic_upscale); } float Environment::get_glow_intensity() const { @@ -512,18 +512,18 @@ float Environment::get_glow_intensity() const { void Environment::set_glow_strength(float p_strength) { glow_strength = p_strength; - VS::get_singleton()->environment_set_glow(environment, glow_enabled, glow_levels, glow_intensity, glow_strength, glow_bloom, VS::EnvironmentGlowBlendMode(glow_blend_mode), glow_hdr_bleed_treshold, glow_hdr_bleed_treshold, glow_bicubic_upscale); + VS::get_singleton()->environment_set_glow(environment, glow_enabled, glow_levels, glow_intensity, glow_strength, glow_bloom, VS::EnvironmentGlowBlendMode(glow_blend_mode), glow_hdr_bleed_threshold, glow_hdr_bleed_threshold, glow_bicubic_upscale); } float Environment::get_glow_strength() const { return glow_strength; } -void Environment::set_glow_bloom(float p_treshold) { +void Environment::set_glow_bloom(float p_threshold) { - glow_bloom = p_treshold; + glow_bloom = p_threshold; - VS::get_singleton()->environment_set_glow(environment, glow_enabled, glow_levels, glow_intensity, glow_strength, glow_bloom, VS::EnvironmentGlowBlendMode(glow_blend_mode), glow_hdr_bleed_treshold, glow_hdr_bleed_treshold, glow_bicubic_upscale); + VS::get_singleton()->environment_set_glow(environment, glow_enabled, glow_levels, glow_intensity, glow_strength, glow_bloom, VS::EnvironmentGlowBlendMode(glow_blend_mode), glow_hdr_bleed_threshold, glow_hdr_bleed_threshold, glow_bicubic_upscale); } float Environment::get_glow_bloom() const { @@ -534,29 +534,29 @@ void Environment::set_glow_blend_mode(GlowBlendMode p_mode) { glow_blend_mode = p_mode; - VS::get_singleton()->environment_set_glow(environment, glow_enabled, glow_levels, glow_intensity, glow_strength, glow_bloom, VS::EnvironmentGlowBlendMode(glow_blend_mode), glow_hdr_bleed_treshold, glow_hdr_bleed_treshold, glow_bicubic_upscale); + VS::get_singleton()->environment_set_glow(environment, glow_enabled, glow_levels, glow_intensity, glow_strength, glow_bloom, VS::EnvironmentGlowBlendMode(glow_blend_mode), glow_hdr_bleed_threshold, glow_hdr_bleed_threshold, glow_bicubic_upscale); } Environment::GlowBlendMode Environment::get_glow_blend_mode() const { return glow_blend_mode; } -void Environment::set_glow_hdr_bleed_treshold(float p_treshold) { +void Environment::set_glow_hdr_bleed_threshold(float p_threshold) { - glow_hdr_bleed_treshold = p_treshold; + glow_hdr_bleed_threshold = p_threshold; - VS::get_singleton()->environment_set_glow(environment, glow_enabled, glow_levels, glow_intensity, glow_strength, glow_bloom, VS::EnvironmentGlowBlendMode(glow_blend_mode), glow_hdr_bleed_treshold, glow_hdr_bleed_treshold, glow_bicubic_upscale); + VS::get_singleton()->environment_set_glow(environment, glow_enabled, glow_levels, glow_intensity, glow_strength, glow_bloom, VS::EnvironmentGlowBlendMode(glow_blend_mode), glow_hdr_bleed_threshold, glow_hdr_bleed_threshold, glow_bicubic_upscale); } -float Environment::get_glow_hdr_bleed_treshold() const { +float Environment::get_glow_hdr_bleed_threshold() const { - return glow_hdr_bleed_treshold; + return glow_hdr_bleed_threshold; } void Environment::set_glow_hdr_bleed_scale(float p_scale) { glow_hdr_bleed_scale = p_scale; - VS::get_singleton()->environment_set_glow(environment, glow_enabled, glow_levels, glow_intensity, glow_strength, glow_bloom, VS::EnvironmentGlowBlendMode(glow_blend_mode), glow_hdr_bleed_treshold, glow_hdr_bleed_treshold, glow_bicubic_upscale); + VS::get_singleton()->environment_set_glow(environment, glow_enabled, glow_levels, glow_intensity, glow_strength, glow_bloom, VS::EnvironmentGlowBlendMode(glow_blend_mode), glow_hdr_bleed_threshold, glow_hdr_bleed_threshold, glow_bicubic_upscale); } float Environment::get_glow_hdr_bleed_scale() const { @@ -566,7 +566,7 @@ float Environment::get_glow_hdr_bleed_scale() const { void Environment::set_glow_bicubic_upscale(bool p_enable) { glow_bicubic_upscale = p_enable; - VS::get_singleton()->environment_set_glow(environment, glow_enabled, glow_levels, glow_intensity, glow_strength, glow_bloom, VS::EnvironmentGlowBlendMode(glow_blend_mode), glow_hdr_bleed_treshold, glow_hdr_bleed_treshold, glow_bicubic_upscale); + VS::get_singleton()->environment_set_glow(environment, glow_enabled, glow_levels, glow_intensity, glow_strength, glow_bloom, VS::EnvironmentGlowBlendMode(glow_blend_mode), glow_hdr_bleed_threshold, glow_hdr_bleed_threshold, glow_bicubic_upscale); } bool Environment::is_glow_bicubic_upscale_enabled() const { @@ -1064,8 +1064,8 @@ void Environment::_bind_methods() { ClassDB::bind_method(D_METHOD("set_glow_blend_mode", "mode"), &Environment::set_glow_blend_mode); ClassDB::bind_method(D_METHOD("get_glow_blend_mode"), &Environment::get_glow_blend_mode); - ClassDB::bind_method(D_METHOD("set_glow_hdr_bleed_treshold", "treshold"), &Environment::set_glow_hdr_bleed_treshold); - ClassDB::bind_method(D_METHOD("get_glow_hdr_bleed_treshold"), &Environment::get_glow_hdr_bleed_treshold); + ClassDB::bind_method(D_METHOD("set_glow_hdr_bleed_threshold", "threshold"), &Environment::set_glow_hdr_bleed_threshold); + ClassDB::bind_method(D_METHOD("get_glow_hdr_bleed_threshold"), &Environment::get_glow_hdr_bleed_threshold); ClassDB::bind_method(D_METHOD("set_glow_hdr_bleed_scale", "scale"), &Environment::set_glow_hdr_bleed_scale); ClassDB::bind_method(D_METHOD("get_glow_hdr_bleed_scale"), &Environment::get_glow_hdr_bleed_scale); @@ -1087,7 +1087,7 @@ void Environment::_bind_methods() { ADD_PROPERTY(PropertyInfo(Variant::REAL, "glow_strength", PROPERTY_HINT_RANGE, "0.0,2.0,0.01"), "set_glow_strength", "get_glow_strength"); ADD_PROPERTY(PropertyInfo(Variant::REAL, "glow_bloom", PROPERTY_HINT_RANGE, "0.0,1.0,0.01"), "set_glow_bloom", "get_glow_bloom"); ADD_PROPERTY(PropertyInfo(Variant::INT, "glow_blend_mode", PROPERTY_HINT_ENUM, "Additive,Screen,Softlight,Replace"), "set_glow_blend_mode", "get_glow_blend_mode"); - ADD_PROPERTY(PropertyInfo(Variant::REAL, "glow_hdr_treshold", PROPERTY_HINT_RANGE, "0.0,4.0,0.01"), "set_glow_hdr_bleed_treshold", "get_glow_hdr_bleed_treshold"); + ADD_PROPERTY(PropertyInfo(Variant::REAL, "glow_hdr_threshold", PROPERTY_HINT_RANGE, "0.0,4.0,0.01"), "set_glow_hdr_bleed_threshold", "get_glow_hdr_bleed_threshold"); ADD_PROPERTY(PropertyInfo(Variant::REAL, "glow_hdr_scale", PROPERTY_HINT_RANGE, "0.0,4.0,0.01"), "set_glow_hdr_bleed_scale", "get_glow_hdr_bleed_scale"); ADD_PROPERTY(PropertyInfo(Variant::BOOL, "glow_bicubic_upscale"), "set_glow_bicubic_upscale", "is_glow_bicubic_upscale_enabled"); @@ -1185,7 +1185,7 @@ Environment::Environment() { glow_strength = 1.0; glow_bloom = 0.0; glow_blend_mode = GLOW_BLEND_MODE_SOFTLIGHT; - glow_hdr_bleed_treshold = 1.0; + glow_hdr_bleed_threshold = 1.0; glow_hdr_bleed_scale = 2.0; glow_bicubic_upscale = false; diff --git a/scene/resources/environment.h b/scene/resources/environment.h index 7eda8506b5..a7c0e2a03d 100644 --- a/scene/resources/environment.h +++ b/scene/resources/environment.h @@ -121,7 +121,7 @@ private: float glow_strength; float glow_bloom; GlowBlendMode glow_blend_mode; - float glow_hdr_bleed_treshold; + float glow_hdr_bleed_threshold; float glow_hdr_bleed_scale; bool glow_bicubic_upscale; @@ -275,14 +275,14 @@ public: void set_glow_strength(float p_strength); float get_glow_strength() const; - void set_glow_bloom(float p_treshold); + void set_glow_bloom(float p_threshold); float get_glow_bloom() const; void set_glow_blend_mode(GlowBlendMode p_mode); GlowBlendMode get_glow_blend_mode() const; - void set_glow_hdr_bleed_treshold(float p_treshold); - float get_glow_hdr_bleed_treshold() const; + void set_glow_hdr_bleed_threshold(float p_threshold); + float get_glow_hdr_bleed_threshold() const; void set_glow_hdr_bleed_scale(float p_scale); float get_glow_hdr_bleed_scale() const; diff --git a/scene/resources/material.cpp b/scene/resources/material.cpp index 6209f99d9d..705702b8be 100644 --- a/scene/resources/material.cpp +++ b/scene/resources/material.cpp @@ -30,11 +30,36 @@ #include "material.h" #include "scene/scene_string_names.h" +void Material::set_next_pass(const Ref<Material> &p_pass) { + + if (next_pass == p_pass) + return; + + next_pass = p_pass; + RID next_pass_rid; + if (next_pass.is_valid()) + next_pass_rid = next_pass->get_rid(); + VS::get_singleton()->material_set_next_pass(material, next_pass_rid); +} + +Ref<Material> Material::get_next_pass() const { + + return next_pass; +} + RID Material::get_rid() const { return material; } +void Material::_bind_methods() { + + ClassDB::bind_method(D_METHOD("set_next_pass", "next_pass:Material"), &Material::set_next_pass); + ClassDB::bind_method(D_METHOD("get_next_pass:Material"), &Material::get_next_pass); + + ADD_PROPERTY(PropertyInfo(Variant::OBJECT, "next_pass", PROPERTY_HINT_RESOURCE_TYPE, "Material"), "set_next_pass", "get_next_pass"); +} + Material::Material() { material = VisualServer::get_singleton()->material_create(); @@ -198,6 +223,8 @@ void SpatialMaterial::init_shaders() { shader_names->uv1_offset = "uv1_offset"; shader_names->uv2_scale = "uv2_scale"; shader_names->uv2_offset = "uv2_offset"; + shader_names->uv1_blend_sharpness = "uv1_blend_sharpness"; + shader_names->uv2_blend_sharpness = "uv2_blend_sharpness"; shader_names->particle_h_frames = "particle_h_frames"; shader_names->particle_v_frames = "particle_v_frames"; @@ -205,6 +232,8 @@ void SpatialMaterial::init_shaders() { shader_names->depth_min_layers = "depth_min_layers"; shader_names->depth_max_layers = "depth_max_layers"; + shader_names->grow = "grow"; + shader_names->texture_names[TEXTURE_ALBEDO] = "texture_albedo"; shader_names->texture_names[TEXTURE_METALLIC] = "texture_metallic"; shader_names->texture_names[TEXTURE_ROUGHNESS] = "texture_roughness"; @@ -289,6 +318,14 @@ void SpatialMaterial::_update_shader() { case DIFFUSE_HALF_LAMBERT: code += ",diffuse_half_lambert"; break; case DIFFUSE_OREN_NAYAR: code += ",diffuse_oren_nayar"; break; case DIFFUSE_BURLEY: code += ",diffuse_burley"; break; + case DIFFUSE_TOON: code += ",diffuse_toon"; break; + } + switch (specular_mode) { + case SPECULAR_SCHLICK_GGX: code += ",specular_schlick_ggx"; break; + case SPECULAR_BLINN: code += ",specular_blinn"; break; + case SPECULAR_PHONG: code += ",specular_phong"; break; + case SPECULAR_TOON: code += ",specular_toon"; break; + case SPECULAR_DISABLED: code += ",specular_disabled"; break; } if (flags[FLAG_UNSHADED]) { @@ -298,21 +335,23 @@ void SpatialMaterial::_update_shader() { code += ",ontop"; } + if (flags[FLAG_UV1_USE_TRIPLANAR] || flags[FLAG_UV2_USE_TRIPLANAR]) { + code += ",world_vertex_coords"; + } code += ";\n"; code += "uniform vec4 albedo : hint_color;\n"; code += "uniform sampler2D texture_albedo : hint_albedo;\n"; code += "uniform float specular;\n"; code += "uniform float metallic;\n"; + if (grow_enabled) { + code += "uniform float grow;\n"; + } code += "uniform float roughness : hint_range(0,1);\n"; code += "uniform float point_size : hint_range(0,128);\n"; code += "uniform sampler2D texture_metallic : hint_white;\n"; code += "uniform sampler2D texture_roughness : hint_white;\n"; - code += "uniform vec2 uv1_scale;\n"; - code += "uniform vec2 uv1_offset;\n"; - code += "uniform vec2 uv2_scale;\n"; - code += "uniform vec2 uv2_offset;\n"; if (billboard_mode == BILLBOARD_PARTICLES) { code += "uniform int particles_anim_h_frames;\n"; code += "uniform int particles_anim_v_frames;\n"; @@ -371,6 +410,26 @@ void SpatialMaterial::_update_shader() { code += "uniform int depth_min_layers;\n"; code += "uniform int depth_max_layers;\n"; } + if (flags[FLAG_UV1_USE_TRIPLANAR]) { + code += "varying vec3 uv1_world_pos;\n"; + } + if (flags[FLAG_UV2_USE_TRIPLANAR]) { + code += "varying vec3 uv2_world_pos;\n"; + } + if (flags[FLAG_UV1_USE_TRIPLANAR]) { + code += "uniform float uv1_blend_sharpness;\n"; + code += "varying vec3 uv1_power_normal;\n"; + } + + if (flags[FLAG_UV2_USE_TRIPLANAR]) { + code += "uniform float uv2_blend_sharpness;\n"; + code += "varying vec3 uv2_power_normal;\n"; + } + + code += "uniform vec3 uv1_scale;\n"; + code += "uniform vec3 uv1_offset;\n"; + code += "uniform vec3 uv2_scale;\n"; + code += "uniform vec3 uv2_offset;\n"; code += "\n\n"; @@ -384,7 +443,10 @@ void SpatialMaterial::_update_shader() { code += "\tPOINT_SIZE=point_size;\n"; } - code += "\tUV=UV*uv1_scale+uv1_offset;\n"; + + if (!flags[FLAG_UV1_USE_TRIPLANAR]) { + code += "\tUV=UV*uv1_scale.xy+uv1_offset.xy;\n"; + } switch (billboard_mode) { case BILLBOARD_DISABLED: { @@ -414,7 +476,6 @@ void SpatialMaterial::_update_shader() { //code += "\tUV+= UV * vec2(float(particle_frame % particles_anim_h_frames),float(particle_frame / particles_anim_v_frames));\n"; //handle rotation // code += "\tmat4 rotation = mat4(" - } break; } @@ -437,20 +498,65 @@ void SpatialMaterial::_update_shader() { code += "\t}\n"; } - if (detail_uv == DETAIL_UV_2) { + if (detail_uv == DETAIL_UV_2 && !flags[FLAG_UV2_USE_TRIPLANAR]) { code += "\tUV2=UV2*uv2_scale+uv2_offset;\n"; } + if (flags[FLAG_UV1_USE_TRIPLANAR] || flags[FLAG_UV2_USE_TRIPLANAR]) { + //generate tangent and binormal in world space + code += "\tTANGENT = vec3(0.0,0.0,-1.0) * abs(NORMAL.x);\n"; + code += "\tTANGENT+= vec3(1.0,0.0,0.0) * abs(NORMAL.y);\n"; + code += "\tTANGENT+= vec3(1.0,0.0,0.0) * abs(NORMAL.z);\n"; + code += "\tTANGENT = normalize(TANGENT);\n"; + + code += "\tBINORMAL = vec3(0.0,1.0,0.0) * abs(NORMAL.x);\n"; + code += "\tBINORMAL+= vec3(0.0,0.0,-1.0) * abs(NORMAL.y);\n"; + code += "\tBINORMAL+= vec3(0.0,1.0,0.0) * abs(NORMAL.z);\n"; + code += "\tBINORMAL = normalize(BINORMAL);\n"; + } + + if (flags[FLAG_UV1_USE_TRIPLANAR]) { + + code += "\tuv1_power_normal=pow(abs(NORMAL),vec3(uv1_blend_sharpness));\n"; + code += "\tuv1_power_normal/=dot(uv1_power_normal,vec3(1.0));\n"; + code += "\tuv1_world_pos = VERTEX * uv1_scale + uv1_offset;\n"; + code += "\tuv1_world_pos *= vec3(1.0,-1.0, 1.0);\n"; + } + + if (flags[FLAG_UV2_USE_TRIPLANAR]) { + + code += "\tuv2_power_normal=pow(abs(NORMAL), vec3(uv2_blend_sharpness));\n"; + code += "\tuv2_power_normal/=dot(uv2_power_normal,vec3(1.0));\n"; + code += "\tuv2_world_pos = VERTEX * uv2_scale + uv2_offset;\n"; + code += "\tuv2_world_pos *= vec3(1.0,-1.0, 1.0);\n"; + } + + if (grow_enabled) { + code += "\tVERTEX+=NORMAL*grow;\n"; + } code += "}\n"; code += "\n\n"; + if (flags[FLAG_UV1_USE_TRIPLANAR] || flags[FLAG_UV2_USE_TRIPLANAR]) { + code += "vec4 triplanar_texture(sampler2D p_sampler,vec3 p_weights,vec3 p_world_pos) {\n"; + code += "\tvec4 samp=vec4(0.0);\n"; + code += "\tsamp+= texture(p_sampler,p_world_pos.xy) * p_weights.z;\n"; + code += "\tsamp+= texture(p_sampler,p_world_pos.xz) * p_weights.y;\n"; + code += "\tsamp+= texture(p_sampler,p_world_pos.zy * vec2(-1.0,1.0)) * p_weights.x;\n"; + code += "\treturn samp;\n"; + code += "}\n"; + } + code += "\n\n"; code += "void fragment() {\n"; - code += "\tvec2 base_uv = UV;\n"; - if (features[FEATURE_DETAIL] && detail_uv == DETAIL_UV_2) { + if (!flags[FLAG_UV1_USE_TRIPLANAR]) { + code += "\tvec2 base_uv = UV;\n"; + } + + if ((features[FEATURE_DETAIL] && detail_uv == DETAIL_UV_2) || (features[FEATURE_AMBIENT_OCCLUSION] && flags[FLAG_AO_ON_UV2])) { code += "\tvec2 base_uv2 = UV2;\n"; } - if (features[FEATURE_DEPTH_MAPPING]) { + if (features[FEATURE_DEPTH_MAPPING] && !flags[FLAG_UV1_USE_TRIPLANAR]) { //depthmap not supported with triplanar code += "\t{\n"; code += "\t\tvec3 view_dir = normalize(normalize(-VERTEX)*mat3(TANGENT,-BINORMAL,NORMAL));\n"; //binormal is negative due to mikktpsace @@ -490,7 +596,11 @@ void SpatialMaterial::_update_shader() { if (flags[FLAG_USE_POINT_SIZE]) { code += "\tvec4 albedo_tex = texture(texture_albedo,POINT_COORD);\n"; } else { - code += "\tvec4 albedo_tex = texture(texture_albedo,base_uv);\n"; + if (flags[FLAG_UV1_USE_TRIPLANAR]) { + code += "\tvec4 albedo_tex = triplanar_texture(texture_albedo,uv1_power_normal,uv1_world_pos);\n"; + } else { + code += "\tvec4 albedo_tex = texture(texture_albedo,base_uv);\n"; + } } if (flags[FLAG_ALBEDO_FROM_VERTEX_COLOR]) { @@ -498,22 +608,39 @@ void SpatialMaterial::_update_shader() { } code += "\tALBEDO = albedo.rgb * albedo_tex.rgb;\n"; - code += "\tfloat metallic_tex = texture(texture_metallic,base_uv).r;\n"; + if (flags[FLAG_UV1_USE_TRIPLANAR]) { + code += "\tfloat metallic_tex = triplanar_texture(texture_metallic,uv1_power_normal,uv1_world_pos).r;\n"; + } else { + code += "\tfloat metallic_tex = texture(texture_metallic,base_uv).r;\n"; + } code += "\tMETALLIC = metallic_tex * metallic;\n"; - code += "\tfloat roughness_tex = texture(texture_roughness,base_uv).r;\n"; + if (flags[FLAG_UV1_USE_TRIPLANAR]) { + code += "\tfloat roughness_tex = triplanar_texture(texture_roughness,uv1_power_normal,uv1_world_pos).r;\n"; + } else { + code += "\tfloat roughness_tex = texture(texture_roughness,base_uv).r;\n"; + } code += "\tROUGHNESS = roughness_tex * roughness;\n"; code += "\tSPECULAR = specular;\n"; if (features[FEATURE_NORMAL_MAPPING]) { - code += "\tNORMALMAP = texture(texture_normal,base_uv).rgb;\n"; + if (flags[FLAG_UV1_USE_TRIPLANAR]) { + code += "\tNORMALMAP = triplanar_texture(texture_normal,uv1_power_normal,uv1_world_pos).rgb;\n"; + } else { + code += "\tNORMALMAP = texture(texture_normal,base_uv).rgb;\n"; + } code += "\tNORMALMAP_DEPTH = normal_scale;\n"; } if (features[FEATURE_EMISSION]) { - code += "\tEMISSION = (emission.rgb+texture(texture_emission,base_uv).rgb)*emission_energy;\n"; + if (flags[FLAG_UV1_USE_TRIPLANAR]) { + code += "\tvec3 emission_tex = triplanar_texture(texture_emission,uv1_power_normal,uv1_world_pos).rgb;\n"; + } else { + code += "\tvec3 emission_tex = texture(texture_emission,base_uv).rgb;\n"; + } + code += "\tEMISSION = (emission.rgb+emission_tex)*emission_energy;\n"; } - if (features[FEATURE_REFRACTION]) { + if (features[FEATURE_REFRACTION] && !flags[FLAG_UV1_USE_TRIPLANAR]) { //refraction not supported with triplanar if (features[FEATURE_NORMAL_MAPPING]) { code += "\tvec3 ref_normal = normalize( mix(NORMAL,TANGENT * NORMALMAP.x + BINORMAL * NORMALMAP.y + NORMAL * NORMALMAP.z,NORMALMAP_DEPTH) ) * SIDE;\n"; @@ -532,38 +659,82 @@ void SpatialMaterial::_update_shader() { } if (features[FEATURE_RIM]) { - code += "\tvec2 rim_tex = texture(texture_rim,base_uv).xw;\n"; + if (flags[FLAG_UV1_USE_TRIPLANAR]) { + code += "\tvec2 rim_tex = triplanar_texture(texture_rim,uv1_power_normal,uv1_world_pos).xy;\n"; + } else { + code += "\tvec2 rim_tex = texture(texture_rim,base_uv).xy;\n"; + } code += "\tRIM = rim*rim_tex.x;"; code += "\tRIM_TINT = rim_tint*rim_tex.y;\n"; } if (features[FEATURE_CLEARCOAT]) { - code += "\tvec2 clearcoat_tex = texture(texture_clearcoat,base_uv).xw;\n"; + if (flags[FLAG_UV1_USE_TRIPLANAR]) { + code += "\tvec2 clearcoat_tex = triplanar_texture(texture_clearcoat,uv1_power_normal,uv1_world_pos).xy;\n"; + } else { + code += "\tvec2 clearcoat_tex = texture(texture_clearcoat,base_uv).xy;\n"; + } code += "\tCLEARCOAT = clearcoat*clearcoat_tex.x;"; code += "\tCLEARCOAT_GLOSS = clearcoat_gloss*clearcoat_tex.y;\n"; } if (features[FEATURE_ANISOTROPY]) { - code += "\tvec4 anisotropy_tex = texture(texture_flowmap,base_uv);\n"; - code += "\tANISOTROPY = anisotropy_ratio*anisotropy_tex.a;\n"; + if (flags[FLAG_UV1_USE_TRIPLANAR]) { + code += "\tvec3 anisotropy_tex = triplanar_texture(texture_flowmap,uv1_power_normal,uv1_world_pos).rga;\n"; + } else { + code += "\tvec3 anisotropy_tex = texture(texture_flowmap,base_uv).rga;\n"; + } + code += "\tANISOTROPY = anisotropy_ratio*anisotropy_tex.b;\n"; code += "\tANISOTROPY_FLOW = anisotropy_tex.rg*2.0-1.0;\n"; } if (features[FEATURE_AMBIENT_OCCLUSION]) { - code += "\tAO = texture(texture_ambient_occlusion,base_uv).r;\n"; + if (flags[FLAG_AO_ON_UV2]) { + if (flags[FLAG_UV2_USE_TRIPLANAR]) { + code += "\tAO = triplanar_texture(texture_ambient_occlusion,uv2_power_normal,uv2_world_pos).r;\n"; + } else { + code += "\tAO = texture(texture_ambient_occlusion,base_uv2).r;\n"; + } + } else { + if (flags[FLAG_UV1_USE_TRIPLANAR]) { + code += "\tAO = triplanar_texture(texture_ambient_occlusion,uv1_power_normal,uv1_world_pos).r;\n"; + } else { + code += "\tAO = texture(texture_ambient_occlusion,base_uv).r;\n"; + } + } } if (features[FEATURE_SUBSURACE_SCATTERING]) { - code += "\tfloat sss_tex = texture(texture_subsurface_scattering,base_uv).r;\n"; + if (flags[FLAG_UV1_USE_TRIPLANAR]) { + code += "\tfloat sss_tex = triplanar_texture(texture_subsurface_scattering,uv1_power_normal,uv1_world_pos).r;\n"; + } else { + code += "\tfloat sss_tex = texture(texture_subsurface_scattering,base_uv).r;\n"; + } code += "\tSSS_STRENGTH=subsurface_scattering_strength*sss_tex;\n"; } if (features[FEATURE_DETAIL]) { - String det_uv = detail_uv == DETAIL_UV_1 ? "base_uv" : "base_uv2"; - code += "\tvec4 detail_tex = texture(texture_detail_albedo," + det_uv + ");\n"; - code += "\tvec4 detail_norm_tex = texture(texture_detail_normal," + det_uv + ");\n"; - code += "\tvec4 detail_mask_tex = texture(texture_detail_mask,base_uv);\n"; + + bool triplanar = (flags[FLAG_UV1_USE_TRIPLANAR] && detail_uv == DETAIL_UV_1) || (flags[FLAG_UV2_USE_TRIPLANAR] && detail_uv == DETAIL_UV_2); + + if (triplanar) { + String tp_uv = detail_uv == DETAIL_UV_1 ? "uv1" : "uv2"; + code += "\tvec4 detail_tex = triplanar_texture(texture_detail_albedo," + tp_uv + "_power_normal," + tp_uv + "_world_pos);\n"; + code += "\tvec4 detail_norm_tex = triplanar_texture(texture_detail_normal," + tp_uv + "_power_normal," + tp_uv + "_world_pos);\n"; + + } else { + String det_uv = detail_uv == DETAIL_UV_1 ? "base_uv" : "base_uv2"; + code += "\tvec4 detail_tex = texture(texture_detail_albedo," + det_uv + ");\n"; + code += "\tvec4 detail_norm_tex = texture(texture_detail_normal," + det_uv + ");\n"; + } + + if (flags[FLAG_UV1_USE_TRIPLANAR]) { + + code += "\tvec4 detail_mask_tex = triplanar_texture(texture_detail_mask,uv1_power_normal);\n"; + } else { + code += "\tvec4 detail_mask_tex = texture(texture_detail_mask,base_uv);\n"; + } switch (detail_blend_mode) { case BLEND_MODE_MIX: { @@ -581,7 +752,6 @@ void SpatialMaterial::_update_shader() { } code += "\tvec3 detail_norm = mix(NORMALMAP,detail_norm_tex.rgb,detail_tex.a);\n"; - code += "\tNORMALMAP = mix(NORMALMAP,detail_norm,detail_mask_tex.r);\n"; code += "\tALBEDO.rgb = mix(ALBEDO.rgb,detail,detail_mask_tex.r);\n"; } @@ -875,6 +1045,19 @@ SpatialMaterial::DiffuseMode SpatialMaterial::get_diffuse_mode() const { return diffuse_mode; } +void SpatialMaterial::set_specular_mode(SpecularMode p_mode) { + + if (specular_mode == p_mode) + return; + + specular_mode = p_mode; + _queue_shader_change(); +} +SpatialMaterial::SpecularMode SpatialMaterial::get_specular_mode() const { + + return specular_mode; +} + void SpatialMaterial::set_flag(Flags p_flag, bool p_enabled) { ERR_FAIL_INDEX(p_flag, FLAG_MAX); @@ -947,6 +1130,10 @@ void SpatialMaterial::_validate_property(PropertyInfo &property) const { if (property.name.begins_with("particles_anim_") && billboard_mode != BILLBOARD_PARTICLES) { property.usage = 0; } + + if (property.name == "params_grow_amount" && !grow_enabled) { + property.usage = 0; + } } void SpatialMaterial::set_line_width(float p_line_width) { @@ -971,49 +1158,71 @@ float SpatialMaterial::get_point_size() const { return point_size; } -void SpatialMaterial::set_uv1_scale(const Vector2 &p_scale) { +void SpatialMaterial::set_uv1_scale(const Vector3 &p_scale) { uv1_scale = p_scale; VS::get_singleton()->material_set_param(_get_material(), shader_names->uv1_scale, p_scale); } -Vector2 SpatialMaterial::get_uv1_scale() const { +Vector3 SpatialMaterial::get_uv1_scale() const { return uv1_scale; } -void SpatialMaterial::set_uv1_offset(const Vector2 &p_offset) { +void SpatialMaterial::set_uv1_offset(const Vector3 &p_offset) { uv1_offset = p_offset; VS::get_singleton()->material_set_param(_get_material(), shader_names->uv1_offset, p_offset); } -Vector2 SpatialMaterial::get_uv1_offset() const { +Vector3 SpatialMaterial::get_uv1_offset() const { return uv1_offset; } -void SpatialMaterial::set_uv2_scale(const Vector2 &p_scale) { +void SpatialMaterial::set_uv1_triplanar_blend_sharpness(float p_sharpness) { + + uv1_triplanar_sharpness = p_sharpness; + VS::get_singleton()->material_set_param(_get_material(), shader_names->uv1_blend_sharpness, p_sharpness); +} + +float SpatialMaterial::get_uv1_triplanar_blend_sharpness() const { + + return uv1_triplanar_sharpness; +} + +void SpatialMaterial::set_uv2_scale(const Vector3 &p_scale) { uv2_scale = p_scale; VS::get_singleton()->material_set_param(_get_material(), shader_names->uv2_scale, p_scale); } -Vector2 SpatialMaterial::get_uv2_scale() const { +Vector3 SpatialMaterial::get_uv2_scale() const { return uv2_scale; } -void SpatialMaterial::set_uv2_offset(const Vector2 &p_offset) { +void SpatialMaterial::set_uv2_offset(const Vector3 &p_offset) { uv2_offset = p_offset; VS::get_singleton()->material_set_param(_get_material(), shader_names->uv2_offset, p_offset); } -Vector2 SpatialMaterial::get_uv2_offset() const { +Vector3 SpatialMaterial::get_uv2_offset() const { return uv2_offset; } +void SpatialMaterial::set_uv2_triplanar_blend_sharpness(float p_sharpness) { + + uv2_triplanar_sharpness = p_sharpness; + VS::get_singleton()->material_set_param(_get_material(), shader_names->uv2_blend_sharpness, p_sharpness); +} + +float SpatialMaterial::get_uv2_triplanar_blend_sharpness() const { + + return uv2_triplanar_sharpness; +} + void SpatialMaterial::set_billboard_mode(BillboardMode p_mode) { billboard_mode = p_mode; @@ -1063,7 +1272,6 @@ void SpatialMaterial::set_depth_deep_parallax(bool p_enable) { deep_parallax = p_enable; _queue_shader_change(); _change_notify(); - ; } bool SpatialMaterial::is_depth_deep_parallax_enabled() const { @@ -1091,6 +1299,26 @@ int SpatialMaterial::get_depth_deep_parallax_max_layers() const { return deep_parallax_max_layers; } +void SpatialMaterial::set_grow_enabled(bool p_enable) { + grow_enabled = p_enable; + _queue_shader_change(); + _change_notify(); +} + +bool SpatialMaterial::is_grow_enabled() const { + return grow_enabled; +} + +void SpatialMaterial::set_grow(float p_grow) { + grow = p_grow; + VS::get_singleton()->material_set_param(_get_material(), shader_names->grow, p_grow); +} + +float SpatialMaterial::get_grow() const { + + return grow; +} + void SpatialMaterial::_bind_methods() { ClassDB::bind_method(D_METHOD("set_albedo", "albedo"), &SpatialMaterial::set_albedo); @@ -1159,6 +1387,9 @@ void SpatialMaterial::_bind_methods() { ClassDB::bind_method(D_METHOD("set_diffuse_mode", "diffuse_mode"), &SpatialMaterial::set_diffuse_mode); ClassDB::bind_method(D_METHOD("get_diffuse_mode"), &SpatialMaterial::get_diffuse_mode); + ClassDB::bind_method(D_METHOD("set_specular_mode", "specular_mode"), &SpatialMaterial::set_specular_mode); + ClassDB::bind_method(D_METHOD("get_specular_mode"), &SpatialMaterial::get_specular_mode); + ClassDB::bind_method(D_METHOD("set_flag", "flag", "enable"), &SpatialMaterial::set_flag); ClassDB::bind_method(D_METHOD("get_flag"), &SpatialMaterial::get_flag); @@ -1177,12 +1408,18 @@ void SpatialMaterial::_bind_methods() { ClassDB::bind_method(D_METHOD("set_uv1_offset", "offset"), &SpatialMaterial::set_uv1_offset); ClassDB::bind_method(D_METHOD("get_uv1_offset"), &SpatialMaterial::get_uv1_offset); + ClassDB::bind_method(D_METHOD("set_uv1_triplanar_blend_sharpness", "sharpness"), &SpatialMaterial::set_uv1_triplanar_blend_sharpness); + ClassDB::bind_method(D_METHOD("get_uv1_triplanar_blend_sharpness"), &SpatialMaterial::get_uv1_triplanar_blend_sharpness); + ClassDB::bind_method(D_METHOD("set_uv2_scale", "scale"), &SpatialMaterial::set_uv2_scale); ClassDB::bind_method(D_METHOD("get_uv2_scale"), &SpatialMaterial::get_uv2_scale); ClassDB::bind_method(D_METHOD("set_uv2_offset", "offset"), &SpatialMaterial::set_uv2_offset); ClassDB::bind_method(D_METHOD("get_uv2_offset"), &SpatialMaterial::get_uv2_offset); + ClassDB::bind_method(D_METHOD("set_uv2_triplanar_blend_sharpness", "sharpness"), &SpatialMaterial::set_uv2_triplanar_blend_sharpness); + ClassDB::bind_method(D_METHOD("get_uv2_triplanar_blend_sharpness"), &SpatialMaterial::get_uv2_triplanar_blend_sharpness); + ClassDB::bind_method(D_METHOD("set_billboard_mode", "mode"), &SpatialMaterial::set_billboard_mode); ClassDB::bind_method(D_METHOD("get_billboard_mode"), &SpatialMaterial::get_billboard_mode); @@ -1204,6 +1441,12 @@ void SpatialMaterial::_bind_methods() { ClassDB::bind_method(D_METHOD("set_depth_deep_parallax_max_layers", "layer"), &SpatialMaterial::set_depth_deep_parallax_max_layers); ClassDB::bind_method(D_METHOD("get_depth_deep_parallax_max_layers"), &SpatialMaterial::get_depth_deep_parallax_max_layers); + 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_grow_enabled", "enable"), &SpatialMaterial::set_grow_enabled); + ClassDB::bind_method(D_METHOD("is_grow_enabled"), &SpatialMaterial::is_grow_enabled); + ADD_GROUP("Flags", "flags_"); ADD_PROPERTYI(PropertyInfo(Variant::BOOL, "flags_transparent"), "set_feature", "get_feature", FEATURE_TRANSPARENT); ADD_PROPERTYI(PropertyInfo(Variant::BOOL, "flags_unshaded"), "set_flag", "get_flag", FLAG_UNSHADED); @@ -1215,13 +1458,16 @@ void SpatialMaterial::_bind_methods() { ADD_PROPERTYI(PropertyInfo(Variant::BOOL, "vertex_color_is_srgb"), "set_flag", "get_flag", FLAG_SRGB_VERTEX_COLOR); ADD_GROUP("Parameters", "params_"); - ADD_PROPERTY(PropertyInfo(Variant::INT, "params_diffuse_mode", PROPERTY_HINT_ENUM, "Lambert,Lambert Wrap,Oren Nayar,Burley"), "set_diffuse_mode", "get_diffuse_mode"); + ADD_PROPERTY(PropertyInfo(Variant::INT, "params_diffuse_mode", PROPERTY_HINT_ENUM, "Lambert,Lambert Wrap,Oren Nayar,Burley,Toon"), "set_diffuse_mode", "get_diffuse_mode"); + ADD_PROPERTY(PropertyInfo(Variant::INT, "params_specular_mode", PROPERTY_HINT_ENUM, "SchlickGGX,Blinn,Phong,Toon,Disabled"), "set_specular_mode", "get_specular_mode"); ADD_PROPERTY(PropertyInfo(Variant::INT, "params_blend_mode", PROPERTY_HINT_ENUM, "Mix,Add,Sub,Mul"), "set_blend_mode", "get_blend_mode"); ADD_PROPERTY(PropertyInfo(Variant::INT, "params_cull_mode", PROPERTY_HINT_ENUM, "Back,Front,Disabled"), "set_cull_mode", "get_cull_mode"); ADD_PROPERTY(PropertyInfo(Variant::INT, "params_depth_draw_mode", PROPERTY_HINT_ENUM, "Opaque Only,Always,Never,Opaque Pre-Pass"), "set_depth_draw_mode", "get_depth_draw_mode"); ADD_PROPERTY(PropertyInfo(Variant::REAL, "params_line_width", PROPERTY_HINT_RANGE, "0.1,128,0.1"), "set_line_width", "get_line_width"); ADD_PROPERTY(PropertyInfo(Variant::REAL, "params_point_size", PROPERTY_HINT_RANGE, "0.1,128,0.1"), "set_point_size", "get_point_size"); ADD_PROPERTY(PropertyInfo(Variant::INT, "params_billboard_mode", PROPERTY_HINT_ENUM, "Disabled,Enabled,Y-Billboard,Particle Billboard"), "set_billboard_mode", "get_billboard_mode"); + ADD_PROPERTY(PropertyInfo(Variant::BOOL, "params_grow"), "set_grow_enabled", "is_grow_enabled"); + ADD_PROPERTY(PropertyInfo(Variant::REAL, "params_grow_amount", PROPERTY_HINT_RANGE, "-16,10,0.01"), "set_grow", "get_grow"); ADD_GROUP("Particles Anim", "particles_anim_"); ADD_PROPERTY(PropertyInfo(Variant::INT, "particles_anim_h_frames", PROPERTY_HINT_RANGE, "1,128,1"), "set_particles_anim_h_frames", "get_particles_anim_h_frames"); ADD_PROPERTY(PropertyInfo(Variant::INT, "particles_anim_v_frames", PROPERTY_HINT_RANGE, "1,128,1"), "set_particles_anim_v_frames", "get_particles_anim_v_frames"); @@ -1271,6 +1517,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_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_GROUP("Depth", "depth_"); ADD_PROPERTYI(PropertyInfo(Variant::BOOL, "depth_enabled"), "set_feature", "get_feature", FEATURE_DEPTH_MAPPING); @@ -1299,12 +1546,16 @@ void SpatialMaterial::_bind_methods() { ADD_PROPERTYI(PropertyInfo(Variant::OBJECT, "detail_normal", PROPERTY_HINT_RESOURCE_TYPE, "Texture"), "set_texture", "get_texture", TEXTURE_DETAIL_NORMAL); ADD_GROUP("UV1", "uv1_"); - ADD_PROPERTY(PropertyInfo(Variant::VECTOR2, "uv1_scale"), "set_uv1_scale", "get_uv1_scale"); - ADD_PROPERTY(PropertyInfo(Variant::VECTOR2, "uv1_offset"), "set_uv1_offset", "get_uv1_offset"); + ADD_PROPERTY(PropertyInfo(Variant::VECTOR3, "uv1_scale"), "set_uv1_scale", "get_uv1_scale"); + ADD_PROPERTY(PropertyInfo(Variant::VECTOR3, "uv1_offset"), "set_uv1_offset", "get_uv1_offset"); + ADD_PROPERTYI(PropertyInfo(Variant::BOOL, "uv1_triplanar"), "set_flag", "get_flag", FLAG_UV1_USE_TRIPLANAR); + ADD_PROPERTY(PropertyInfo(Variant::REAL, "uv1_triplanar_sharpness", PROPERTY_HINT_EXP_EASING), "set_uv1_triplanar_blend_sharpness", "get_uv1_triplanar_blend_sharpness"); ADD_GROUP("UV2", "uv2_"); - ADD_PROPERTY(PropertyInfo(Variant::VECTOR2, "uv2_scale"), "set_uv2_scale", "get_uv2_scale"); - ADD_PROPERTY(PropertyInfo(Variant::VECTOR2, "uv2_offset"), "set_uv2_offset", "get_uv2_offset"); + ADD_PROPERTY(PropertyInfo(Variant::VECTOR3, "uv2_scale"), "set_uv2_scale", "get_uv2_scale"); + ADD_PROPERTY(PropertyInfo(Variant::VECTOR3, "uv2_offset"), "set_uv2_offset", "get_uv2_offset"); + ADD_PROPERTYI(PropertyInfo(Variant::BOOL, "uv2_triplanar"), "set_flag", "get_flag", FLAG_UV2_USE_TRIPLANAR); + ADD_PROPERTY(PropertyInfo(Variant::REAL, "uv2_triplanar_sharpness", PROPERTY_HINT_EXP_EASING), "set_uv2_triplanar_blend_sharpness", "get_uv2_triplanar_blend_sharpness"); BIND_CONSTANT(TEXTURE_ALBEDO); BIND_CONSTANT(TEXTURE_METALLIC); @@ -1365,6 +1616,13 @@ void SpatialMaterial::_bind_methods() { BIND_CONSTANT(DIFFUSE_HALF_LAMBERT); BIND_CONSTANT(DIFFUSE_OREN_NAYAR); BIND_CONSTANT(DIFFUSE_BURLEY); + BIND_CONSTANT(DIFFUSE_TOON); + + BIND_CONSTANT(SPECULAR_SCHLICK_GGX); + BIND_CONSTANT(SPECULAR_BLINN); + BIND_CONSTANT(SPECULAR_PHONG); + BIND_CONSTANT(SPECULAR_TOON); + BIND_CONSTANT(SPECULAR_DISABLED); BIND_CONSTANT(BILLBOARD_DISABLED); BIND_CONSTANT(BILLBOARD_ENABLED); @@ -1393,15 +1651,20 @@ SpatialMaterial::SpatialMaterial() set_refraction(0.05); set_line_width(1); set_point_size(1); - set_uv1_offset(Vector2(0, 0)); - set_uv1_scale(Vector2(1, 1)); - set_uv2_offset(Vector2(0, 0)); - set_uv2_scale(Vector2(1, 1)); + set_uv1_offset(Vector3(0, 0, 0)); + set_uv1_scale(Vector3(1, 1, 1)); + set_uv1_triplanar_blend_sharpness(1); + set_uv2_offset(Vector3(0, 0, 0)); + set_uv2_scale(Vector3(1, 1, 1)); + set_uv2_triplanar_blend_sharpness(1); set_billboard_mode(BILLBOARD_DISABLED); set_particles_anim_h_frames(1); set_particles_anim_v_frames(1); set_particles_anim_loop(false); + grow_enabled = false; + set_grow(0.0); + deep_parallax = false; set_depth_deep_parallax_min_layers(8); set_depth_deep_parallax_max_layers(32); @@ -1415,6 +1678,7 @@ SpatialMaterial::SpatialMaterial() flags[i] = 0; } diffuse_mode = DIFFUSE_LAMBERT; + specular_mode = SPECULAR_SCHLICK_GGX; for (int i = 0; i < FEATURE_MAX; i++) { features[i] = false; diff --git a/scene/resources/material.h b/scene/resources/material.h index fb6c5b81d9..276064bce4 100644 --- a/scene/resources/material.h +++ b/scene/resources/material.h @@ -47,11 +47,16 @@ class Material : public Resource { OBJ_SAVE_TYPE(Material) RID material; + Ref<Material> next_pass; protected: _FORCE_INLINE_ RID _get_material() const { return material; } + static void _bind_methods(); public: + void set_next_pass(const Ref<Material> &p_pass); + Ref<Material> get_next_pass() const; + virtual RID get_rid() const; Material(); virtual ~Material(); @@ -155,6 +160,9 @@ public: FLAG_SRGB_VERTEX_COLOR, FLAG_USE_POINT_SIZE, FLAG_FIXED_SIZE, + FLAG_UV1_USE_TRIPLANAR, + FLAG_UV2_USE_TRIPLANAR, + FLAG_AO_ON_UV2, FLAG_MAX }; @@ -163,6 +171,15 @@ public: DIFFUSE_HALF_LAMBERT, DIFFUSE_OREN_NAYAR, DIFFUSE_BURLEY, + DIFFUSE_TOON, + }; + + enum SpecularMode { + SPECULAR_SCHLICK_GGX, + SPECULAR_BLINN, + SPECULAR_PHONG, + SPECULAR_TOON, + SPECULAR_DISABLED, }; enum BillboardMode { @@ -176,20 +193,22 @@ private: union MaterialKey { struct { - uint32_t feature_mask : 11; - uint32_t detail_uv : 1; - uint32_t blend_mode : 2; - uint32_t depth_draw_mode : 2; - uint32_t cull_mode : 2; - uint32_t flags : 6; - uint32_t detail_blend_mode : 2; - uint32_t diffuse_mode : 2; - uint32_t invalid_key : 1; - uint32_t deep_parallax : 1; - uint32_t billboard_mode : 2; + uint64_t feature_mask : 11; + uint64_t detail_uv : 1; + uint64_t blend_mode : 2; + uint64_t depth_draw_mode : 2; + uint64_t cull_mode : 2; + uint64_t flags : 9; + uint64_t detail_blend_mode : 2; + uint64_t diffuse_mode : 3; + uint64_t specular_mode : 2; + uint64_t invalid_key : 1; + uint64_t deep_parallax : 1; + uint64_t billboard_mode : 2; + uint64_t grow : 1; }; - uint32_t key; + uint64_t key; bool operator<(const MaterialKey &p_key) const { return key < p_key.key; @@ -225,9 +244,10 @@ private: } mk.detail_blend_mode = detail_blend_mode; mk.diffuse_mode = diffuse_mode; + mk.specular_mode = specular_mode; mk.billboard_mode = billboard_mode; mk.deep_parallax = deep_parallax ? 1 : 0; - ; + mk.grow = grow_enabled; return mk; } @@ -258,6 +278,9 @@ private: StringName particles_anim_loop; StringName depth_min_layers; StringName depth_max_layers; + StringName uv1_blend_sharpness; + StringName uv2_blend_sharpness; + StringName grow; StringName texture_names[TEXTURE_MAX]; }; @@ -289,15 +312,19 @@ private: float refraction; float line_width; float point_size; + bool grow_enabled; + float grow; int particles_anim_h_frames; int particles_anim_v_frames; bool particles_anim_loop; - Vector2 uv1_scale; - Vector2 uv1_offset; + Vector3 uv1_scale; + Vector3 uv1_offset; + float uv1_triplanar_sharpness; - Vector2 uv2_scale; - Vector2 uv2_offset; + Vector3 uv2_scale; + Vector3 uv2_offset; + float uv2_triplanar_sharpness; DetailUV detail_uv; @@ -310,6 +337,7 @@ private: DepthDrawMode depth_draw_mode; CullMode cull_mode; bool flags[FLAG_MAX]; + SpecularMode specular_mode; DiffuseMode diffuse_mode; BillboardMode billboard_mode; @@ -402,6 +430,9 @@ public: void set_diffuse_mode(DiffuseMode p_mode); DiffuseMode get_diffuse_mode() const; + void set_specular_mode(SpecularMode p_mode); + SpecularMode get_specular_mode() const; + void set_flag(Flags p_flag, bool p_enabled); bool get_flag(Flags p_flag) const; @@ -411,17 +442,23 @@ public: void set_feature(Feature p_feature, bool p_enabled); bool get_feature(Feature p_feature) const; - void set_uv1_scale(const Vector2 &p_scale); - Vector2 get_uv1_scale() const; + void set_uv1_scale(const Vector3 &p_scale); + Vector3 get_uv1_scale() const; - void set_uv1_offset(const Vector2 &p_offset); - Vector2 get_uv1_offset() const; + void set_uv1_offset(const Vector3 &p_offset); + Vector3 get_uv1_offset() const; - void set_uv2_scale(const Vector2 &p_scale); - Vector2 get_uv2_scale() const; + void set_uv1_triplanar_blend_sharpness(float p_sharpness); + float get_uv1_triplanar_blend_sharpness() const; - void set_uv2_offset(const Vector2 &p_offset); - Vector2 get_uv2_offset() const; + void set_uv2_scale(const Vector3 &p_scale); + Vector3 get_uv2_scale() const; + + void set_uv2_offset(const Vector3 &p_offset); + Vector3 get_uv2_offset() const; + + void set_uv2_triplanar_blend_sharpness(float p_sharpness); + float get_uv2_triplanar_blend_sharpness() const; void set_billboard_mode(BillboardMode p_mode); BillboardMode get_billboard_mode() const; @@ -434,6 +471,12 @@ public: void set_particles_anim_loop(int p_frames); int get_particles_anim_loop() const; + void set_grow_enabled(bool p_enable); + bool is_grow_enabled() const; + + void set_grow(float p_grow); + float get_grow() const; + static void init_shaders(); static void finish_shaders(); static void flush_changes(); @@ -450,6 +493,7 @@ VARIANT_ENUM_CAST(SpatialMaterial::DepthDrawMode) VARIANT_ENUM_CAST(SpatialMaterial::CullMode) VARIANT_ENUM_CAST(SpatialMaterial::Flags) VARIANT_ENUM_CAST(SpatialMaterial::DiffuseMode) +VARIANT_ENUM_CAST(SpatialMaterial::SpecularMode) VARIANT_ENUM_CAST(SpatialMaterial::BillboardMode) ////////////////////// diff --git a/servers/audio/effects/audio_effect_compressor.cpp b/servers/audio/effects/audio_effect_compressor.cpp index 997a620f7c..491e6ecc81 100644 --- a/servers/audio/effects/audio_effect_compressor.cpp +++ b/servers/audio/effects/audio_effect_compressor.cpp @@ -32,7 +32,7 @@ void AudioEffectCompressorInstance::process(const AudioFrame *p_src_frames, AudioFrame *p_dst_frames, int p_frame_count) { - float treshold = Math::db2linear(base->treshold); + float threshold = Math::db2linear(base->threshold); float sample_rate = AudioServer::get_singleton()->get_mix_rate(); float ratatcoef = exp(-1 / (0.00001f * sample_rate)); @@ -66,7 +66,7 @@ void AudioEffectCompressorInstance::process(const AudioFrame *p_src_frames, Audi float peak = MAX(s.l, s.r); - float overdb = 2.08136898f * Math::linear2db(peak / treshold); + float overdb = 2.08136898f * Math::linear2db(peak / threshold); if (overdb < 0.0) //we only care about what goes over to compress overdb = 0.0; @@ -125,14 +125,14 @@ Ref<AudioEffectInstance> AudioEffectCompressor::instance() { return ins; } -void AudioEffectCompressor::set_treshold(float p_treshold) { +void AudioEffectCompressor::set_threshold(float p_threshold) { - treshold = p_treshold; + threshold = p_threshold; } -float AudioEffectCompressor::get_treshold() const { +float AudioEffectCompressor::get_threshold() const { - return treshold; + return threshold; } void AudioEffectCompressor::set_ratio(float p_ratio) { @@ -208,8 +208,8 @@ void AudioEffectCompressor::_validate_property(PropertyInfo &property) const { void AudioEffectCompressor::_bind_methods() { - ClassDB::bind_method(D_METHOD("set_treshold", "treshold"), &AudioEffectCompressor::set_treshold); - ClassDB::bind_method(D_METHOD("get_treshold"), &AudioEffectCompressor::get_treshold); + ClassDB::bind_method(D_METHOD("set_threshold", "threshold"), &AudioEffectCompressor::set_threshold); + ClassDB::bind_method(D_METHOD("get_threshold"), &AudioEffectCompressor::get_threshold); ClassDB::bind_method(D_METHOD("set_ratio", "ratio"), &AudioEffectCompressor::set_ratio); ClassDB::bind_method(D_METHOD("get_ratio"), &AudioEffectCompressor::get_ratio); @@ -229,7 +229,7 @@ void AudioEffectCompressor::_bind_methods() { ClassDB::bind_method(D_METHOD("set_sidechain", "sidechain"), &AudioEffectCompressor::set_sidechain); ClassDB::bind_method(D_METHOD("get_sidechain"), &AudioEffectCompressor::get_sidechain); - ADD_PROPERTY(PropertyInfo(Variant::REAL, "treshold", PROPERTY_HINT_RANGE, "-60,0,0.1"), "set_treshold", "get_treshold"); + ADD_PROPERTY(PropertyInfo(Variant::REAL, "threshold", PROPERTY_HINT_RANGE, "-60,0,0.1"), "set_threshold", "get_threshold"); ADD_PROPERTY(PropertyInfo(Variant::REAL, "ratio", PROPERTY_HINT_RANGE, "1,48,0.1"), "set_ratio", "get_ratio"); ADD_PROPERTY(PropertyInfo(Variant::REAL, "gain", PROPERTY_HINT_RANGE, "-20,20,0.1"), "set_gain", "get_gain"); ADD_PROPERTY(PropertyInfo(Variant::REAL, "attack_us", PROPERTY_HINT_RANGE, "20,2000,1"), "set_attack_us", "get_attack_us"); @@ -239,7 +239,7 @@ void AudioEffectCompressor::_bind_methods() { } AudioEffectCompressor::AudioEffectCompressor() { - treshold = 0; + threshold = 0; ratio = 4; gain = 0; attack_us = 20; diff --git a/servers/audio/effects/audio_effect_compressor.h b/servers/audio/effects/audio_effect_compressor.h index a624370962..550302056c 100644 --- a/servers/audio/effects/audio_effect_compressor.h +++ b/servers/audio/effects/audio_effect_compressor.h @@ -51,7 +51,7 @@ class AudioEffectCompressor : public AudioEffect { GDCLASS(AudioEffectCompressor, AudioEffect) friend class AudioEffectCompressorInstance; - float treshold; + float threshold; float ratio; float gain; float attack_us; @@ -66,8 +66,8 @@ protected: public: Ref<AudioEffectInstance> instance(); - void set_treshold(float p_treshold); - float get_treshold() const; + void set_threshold(float p_threshold); + float get_threshold() const; void set_ratio(float p_ratio); float get_ratio() const; diff --git a/servers/audio/effects/audio_effect_limiter.cpp b/servers/audio/effects/audio_effect_limiter.cpp index e049e5d53a..9f39db0440 100644 --- a/servers/audio/effects/audio_effect_limiter.cpp +++ b/servers/audio/effects/audio_effect_limiter.cpp @@ -31,8 +31,8 @@ void AudioEffectLimiterInstance::process(const AudioFrame *p_src_frames, AudioFrame *p_dst_frames, int p_frame_count) { - float thresh = Math::db2linear(base->treshold); - float threshdb = base->treshold; + float thresh = Math::db2linear(base->threshold); + float threshdb = base->threshold; float ceiling = Math::db2linear(base->ceiling); float ceildb = base->ceiling; float makeup = Math::db2linear(ceildb - threshdb); @@ -81,14 +81,14 @@ Ref<AudioEffectInstance> AudioEffectLimiter::instance() { return ins; } -void AudioEffectLimiter::set_treshold_db(float p_treshold) { +void AudioEffectLimiter::set_threshold_db(float p_threshold) { - treshold = p_treshold; + threshold = p_threshold; } -float AudioEffectLimiter::get_treshold_db() const { +float AudioEffectLimiter::get_threshold_db() const { - return treshold; + return threshold; } void AudioEffectLimiter::set_ceiling_db(float p_ceiling) { @@ -123,8 +123,8 @@ void AudioEffectLimiter::_bind_methods() { ClassDB::bind_method(D_METHOD("set_ceiling_db", "ceiling"), &AudioEffectLimiter::set_ceiling_db); ClassDB::bind_method(D_METHOD("get_ceiling_db"), &AudioEffectLimiter::get_ceiling_db); - ClassDB::bind_method(D_METHOD("set_treshold_db", "treshold"), &AudioEffectLimiter::set_treshold_db); - ClassDB::bind_method(D_METHOD("get_treshold_db"), &AudioEffectLimiter::get_treshold_db); + ClassDB::bind_method(D_METHOD("set_threshold_db", "threshold"), &AudioEffectLimiter::set_threshold_db); + ClassDB::bind_method(D_METHOD("get_threshold_db"), &AudioEffectLimiter::get_threshold_db); ClassDB::bind_method(D_METHOD("set_soft_clip_db", "soft_clip"), &AudioEffectLimiter::set_soft_clip_db); ClassDB::bind_method(D_METHOD("get_soft_clip_db"), &AudioEffectLimiter::get_soft_clip_db); @@ -133,13 +133,13 @@ void AudioEffectLimiter::_bind_methods() { ClassDB::bind_method(D_METHOD("get_soft_clip_ratio"), &AudioEffectLimiter::get_soft_clip_ratio); ADD_PROPERTY(PropertyInfo(Variant::REAL, "ceiling_db", PROPERTY_HINT_RANGE, "-20,-0.1,0.1"), "set_ceiling_db", "get_ceiling_db"); - ADD_PROPERTY(PropertyInfo(Variant::REAL, "treshold_db", PROPERTY_HINT_RANGE, "-30,0,0.1"), "set_treshold_db", "get_treshold_db"); + ADD_PROPERTY(PropertyInfo(Variant::REAL, "threshold_db", PROPERTY_HINT_RANGE, "-30,0,0.1"), "set_threshold_db", "get_threshold_db"); ADD_PROPERTY(PropertyInfo(Variant::REAL, "soft_clip_db", PROPERTY_HINT_RANGE, "0,6,0.1"), "set_soft_clip_db", "get_soft_clip_db"); ADD_PROPERTY(PropertyInfo(Variant::REAL, "soft_clip_ratio", PROPERTY_HINT_RANGE, "3,20,0.1"), "set_soft_clip_ratio", "get_soft_clip_ratio"); } AudioEffectLimiter::AudioEffectLimiter() { - treshold = 0; + threshold = 0; ceiling = -0.1; soft_clip = 2; soft_clip_ratio = 10; diff --git a/servers/audio/effects/audio_effect_limiter.h b/servers/audio/effects/audio_effect_limiter.h index a684eccbfa..e15ffe5b34 100644 --- a/servers/audio/effects/audio_effect_limiter.h +++ b/servers/audio/effects/audio_effect_limiter.h @@ -49,7 +49,7 @@ class AudioEffectLimiter : public AudioEffect { GDCLASS(AudioEffectLimiter, AudioEffect) friend class AudioEffectLimiterInstance; - float treshold; + float threshold; float ceiling; float soft_clip; float soft_clip_ratio; @@ -58,8 +58,8 @@ protected: static void _bind_methods(); public: - void set_treshold_db(float p_treshold); - float get_treshold_db() const; + void set_threshold_db(float p_threshold); + float get_threshold_db() const; void set_ceiling_db(float p_ceiling); float get_ceiling_db() const; diff --git a/servers/audio_server.cpp b/servers/audio_server.cpp index 095e66ed37..f32784343c 100644 --- a/servers/audio_server.cpp +++ b/servers/audio_server.cpp @@ -252,7 +252,7 @@ void AudioServer::_mix_step() { if (!bus->channels[k].used) { //see if any audio is contained, because channel was not used - if (MAX(peak.r, peak.l) > Math::db2linear(channel_disable_treshold_db)) { + if (MAX(peak.r, peak.l) > Math::db2linear(channel_disable_threshold_db)) { bus->channels[k].last_mix_with_audio = mix_frames; } else if (mix_frames - bus->channels[k].last_mix_with_audio > channel_disable_frames) { bus->channels[k].active = false; @@ -713,7 +713,7 @@ bool AudioServer::is_bus_channel_active(int p_bus, int p_channel) const { void AudioServer::init() { - channel_disable_treshold_db = GLOBAL_DEF("audio/channel_disable_treshold_db", -60.0); + channel_disable_threshold_db = GLOBAL_DEF("audio/channel_disable_threshold_db", -60.0); channel_disable_frames = float(GLOBAL_DEF("audio/channel_disable_time", 2.0)) * get_mix_rate(); buffer_size = 1024; //harcoded for now switch (get_speaker_mode()) { diff --git a/servers/audio_server.h b/servers/audio_server.h index f4c22c0b33..e3b4a3021c 100644 --- a/servers/audio_server.h +++ b/servers/audio_server.h @@ -113,7 +113,7 @@ private: uint64_t mix_count; uint64_t mix_frames; - float channel_disable_treshold_db; + float channel_disable_threshold_db; uint32_t channel_disable_frames; int to_mix; diff --git a/servers/physics/body_sw.cpp b/servers/physics/body_sw.cpp index 715f93c1c1..1f32c059a8 100644 --- a/servers/physics/body_sw.cpp +++ b/servers/physics/body_sw.cpp @@ -706,7 +706,7 @@ bool BodySW::sleep_test(real_t p_step) { else if (!can_sleep) return false; - if (Math::abs(angular_velocity.length()) < get_space()->get_body_angular_velocity_sleep_treshold() && Math::abs(linear_velocity.length_squared()) < get_space()->get_body_linear_velocity_sleep_treshold() * get_space()->get_body_linear_velocity_sleep_treshold()) { + if (Math::abs(angular_velocity.length()) < get_space()->get_body_angular_velocity_sleep_threshold() && Math::abs(linear_velocity.length_squared()) < get_space()->get_body_linear_velocity_sleep_threshold() * get_space()->get_body_linear_velocity_sleep_threshold()) { still_time += p_step; diff --git a/servers/physics/collision_solver_sat.cpp b/servers/physics/collision_solver_sat.cpp index 427a75cf93..128f78e46e 100644 --- a/servers/physics/collision_solver_sat.cpp +++ b/servers/physics/collision_solver_sat.cpp @@ -30,7 +30,7 @@ #include "collision_solver_sat.h" #include "geometry.h" -#define _EDGE_IS_VALID_SUPPORT_TRESHOLD 0.02 +#define _EDGE_IS_VALID_SUPPORT_THRESHOLD 0.02 struct _CollectorCallback { diff --git a/servers/physics/physics_server_sw.cpp b/servers/physics/physics_server_sw.cpp index 455863da91..733bd5b63b 100644 --- a/servers/physics/physics_server_sw.cpp +++ b/servers/physics/physics_server_sw.cpp @@ -812,13 +812,13 @@ void PhysicsServerSW::body_get_collision_exceptions(RID p_body, List<RID> *p_exc } }; -void PhysicsServerSW::body_set_contacts_reported_depth_treshold(RID p_body, real_t p_treshold) { +void PhysicsServerSW::body_set_contacts_reported_depth_threshold(RID p_body, real_t p_threshold) { BodySW *body = body_owner.get(p_body); ERR_FAIL_COND(!body); }; -real_t PhysicsServerSW::body_get_contacts_reported_depth_treshold(RID p_body) const { +real_t PhysicsServerSW::body_get_contacts_reported_depth_threshold(RID p_body) const { BodySW *body = body_owner.get(p_body); ERR_FAIL_COND_V(!body, 0); diff --git a/servers/physics/physics_server_sw.h b/servers/physics/physics_server_sw.h index 559e9aeb51..a0a1bcf963 100644 --- a/servers/physics/physics_server_sw.h +++ b/servers/physics/physics_server_sw.h @@ -200,8 +200,8 @@ public: virtual void body_remove_collision_exception(RID p_body, RID p_body_b); virtual void body_get_collision_exceptions(RID p_body, List<RID> *p_exceptions); - virtual void body_set_contacts_reported_depth_treshold(RID p_body, real_t p_treshold); - virtual real_t body_get_contacts_reported_depth_treshold(RID p_body) const; + virtual void body_set_contacts_reported_depth_threshold(RID p_body, real_t p_threshold); + virtual real_t body_get_contacts_reported_depth_threshold(RID p_body) const; virtual void body_set_omit_force_integration(RID p_body, bool p_omit); virtual bool body_is_omitting_force_integration(RID p_body) const; diff --git a/servers/physics/shape_sw.cpp b/servers/physics/shape_sw.cpp index 7b3df37a63..a5cea8aff7 100644 --- a/servers/physics/shape_sw.cpp +++ b/servers/physics/shape_sw.cpp @@ -32,8 +32,8 @@ #include "quick_hull.h" #include "sort.h" #define _POINT_SNAP 0.001953125 -#define _EDGE_IS_VALID_SUPPORT_TRESHOLD 0.0002 -#define _FACE_IS_VALID_SUPPORT_TRESHOLD 0.9998 +#define _EDGE_IS_VALID_SUPPORT_THRESHOLD 0.0002 +#define _FACE_IS_VALID_SUPPORT_THRESHOLD 0.9998 void ShapeSW::configure(const Rect3 &p_aabb) { aabb = p_aabb; @@ -165,7 +165,7 @@ Vector3 RayShapeSW::get_support(const Vector3 &p_normal) const { void RayShapeSW::get_supports(const Vector3 &p_normal, int p_max, Vector3 *r_supports, int &r_amount) const { - if (Math::abs(p_normal.z) < _EDGE_IS_VALID_SUPPORT_TRESHOLD) { + if (Math::abs(p_normal.z) < _EDGE_IS_VALID_SUPPORT_THRESHOLD) { r_amount = 2; r_supports[0] = Vector3(0, 0, 0); @@ -306,7 +306,7 @@ void BoxShapeSW::get_supports(const Vector3 &p_normal, int p_max, Vector3 *r_sup Vector3 axis; axis[i] = 1.0; real_t dot = p_normal.dot(axis); - if (Math::abs(dot) > _FACE_IS_VALID_SUPPORT_TRESHOLD) { + if (Math::abs(dot) > _FACE_IS_VALID_SUPPORT_THRESHOLD) { //Vector3 axis_b; @@ -350,7 +350,7 @@ void BoxShapeSW::get_supports(const Vector3 &p_normal, int p_max, Vector3 *r_sup Vector3 axis; axis[i] = 1.0; - if (Math::abs(p_normal.dot(axis)) < _EDGE_IS_VALID_SUPPORT_TRESHOLD) { + if (Math::abs(p_normal.dot(axis)) < _EDGE_IS_VALID_SUPPORT_THRESHOLD) { r_amount = 2; @@ -460,7 +460,7 @@ void CapsuleShapeSW::get_supports(const Vector3 &p_normal, int p_max, Vector3 *r real_t d = n.z; - if (Math::abs(d) < _EDGE_IS_VALID_SUPPORT_TRESHOLD) { + if (Math::abs(d) < _EDGE_IS_VALID_SUPPORT_THRESHOLD) { // make it flat n.z = 0.0; @@ -655,7 +655,7 @@ void ConvexPolygonShapeSW::get_supports(const Vector3 &p_normal, int p_max, Vect for (int i = 0; i < fc; i++) { - if (faces[i].plane.normal.dot(p_normal) > _FACE_IS_VALID_SUPPORT_TRESHOLD) { + if (faces[i].plane.normal.dot(p_normal) > _FACE_IS_VALID_SUPPORT_THRESHOLD) { int ic = faces[i].indices.size(); const int *ind = faces[i].indices.ptr(); @@ -685,7 +685,7 @@ void ConvexPolygonShapeSW::get_supports(const Vector3 &p_normal, int p_max, Vect real_t dot = (vertices[edges[i].a] - vertices[edges[i].b]).normalized().dot(p_normal); dot = ABS(dot); - if (dot < _EDGE_IS_VALID_SUPPORT_TRESHOLD && (edges[i].a == vtx || edges[i].b == vtx)) { + if (dot < _EDGE_IS_VALID_SUPPORT_THRESHOLD && (edges[i].a == vtx || edges[i].b == vtx)) { r_amount = 2; r_supports[0] = vertices[edges[i].a]; @@ -818,7 +818,7 @@ void FaceShapeSW::get_supports(const Vector3 &p_normal, int p_max, Vector3 *r_su Vector3 n = p_normal; /** TEST FACE AS SUPPORT **/ - if (normal.dot(n) > _FACE_IS_VALID_SUPPORT_TRESHOLD) { + if (normal.dot(n) > _FACE_IS_VALID_SUPPORT_THRESHOLD) { r_amount = 3; for (int i = 0; i < 3; i++) { @@ -854,7 +854,7 @@ void FaceShapeSW::get_supports(const Vector3 &p_normal, int p_max, Vector3 *r_su // check if edge is valid as a support real_t dot = (vertex[i] - vertex[nx]).normalized().dot(n); dot = ABS(dot); - if (dot < _EDGE_IS_VALID_SUPPORT_TRESHOLD) { + if (dot < _EDGE_IS_VALID_SUPPORT_THRESHOLD) { r_amount = 2; r_supports[0] = vertex[i]; diff --git a/servers/physics/space_sw.cpp b/servers/physics/space_sw.cpp index 67ac21e4f9..2bf98cecfa 100644 --- a/servers/physics/space_sw.cpp +++ b/servers/physics/space_sw.cpp @@ -597,8 +597,8 @@ void SpaceSW::set_param(PhysicsServer::SpaceParameter p_param, real_t p_value) { case PhysicsServer::SPACE_PARAM_CONTACT_RECYCLE_RADIUS: contact_recycle_radius = p_value; break; case PhysicsServer::SPACE_PARAM_CONTACT_MAX_SEPARATION: contact_max_separation = p_value; break; case PhysicsServer::SPACE_PARAM_BODY_MAX_ALLOWED_PENETRATION: contact_max_allowed_penetration = p_value; break; - case PhysicsServer::SPACE_PARAM_BODY_LINEAR_VELOCITY_SLEEP_TRESHOLD: body_linear_velocity_sleep_threshold = p_value; break; - case PhysicsServer::SPACE_PARAM_BODY_ANGULAR_VELOCITY_SLEEP_TRESHOLD: body_angular_velocity_sleep_threshold = p_value; break; + case PhysicsServer::SPACE_PARAM_BODY_LINEAR_VELOCITY_SLEEP_THRESHOLD: body_linear_velocity_sleep_threshold = p_value; break; + case PhysicsServer::SPACE_PARAM_BODY_ANGULAR_VELOCITY_SLEEP_THRESHOLD: body_angular_velocity_sleep_threshold = p_value; break; case PhysicsServer::SPACE_PARAM_BODY_TIME_TO_SLEEP: body_time_to_sleep = p_value; break; case PhysicsServer::SPACE_PARAM_BODY_ANGULAR_VELOCITY_DAMP_RATIO: body_angular_velocity_damp_ratio = p_value; break; case PhysicsServer::SPACE_PARAM_CONSTRAINT_DEFAULT_BIAS: constraint_bias = p_value; break; @@ -612,8 +612,8 @@ real_t SpaceSW::get_param(PhysicsServer::SpaceParameter p_param) const { case PhysicsServer::SPACE_PARAM_CONTACT_RECYCLE_RADIUS: return contact_recycle_radius; case PhysicsServer::SPACE_PARAM_CONTACT_MAX_SEPARATION: return contact_max_separation; case PhysicsServer::SPACE_PARAM_BODY_MAX_ALLOWED_PENETRATION: return contact_max_allowed_penetration; - case PhysicsServer::SPACE_PARAM_BODY_LINEAR_VELOCITY_SLEEP_TRESHOLD: return body_linear_velocity_sleep_threshold; - case PhysicsServer::SPACE_PARAM_BODY_ANGULAR_VELOCITY_SLEEP_TRESHOLD: return body_angular_velocity_sleep_threshold; + case PhysicsServer::SPACE_PARAM_BODY_LINEAR_VELOCITY_SLEEP_THRESHOLD: return body_linear_velocity_sleep_threshold; + case PhysicsServer::SPACE_PARAM_BODY_ANGULAR_VELOCITY_SLEEP_THRESHOLD: return body_angular_velocity_sleep_threshold; case PhysicsServer::SPACE_PARAM_BODY_TIME_TO_SLEEP: return body_time_to_sleep; case PhysicsServer::SPACE_PARAM_BODY_ANGULAR_VELOCITY_DAMP_RATIO: return body_angular_velocity_damp_ratio; case PhysicsServer::SPACE_PARAM_CONSTRAINT_DEFAULT_BIAS: return constraint_bias; diff --git a/servers/physics/space_sw.h b/servers/physics/space_sw.h index 782bacbd65..b0e54f647c 100644 --- a/servers/physics/space_sw.h +++ b/servers/physics/space_sw.h @@ -152,8 +152,8 @@ public: _FORCE_INLINE_ real_t get_contact_max_separation() const { return contact_max_separation; } _FORCE_INLINE_ real_t get_contact_max_allowed_penetration() const { return contact_max_allowed_penetration; } _FORCE_INLINE_ real_t get_constraint_bias() const { return constraint_bias; } - _FORCE_INLINE_ real_t get_body_linear_velocity_sleep_treshold() const { return body_linear_velocity_sleep_threshold; } - _FORCE_INLINE_ real_t get_body_angular_velocity_sleep_treshold() const { return body_angular_velocity_sleep_threshold; } + _FORCE_INLINE_ real_t get_body_linear_velocity_sleep_threshold() const { return body_linear_velocity_sleep_threshold; } + _FORCE_INLINE_ real_t get_body_angular_velocity_sleep_threshold() const { return body_angular_velocity_sleep_threshold; } _FORCE_INLINE_ real_t get_body_time_to_sleep() const { return body_time_to_sleep; } _FORCE_INLINE_ real_t get_body_angular_velocity_damp_ratio() const { return body_angular_velocity_damp_ratio; } diff --git a/servers/physics_2d/body_2d_sw.cpp b/servers/physics_2d/body_2d_sw.cpp index 538ea10211..91b5646ef5 100644 --- a/servers/physics_2d/body_2d_sw.cpp +++ b/servers/physics_2d/body_2d_sw.cpp @@ -621,7 +621,7 @@ bool Body2DSW::sleep_test(real_t p_step) { else if (!can_sleep) return false; - if (Math::abs(angular_velocity) < get_space()->get_body_angular_velocity_sleep_treshold() && Math::abs(linear_velocity.length_squared()) < get_space()->get_body_linear_velocity_sleep_treshold() * get_space()->get_body_linear_velocity_sleep_treshold()) { + if (Math::abs(angular_velocity) < get_space()->get_body_angular_velocity_sleep_threshold() && Math::abs(linear_velocity.length_squared()) < get_space()->get_body_linear_velocity_sleep_threshold() * get_space()->get_body_linear_velocity_sleep_threshold()) { still_time += p_step; diff --git a/servers/physics_2d/broad_phase_2d_hash_grid.cpp b/servers/physics_2d/broad_phase_2d_hash_grid.cpp index 438cd416f6..29f3396a1d 100644 --- a/servers/physics_2d/broad_phase_2d_hash_grid.cpp +++ b/servers/physics_2d/broad_phase_2d_hash_grid.cpp @@ -636,7 +636,7 @@ BroadPhase2DHashGrid::BroadPhase2DHashGrid() { hash_table = memnew_arr(PosBin *, hash_table_size); cell_size = GLOBAL_DEF("physics/2d/cell_size", 128); - large_object_min_surface = GLOBAL_DEF("physics/2d/large_object_surface_treshold_in_cells", 512); + large_object_min_surface = GLOBAL_DEF("physics/2d/large_object_surface_threshold_in_cells", 512); for (int i = 0; i < hash_table_size; i++) hash_table[i] = NULL; diff --git a/servers/physics_2d/physics_2d_server_sw.cpp b/servers/physics_2d/physics_2d_server_sw.cpp index 1d88710f1a..fe016d4d0c 100644 --- a/servers/physics_2d/physics_2d_server_sw.cpp +++ b/servers/physics_2d/physics_2d_server_sw.cpp @@ -853,13 +853,13 @@ void Physics2DServerSW::body_get_collision_exceptions(RID p_body, List<RID> *p_e } }; -void Physics2DServerSW::body_set_contacts_reported_depth_treshold(RID p_body, real_t p_treshold) { +void Physics2DServerSW::body_set_contacts_reported_depth_threshold(RID p_body, real_t p_threshold) { Body2DSW *body = body_owner.get(p_body); ERR_FAIL_COND(!body); }; -real_t Physics2DServerSW::body_get_contacts_reported_depth_treshold(RID p_body) const { +real_t Physics2DServerSW::body_get_contacts_reported_depth_threshold(RID p_body) const { Body2DSW *body = body_owner.get(p_body); ERR_FAIL_COND_V(!body, 0); diff --git a/servers/physics_2d/physics_2d_server_sw.h b/servers/physics_2d/physics_2d_server_sw.h index 9cbdfc598f..da72784b6f 100644 --- a/servers/physics_2d/physics_2d_server_sw.h +++ b/servers/physics_2d/physics_2d_server_sw.h @@ -205,8 +205,8 @@ public: virtual void body_remove_collision_exception(RID p_body, RID p_body_b); virtual void body_get_collision_exceptions(RID p_body, List<RID> *p_exceptions); - virtual void body_set_contacts_reported_depth_treshold(RID p_body, real_t p_treshold); - virtual real_t body_get_contacts_reported_depth_treshold(RID p_body) const; + virtual void body_set_contacts_reported_depth_threshold(RID p_body, real_t p_threshold); + virtual real_t body_get_contacts_reported_depth_threshold(RID p_body) const; virtual void body_set_omit_force_integration(RID p_body, bool p_omit); virtual bool body_is_omitting_force_integration(RID p_body) const; diff --git a/servers/physics_2d/physics_2d_server_wrap_mt.h b/servers/physics_2d/physics_2d_server_wrap_mt.h index 9fcfebef6b..ac9066582e 100644 --- a/servers/physics_2d/physics_2d_server_wrap_mt.h +++ b/servers/physics_2d/physics_2d_server_wrap_mt.h @@ -233,8 +233,8 @@ public: FUNC2(body_set_max_contacts_reported, RID, int); FUNC1RC(int, body_get_max_contacts_reported, RID); - FUNC2(body_set_contacts_reported_depth_treshold, RID, real_t); - FUNC1RC(real_t, body_get_contacts_reported_depth_treshold, RID); + FUNC2(body_set_contacts_reported_depth_threshold, RID, real_t); + FUNC1RC(real_t, body_get_contacts_reported_depth_threshold, RID); FUNC2(body_set_omit_force_integration, RID, bool); FUNC1RC(bool, body_is_omitting_force_integration, RID); diff --git a/servers/physics_2d/shape_2d_sw.cpp b/servers/physics_2d/shape_2d_sw.cpp index 245b4e15bc..e153ee985c 100644 --- a/servers/physics_2d/shape_2d_sw.cpp +++ b/servers/physics_2d/shape_2d_sw.cpp @@ -197,7 +197,7 @@ Variant RayShape2DSW::get_data() const { void SegmentShape2DSW::get_supports(const Vector2 &p_normal, Vector2 *r_supports, int &r_amount) const { - if (Math::abs(p_normal.dot(n)) > _SEGMENT_IS_VALID_SUPPORT_TRESHOLD) { + if (Math::abs(p_normal.dot(n)) > _SEGMENT_IS_VALID_SUPPORT_THRESHOLD) { r_supports[0] = a; r_supports[1] = b; r_amount = 2; @@ -337,7 +337,7 @@ void RectangleShape2DSW::get_supports(const Vector2 &p_normal, Vector2 *r_suppor Vector2 ag; ag[i] = 1.0; real_t dp = ag.dot(p_normal); - if (Math::abs(dp) < _SEGMENT_IS_VALID_SUPPORT_TRESHOLD) + if (Math::abs(dp) < _SEGMENT_IS_VALID_SUPPORT_THRESHOLD) continue; real_t sgn = dp > 0 ? 1.0 : -1.0; @@ -400,7 +400,7 @@ void CapsuleShape2DSW::get_supports(const Vector2 &p_normal, Vector2 *r_supports real_t d = n.y; - if (Math::abs(d) < (1.0 - _SEGMENT_IS_VALID_SUPPORT_TRESHOLD)) { + if (Math::abs(d) < (1.0 - _SEGMENT_IS_VALID_SUPPORT_THRESHOLD)) { // make it flat n.y = 0.0; @@ -547,7 +547,7 @@ void ConvexPolygonShape2DSW::get_supports(const Vector2 &p_normal, Vector2 *r_su } //test segment - if (points[i].normal.dot(p_normal) > _SEGMENT_IS_VALID_SUPPORT_TRESHOLD) { + if (points[i].normal.dot(p_normal) > _SEGMENT_IS_VALID_SUPPORT_THRESHOLD) { r_amount = 2; r_supports[0] = points[i].pos; diff --git a/servers/physics_2d/shape_2d_sw.h b/servers/physics_2d/shape_2d_sw.h index 4cc98b7f1e..a75a4338e7 100644 --- a/servers/physics_2d/shape_2d_sw.h +++ b/servers/physics_2d/shape_2d_sw.h @@ -31,7 +31,7 @@ #define SHAPE_2D_2DSW_H #include "servers/physics_2d_server.h" -#define _SEGMENT_IS_VALID_SUPPORT_TRESHOLD 0.99998 +#define _SEGMENT_IS_VALID_SUPPORT_THRESHOLD 0.99998 /* @@ -106,7 +106,7 @@ public: if (r_amount == 1) { - if (Math::abs(p_normal.dot(p_cast.normalized())) < (1.0 - _SEGMENT_IS_VALID_SUPPORT_TRESHOLD)) { + if (Math::abs(p_normal.dot(p_cast.normalized())) < (1.0 - _SEGMENT_IS_VALID_SUPPORT_THRESHOLD)) { //make line because they are parallel r_amount = 2; r_supports[1] = r_supports[0] + p_cast; @@ -117,7 +117,7 @@ public: } else { - if (Math::abs(p_normal.dot(p_cast.normalized())) < (1.0 - _SEGMENT_IS_VALID_SUPPORT_TRESHOLD)) { + if (Math::abs(p_normal.dot(p_cast.normalized())) < (1.0 - _SEGMENT_IS_VALID_SUPPORT_THRESHOLD)) { //optimize line and make it larger because they are parallel if ((r_supports[1] - r_supports[0]).dot(p_cast) > 0) { //larger towards 1 diff --git a/servers/physics_2d/space_2d_sw.cpp b/servers/physics_2d/space_2d_sw.cpp index 0b31ff144b..7049a9cf34 100644 --- a/servers/physics_2d/space_2d_sw.cpp +++ b/servers/physics_2d/space_2d_sw.cpp @@ -1130,8 +1130,8 @@ void Space2DSW::set_param(Physics2DServer::SpaceParameter p_param, real_t p_valu case Physics2DServer::SPACE_PARAM_CONTACT_RECYCLE_RADIUS: contact_recycle_radius = p_value; break; case Physics2DServer::SPACE_PARAM_CONTACT_MAX_SEPARATION: contact_max_separation = p_value; break; case Physics2DServer::SPACE_PARAM_BODY_MAX_ALLOWED_PENETRATION: contact_max_allowed_penetration = p_value; break; - case Physics2DServer::SPACE_PARAM_BODY_LINEAR_VELOCITY_SLEEP_TRESHOLD: body_linear_velocity_sleep_treshold = p_value; break; - case Physics2DServer::SPACE_PARAM_BODY_ANGULAR_VELOCITY_SLEEP_TRESHOLD: body_angular_velocity_sleep_treshold = p_value; break; + case Physics2DServer::SPACE_PARAM_BODY_LINEAR_VELOCITY_SLEEP_THRESHOLD: body_linear_velocity_sleep_threshold = p_value; break; + case Physics2DServer::SPACE_PARAM_BODY_ANGULAR_VELOCITY_SLEEP_THRESHOLD: body_angular_velocity_sleep_threshold = p_value; break; case Physics2DServer::SPACE_PARAM_BODY_TIME_TO_SLEEP: body_time_to_sleep = p_value; break; case Physics2DServer::SPACE_PARAM_CONSTRAINT_DEFAULT_BIAS: constraint_bias = p_value; break; } @@ -1144,8 +1144,8 @@ real_t Space2DSW::get_param(Physics2DServer::SpaceParameter p_param) const { case Physics2DServer::SPACE_PARAM_CONTACT_RECYCLE_RADIUS: return contact_recycle_radius; case Physics2DServer::SPACE_PARAM_CONTACT_MAX_SEPARATION: return contact_max_separation; case Physics2DServer::SPACE_PARAM_BODY_MAX_ALLOWED_PENETRATION: return contact_max_allowed_penetration; - case Physics2DServer::SPACE_PARAM_BODY_LINEAR_VELOCITY_SLEEP_TRESHOLD: return body_linear_velocity_sleep_treshold; - case Physics2DServer::SPACE_PARAM_BODY_ANGULAR_VELOCITY_SLEEP_TRESHOLD: return body_angular_velocity_sleep_treshold; + case Physics2DServer::SPACE_PARAM_BODY_LINEAR_VELOCITY_SLEEP_THRESHOLD: return body_linear_velocity_sleep_threshold; + case Physics2DServer::SPACE_PARAM_BODY_ANGULAR_VELOCITY_SLEEP_THRESHOLD: return body_angular_velocity_sleep_threshold; case Physics2DServer::SPACE_PARAM_BODY_TIME_TO_SLEEP: return body_time_to_sleep; case Physics2DServer::SPACE_PARAM_CONSTRAINT_DEFAULT_BIAS: return constraint_bias; } @@ -1186,8 +1186,8 @@ Space2DSW::Space2DSW() { contact_max_allowed_penetration = 0.3; constraint_bias = 0.2; - body_linear_velocity_sleep_treshold = GLOBAL_DEF("physics/2d/sleep_threashold_linear", 2.0); - body_angular_velocity_sleep_treshold = GLOBAL_DEF("physics/2d/sleep_threshold_angular", (8.0 / 180.0 * Math_PI)); + body_linear_velocity_sleep_threshold = GLOBAL_DEF("physics/2d/sleep_threashold_linear", 2.0); + body_angular_velocity_sleep_threshold = GLOBAL_DEF("physics/2d/sleep_threshold_angular", (8.0 / 180.0 * Math_PI)); body_time_to_sleep = GLOBAL_DEF("physics/2d/time_before_sleep", 0.5); broadphase = BroadPhase2DSW::create_func(); diff --git a/servers/physics_2d/space_2d_sw.h b/servers/physics_2d/space_2d_sw.h index 64841c4328..a28233a4a6 100644 --- a/servers/physics_2d/space_2d_sw.h +++ b/servers/physics_2d/space_2d_sw.h @@ -103,8 +103,8 @@ private: CollisionObject2DSW *intersection_query_results[INTERSECTION_QUERY_MAX]; int intersection_query_subindex_results[INTERSECTION_QUERY_MAX]; - real_t body_linear_velocity_sleep_treshold; - real_t body_angular_velocity_sleep_treshold; + real_t body_linear_velocity_sleep_threshold; + real_t body_angular_velocity_sleep_threshold; real_t body_time_to_sleep; bool locked; @@ -152,8 +152,8 @@ public: _FORCE_INLINE_ real_t get_contact_max_separation() const { return contact_max_separation; } _FORCE_INLINE_ real_t get_contact_max_allowed_penetration() const { return contact_max_allowed_penetration; } _FORCE_INLINE_ real_t get_constraint_bias() const { return constraint_bias; } - _FORCE_INLINE_ real_t get_body_linear_velocity_sleep_treshold() const { return body_linear_velocity_sleep_treshold; } - _FORCE_INLINE_ real_t get_body_angular_velocity_sleep_treshold() const { return body_angular_velocity_sleep_treshold; } + _FORCE_INLINE_ real_t get_body_linear_velocity_sleep_threshold() const { return body_linear_velocity_sleep_threshold; } + _FORCE_INLINE_ real_t get_body_angular_velocity_sleep_threshold() const { return body_angular_velocity_sleep_threshold; } _FORCE_INLINE_ real_t get_body_time_to_sleep() const { return body_time_to_sleep; } void update(); diff --git a/servers/physics_2d_server.cpp b/servers/physics_2d_server.cpp index 55ea2b41e7..fb7e89bd9e 100644 --- a/servers/physics_2d_server.cpp +++ b/servers/physics_2d_server.cpp @@ -607,8 +607,8 @@ void Physics2DServer::_bind_methods() { BIND_CONSTANT(SPACE_PARAM_CONTACT_RECYCLE_RADIUS); BIND_CONSTANT(SPACE_PARAM_CONTACT_MAX_SEPARATION); BIND_CONSTANT(SPACE_PARAM_BODY_MAX_ALLOWED_PENETRATION); - BIND_CONSTANT(SPACE_PARAM_BODY_LINEAR_VELOCITY_SLEEP_TRESHOLD); - BIND_CONSTANT(SPACE_PARAM_BODY_ANGULAR_VELOCITY_SLEEP_TRESHOLD); + BIND_CONSTANT(SPACE_PARAM_BODY_LINEAR_VELOCITY_SLEEP_THRESHOLD); + BIND_CONSTANT(SPACE_PARAM_BODY_ANGULAR_VELOCITY_SLEEP_THRESHOLD); BIND_CONSTANT(SPACE_PARAM_BODY_TIME_TO_SLEEP); BIND_CONSTANT(SPACE_PARAM_CONSTRAINT_DEFAULT_BIAS); diff --git a/servers/physics_2d_server.h b/servers/physics_2d_server.h index f50faa42eb..e396424707 100644 --- a/servers/physics_2d_server.h +++ b/servers/physics_2d_server.h @@ -272,8 +272,8 @@ public: SPACE_PARAM_CONTACT_RECYCLE_RADIUS, SPACE_PARAM_CONTACT_MAX_SEPARATION, SPACE_PARAM_BODY_MAX_ALLOWED_PENETRATION, - SPACE_PARAM_BODY_LINEAR_VELOCITY_SLEEP_TRESHOLD, - SPACE_PARAM_BODY_ANGULAR_VELOCITY_SLEEP_TRESHOLD, + SPACE_PARAM_BODY_LINEAR_VELOCITY_SLEEP_THRESHOLD, + SPACE_PARAM_BODY_ANGULAR_VELOCITY_SLEEP_THRESHOLD, SPACE_PARAM_BODY_TIME_TO_SLEEP, SPACE_PARAM_CONSTRAINT_DEFAULT_BIAS, }; @@ -454,8 +454,8 @@ public: virtual int body_get_max_contacts_reported(RID p_body) const = 0; //missing remove - virtual void body_set_contacts_reported_depth_treshold(RID p_body, float p_treshold) = 0; - virtual float body_get_contacts_reported_depth_treshold(RID p_body) const = 0; + virtual void body_set_contacts_reported_depth_threshold(RID p_body, float p_threshold) = 0; + virtual float body_get_contacts_reported_depth_threshold(RID p_body) const = 0; virtual void body_set_omit_force_integration(RID p_body, bool p_omit) = 0; virtual bool body_is_omitting_force_integration(RID p_body) const = 0; diff --git a/servers/physics_server.h b/servers/physics_server.h index 3d1a2aec7a..21c65a74d0 100644 --- a/servers/physics_server.h +++ b/servers/physics_server.h @@ -261,8 +261,8 @@ public: SPACE_PARAM_CONTACT_RECYCLE_RADIUS, SPACE_PARAM_CONTACT_MAX_SEPARATION, SPACE_PARAM_BODY_MAX_ALLOWED_PENETRATION, - SPACE_PARAM_BODY_LINEAR_VELOCITY_SLEEP_TRESHOLD, - SPACE_PARAM_BODY_ANGULAR_VELOCITY_SLEEP_TRESHOLD, + SPACE_PARAM_BODY_LINEAR_VELOCITY_SLEEP_THRESHOLD, + SPACE_PARAM_BODY_ANGULAR_VELOCITY_SLEEP_THRESHOLD, SPACE_PARAM_BODY_TIME_TO_SLEEP, SPACE_PARAM_BODY_ANGULAR_VELOCITY_DAMP_RATIO, SPACE_PARAM_CONSTRAINT_DEFAULT_BIAS, @@ -447,8 +447,8 @@ public: virtual int body_get_max_contacts_reported(RID p_body) const = 0; //missing remove - virtual void body_set_contacts_reported_depth_treshold(RID p_body, float p_treshold) = 0; - virtual float body_get_contacts_reported_depth_treshold(RID p_body) const = 0; + virtual void body_set_contacts_reported_depth_threshold(RID p_body, float p_threshold) = 0; + virtual float body_get_contacts_reported_depth_threshold(RID p_body) const = 0; virtual void body_set_omit_force_integration(RID p_body, bool p_omit) = 0; virtual bool body_is_omitting_force_integration(RID p_body) const = 0; diff --git a/servers/visual/rasterizer.h b/servers/visual/rasterizer.h index 69fd097ee8..ca80d5e457 100644 --- a/servers/visual/rasterizer.h +++ b/servers/visual/rasterizer.h @@ -61,7 +61,7 @@ public: virtual void environment_set_dof_blur_near(RID p_env, bool p_enable, float p_distance, float p_transition, float p_far_amount, VS::EnvironmentDOFBlurQuality p_quality) = 0; virtual void environment_set_dof_blur_far(RID p_env, bool p_enable, float p_distance, float p_transition, float p_far_amount, VS::EnvironmentDOFBlurQuality p_quality) = 0; - virtual void environment_set_glow(RID p_env, bool p_enable, int p_level_flags, float p_intensity, float p_strength, float p_bloom_treshold, VS::EnvironmentGlowBlendMode p_blend_mode, float p_hdr_bleed_treshold, float p_hdr_bleed_scale, bool p_bicubic_upscale) = 0; + virtual void environment_set_glow(RID p_env, bool p_enable, int p_level_flags, float p_intensity, float p_strength, float p_bloom_threshold, VS::EnvironmentGlowBlendMode p_blend_mode, float p_hdr_bleed_threshold, float p_hdr_bleed_scale, bool p_bicubic_upscale) = 0; virtual void environment_set_fog(RID p_env, bool p_enable, float p_begin, float p_end, RID p_gradient_texture) = 0; virtual void environment_set_ssr(RID p_env, bool p_enable, int p_max_steps, float p_fade_int, float p_fade_out, float p_depth_tolerance, bool p_roughness) = 0; @@ -225,6 +225,8 @@ public: virtual void material_set_line_width(RID p_material, float p_width) = 0; + virtual void material_set_next_pass(RID p_material, RID p_next_material) = 0; + virtual bool material_is_animated(RID p_material) = 0; virtual bool material_casts_shadows(RID p_material) = 0; diff --git a/servers/visual/shader_language.cpp b/servers/visual/shader_language.cpp index 96d56dfc56..49f9e161fa 100644 --- a/servers/visual/shader_language.cpp +++ b/servers/visual/shader_language.cpp @@ -1357,11 +1357,8 @@ const ShaderLanguage::BuiltinFuncDef ShaderLanguage::builtin_func_defs[] = { { "tanh", TYPE_FLOAT, { TYPE_FLOAT, TYPE_VOID } }, //builtins - exponential { "pow", TYPE_FLOAT, { TYPE_FLOAT, TYPE_FLOAT, TYPE_VOID } }, - { "pow", TYPE_VEC2, { TYPE_VEC2, TYPE_FLOAT, TYPE_VOID } }, { "pow", TYPE_VEC2, { TYPE_VEC2, TYPE_VEC2, TYPE_VOID } }, - { "pow", TYPE_VEC3, { TYPE_VEC3, TYPE_FLOAT, TYPE_VOID } }, { "pow", TYPE_VEC3, { TYPE_VEC3, TYPE_VEC3, TYPE_VOID } }, - { "pow", TYPE_VEC4, { TYPE_VEC4, TYPE_FLOAT, TYPE_VOID } }, { "pow", TYPE_VEC4, { TYPE_VEC4, TYPE_VEC4, TYPE_VOID } }, { "exp", TYPE_FLOAT, { TYPE_FLOAT, TYPE_VOID } }, { "exp", TYPE_VEC2, { TYPE_VEC2, TYPE_VOID } }, diff --git a/servers/visual/shader_types.cpp b/servers/visual/shader_types.cpp index b04c8716fb..599a6419a7 100644 --- a/servers/visual/shader_types.cpp +++ b/servers/visual/shader_types.cpp @@ -136,8 +136,16 @@ ShaderTypes::ShaderTypes() { shader_modes[VS::SHADER_SPATIAL].modes.insert("diffuse_half_lambert"); shader_modes[VS::SHADER_SPATIAL].modes.insert("diffuse_oren_nayar"); shader_modes[VS::SHADER_SPATIAL].modes.insert("diffuse_burley"); + shader_modes[VS::SHADER_SPATIAL].modes.insert("diffuse_toon"); - shader_modes[VS::SHADER_SPATIAL].modes.insert("skip_default_transform"); + shader_modes[VS::SHADER_SPATIAL].modes.insert("specular_schlick_ggx"); + shader_modes[VS::SHADER_SPATIAL].modes.insert("specular_blinn"); + shader_modes[VS::SHADER_SPATIAL].modes.insert("specular_phong"); + shader_modes[VS::SHADER_SPATIAL].modes.insert("specular_toon"); + shader_modes[VS::SHADER_SPATIAL].modes.insert("specular_disabled"); + + shader_modes[VS::SHADER_SPATIAL].modes.insert("skip_vertex_transform"); + shader_modes[VS::SHADER_SPATIAL].modes.insert("world_vertex_coords"); /************ CANVAS ITEM **************************/ @@ -188,7 +196,7 @@ ShaderTypes::ShaderTypes() { shader_modes[VS::SHADER_CANVAS_ITEM].functions["light"]["POINT_COORD"] = ShaderLanguage::TYPE_VEC2; shader_modes[VS::SHADER_CANVAS_ITEM].functions["light"]["TIME"] = ShaderLanguage::TYPE_FLOAT; - shader_modes[VS::SHADER_CANVAS_ITEM].modes.insert("skip_transform"); + shader_modes[VS::SHADER_CANVAS_ITEM].modes.insert("skip_vertex_transform"); shader_modes[VS::SHADER_CANVAS_ITEM].modes.insert("blend_mix"); shader_modes[VS::SHADER_CANVAS_ITEM].modes.insert("blend_add"); diff --git a/servers/visual/visual_server_raster.h b/servers/visual/visual_server_raster.h index 448af17478..1573116c50 100644 --- a/servers/visual/visual_server_raster.h +++ b/servers/visual/visual_server_raster.h @@ -685,6 +685,7 @@ public: BIND2RC(Variant, material_get_param, RID, const StringName &) BIND2(material_set_line_width, RID, float) + BIND2(material_set_next_pass, RID, RID) /* MESH API */ diff --git a/servers/visual/visual_server_wrap_mt.h b/servers/visual/visual_server_wrap_mt.h index c8afc18740..6a1b0f7e46 100644 --- a/servers/visual/visual_server_wrap_mt.h +++ b/servers/visual/visual_server_wrap_mt.h @@ -129,6 +129,7 @@ public: FUNC2RC(Variant, material_get_param, RID, const StringName &) FUNC2(material_set_line_width, RID, float) + FUNC2(material_set_next_pass, RID, RID) /* MESH API */ diff --git a/servers/visual_server.h b/servers/visual_server.h index 06ceb2cf4c..fbd7fc16ac 100644 --- a/servers/visual_server.h +++ b/servers/visual_server.h @@ -177,6 +177,7 @@ public: virtual Variant material_get_param(RID p_material, const StringName &p_param) const = 0; virtual void material_set_line_width(RID p_material, float p_width) = 0; + virtual void material_set_next_pass(RID p_material, RID p_next_material) = 0; /* MESH API */ @@ -657,7 +658,7 @@ public: GLOW_BLEND_MODE_SOFTLIGHT, GLOW_BLEND_MODE_REPLACE, }; - virtual void environment_set_glow(RID p_env, bool p_enable, int p_level_flags, float p_intensity, float p_strength, float p_bloom_treshold, EnvironmentGlowBlendMode p_blend_mode, float p_hdr_bleed_treshold, float p_hdr_bleed_scale, bool p_bicubic_upscale) = 0; + virtual void environment_set_glow(RID p_env, bool p_enable, int p_level_flags, float p_intensity, float p_strength, float p_bloom_threshold, EnvironmentGlowBlendMode p_blend_mode, float p_hdr_bleed_threshold, float p_hdr_bleed_scale, bool p_bicubic_upscale) = 0; enum EnvironmentToneMapper { ENV_TONE_MAPPER_LINEAR, |