diff options
26 files changed, 71 insertions, 34 deletions
diff --git a/doc/classes/Control.xml b/doc/classes/Control.xml index 5693876194..f2ab6cb07e 100644 --- a/doc/classes/Control.xml +++ b/doc/classes/Control.xml @@ -801,7 +801,7 @@ Shows the given control at the mouse pointer. A good time to call this method is in [method _get_drag_data]. The control must not be in the scene tree. You should not free the control, and you should not keep a reference to the control beyond the duration of the drag. It will be deleted automatically after the drag has ended. [codeblocks] [gdscript] - export (Color, RGBA) var color = Color(1, 0, 0, 1) + @export var color = Color(1, 0, 0, 1) func _get_drag_data(position): # Use a control that is not in the tree diff --git a/doc/classes/EditorSettings.xml b/doc/classes/EditorSettings.xml index 70ea69a336..29123dbc70 100644 --- a/doc/classes/EditorSettings.xml +++ b/doc/classes/EditorSettings.xml @@ -757,7 +757,7 @@ </member> <member name="text_editor/behavior/indent/type" type="int" setter="" getter=""> The indentation style to use (tabs or spaces). - [b]Note:[/b] The [url=$DOCS_URL/getting_started/scripting/gdscript/gdscript_styleguide.html]GDScript style guide[/url] recommends using tabs for indentation. It is advised to change this setting only if you need to work on a project that currently uses spaces for indentation. + [b]Note:[/b] The [url=$DOCS_URL/tutorials/scripting/gdscript/gdscript_styleguide.html]GDScript style guide[/url] recommends using tabs for indentation. It is advised to change this setting only if you need to work on a project that currently uses spaces for indentation. </member> <member name="text_editor/behavior/navigation/drag_and_drop_selection" type="bool" setter="" getter=""> If [code]true[/code], allows drag-and-dropping text in the script editor to move text. Disable this if you find yourself accidentally drag-and-dropping text in the script editor. diff --git a/doc/classes/VoxelGI.xml b/doc/classes/VoxelGI.xml index cc78426736..e453fbd855 100644 --- a/doc/classes/VoxelGI.xml +++ b/doc/classes/VoxelGI.xml @@ -11,7 +11,7 @@ [b]Note:[/b] Meshes should have sufficiently thick walls to avoid light leaks (avoid one-sided walls). For interior levels, enclose your level geometry in a sufficiently large box and bridge the loops to close the mesh. To further prevent light leaks, you can also strategically place temporary [MeshInstance3D] nodes with their [member GeometryInstance3D.gi_mode] set to [constant GeometryInstance3D.GI_MODE_STATIC]. These temporary nodes can then be hidden after baking the [VoxelGI] node. </description> <tutorials> - <link title="GI probes">$DOCS_URL/tutorials/3d/gi_probes.html</link> + <link title="VoxelGI">$DOCS_URL/tutorials/3d/using_voxel_gi.html</link> <link title="Third Person Shooter Demo">https://godotengine.org/asset-library/asset/678</link> </tutorials> <methods> diff --git a/drivers/gles3/rasterizer_canvas_gles3.cpp b/drivers/gles3/rasterizer_canvas_gles3.cpp index 9c6e6baaec..2f7e68e463 100644 --- a/drivers/gles3/rasterizer_canvas_gles3.cpp +++ b/drivers/gles3/rasterizer_canvas_gles3.cpp @@ -224,13 +224,12 @@ void RasterizerCanvasGLES3::canvas_render_items(RID p_to_render_target, Item *p_ l = l->next_ptr; ERR_CONTINUE(!clight); } - Transform2D to_light_xform = (p_canvas_transform * l->light_shader_xform).affine_inverse(); Vector2 canvas_light_pos = p_canvas_transform.xform(l->xform.get_origin()); //convert light position to canvas coordinates, as all computation is done in canvas coords to avoid precision loss state.light_uniforms[index].position[0] = canvas_light_pos.x; state.light_uniforms[index].position[1] = canvas_light_pos.y; - _update_transform_2d_to_mat2x4(to_light_xform, state.light_uniforms[index].matrix); + _update_transform_2d_to_mat2x4(l->light_shader_xform.affine_inverse(), state.light_uniforms[index].matrix); _update_transform_2d_to_mat2x4(l->xform_cache.affine_inverse(), state.light_uniforms[index].shadow_matrix); state.light_uniforms[index].height = l->height * (p_canvas_transform.columns[0].length() + p_canvas_transform.columns[1].length()) * 0.5; //approximate height conversion to the canvas size, since all calculations are done in canvas coords to avoid precision loss diff --git a/drivers/gles3/rasterizer_gles3.cpp b/drivers/gles3/rasterizer_gles3.cpp index a9ec48fcd5..7cbce428cb 100644 --- a/drivers/gles3/rasterizer_gles3.cpp +++ b/drivers/gles3/rasterizer_gles3.cpp @@ -198,7 +198,11 @@ void RasterizerGLES3::finalize() { memdelete(config); } +RasterizerGLES3 *RasterizerGLES3::singleton = nullptr; + RasterizerGLES3::RasterizerGLES3() { + singleton = this; + #ifdef GLAD_ENABLED if (!gladLoaderLoadGL()) { ERR_PRINT("Error initializing GLAD"); diff --git a/drivers/gles3/rasterizer_gles3.h b/drivers/gles3/rasterizer_gles3.h index 0ba84ce412..e29ccefdbd 100644 --- a/drivers/gles3/rasterizer_gles3.h +++ b/drivers/gles3/rasterizer_gles3.h @@ -67,6 +67,7 @@ protected: GLES3::CopyEffects *copy_effects = nullptr; RasterizerCanvasGLES3 *canvas = nullptr; RasterizerSceneGLES3 *scene = nullptr; + static RasterizerGLES3 *singleton; void _blit_render_target_to_screen(RID p_render_target, DisplayServer::WindowID p_screen, const Rect2 &p_screen_rect, uint32_t p_layer, bool p_first = true); @@ -107,6 +108,7 @@ public: _ALWAYS_INLINE_ double get_frame_delta_time() const { return delta; } _ALWAYS_INLINE_ double get_total_time() const { return time_total; } + static RasterizerGLES3 *get_singleton() { return singleton; } RasterizerGLES3(); ~RasterizerGLES3(); }; diff --git a/drivers/gles3/storage/material_storage.cpp b/drivers/gles3/storage/material_storage.cpp index 2c530e3ae6..c585895f4b 100644 --- a/drivers/gles3/storage/material_storage.cpp +++ b/drivers/gles3/storage/material_storage.cpp @@ -38,6 +38,7 @@ #include "texture_storage.h" #include "drivers/gles3/rasterizer_canvas_gles3.h" +#include "drivers/gles3/rasterizer_gles3.h" using namespace GLES3; @@ -1721,7 +1722,7 @@ MaterialStorage::MaterialStorage() { actions.default_filter = ShaderLanguage::FILTER_LINEAR_MIPMAP; actions.default_repeat = ShaderLanguage::REPEAT_ENABLE; - actions.check_multiview_samplers = true; + actions.check_multiview_samplers = RasterizerGLES3::get_singleton()->is_xr_enabled(); actions.global_buffer_array_variable = "global_shader_uniforms"; shaders.compiler_scene.initialize(actions); diff --git a/drivers/vulkan/vulkan_context.cpp b/drivers/vulkan/vulkan_context.cpp index b8cea7136d..f185a5cb88 100644 --- a/drivers/vulkan/vulkan_context.cpp +++ b/drivers/vulkan/vulkan_context.cpp @@ -101,6 +101,7 @@ VkResult VulkanContext::vkCreateRenderPass2KHR(VkDevice p_device, const VkRender attachments.push_back(att); } + Vector<Vector<VkAttachmentReference>> attachment_references; Vector<VkSubpassDescription> subpasses; for (uint32_t i = 0; i < p_create_info->subpassCount; i++) { // Here we need to do more, again it's just stripping out type and next @@ -124,6 +125,10 @@ VkResult VulkanContext::vkCreateRenderPass2KHR(VkDevice p_device, const VkRender p_create_info->pSubpasses[i].preserveAttachmentCount, /* preserveAttachmentCount */ p_create_info->pSubpasses[i].pPreserveAttachments /* pPreserveAttachments */ }; + attachment_references.push_back(input_attachments); + attachment_references.push_back(color_attachments); + attachment_references.push_back(resolve_attachments); + attachment_references.push_back(depth_attachments); subpasses.push_back(subpass); } diff --git a/modules/gdscript/gdscript_analyzer.cpp b/modules/gdscript/gdscript_analyzer.cpp index f130020706..96c35516bc 100644 --- a/modules/gdscript/gdscript_analyzer.cpp +++ b/modules/gdscript/gdscript_analyzer.cpp @@ -657,6 +657,10 @@ GDScriptParser::DataType GDScriptAnalyzer::resolve_datatype(GDScriptParser::Type } else if (ProjectSettings::get_singleton()->has_autoload(first) && ProjectSettings::get_singleton()->get_autoload(first).is_singleton) { const ProjectSettings::AutoloadInfo &autoload = ProjectSettings::get_singleton()->get_autoload(first); Ref<GDScriptParserRef> ref = get_parser_for(autoload.path); + if (ref.is_null()) { + push_error(vformat(R"(The referenced autoload "%s" (from "%s") could not be loaded.)", first, autoload.path), p_type); + return bad_type; + } if (ref->raise_status(GDScriptParserRef::INHERITANCE_SOLVED) != OK) { push_error(vformat(R"(Could not parse singleton "%s" from "%s".)", first, autoload.path), p_type); return bad_type; diff --git a/modules/gdscript/gdscript_byte_codegen.cpp b/modules/gdscript/gdscript_byte_codegen.cpp index a13bf8009f..5b092e3691 100644 --- a/modules/gdscript/gdscript_byte_codegen.cpp +++ b/modules/gdscript/gdscript_byte_codegen.cpp @@ -581,7 +581,8 @@ void GDScriptByteCodeGenerator::write_unary_operator(const Address &p_target, Va } void GDScriptByteCodeGenerator::write_binary_operator(const Address &p_target, Variant::Operator p_operator, const Address &p_left_operand, const Address &p_right_operand) { - if (HAS_BUILTIN_TYPE(p_left_operand) && HAS_BUILTIN_TYPE(p_right_operand)) { + // Avoid validated evaluator for modulo and division when operands are int, since there's no check for division by zero. + if (HAS_BUILTIN_TYPE(p_left_operand) && HAS_BUILTIN_TYPE(p_right_operand) && ((p_operator != Variant::OP_DIVIDE && p_operator != Variant::OP_MODULE) || p_left_operand.type.builtin_type != Variant::INT || p_right_operand.type.builtin_type != Variant::INT)) { if (p_target.mode == Address::TEMPORARY) { Variant::Type result_type = Variant::get_operator_return_type(p_operator, p_left_operand.type.builtin_type, p_right_operand.type.builtin_type); Variant::Type temp_type = temporaries[p_target.address].type; diff --git a/servers/rendering/renderer_compositor.cpp b/servers/rendering/renderer_compositor.cpp index 069b51feaa..a6083fe70d 100644 --- a/servers/rendering/renderer_compositor.cpp +++ b/servers/rendering/renderer_compositor.cpp @@ -35,6 +35,8 @@ #include "core/string/print_string.h" #include "servers/xr_server.h" +RendererCompositor *RendererCompositor::singleton = nullptr; + RendererCompositor *(*RendererCompositor::_create_func)() = nullptr; bool RendererCompositor::low_end = false; @@ -47,6 +49,8 @@ bool RendererCompositor::is_xr_enabled() const { } RendererCompositor::RendererCompositor() { + singleton = this; + if (XRServer::get_xr_mode() == XRServer::XRMODE_DEFAULT) { xr_enabled = GLOBAL_GET("xr/shaders/enabled"); } else { diff --git a/servers/rendering/renderer_compositor.h b/servers/rendering/renderer_compositor.h index 9fb79a290b..ff7792741c 100644 --- a/servers/rendering/renderer_compositor.h +++ b/servers/rendering/renderer_compositor.h @@ -70,6 +70,7 @@ struct BlitToScreen { class RendererCompositor { private: bool xr_enabled = false; + static RendererCompositor *singleton; protected: static RendererCompositor *(*_create_func)(); @@ -107,6 +108,7 @@ public: static bool is_low_end() { return low_end; }; virtual bool is_xr_enabled() const; + static RendererCompositor *get_singleton() { return singleton; } RendererCompositor(); virtual ~RendererCompositor() {} }; diff --git a/servers/rendering/renderer_rd/effects/copy_effects.cpp b/servers/rendering/renderer_rd/effects/copy_effects.cpp index bcea9225ea..86484c982a 100644 --- a/servers/rendering/renderer_rd/effects/copy_effects.cpp +++ b/servers/rendering/renderer_rd/effects/copy_effects.cpp @@ -110,7 +110,7 @@ CopyEffects::CopyEffects(bool p_prefer_raster_effects) { copy_to_fb.shader.initialize(copy_modes); - if (!RendererCompositorRD::singleton->is_xr_enabled()) { + if (!RendererCompositorRD::get_singleton()->is_xr_enabled()) { copy_to_fb.shader.set_variant_enabled(COPY_TO_FB_MULTIVIEW, false); copy_to_fb.shader.set_variant_enabled(COPY_TO_FB_MULTIVIEW_WITH_DEPTH, false); } @@ -266,7 +266,7 @@ CopyEffects::CopyEffects(bool p_prefer_raster_effects) { specular_merge.shader.initialize(specular_modes); - if (!RendererCompositorRD::singleton->is_xr_enabled()) { + if (!RendererCompositorRD::get_singleton()->is_xr_enabled()) { specular_merge.shader.set_variant_enabled(SPECULAR_MERGE_ADD_MULTIVIEW, false); specular_merge.shader.set_variant_enabled(SPECULAR_MERGE_SSR_MULTIVIEW, false); specular_merge.shader.set_variant_enabled(SPECULAR_MERGE_ADDITIVE_ADD_MULTIVIEW, false); diff --git a/servers/rendering/renderer_rd/effects/tone_mapper.cpp b/servers/rendering/renderer_rd/effects/tone_mapper.cpp index 7b152b524f..821960bb3b 100644 --- a/servers/rendering/renderer_rd/effects/tone_mapper.cpp +++ b/servers/rendering/renderer_rd/effects/tone_mapper.cpp @@ -56,7 +56,7 @@ ToneMapper::ToneMapper() { tonemap.shader.initialize(tonemap_modes); - if (!RendererCompositorRD::singleton->is_xr_enabled()) { + if (!RendererCompositorRD::get_singleton()->is_xr_enabled()) { tonemap.shader.set_variant_enabled(TONEMAP_MODE_NORMAL_MULTIVIEW, false); tonemap.shader.set_variant_enabled(TONEMAP_MODE_BICUBIC_GLOW_FILTER_MULTIVIEW, false); tonemap.shader.set_variant_enabled(TONEMAP_MODE_1D_LUT_MULTIVIEW, false); diff --git a/servers/rendering/renderer_rd/effects/vrs.cpp b/servers/rendering/renderer_rd/effects/vrs.cpp index 4bc5d7b597..6ec8612029 100644 --- a/servers/rendering/renderer_rd/effects/vrs.cpp +++ b/servers/rendering/renderer_rd/effects/vrs.cpp @@ -44,7 +44,7 @@ VRS::VRS() { vrs_shader.shader.initialize(vrs_modes); - if (!RendererCompositorRD::singleton->is_xr_enabled()) { + if (!RendererCompositorRD::get_singleton()->is_xr_enabled()) { vrs_shader.shader.set_variant_enabled(VRS_MULTIVIEW, false); } diff --git a/servers/rendering/renderer_rd/environment/sky.cpp b/servers/rendering/renderer_rd/environment/sky.cpp index 7fff349b3c..788ec1cee4 100644 --- a/servers/rendering/renderer_rd/environment/sky.cpp +++ b/servers/rendering/renderer_rd/environment/sky.cpp @@ -276,7 +276,7 @@ void SkyRD::ReflectionData::update_reflection_data(int p_size, int p_mipmaps, bo int mipmaps = p_mipmaps; uint32_t w = p_size, h = p_size; - EffectsRD *effects = RendererCompositorRD::singleton->get_effects(); + EffectsRD *effects = RendererCompositorRD::get_singleton()->get_effects(); ERR_FAIL_NULL_MSG(effects, "Effects haven't been initialized"); bool prefer_raster_effects = effects->get_prefer_raster_effects(); @@ -756,7 +756,7 @@ void SkyRD::init() { sky_shader.shader.initialize(sky_modes, defines); - if (!RendererCompositorRD::singleton->is_xr_enabled()) { + if (!RendererCompositorRD::get_singleton()->is_xr_enabled()) { sky_shader.shader.set_variant_enabled(SKY_VERSION_BACKGROUND_MULTIVIEW, false); sky_shader.shader.set_variant_enabled(SKY_VERSION_HALF_RES_MULTIVIEW, false); sky_shader.shader.set_variant_enabled(SKY_VERSION_QUARTER_RES_MULTIVIEW, false); diff --git a/servers/rendering/renderer_rd/forward_clustered/scene_shader_forward_clustered.cpp b/servers/rendering/renderer_rd/forward_clustered/scene_shader_forward_clustered.cpp index 3b3979b198..ff180b5465 100644 --- a/servers/rendering/renderer_rd/forward_clustered/scene_shader_forward_clustered.cpp +++ b/servers/rendering/renderer_rd/forward_clustered/scene_shader_forward_clustered.cpp @@ -504,7 +504,7 @@ void SceneShaderForwardClustered::init(const String p_defines) { shader.initialize(shader_versions, p_defines); - if (!RendererCompositorRD::singleton->is_xr_enabled()) { + if (!RendererCompositorRD::get_singleton()->is_xr_enabled()) { shader.set_variant_enabled(SHADER_VERSION_DEPTH_PASS_MULTIVIEW, false); shader.set_variant_enabled(SHADER_VERSION_DEPTH_PASS_WITH_NORMAL_AND_ROUGHNESS_MULTIVIEW, false); shader.set_variant_enabled(SHADER_VERSION_DEPTH_PASS_WITH_NORMAL_AND_ROUGHNESS_AND_VOXEL_GI_MULTIVIEW, false); @@ -730,7 +730,7 @@ void SceneShaderForwardClustered::init(const String p_defines) { actions.global_buffer_array_variable = "global_shader_uniforms.data"; actions.instance_uniform_index_variable = "instances.data[instance_index_interp].instance_uniforms_ofs"; - actions.check_multiview_samplers = true; // make sure we check sampling multiview textures + actions.check_multiview_samplers = RendererCompositorRD::get_singleton()->is_xr_enabled(); // Make sure we check sampling multiview textures. compiler.initialize(actions); } diff --git a/servers/rendering/renderer_rd/forward_mobile/scene_shader_forward_mobile.cpp b/servers/rendering/renderer_rd/forward_mobile/scene_shader_forward_mobile.cpp index cc4a7dfa47..0e992eb965 100644 --- a/servers/rendering/renderer_rd/forward_mobile/scene_shader_forward_mobile.cpp +++ b/servers/rendering/renderer_rd/forward_mobile/scene_shader_forward_mobile.cpp @@ -421,7 +421,7 @@ void SceneShaderForwardMobile::init(const String p_defines) { shader.initialize(shader_versions, p_defines); - if (!RendererCompositorRD::singleton->is_xr_enabled()) { + if (!RendererCompositorRD::get_singleton()->is_xr_enabled()) { shader.set_variant_enabled(SHADER_VERSION_COLOR_PASS_MULTIVIEW, false); shader.set_variant_enabled(SHADER_VERSION_LIGHTMAP_COLOR_PASS_MULTIVIEW, false); shader.set_variant_enabled(SHADER_VERSION_SHADOW_PASS_MULTIVIEW, false); @@ -610,7 +610,7 @@ void SceneShaderForwardMobile::init(const String p_defines) { actions.instance_uniform_index_variable = "draw_call.instance_uniforms_ofs"; actions.apply_luminance_multiplier = true; // apply luminance multiplier to screen texture - actions.check_multiview_samplers = true; // make sure we check sampling multiview textures + actions.check_multiview_samplers = RendererCompositorRD::get_singleton()->is_xr_enabled(); // Make sure we check sampling multiview textures. compiler.initialize(actions); } diff --git a/servers/rendering/renderer_rd/renderer_canvas_render_rd.cpp b/servers/rendering/renderer_rd/renderer_canvas_render_rd.cpp index f102bc0650..78bdd3f541 100644 --- a/servers/rendering/renderer_rd/renderer_canvas_render_rd.cpp +++ b/servers/rendering/renderer_rd/renderer_canvas_render_rd.cpp @@ -919,7 +919,7 @@ void RendererCanvasRenderRD::_render_item(RD::DrawListID p_draw_list, RID p_rend } break; case Item::Command::TYPE_ANIMATION_SLICE: { const Item::CommandAnimationSlice *as = static_cast<const Item::CommandAnimationSlice *>(c); - double current_time = RendererCompositorRD::singleton->get_total_time(); + double current_time = RendererCompositorRD::get_singleton()->get_total_time(); double local_time = Math::fposmod(current_time - as->offset, as->animation_length); skipping = !(local_time >= as->slice_begin && local_time < as->slice_end); @@ -1252,13 +1252,12 @@ void RendererCanvasRenderRD::canvas_render_items(RID p_to_render_target, Item *p l = l->next_ptr; ERR_CONTINUE(!clight); } - Transform2D to_light_xform = (p_canvas_transform * l->light_shader_xform).affine_inverse(); Vector2 canvas_light_pos = p_canvas_transform.xform(l->xform.get_origin()); //convert light position to canvas coordinates, as all computation is done in canvas coords to avoid precision loss state.light_uniforms[index].position[0] = canvas_light_pos.x; state.light_uniforms[index].position[1] = canvas_light_pos.y; - _update_transform_2d_to_mat2x4(to_light_xform, state.light_uniforms[index].matrix); + _update_transform_2d_to_mat2x4(l->light_shader_xform.affine_inverse(), state.light_uniforms[index].matrix); _update_transform_2d_to_mat2x4(l->xform_cache.affine_inverse(), state.light_uniforms[index].shadow_matrix); state.light_uniforms[index].height = l->height * (p_canvas_transform.columns[0].length() + p_canvas_transform.columns[1].length()) * 0.5; //approximate height conversion to the canvas size, since all calculations are done in canvas coords to avoid precision loss diff --git a/servers/rendering/renderer_rd/renderer_compositor_rd.h b/servers/rendering/renderer_rd/renderer_compositor_rd.h index 43c8d78dee..eae4327908 100644 --- a/servers/rendering/renderer_rd/renderer_compositor_rd.h +++ b/servers/rendering/renderer_rd/renderer_compositor_rd.h @@ -101,6 +101,7 @@ protected: double delta = 0.0; static uint64_t frame; + static RendererCompositorRD *singleton; public: RendererUtilities *get_utilities() { return utilities; }; @@ -145,7 +146,7 @@ public: low_end = false; } - static RendererCompositorRD *singleton; + static RendererCompositorRD *get_singleton() { return singleton; } RendererCompositorRD(); ~RendererCompositorRD(); }; diff --git a/servers/rendering/renderer_rd/shaders/effects/ssao.glsl b/servers/rendering/renderer_rd/shaders/effects/ssao.glsl index ffaa6872c9..58efc68bc7 100644 --- a/servers/rendering/renderer_rd/shaders/effects/ssao.glsl +++ b/servers/rendering/renderer_rd/shaders/effects/ssao.glsl @@ -307,8 +307,8 @@ void generate_SSAO_shadows_internal(out float r_shadow_term, out vec4 r_edges, o // edge mask for between this and left/right/top/bottom neighbor pixels - not used in quality level 0 so initialize to "no edge" (1 is no edge, 0 is edge) vec4 edgesLRTB = vec4(1.0, 1.0, 1.0, 1.0); - // Move center pixel slightly towards camera to avoid imprecision artifacts due to using of 16bit depth buffer; a lot smaller offsets needed when using 32bit floats - pix_center_pos *= 0.9992; + // Move center pixel slightly towards camera to avoid imprecision artifacts due to using of 16bit depth buffer. + pix_center_pos *= 0.99; if (!p_adaptive_base && (p_quality_level >= SSAO_DEPTH_BASED_EDGES_ENABLE_AT_QUALITY_PRESET)) { edgesLRTB = calculate_edges(pix_z, pix_left_z, pix_right_z, pix_top_z, pix_bottom_z); diff --git a/servers/rendering/renderer_rd/shaders/effects/ssil.glsl b/servers/rendering/renderer_rd/shaders/effects/ssil.glsl index de7b97953f..fac13b0e3f 100644 --- a/servers/rendering/renderer_rd/shaders/effects/ssil.glsl +++ b/servers/rendering/renderer_rd/shaders/effects/ssil.glsl @@ -321,8 +321,8 @@ void generate_SSIL(out vec3 r_color, out vec4 r_edges, out float r_obscurance, o // edge mask for between this and left/right/top/bottom neighbor pixels - not used in quality level 0 so initialize to "no edge" (1 is no edge, 0 is edge) vec4 edgesLRTB = vec4(1.0, 1.0, 1.0, 1.0); - // Move center pixel slightly towards camera to avoid imprecision artifacts due to using of 16bit depth buffer; a lot smaller offsets needed when using 32bit floats - pix_center_pos *= 0.9992; + // Move center pixel slightly towards camera to avoid imprecision artifacts due to using of 16bit depth buffer. + pix_center_pos *= 0.99; if (!p_adaptive_base && (p_quality_level >= SSIL_DEPTH_BASED_EDGES_ENABLE_AT_QUALITY_PRESET)) { edgesLRTB = calculate_edges(pix_z, pix_left_z, pix_right_z, pix_top_z, pix_bottom_z); diff --git a/servers/rendering/renderer_rd/storage_rd/particles_storage.cpp b/servers/rendering/renderer_rd/storage_rd/particles_storage.cpp index 00fb8acca8..3ed5d7dda8 100644 --- a/servers/rendering/renderer_rd/storage_rd/particles_storage.cpp +++ b/servers/rendering/renderer_rd/storage_rd/particles_storage.cpp @@ -774,7 +774,7 @@ void ParticlesStorage::_particles_process(Particles *p_particles, double p_delta p_particles->phase = new_phase; - frame_params.time = RendererCompositorRD::singleton->get_total_time(); + frame_params.time = RendererCompositorRD::get_singleton()->get_total_time(); frame_params.delta = p_delta * p_particles->speed_scale; frame_params.random_seed = p_particles->random_seed; frame_params.explosiveness = p_particles->explosiveness; @@ -1228,7 +1228,7 @@ void ParticlesStorage::particles_set_view_axis(RID p_particles, const Vector3 &p RD::get_singleton()->compute_list_dispatch_threads(compute_list, particles->amount, 1, 1); RD::get_singleton()->compute_list_end(); - RendererCompositorRD::singleton->get_effects()->sort_buffer(particles->particles_sort_uniform_set, particles->amount); + RendererCompositorRD::get_singleton()->get_effects()->sort_buffer(particles->particles_sort_uniform_set, particles->amount); } if (particles->trails_enabled && particles->trail_bind_poses.size() > 1) { @@ -1341,7 +1341,7 @@ void ParticlesStorage::update_particles() { particles->inactive = false; particles->inactive_time = 0; } else { - particles->inactive_time += particles->speed_scale * RendererCompositorRD::singleton->get_frame_delta_time(); + particles->inactive_time += particles->speed_scale * RendererCompositorRD::get_singleton()->get_frame_delta_time(); if (particles->inactive_time > particles->lifetime * 1.2) { particles->inactive = true; continue; @@ -1442,7 +1442,7 @@ void ParticlesStorage::update_particles() { frame_time = 1.0 / fixed_fps; decr = frame_time; } - double delta = RendererCompositorRD::singleton->get_frame_delta_time(); + double delta = RendererCompositorRD::get_singleton()->get_frame_delta_time(); if (delta > 0.1) { //avoid recursive stalls if fps goes below 10 delta = 0.1; } else if (delta <= 0.0) { //unlikely but.. @@ -1461,7 +1461,7 @@ void ParticlesStorage::update_particles() { if (zero_time_scale) { _particles_process(particles, 0.0); } else { - _particles_process(particles, RendererCompositorRD::singleton->get_frame_delta_time()); + _particles_process(particles, RendererCompositorRD::get_singleton()->get_frame_delta_time()); } } diff --git a/servers/rendering/renderer_viewport.cpp b/servers/rendering/renderer_viewport.cpp index 0e2a3c682d..f609fa6023 100644 --- a/servers/rendering/renderer_viewport.cpp +++ b/servers/rendering/renderer_viewport.cpp @@ -349,7 +349,7 @@ void RendererViewport::_draw_viewport(Viewport *p_viewport) { Transform2D scale; scale.scale(cl->rect_cache.size); scale.columns[2] = cl->rect_cache.position; - cl->light_shader_xform = cl->xform * scale; + cl->light_shader_xform = xf * cl->xform * scale; if (cl->use_shadow) { cl->shadows_next_ptr = lights_with_shadow; if (lights_with_shadow == nullptr) { diff --git a/servers/rendering/shader_language.cpp b/servers/rendering/shader_language.cpp index 940363a7e8..958e960ab2 100644 --- a/servers/rendering/shader_language.cpp +++ b/servers/rendering/shader_language.cpp @@ -33,6 +33,7 @@ #include "core/os/os.h" #include "core/string/print_string.h" #include "core/templates/local_vector.h" +#include "servers/rendering/renderer_compositor.h" #include "servers/rendering_server.h" #include "shader_types.h" @@ -3055,7 +3056,7 @@ const ShaderLanguage::BuiltinFuncConstArgs ShaderLanguage::builtin_func_const_ar bool ShaderLanguage::is_const_suffix_lut_initialized = false; -bool ShaderLanguage::_validate_function_call(BlockNode *p_block, const FunctionInfo &p_function_info, OperatorNode *p_func, DataType *r_ret_type, StringName *r_ret_type_str) { +bool ShaderLanguage::_validate_function_call(BlockNode *p_block, const FunctionInfo &p_function_info, OperatorNode *p_func, DataType *r_ret_type, StringName *r_ret_type_str, bool *r_is_custom_function) { ERR_FAIL_COND_V(p_func->op != OP_CALL && p_func->op != OP_CONSTRUCT, false); Vector<DataType> args; @@ -3479,6 +3480,9 @@ bool ShaderLanguage::_validate_function_call(BlockNode *p_block, const FunctionI } } + if (r_is_custom_function) { + *r_is_custom_function = true; + } return true; } } @@ -5251,7 +5255,8 @@ ShaderLanguage::Node *ShaderLanguage::_parse_expression(BlockNode *p_block, cons return nullptr; } - if (!_validate_function_call(p_block, p_function_info, func, &func->return_cache, &func->struct_name)) { + bool is_custom_func = false; + if (!_validate_function_call(p_block, p_function_info, func, &func->return_cache, &func->struct_name, &is_custom_func)) { _set_error(vformat(RTR("No matching function found for: '%s'."), String(funcname->name))); return nullptr; } @@ -5391,6 +5396,16 @@ ShaderLanguage::Node *ShaderLanguage::_parse_expression(BlockNode *p_block, cons //being sampler, this either comes from a uniform ShaderNode::Uniform *u = &shader->uniforms[varname]; ERR_CONTINUE(u->type != call_function->arguments[i].type); //this should have been validated previously + + if (RendererCompositor::get_singleton()->is_xr_enabled() && is_custom_func) { + ShaderNode::Uniform::Hint hint = u->hint; + + if (hint == ShaderNode::Uniform::HINT_DEPTH_TEXTURE || hint == ShaderNode::Uniform::HINT_SCREEN_TEXTURE || hint == ShaderNode::Uniform::HINT_NORMAL_ROUGHNESS_TEXTURE) { + _set_error(vformat(RTR("Unable to pass a multiview texture sampler as a parameter to custom function. Consider to sample it in the main function and then pass the vector result to it."), get_uniform_hint_name(hint))); + return nullptr; + } + } + //propagate if (!_propagate_function_call_sampler_uniform_settings(name, i, u->filter, u->repeat)) { return nullptr; diff --git a/servers/rendering/shader_language.h b/servers/rendering/shader_language.h index aea61e42c3..220160e5fd 100644 --- a/servers/rendering/shader_language.h +++ b/servers/rendering/shader_language.h @@ -1088,7 +1088,7 @@ private: bool _compare_datatypes(DataType p_datatype_a, String p_datatype_name_a, int p_array_size_a, DataType p_datatype_b, String p_datatype_name_b, int p_array_size_b); bool _compare_datatypes_in_nodes(Node *a, Node *b); - bool _validate_function_call(BlockNode *p_block, const FunctionInfo &p_function_info, OperatorNode *p_func, DataType *r_ret_type, StringName *r_ret_type_str); + bool _validate_function_call(BlockNode *p_block, const FunctionInfo &p_function_info, OperatorNode *p_func, DataType *r_ret_type, StringName *r_ret_type_str, bool *r_is_custom_function = nullptr); bool _parse_function_arguments(BlockNode *p_block, const FunctionInfo &p_function_info, OperatorNode *p_func, int *r_complete_arg = nullptr); bool _propagate_function_call_sampler_uniform_settings(StringName p_name, int p_argument, TextureFilter p_filter, TextureRepeat p_repeat); bool _propagate_function_call_sampler_builtin_reference(StringName p_name, int p_argument, const StringName &p_builtin); |