diff options
author | Rémi Verschelde <rverschelde@gmail.com> | 2020-02-11 14:01:43 +0100 |
---|---|---|
committer | Rémi Verschelde <rverschelde@gmail.com> | 2020-02-11 14:08:44 +0100 |
commit | db81928e08cb58d5f67908c6dfcf9433e572ffe8 (patch) | |
tree | d9a3ec0c72f3a4eda02e16ed883f560e02cf1ccf /servers/visual/rasterizer_rd | |
parent | eb2b1a602247b88b0710a5eaae0146e0afeed265 (diff) |
Vulkan: Move thirdparty code out of drivers, style fixes
- `vk_enum_string_helper.h` is a generated file taken from the SDK
(Vulkan-ValidationLayers).
- `vk_mem_alloc.h` is a library from GPUOpen:
https://github.com/GPUOpen-LibrariesAndSDKs/VulkanMemoryAllocator
Diffstat (limited to 'servers/visual/rasterizer_rd')
40 files changed, 315 insertions, 244 deletions
diff --git a/servers/visual/rasterizer_rd/light_cluster_builder.cpp b/servers/visual/rasterizer_rd/light_cluster_builder.cpp index 5236c5d1f2..5fe734e82d 100644 --- a/servers/visual/rasterizer_rd/light_cluster_builder.cpp +++ b/servers/visual/rasterizer_rd/light_cluster_builder.cpp @@ -1,3 +1,33 @@ +/*************************************************************************/ +/* light_cluster_builder.cpp */ +/*************************************************************************/ +/* This file is part of: */ +/* GODOT ENGINE */ +/* https://godotengine.org */ +/*************************************************************************/ +/* Copyright (c) 2007-2020 Juan Linietsky, Ariel Manzur. */ +/* Copyright (c) 2014-2020 Godot Engine contributors (cf. AUTHORS.md). */ +/* */ +/* Permission is hereby granted, free of charge, to any person obtaining */ +/* a copy of this software and associated documentation files (the */ +/* "Software"), to deal in the Software without restriction, including */ +/* without limitation the rights to use, copy, modify, merge, publish, */ +/* distribute, sublicense, and/or sell copies of the Software, and to */ +/* permit persons to whom the Software is furnished to do so, subject to */ +/* the following conditions: */ +/* */ +/* The above copyright notice and this permission notice shall be */ +/* included in all copies or substantial portions of the Software. */ +/* */ +/* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, */ +/* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF */ +/* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.*/ +/* IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY */ +/* CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, */ +/* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE */ +/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ +/*************************************************************************/ + #include "light_cluster_builder.h" void LightClusterBuilder::begin(const Transform &p_view_transform, const CameraMatrix &p_cam_projection) { diff --git a/servers/visual/rasterizer_rd/light_cluster_builder.h b/servers/visual/rasterizer_rd/light_cluster_builder.h index f391262356..fd2bd612c3 100644 --- a/servers/visual/rasterizer_rd/light_cluster_builder.h +++ b/servers/visual/rasterizer_rd/light_cluster_builder.h @@ -1,3 +1,33 @@ +/*************************************************************************/ +/* light_cluster_builder.h */ +/*************************************************************************/ +/* This file is part of: */ +/* GODOT ENGINE */ +/* https://godotengine.org */ +/*************************************************************************/ +/* Copyright (c) 2007-2020 Juan Linietsky, Ariel Manzur. */ +/* Copyright (c) 2014-2020 Godot Engine contributors (cf. AUTHORS.md). */ +/* */ +/* Permission is hereby granted, free of charge, to any person obtaining */ +/* a copy of this software and associated documentation files (the */ +/* "Software"), to deal in the Software without restriction, including */ +/* without limitation the rights to use, copy, modify, merge, publish, */ +/* distribute, sublicense, and/or sell copies of the Software, and to */ +/* permit persons to whom the Software is furnished to do so, subject to */ +/* the following conditions: */ +/* */ +/* The above copyright notice and this permission notice shall be */ +/* included in all copies or substantial portions of the Software. */ +/* */ +/* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, */ +/* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF */ +/* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.*/ +/* IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY */ +/* CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, */ +/* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE */ +/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ +/*************************************************************************/ + #ifndef LIGHT_CLUSTER_BUILDER_H #define LIGHT_CLUSTER_BUILDER_H diff --git a/servers/visual/rasterizer_rd/rasterizer_canvas_rd.cpp b/servers/visual/rasterizer_rd/rasterizer_canvas_rd.cpp index 000fdfda0c..7012cb04cd 100644 --- a/servers/visual/rasterizer_rd/rasterizer_canvas_rd.cpp +++ b/servers/visual/rasterizer_rd/rasterizer_canvas_rd.cpp @@ -5,8 +5,8 @@ /* GODOT ENGINE */ /* https://godotengine.org */ /*************************************************************************/ -/* Copyright (c) 2007-2019 Juan Linietsky, Ariel Manzur. */ -/* Copyright (c) 2014-2019 Godot Engine contributors (cf. AUTHORS.md) */ +/* Copyright (c) 2007-2020 Juan Linietsky, Ariel Manzur. */ +/* Copyright (c) 2014-2020 Godot Engine contributors (cf. AUTHORS.md). */ /* */ /* Permission is hereby granted, free of charge, to any person obtaining */ /* a copy of this software and associated documentation files (the */ diff --git a/servers/visual/rasterizer_rd/rasterizer_canvas_rd.h b/servers/visual/rasterizer_rd/rasterizer_canvas_rd.h index eee1b194fb..17560ea540 100644 --- a/servers/visual/rasterizer_rd/rasterizer_canvas_rd.h +++ b/servers/visual/rasterizer_rd/rasterizer_canvas_rd.h @@ -5,8 +5,8 @@ /* GODOT ENGINE */ /* https://godotengine.org */ /*************************************************************************/ -/* Copyright (c) 2007-2019 Juan Linietsky, Ariel Manzur. */ -/* Copyright (c) 2014-2019 Godot Engine contributors (cf. AUTHORS.md) */ +/* Copyright (c) 2007-2020 Juan Linietsky, Ariel Manzur. */ +/* Copyright (c) 2014-2020 Godot Engine contributors (cf. AUTHORS.md). */ /* */ /* Permission is hereby granted, free of charge, to any person obtaining */ /* a copy of this software and associated documentation files (the */ diff --git a/servers/visual/rasterizer_rd/rasterizer_effects_rd.cpp b/servers/visual/rasterizer_rd/rasterizer_effects_rd.cpp index b775401496..4b8b3334b5 100644 --- a/servers/visual/rasterizer_rd/rasterizer_effects_rd.cpp +++ b/servers/visual/rasterizer_rd/rasterizer_effects_rd.cpp @@ -5,8 +5,8 @@ /* GODOT ENGINE */ /* https://godotengine.org */ /*************************************************************************/ -/* Copyright (c) 2007-2019 Juan Linietsky, Ariel Manzur. */ -/* Copyright (c) 2014-2019 Godot Engine contributors (cf. AUTHORS.md) */ +/* Copyright (c) 2007-2020 Juan Linietsky, Ariel Manzur. */ +/* Copyright (c) 2014-2020 Godot Engine contributors (cf. AUTHORS.md). */ /* */ /* Permission is hereby granted, free of charge, to any person obtaining */ /* a copy of this software and associated documentation files (the */ diff --git a/servers/visual/rasterizer_rd/rasterizer_effects_rd.h b/servers/visual/rasterizer_rd/rasterizer_effects_rd.h index 3495c9dcfe..cd5634d564 100644 --- a/servers/visual/rasterizer_rd/rasterizer_effects_rd.h +++ b/servers/visual/rasterizer_rd/rasterizer_effects_rd.h @@ -5,8 +5,8 @@ /* GODOT ENGINE */ /* https://godotengine.org */ /*************************************************************************/ -/* Copyright (c) 2007-2019 Juan Linietsky, Ariel Manzur. */ -/* Copyright (c) 2014-2019 Godot Engine contributors (cf. AUTHORS.md) */ +/* Copyright (c) 2007-2020 Juan Linietsky, Ariel Manzur. */ +/* Copyright (c) 2014-2020 Godot Engine contributors (cf. AUTHORS.md). */ /* */ /* Permission is hereby granted, free of charge, to any person obtaining */ /* a copy of this software and associated documentation files (the */ diff --git a/servers/visual/rasterizer_rd/rasterizer_rd.cpp b/servers/visual/rasterizer_rd/rasterizer_rd.cpp index 9a55235fa1..34be4817f6 100644 --- a/servers/visual/rasterizer_rd/rasterizer_rd.cpp +++ b/servers/visual/rasterizer_rd/rasterizer_rd.cpp @@ -5,8 +5,8 @@ /* GODOT ENGINE */ /* https://godotengine.org */ /*************************************************************************/ -/* Copyright (c) 2007-2019 Juan Linietsky, Ariel Manzur. */ -/* Copyright (c) 2014-2019 Godot Engine contributors (cf. AUTHORS.md) */ +/* Copyright (c) 2007-2020 Juan Linietsky, Ariel Manzur. */ +/* Copyright (c) 2014-2020 Godot Engine contributors (cf. AUTHORS.md). */ /* */ /* Permission is hereby granted, free of charge, to any person obtaining */ /* a copy of this software and associated documentation files (the */ diff --git a/servers/visual/rasterizer_rd/rasterizer_rd.h b/servers/visual/rasterizer_rd/rasterizer_rd.h index 0e95068a4f..d14e9fb36e 100644 --- a/servers/visual/rasterizer_rd/rasterizer_rd.h +++ b/servers/visual/rasterizer_rd/rasterizer_rd.h @@ -5,8 +5,8 @@ /* GODOT ENGINE */ /* https://godotengine.org */ /*************************************************************************/ -/* Copyright (c) 2007-2019 Juan Linietsky, Ariel Manzur. */ -/* Copyright (c) 2014-2019 Godot Engine contributors (cf. AUTHORS.md) */ +/* Copyright (c) 2007-2020 Juan Linietsky, Ariel Manzur. */ +/* Copyright (c) 2014-2020 Godot Engine contributors (cf. AUTHORS.md). */ /* */ /* Permission is hereby granted, free of charge, to any person obtaining */ /* a copy of this software and associated documentation files (the */ diff --git a/servers/visual/rasterizer_rd/rasterizer_scene_high_end_rd.cpp b/servers/visual/rasterizer_rd/rasterizer_scene_high_end_rd.cpp index ad6d689b69..f029cddc79 100644 --- a/servers/visual/rasterizer_rd/rasterizer_scene_high_end_rd.cpp +++ b/servers/visual/rasterizer_rd/rasterizer_scene_high_end_rd.cpp @@ -1,12 +1,12 @@ /*************************************************************************/ -/* rasterizer_scene_forward_rd.cpp */ +/* rasterizer_scene_high_end_rd.cpp */ /*************************************************************************/ /* This file is part of: */ /* GODOT ENGINE */ /* https://godotengine.org */ /*************************************************************************/ -/* Copyright (c) 2007-2019 Juan Linietsky, Ariel Manzur. */ -/* Copyright (c) 2014-2019 Godot Engine contributors (cf. AUTHORS.md) */ +/* Copyright (c) 2007-2020 Juan Linietsky, Ariel Manzur. */ +/* Copyright (c) 2014-2020 Godot Engine contributors (cf. AUTHORS.md). */ /* */ /* Permission is hereby granted, free of charge, to any person obtaining */ /* a copy of this software and associated documentation files (the */ diff --git a/servers/visual/rasterizer_rd/rasterizer_scene_high_end_rd.h b/servers/visual/rasterizer_rd/rasterizer_scene_high_end_rd.h index ef90d3a283..647b8f225e 100644 --- a/servers/visual/rasterizer_rd/rasterizer_scene_high_end_rd.h +++ b/servers/visual/rasterizer_rd/rasterizer_scene_high_end_rd.h @@ -1,12 +1,12 @@ /*************************************************************************/ -/* rasterizer_scene_forward_rd.h */ +/* rasterizer_scene_high_end_rd.h */ /*************************************************************************/ /* This file is part of: */ /* GODOT ENGINE */ /* https://godotengine.org */ /*************************************************************************/ -/* Copyright (c) 2007-2019 Juan Linietsky, Ariel Manzur. */ -/* Copyright (c) 2014-2019 Godot Engine contributors (cf. AUTHORS.md) */ +/* Copyright (c) 2007-2020 Juan Linietsky, Ariel Manzur. */ +/* Copyright (c) 2014-2020 Godot Engine contributors (cf. AUTHORS.md). */ /* */ /* Permission is hereby granted, free of charge, to any person obtaining */ /* a copy of this software and associated documentation files (the */ diff --git a/servers/visual/rasterizer_rd/rasterizer_scene_rd.cpp b/servers/visual/rasterizer_rd/rasterizer_scene_rd.cpp index a40211726c..c1adcba378 100644 --- a/servers/visual/rasterizer_rd/rasterizer_scene_rd.cpp +++ b/servers/visual/rasterizer_rd/rasterizer_scene_rd.cpp @@ -5,8 +5,8 @@ /* GODOT ENGINE */ /* https://godotengine.org */ /*************************************************************************/ -/* Copyright (c) 2007-2019 Juan Linietsky, Ariel Manzur. */ -/* Copyright (c) 2014-2019 Godot Engine contributors (cf. AUTHORS.md) */ +/* Copyright (c) 2007-2020 Juan Linietsky, Ariel Manzur. */ +/* Copyright (c) 2014-2020 Godot Engine contributors (cf. AUTHORS.md). */ /* */ /* Permission is hereby granted, free of charge, to any person obtaining */ /* a copy of this software and associated documentation files (the */ diff --git a/servers/visual/rasterizer_rd/rasterizer_scene_rd.h b/servers/visual/rasterizer_rd/rasterizer_scene_rd.h index 2b519ce2f5..89f4b51dce 100644 --- a/servers/visual/rasterizer_rd/rasterizer_scene_rd.h +++ b/servers/visual/rasterizer_rd/rasterizer_scene_rd.h @@ -5,8 +5,8 @@ /* GODOT ENGINE */ /* https://godotengine.org */ /*************************************************************************/ -/* Copyright (c) 2007-2019 Juan Linietsky, Ariel Manzur. */ -/* Copyright (c) 2014-2019 Godot Engine contributors (cf. AUTHORS.md) */ +/* Copyright (c) 2007-2020 Juan Linietsky, Ariel Manzur. */ +/* Copyright (c) 2014-2020 Godot Engine contributors (cf. AUTHORS.md). */ /* */ /* Permission is hereby granted, free of charge, to any person obtaining */ /* a copy of this software and associated documentation files (the */ diff --git a/servers/visual/rasterizer_rd/rasterizer_storage_rd.cpp b/servers/visual/rasterizer_rd/rasterizer_storage_rd.cpp index cab501acb8..c92400c188 100644 --- a/servers/visual/rasterizer_rd/rasterizer_storage_rd.cpp +++ b/servers/visual/rasterizer_rd/rasterizer_storage_rd.cpp @@ -5,8 +5,8 @@ /* GODOT ENGINE */ /* https://godotengine.org */ /*************************************************************************/ -/* Copyright (c) 2007-2019 Juan Linietsky, Ariel Manzur. */ -/* Copyright (c) 2014-2019 Godot Engine contributors (cf. AUTHORS.md) */ +/* Copyright (c) 2007-2020 Juan Linietsky, Ariel Manzur. */ +/* Copyright (c) 2014-2020 Godot Engine contributors (cf. AUTHORS.md). */ /* */ /* Permission is hereby granted, free of charge, to any person obtaining */ /* a copy of this software and associated documentation files (the */ diff --git a/servers/visual/rasterizer_rd/rasterizer_storage_rd.h b/servers/visual/rasterizer_rd/rasterizer_storage_rd.h index 849e7728b8..7ab8b904ad 100644 --- a/servers/visual/rasterizer_rd/rasterizer_storage_rd.h +++ b/servers/visual/rasterizer_rd/rasterizer_storage_rd.h @@ -5,8 +5,8 @@ /* GODOT ENGINE */ /* https://godotengine.org */ /*************************************************************************/ -/* Copyright (c) 2007-2019 Juan Linietsky, Ariel Manzur. */ -/* Copyright (c) 2014-2019 Godot Engine contributors (cf. AUTHORS.md) */ +/* Copyright (c) 2007-2020 Juan Linietsky, Ariel Manzur. */ +/* Copyright (c) 2014-2020 Godot Engine contributors (cf. AUTHORS.md). */ /* */ /* Permission is hereby granted, free of charge, to any person obtaining */ /* a copy of this software and associated documentation files (the */ diff --git a/servers/visual/rasterizer_rd/render_pipeline_vertex_format_cache_rd.cpp b/servers/visual/rasterizer_rd/render_pipeline_vertex_format_cache_rd.cpp index aef6f07b2f..4ee020aa69 100644 --- a/servers/visual/rasterizer_rd/render_pipeline_vertex_format_cache_rd.cpp +++ b/servers/visual/rasterizer_rd/render_pipeline_vertex_format_cache_rd.cpp @@ -5,8 +5,8 @@ /* GODOT ENGINE */ /* https://godotengine.org */ /*************************************************************************/ -/* Copyright (c) 2007-2019 Juan Linietsky, Ariel Manzur. */ -/* Copyright (c) 2014-2019 Godot Engine contributors (cf. AUTHORS.md) */ +/* Copyright (c) 2007-2020 Juan Linietsky, Ariel Manzur. */ +/* Copyright (c) 2014-2020 Godot Engine contributors (cf. AUTHORS.md). */ /* */ /* Permission is hereby granted, free of charge, to any person obtaining */ /* a copy of this software and associated documentation files (the */ diff --git a/servers/visual/rasterizer_rd/render_pipeline_vertex_format_cache_rd.h b/servers/visual/rasterizer_rd/render_pipeline_vertex_format_cache_rd.h index 70404f2cfd..173e839330 100644 --- a/servers/visual/rasterizer_rd/render_pipeline_vertex_format_cache_rd.h +++ b/servers/visual/rasterizer_rd/render_pipeline_vertex_format_cache_rd.h @@ -5,8 +5,8 @@ /* GODOT ENGINE */ /* https://godotengine.org */ /*************************************************************************/ -/* Copyright (c) 2007-2019 Juan Linietsky, Ariel Manzur. */ -/* Copyright (c) 2014-2019 Godot Engine contributors (cf. AUTHORS.md) */ +/* Copyright (c) 2007-2020 Juan Linietsky, Ariel Manzur. */ +/* Copyright (c) 2014-2020 Godot Engine contributors (cf. AUTHORS.md). */ /* */ /* Permission is hereby granted, free of charge, to any person obtaining */ /* a copy of this software and associated documentation files (the */ diff --git a/servers/visual/rasterizer_rd/shader_compiler_rd.cpp b/servers/visual/rasterizer_rd/shader_compiler_rd.cpp index c702cc5138..4d89ae14d1 100644 --- a/servers/visual/rasterizer_rd/shader_compiler_rd.cpp +++ b/servers/visual/rasterizer_rd/shader_compiler_rd.cpp @@ -5,8 +5,8 @@ /* GODOT ENGINE */ /* https://godotengine.org */ /*************************************************************************/ -/* Copyright (c) 2007-2019 Juan Linietsky, Ariel Manzur. */ -/* Copyright (c) 2014-2019 Godot Engine contributors (cf. AUTHORS.md) */ +/* Copyright (c) 2007-2020 Juan Linietsky, Ariel Manzur. */ +/* Copyright (c) 2014-2020 Godot Engine contributors (cf. AUTHORS.md). */ /* */ /* Permission is hereby granted, free of charge, to any person obtaining */ /* a copy of this software and associated documentation files (the */ diff --git a/servers/visual/rasterizer_rd/shader_compiler_rd.h b/servers/visual/rasterizer_rd/shader_compiler_rd.h index 63e00595e3..c267c2b6d8 100644 --- a/servers/visual/rasterizer_rd/shader_compiler_rd.h +++ b/servers/visual/rasterizer_rd/shader_compiler_rd.h @@ -5,8 +5,8 @@ /* GODOT ENGINE */ /* https://godotengine.org */ /*************************************************************************/ -/* Copyright (c) 2007-2019 Juan Linietsky, Ariel Manzur. */ -/* Copyright (c) 2014-2019 Godot Engine contributors (cf. AUTHORS.md) */ +/* Copyright (c) 2007-2020 Juan Linietsky, Ariel Manzur. */ +/* Copyright (c) 2014-2020 Godot Engine contributors (cf. AUTHORS.md). */ /* */ /* Permission is hereby granted, free of charge, to any person obtaining */ /* a copy of this software and associated documentation files (the */ diff --git a/servers/visual/rasterizer_rd/shader_rd.cpp b/servers/visual/rasterizer_rd/shader_rd.cpp index 98e0c99c2e..cc6c13f598 100644 --- a/servers/visual/rasterizer_rd/shader_rd.cpp +++ b/servers/visual/rasterizer_rd/shader_rd.cpp @@ -5,8 +5,8 @@ /* GODOT ENGINE */ /* https://godotengine.org */ /*************************************************************************/ -/* Copyright (c) 2007-2019 Juan Linietsky, Ariel Manzur. */ -/* Copyright (c) 2014-2019 Godot Engine contributors (cf. AUTHORS.md) */ +/* Copyright (c) 2007-2020 Juan Linietsky, Ariel Manzur. */ +/* Copyright (c) 2014-2020 Godot Engine contributors (cf. AUTHORS.md). */ /* */ /* Permission is hereby granted, free of charge, to any person obtaining */ /* a copy of this software and associated documentation files (the */ diff --git a/servers/visual/rasterizer_rd/shader_rd.h b/servers/visual/rasterizer_rd/shader_rd.h index 4d1e9576ce..dce46fc0b5 100644 --- a/servers/visual/rasterizer_rd/shader_rd.h +++ b/servers/visual/rasterizer_rd/shader_rd.h @@ -5,8 +5,8 @@ /* GODOT ENGINE */ /* https://godotengine.org */ /*************************************************************************/ -/* Copyright (c) 2007-2019 Juan Linietsky, Ariel Manzur. */ -/* Copyright (c) 2014-2019 Godot Engine contributors (cf. AUTHORS.md) */ +/* Copyright (c) 2007-2020 Juan Linietsky, Ariel Manzur. */ +/* Copyright (c) 2014-2020 Godot Engine contributors (cf. AUTHORS.md). */ /* */ /* Permission is hereby granted, free of charge, to any person obtaining */ /* a copy of this software and associated documentation files (the */ diff --git a/servers/visual/rasterizer_rd/shaders/blur.glsl b/servers/visual/rasterizer_rd/shaders/blur.glsl index 03456dc97e..87c20ebaef 100644 --- a/servers/visual/rasterizer_rd/shaders/blur.glsl +++ b/servers/visual/rasterizer_rd/shaders/blur.glsl @@ -125,14 +125,14 @@ void main() { //Glow uses larger sigma 1 for a more rounded blur effect -#define GLOW_ADD( m_ofs, m_mult )\ - {\ - vec2 ofs = uv_interp + m_ofs * pix_size;\ - vec4 c = texture(source_color, ofs ) * m_mult; \ - if (any(lessThan(ofs,vec2(0.0))) || any(greaterThan(ofs,vec2(1.0)))) {\ - c*=0.0;\ - }\ - color+=c;\ +#define GLOW_ADD(m_ofs, m_mult) \ + { \ + vec2 ofs = uv_interp + m_ofs * pix_size; \ + vec4 c = texture(source_color, ofs) * m_mult; \ + if (any(lessThan(ofs, vec2(0.0))) || any(greaterThan(ofs, vec2(1.0)))) { \ + c *= 0.0; \ + } \ + color += c; \ } if (bool(blur.flags & FLAG_HORIZONTAL)) { @@ -140,22 +140,22 @@ void main() { vec2 pix_size = blur.pixel_size; pix_size *= 0.5; //reading from larger buffer, so use more samples vec4 color = texture(source_color, uv_interp + vec2(0.0, 0.0) * pix_size) * 0.174938; - GLOW_ADD(vec2(1.0, 0.0),0.165569); - GLOW_ADD(vec2(2.0, 0.0),0.140367); + GLOW_ADD(vec2(1.0, 0.0), 0.165569); + GLOW_ADD(vec2(2.0, 0.0), 0.140367); GLOW_ADD(vec2(3.0, 0.0), 0.106595); - GLOW_ADD(vec2(-1.0, 0.0),0.165569); - GLOW_ADD(vec2(-2.0, 0.0),0.140367); - GLOW_ADD(vec2(-3.0, 0.0),0.106595); + GLOW_ADD(vec2(-1.0, 0.0), 0.165569); + GLOW_ADD(vec2(-2.0, 0.0), 0.140367); + GLOW_ADD(vec2(-3.0, 0.0), 0.106595); color *= blur.glow_strength; frag_color = color; } else { vec2 pix_size = blur.pixel_size; vec4 color = texture(source_color, uv_interp + vec2(0.0, 0.0) * pix_size) * 0.288713; - GLOW_ADD(vec2(0.0, 1.0),0.233062); - GLOW_ADD(vec2(0.0, 2.0),0.122581); - GLOW_ADD(vec2(0.0, -1.0),0.233062); - GLOW_ADD(vec2(0.0, -2.0),0.122581); + GLOW_ADD(vec2(0.0, 1.0), 0.233062); + GLOW_ADD(vec2(0.0, 2.0), 0.122581); + GLOW_ADD(vec2(0.0, -1.0), 0.233062); + GLOW_ADD(vec2(0.0, -2.0), 0.122581); color *= blur.glow_strength; frag_color = color; } @@ -280,7 +280,7 @@ void main() { #ifdef MODE_SIMPLE_COPY vec4 color = texture(source_color, uv_interp, 0.0); if (bool(blur.flags & FLAG_COPY_FORCE_LUMINANCE)) { - color.rgb = vec3(max(max(color.r,color.g),color.b)); + color.rgb = vec3(max(max(color.r, color.g), color.b)); } frag_color = color; #endif diff --git a/servers/visual/rasterizer_rd/shaders/blur_inc.glsl b/servers/visual/rasterizer_rd/shaders/blur_inc.glsl index a008e00102..33ba9de7bb 100644 --- a/servers/visual/rasterizer_rd/shaders/blur_inc.glsl +++ b/servers/visual/rasterizer_rd/shaders/blur_inc.glsl @@ -31,4 +31,5 @@ layout(push_constant, binding = 1, std430) uniform Blur { float camera_z_near; vec4 ssao_color; -} blur; +} +blur; diff --git a/servers/visual/rasterizer_rd/shaders/bokeh_dof.glsl b/servers/visual/rasterizer_rd/shaders/bokeh_dof.glsl index e4508d3c8c..7153fe6b17 100644 --- a/servers/visual/rasterizer_rd/shaders/bokeh_dof.glsl +++ b/servers/visual/rasterizer_rd/shaders/bokeh_dof.glsl @@ -1,6 +1,6 @@ /* clang-format off */ [compute] -/* clang-format on */ + #version 450 VERSION_DEFINES @@ -8,7 +8,7 @@ VERSION_DEFINES #define BLOCK_SIZE 8 layout(local_size_x = BLOCK_SIZE, local_size_y = BLOCK_SIZE, local_size_z = 1) in; - +/* clang-format on */ #ifdef MODE_GEN_BLUR_SIZE layout(rgba16f, set = 0, binding = 0) uniform restrict image2D color_image; @@ -27,7 +27,6 @@ layout(set = 1, binding = 0) uniform sampler2D source_bokeh; // based on https://www.shadertoy.com/view/Xd3GDl - layout(push_constant, binding = 1, std430) uniform Params { ivec2 size; float z_far; @@ -51,7 +50,8 @@ layout(push_constant, binding = 1, std430) uniform Params { bool use_jitter; float jitter_seed; uint pad[2]; -} params; +} +params; //used to work around downsampling filter #define DEPTH_GAP 0.0 @@ -59,7 +59,7 @@ layout(push_constant, binding = 1, std430) uniform Params { #ifdef MODE_GEN_BLUR_SIZE float get_depth_at_pos(vec2 uv) { - float depth = textureLod(source_depth,uv,0.0).x; + float depth = textureLod(source_depth, uv, 0.0).x; if (params.orthogonal) { depth = ((depth + (params.z_far + params.z_near) / (params.z_far - params.z_near)) * (params.z_far - params.z_near)) / 2.0; } else { @@ -68,15 +68,14 @@ float get_depth_at_pos(vec2 uv) { return depth; } - float get_blur_size(float depth) { if (params.blur_near_active && depth < params.blur_near_begin) { - return - (1.0 - smoothstep(params.blur_near_end,params.blur_near_begin,depth) ) * params.blur_size - DEPTH_GAP; //near blur is negative + return -(1.0 - smoothstep(params.blur_near_end, params.blur_near_begin, depth)) * params.blur_size - DEPTH_GAP; //near blur is negative } if (params.blur_far_active && depth > params.blur_far_begin) { - return smoothstep(params.blur_far_begin,params.blur_far_end,depth) * params.blur_size + DEPTH_GAP; + return smoothstep(params.blur_far_begin, params.blur_far_end, depth) * params.blur_size + DEPTH_GAP; } return 0.0; @@ -86,10 +85,9 @@ float get_blur_size(float depth) { const float GOLDEN_ANGLE = 2.39996323; - //note: uniform pdf rand [0;1[ float hash12n(vec2 p) { - p = fract(p * vec2(5.3987, 5.4421)); + p = fract(p * vec2(5.3987, 5.4421)); p += dot(p.yx, p.xy + vec2(21.5351, 14.3137)); return fract(p.x * p.y * 95.4307); } @@ -99,20 +97,20 @@ float hash12n(vec2 p) { vec4 weighted_filter_dir(vec2 dir, vec2 uv, vec2 pixel_size) { dir *= pixel_size; - vec4 color = texture(color_texture,uv); + vec4 color = texture(color_texture, uv); vec4 accum = color; float total = 1.0; - float blur_scale = params.blur_size/float(params.blur_steps); + float blur_scale = params.blur_size / float(params.blur_steps); if (params.use_jitter) { - uv += dir * (hash12n(uv+params.jitter_seed) - 0.5); + uv += dir * (hash12n(uv + params.jitter_seed) - 0.5); } - for(int i=-params.blur_steps;i<=params.blur_steps;i++) { + for (int i = -params.blur_steps; i <= params.blur_steps; i++) { - if (i==0) { + if (i == 0) { continue; } float radius = float(i) * blur_scale; @@ -130,12 +128,11 @@ vec4 weighted_filter_dir(vec2 dir, vec2 uv, vec2 pixel_size) { limit -= DEPTH_GAP; - float m = smoothstep(radius-0.5, radius+0.5, limit); + float m = smoothstep(radius - 0.5, radius + 0.5, limit); - accum += mix(color, sample_color, m ); + accum += mix(color, sample_color, m); total += 1.0; - } return accum / total; @@ -147,80 +144,76 @@ void main() { ivec2 pos = ivec2(gl_GlobalInvocationID.xy); - if (any(greaterThan(pos,params.size))) { //too large, do nothing + if (any(greaterThan(pos, params.size))) { //too large, do nothing return; } - vec2 pixel_size = 1.0/vec2(params.size); + vec2 pixel_size = 1.0 / vec2(params.size); vec2 uv = vec2(pos) / vec2(params.size); #ifdef MODE_GEN_BLUR_SIZE - uv+=pixel_size * 0.5; + uv += pixel_size * 0.5; //precompute size in alpha channel float depth = get_depth_at_pos(uv); float size = get_blur_size(depth); - vec4 color = imageLoad(color_image,pos); + vec4 color = imageLoad(color_image, pos); color.a = size; - imageStore(color_image,pos,color); + imageStore(color_image, pos, color); #endif #ifdef MODE_BOKEH_BOX //pixel_size*=0.5; //resolution is doubled if (params.second_pass || !params.half_size) { - uv+=pixel_size * 0.5; //half pixel to read centers + uv += pixel_size * 0.5; //half pixel to read centers } else { - uv+=pixel_size * 0.25; //half pixel to read centers from full res + uv += pixel_size * 0.25; //half pixel to read centers from full res } - vec2 dir = (params.second_pass ? vec2(0.0,1.0) : vec2(1.0,0.0)); + vec2 dir = (params.second_pass ? vec2(0.0, 1.0) : vec2(1.0, 0.0)); - vec4 color = weighted_filter_dir(dir,uv,pixel_size); + vec4 color = weighted_filter_dir(dir, uv, pixel_size); - imageStore(bokeh_image,pos,color); + imageStore(bokeh_image, pos, color); #endif #ifdef MODE_BOKEH_HEXAGONAL - //pixel_size*=0.5; //resolution is doubled if (params.second_pass || !params.half_size) { - uv+=pixel_size * 0.5; //half pixel to read centers + uv += pixel_size * 0.5; //half pixel to read centers } else { - uv+=pixel_size * 0.25; //half pixel to read centers from full res + uv += pixel_size * 0.25; //half pixel to read centers from full res } - vec2 dir = (params.second_pass ? normalize(vec2( 1.0, 0.577350269189626 )) : vec2(0.0,1.0)); + vec2 dir = (params.second_pass ? normalize(vec2(1.0, 0.577350269189626)) : vec2(0.0, 1.0)); - vec4 color = weighted_filter_dir(dir,uv,pixel_size); + vec4 color = weighted_filter_dir(dir, uv, pixel_size); if (params.second_pass) { - dir = normalize(vec2( -1.0, 0.577350269189626 )); + dir = normalize(vec2(-1.0, 0.577350269189626)); - vec4 color2 = weighted_filter_dir(dir,uv,pixel_size); + vec4 color2 = weighted_filter_dir(dir, uv, pixel_size); - color.rgb = min(color.rgb,color2.rgb); + color.rgb = min(color.rgb, color2.rgb); color.a = (color.a + color2.a) * 0.5; } - imageStore(bokeh_image,pos,color); - - + imageStore(bokeh_image, pos, color); #endif - #ifdef MODE_BOKEH_CIRCULAR if (params.half_size) { - pixel_size*=0.5; //resolution is doubled + pixel_size *= 0.5; //resolution is doubled } - uv+=pixel_size * 0.5; //half pixel to read centers + uv += pixel_size * 0.5; //half pixel to read centers - vec4 color = texture(color_texture,uv); + vec4 color = texture(color_texture, uv); float accum = 1.0; float radius = params.blur_scale; @@ -230,37 +223,36 @@ void main() { vec4 sample_color = texture(color_texture, suv); float sample_size = abs(sample_color.a); if (sample_color.a > color.a) { - sample_size = clamp(sample_size, 0.0, abs(color.a)*2.0); + sample_size = clamp(sample_size, 0.0, abs(color.a) * 2.0); } - float m = smoothstep(radius-0.5, radius+0.5, sample_size); - color += mix(color/accum, sample_color, m); + float m = smoothstep(radius - 0.5, radius + 0.5, sample_size); + color += mix(color / accum, sample_color, m); accum += 1.0; - radius += params.blur_scale/radius; + radius += params.blur_scale / radius; } color /= accum; - imageStore(bokeh_image,pos,color); + imageStore(bokeh_image, pos, color); #endif #ifdef MODE_COMPOSITE_BOKEH - uv+=pixel_size * 0.5; - vec4 color = imageLoad(color_image,pos); - vec4 bokeh = texture(source_bokeh,uv); + uv += pixel_size * 0.5; + vec4 color = imageLoad(color_image, pos); + vec4 bokeh = texture(source_bokeh, uv); float mix_amount; if (bokeh.a < color.a) { - mix_amount = min(1.0,max(0.0,max(abs(color.a),abs(bokeh.a))-DEPTH_GAP)); + mix_amount = min(1.0, max(0.0, max(abs(color.a), abs(bokeh.a)) - DEPTH_GAP)); } else { - mix_amount = min(1.0,max(0.0,abs(color.a)-DEPTH_GAP)); + mix_amount = min(1.0, max(0.0, abs(color.a) - DEPTH_GAP)); } - color.rgb = mix(color.rgb,bokeh.rgb,mix_amount); //blend between hires and lowres + color.rgb = mix(color.rgb, bokeh.rgb, mix_amount); //blend between hires and lowres - color.a=0; //reset alpha - imageStore(color_image,pos,color); + color.a = 0; //reset alpha + imageStore(color_image, pos, color); #endif - } diff --git a/servers/visual/rasterizer_rd/shaders/canvas_occlusion.glsl b/servers/visual/rasterizer_rd/shaders/canvas_occlusion.glsl index 7486fab140..7b30cc8fe9 100644 --- a/servers/visual/rasterizer_rd/shaders/canvas_occlusion.glsl +++ b/servers/visual/rasterizer_rd/shaders/canvas_occlusion.glsl @@ -12,7 +12,8 @@ layout(push_constant, binding = 0, std430) uniform Constants { mat2x4 modelview; vec2 direction; vec2 pad; -} constants; +} +constants; layout(location = 0) out highp float depth; diff --git a/servers/visual/rasterizer_rd/shaders/canvas_uniforms_inc.glsl b/servers/visual/rasterizer_rd/shaders/canvas_uniforms_inc.glsl index 73a0f6ffe4..1ac43480cd 100644 --- a/servers/visual/rasterizer_rd/shaders/canvas_uniforms_inc.glsl +++ b/servers/visual/rasterizer_rd/shaders/canvas_uniforms_inc.glsl @@ -50,7 +50,8 @@ layout(push_constant, binding = 0, std430) uniform DrawData { #endif vec2 color_texture_pixel_size; uint lights[4]; -} draw_data; +} +draw_data; // The values passed per draw primitives are cached within it @@ -80,14 +81,16 @@ layout(set = 2, binding = 0, std140) uniform CanvasData { float time; float time_pad; //uint light_count; -} canvas_data; +} +canvas_data; layout(set = 2, binding = 1) uniform textureBuffer skeleton_buffer; layout(set = 2, binding = 2, std140) uniform SkeletonData { mat4 skeleton_transform; //in world coordinates mat4 skeleton_transform_inverse; -} skeleton_data; +} +skeleton_data; #ifdef USE_LIGHTING @@ -119,7 +122,8 @@ struct Light { layout(set = 2, binding = 3, std140) uniform LightData { Light data[MAX_LIGHTS]; -} light_array; +} +light_array; layout(set = 2, binding = 4) uniform texture2D light_textures[MAX_LIGHT_TEXTURES]; layout(set = 2, binding = 5) uniform texture2D shadow_textures[MAX_LIGHT_TEXTURES]; diff --git a/servers/visual/rasterizer_rd/shaders/copy.glsl b/servers/visual/rasterizer_rd/shaders/copy.glsl index d180fecd5a..cbb9b546a3 100644 --- a/servers/visual/rasterizer_rd/shaders/copy.glsl +++ b/servers/visual/rasterizer_rd/shaders/copy.glsl @@ -35,7 +35,8 @@ layout(push_constant, binding = 0, std430) uniform Params { float z_far; float z_near; bool z_flip; -} params; +} +params; layout(location = 0) out float depth_buffer; diff --git a/servers/visual/rasterizer_rd/shaders/cubemap_roughness.glsl b/servers/visual/rasterizer_rd/shaders/cubemap_roughness.glsl index de941c335f..011dfce985 100644 --- a/servers/visual/rasterizer_rd/shaders/cubemap_roughness.glsl +++ b/servers/visual/rasterizer_rd/shaders/cubemap_roughness.glsl @@ -36,7 +36,8 @@ layout(push_constant, binding = 1, std430) uniform Params { uint sample_count; float roughness; bool use_direct_write; -} params; +} +params; layout(location = 0) in vec2 uv_interp; diff --git a/servers/visual/rasterizer_rd/shaders/giprobe.glsl b/servers/visual/rasterizer_rd/shaders/giprobe.glsl index dcbefdb933..fd09f96a57 100644 --- a/servers/visual/rasterizer_rd/shaders/giprobe.glsl +++ b/servers/visual/rasterizer_rd/shaders/giprobe.glsl @@ -23,7 +23,8 @@ struct CellChildren { layout(set = 0, binding = 1, std430) buffer CellChildrenBuffer { CellChildren data[]; -} cell_children; +} +cell_children; struct CellData { uint position; // xyz 10 bits @@ -34,7 +35,8 @@ struct CellData { layout(set = 0, binding = 2, std430) buffer CellDataBuffer { CellData data[]; -} cell_data; +} +cell_data; #endif // MODE DYNAMIC @@ -63,7 +65,8 @@ struct Light { layout(set = 0, binding = 3, std140) uniform Lights { Light data[MAX_LIGHTS]; -} lights; +} +lights; #endif // MODE COMPUTE LIGHT @@ -93,11 +96,13 @@ layout(push_constant, binding = 0, std430) uniform Params { uint cell_count; float aniso_strength; uint pad; -} params; +} +params; layout(set = 0, binding = 4, std430) buffer Outputs { vec4 data[]; -} outputs; +} +outputs; #endif // MODE DYNAMIC @@ -138,7 +143,8 @@ layout(push_constant, binding = 0, std430) uniform Params { bool on_mipmap; float propagation; float pad[3]; -} params; +} +params; #ifdef MODE_DYNAMIC_LIGHTING diff --git a/servers/visual/rasterizer_rd/shaders/giprobe_debug.glsl b/servers/visual/rasterizer_rd/shaders/giprobe_debug.glsl index fa5e07bf3c..b1784e7eee 100644 --- a/servers/visual/rasterizer_rd/shaders/giprobe_debug.glsl +++ b/servers/visual/rasterizer_rd/shaders/giprobe_debug.glsl @@ -15,7 +15,8 @@ struct CellData { layout(set = 0, binding = 1, std140) buffer CellDataBuffer { CellData data[]; -} cell_data; +} +cell_data; layout(set = 0, binding = 2) uniform texture3D color_tex; @@ -35,7 +36,8 @@ layout(push_constant, binding = 0, std430) uniform Params { uint level; ivec3 bounds; uint pad; -} params; +} +params; layout(location = 0) out vec4 color_interp; diff --git a/servers/visual/rasterizer_rd/shaders/giprobe_sdf.glsl b/servers/visual/rasterizer_rd/shaders/giprobe_sdf.glsl index dd3910f52e..d089236723 100644 --- a/servers/visual/rasterizer_rd/shaders/giprobe_sdf.glsl +++ b/servers/visual/rasterizer_rd/shaders/giprobe_sdf.glsl @@ -19,7 +19,8 @@ struct CellChildren { layout(set = 0, binding = 1, std430) buffer CellChildrenBuffer { CellChildren data[]; -} cell_children; +} +cell_children; struct CellData { uint position; // xyz 10 bits @@ -30,7 +31,8 @@ struct CellData { layout(set = 0, binding = 2, std430) buffer CellDataBuffer { CellData data[]; -} cell_data; +} +cell_data; layout(r8ui, set = 0, binding = 3) uniform restrict writeonly uimage3D sdf_tex; @@ -39,7 +41,8 @@ layout(push_constant, binding = 0, std430) uniform Params { uint end; uint pad0; uint pad1; -} params; +} +params; void main() { diff --git a/servers/visual/rasterizer_rd/shaders/giprobe_write.glsl b/servers/visual/rasterizer_rd/shaders/giprobe_write.glsl index 50412a3b2f..c832223b1e 100644 --- a/servers/visual/rasterizer_rd/shaders/giprobe_write.glsl +++ b/servers/visual/rasterizer_rd/shaders/giprobe_write.glsl @@ -17,7 +17,8 @@ struct CellChildren { layout(set = 0, binding = 1, std430) buffer CellChildrenBuffer { CellChildren data[]; -} cell_children; +} +cell_children; struct CellData { uint position; // xyz 10 bits @@ -28,7 +29,8 @@ struct CellData { layout(set = 0, binding = 2, std430) buffer CellDataBuffer { CellData data[]; -} cell_data; +} +cell_data; #define LIGHT_TYPE_DIRECTIONAL 0 #define LIGHT_TYPE_OMNI 1 @@ -54,7 +56,8 @@ struct Light { layout(set = 0, binding = 3, std140) uniform Lights { Light data[MAX_LIGHTS]; -} lights; +} +lights; #endif @@ -70,11 +73,13 @@ layout(push_constant, binding = 0, std430) uniform Params { uint cell_offset; uint cell_count; uint pad[2]; -} params; +} +params; layout(set = 0, binding = 4, std140) uniform Outputs { vec4 data[]; -} output; +} +output; #ifdef MODE_COMPUTE_LIGHT diff --git a/servers/visual/rasterizer_rd/shaders/luminance_reduce.glsl b/servers/visual/rasterizer_rd/shaders/luminance_reduce.glsl index d3001e6fcb..4bf5b7e7f1 100644 --- a/servers/visual/rasterizer_rd/shaders/luminance_reduce.glsl +++ b/servers/visual/rasterizer_rd/shaders/luminance_reduce.glsl @@ -1,6 +1,6 @@ /* clang-format off */ [compute] -/* clang-format on */ + #version 450 VERSION_DEFINES @@ -8,9 +8,9 @@ VERSION_DEFINES #define BLOCK_SIZE 8 layout(local_size_x = BLOCK_SIZE, local_size_y = BLOCK_SIZE, local_size_z = 1) in; +/* clang-format on */ -shared float tmp_data[BLOCK_SIZE*BLOCK_SIZE]; - +shared float tmp_data[BLOCK_SIZE * BLOCK_SIZE]; #ifdef READ_TEXTURE @@ -36,19 +36,19 @@ layout(push_constant, binding = 1, std430) uniform Params { float min_luminance; float exposure_adjust; float pad[3]; -} params; +} +params; void main() { - uint t = gl_LocalInvocationID.y * BLOCK_SIZE + gl_LocalInvocationID.x; ivec2 pos = ivec2(gl_GlobalInvocationID.xy); - if (any(lessThan(pos,params.source_size))) { + if (any(lessThan(pos, params.source_size))) { #ifdef READ_TEXTURE - vec3 v = texelFetch(source_texture,pos,0).rgb; - tmp_data[t] = max(v.r,max(v.g,v.b)); + vec3 v = texelFetch(source_texture, pos, 0).rgb; + tmp_data[t] = max(v.r, max(v.g, v.b)); #else tmp_data[t] = imageLoad(source_luminance, pos).r; #endif @@ -59,28 +59,28 @@ void main() { groupMemoryBarrier(); barrier(); - uint size = (BLOCK_SIZE * BLOCK_SIZE)>>1; + uint size = (BLOCK_SIZE * BLOCK_SIZE) >> 1; do { - if (t<size) { - tmp_data[t]+=tmp_data[t+size]; + if (t < size) { + tmp_data[t] += tmp_data[t + size]; } groupMemoryBarrier(); barrier(); - size>>=1; + size >>= 1; - } while(size>=1); + } while (size >= 1); - if (t==0) { + if (t == 0) { //compute rect size - ivec2 rect_size = min(params.source_size - pos,ivec2(BLOCK_SIZE)); - float avg = tmp_data[0] / float(rect_size.x*rect_size.y); + ivec2 rect_size = min(params.source_size - pos, ivec2(BLOCK_SIZE)); + float avg = tmp_data[0] / float(rect_size.x * rect_size.y); //float avg = tmp_data[0] / float(BLOCK_SIZE*BLOCK_SIZE); - pos/=ivec2(BLOCK_SIZE); + pos /= ivec2(BLOCK_SIZE); #ifdef WRITE_LUMINANCE float prev_lum = texelFetch(prev_luminance, ivec2(0, 0), 0).r; //1 pixel previous exposure - avg= clamp(prev_lum + (avg - prev_lum) * params.exposure_adjust, params.min_luminance, params.max_luminance); + avg = clamp(prev_lum + (avg - prev_lum) * params.exposure_adjust, params.min_luminance, params.max_luminance); #endif imageStore(dest_luminance, pos, vec4(avg)); } diff --git a/servers/visual/rasterizer_rd/shaders/roughness_limiter.glsl b/servers/visual/rasterizer_rd/shaders/roughness_limiter.glsl index 5e0491c979..3637b1abb2 100644 --- a/servers/visual/rasterizer_rd/shaders/roughness_limiter.glsl +++ b/servers/visual/rasterizer_rd/shaders/roughness_limiter.glsl @@ -1,13 +1,12 @@ /* clang-format off */ [compute] -/* clang-format on */ #version 450 VERSION_DEFINES layout(local_size_x = 8, local_size_y = 8, local_size_z = 1) in; - +/* clang-format on */ layout(set = 0, binding = 0) uniform sampler2D source_normal; layout(r8, set = 1, binding = 0) uniform restrict writeonly image2D dest_roughness; @@ -16,7 +15,8 @@ layout(push_constant, binding = 1, std430) uniform Params { ivec2 screen_size; float curve; uint pad; -} params; +} +params; #define HALF_PI 1.5707963267948966 @@ -24,16 +24,16 @@ void main() { // Pixel being shaded ivec2 pos = ivec2(gl_GlobalInvocationID.xy); - if (any(greaterThan(pos,params.screen_size))) { //too large, do nothing + if (any(greaterThan(pos, params.screen_size))) { //too large, do nothing return; } vec3 normal_accum = vec3(0.0); float accum = 0.0; - for(int i=0;i<=1;i++) { - for(int j=0;j<=1;j++) { - normal_accum += normalize(texelFetch(source_normal,pos+ivec2(i,j),0).xyz * 2.0 - 1.0); - accum+=1.0; + for (int i = 0; i <= 1; i++) { + for (int j = 0; j <= 1; j++) { + normal_accum += normalize(texelFetch(source_normal, pos + ivec2(i, j), 0).xyz * 2.0 - 1.0); + accum += 1.0; } } @@ -46,7 +46,7 @@ void main() { if (r < 1.0) { float threshold = 0.4; -/* + /* //Formula from Filament, does not make sense to me. float r2 = r * r; @@ -54,7 +54,7 @@ void main() { float variance = 0.25f / kappa; limit = sqrt(min(2.0f * variance, threshold * threshold)); //*/ -/* + /* //Formula based on probability distribution graph float width = acos(max(0.0,r)); // convert to angle (width) @@ -62,12 +62,12 @@ void main() { limit = min(sqrt(roughness), threshold); //convert to perceptual roughness and apply threshold //*/ - limit = min(sqrt(pow(acos(max(0.0,r)) / HALF_PI ,params.curve)), threshold); //convert to perceptual roughness and apply threshold + limit = min(sqrt(pow(acos(max(0.0, r)) / HALF_PI, params.curve)), threshold); //convert to perceptual roughness and apply threshold //limit = 0.5; } else { limit = 0.0; } - imageStore(dest_roughness,pos,vec4(limit)); + imageStore(dest_roughness, pos, vec4(limit)); } diff --git a/servers/visual/rasterizer_rd/shaders/scene_high_end.glsl b/servers/visual/rasterizer_rd/shaders/scene_high_end.glsl index 8aee680c1e..07f4770b14 100644 --- a/servers/visual/rasterizer_rd/shaders/scene_high_end.glsl +++ b/servers/visual/rasterizer_rd/shaders/scene_high_end.glsl @@ -1151,7 +1151,7 @@ void gi_probe_compute(uint index, vec3 position, vec3 normal, vec3 ref_vec, mat3 ao = 1.0 - min(1.0, ao); - light = mix(scene_data.ao_color.rgb,light,mix(1.0, ao, gi_probes.data[index].ambient_occlusion)); + light = mix(scene_data.ao_color.rgb, light, mix(1.0, ao, gi_probes.data[index].ambient_occlusion)); } out_diff += vec4(light * blend, blend); @@ -1272,7 +1272,6 @@ FRAGMENT_SHADER_CODE #endif // !USE_SHADOW_TO_OPACITY - #if defined(NORMALMAP_USED) normalmap.xy = normalmap.xy * 2.0 - 1.0; @@ -1312,12 +1311,10 @@ FRAGMENT_SHADER_CODE #if !defined(MODE_RENDER_DEPTH) && !defined(MODE_UNSHADED) if (scene_data.roughness_limiter_enabled) { - float limit = texelFetch(sampler2D(roughness_buffer, material_samplers[SAMPLER_NEAREST_CLAMP]),ivec2(gl_FragCoord.xy),0).r; - roughness = max(roughness,limit); - + float limit = texelFetch(sampler2D(roughness_buffer, material_samplers[SAMPLER_NEAREST_CLAMP]), ivec2(gl_FragCoord.xy), 0).r; + roughness = max(roughness, limit); } - if (scene_data.use_reflection_cubemap) { vec3 ref_vec = reflect(-view, normal); @@ -1407,7 +1404,7 @@ FRAGMENT_SHADER_CODE } #endif - uvec4 cluster_cell = texture(usampler3D(cluster_texture, material_samplers[SAMPLER_NEAREST_CLAMP]),vec3(screen_uv,(abs(vertex.z)-scene_data.z_near)/(scene_data.z_far-scene_data.z_near))); + uvec4 cluster_cell = texture(usampler3D(cluster_texture, material_samplers[SAMPLER_NEAREST_CLAMP]), vec3(screen_uv, (abs(vertex.z) - scene_data.z_near) / (scene_data.z_far - scene_data.z_near))); { // process reflections @@ -1544,7 +1541,7 @@ FRAGMENT_SHADER_CODE uint light_index = cluster_data.indices[omni_light_pointer + i]; - if (!bool(lights.data[light_index].mask&instances.data[instance_index].layer_mask)) { + if (!bool(lights.data[light_index].mask & instances.data[instance_index].layer_mask)) { continue; //not masked } @@ -1577,7 +1574,7 @@ FRAGMENT_SHADER_CODE uint light_index = cluster_data.indices[spot_light_pointer + i]; - if (!bool(lights.data[light_index].mask&instances.data[instance_index].layer_mask)) { + if (!bool(lights.data[light_index].mask & instances.data[instance_index].layer_mask)) { continue; //not masked } @@ -1648,7 +1645,7 @@ FRAGMENT_SHADER_CODE #endif #ifdef MODE_RENDER_NORMAL - normal_output_buffer = vec4(normal * 0.5 + 0.5,0.0); + normal_output_buffer = vec4(normal * 0.5 + 0.5, 0.0); #ifdef MODE_RENDER_ROUGHNESS roughness_output_buffer = roughness; #endif //MODE_RENDER_ROUGHNESS @@ -1664,24 +1661,24 @@ FRAGMENT_SHADER_CODE #if defined(AO_USED) if (scene_data.ssao_enabled && scene_data.ssao_ao_affect > 0.0) { - float ssao = texture(sampler2D(ao_buffer, material_samplers[SAMPLER_LINEAR_CLAMP]),screen_uv).r; - ao = mix(ao,min(ao,ssao),scene_data.ssao_ao_affect); - ao_light_affect = mix(ao_light_affect,max(ao_light_affect,scene_data.ssao_light_affect),scene_data.ssao_ao_affect); + float ssao = texture(sampler2D(ao_buffer, material_samplers[SAMPLER_LINEAR_CLAMP]), screen_uv).r; + ao = mix(ao, min(ao, ssao), scene_data.ssao_ao_affect); + ao_light_affect = mix(ao_light_affect, max(ao_light_affect, scene_data.ssao_light_affect), scene_data.ssao_ao_affect); } - ambient_light = mix(scene_data.ao_color.rgb,ambient_light,ao); + ambient_light = mix(scene_data.ao_color.rgb, ambient_light, ao); ao_light_affect = mix(1.0, ao, ao_light_affect); - specular_light = mix(scene_data.ao_color.rgb,specular_light,ao_light_affect); - diffuse_light = mix(scene_data.ao_color.rgb,diffuse_light,ao_light_affect); + specular_light = mix(scene_data.ao_color.rgb, specular_light, ao_light_affect); + diffuse_light = mix(scene_data.ao_color.rgb, diffuse_light, ao_light_affect); #else if (scene_data.ssao_enabled) { - float ao = texture(sampler2D(ao_buffer, material_samplers[SAMPLER_LINEAR_CLAMP]),screen_uv).r; - ambient_light = mix(scene_data.ao_color.rgb,ambient_light,ao); - float ao_light_affect = mix(1.0, ao,scene_data.ssao_light_affect); - specular_light = mix(scene_data.ao_color.rgb,specular_light,ao_light_affect); - diffuse_light = mix(scene_data.ao_color.rgb,diffuse_light,ao_light_affect); + float ao = texture(sampler2D(ao_buffer, material_samplers[SAMPLER_LINEAR_CLAMP]), screen_uv).r; + ambient_light = mix(scene_data.ao_color.rgb, ambient_light, ao); + float ao_light_affect = mix(1.0, ao, scene_data.ssao_light_affect); + specular_light = mix(scene_data.ao_color.rgb, specular_light, ao_light_affect); + diffuse_light = mix(scene_data.ao_color.rgb, diffuse_light, ao_light_affect); } #endif // AO_USED diff --git a/servers/visual/rasterizer_rd/shaders/scene_high_end_inc.glsl b/servers/visual/rasterizer_rd/shaders/scene_high_end_inc.glsl index 384e51bbce..9b14499923 100644 --- a/servers/visual/rasterizer_rd/shaders/scene_high_end_inc.glsl +++ b/servers/visual/rasterizer_rd/shaders/scene_high_end_inc.glsl @@ -4,7 +4,8 @@ layout(push_constant, binding = 0, std430) uniform DrawCall { uint instance_index; uint pad[3]; //16 bits minimum size -} draw_call; +} +draw_call; /* Set 0 Scene data that never changes, ever */ @@ -101,7 +102,8 @@ layout(set = 0, binding = 3, std140) uniform SceneData { float fog_height_max; float fog_height_curve; #endif -} scene_data; +} +scene_data; #define INSTANCE_FLAGS_FORWARD_MASK 0x7 #define INSTANCE_FLAGS_FORWARD_OMNI_LIGHT_SHIFT 3 @@ -129,7 +131,8 @@ struct InstanceData { layout(set = 0, binding = 4, std430) buffer Instances { InstanceData data[]; -} instances; +} +instances; struct LightData { //this structure needs to be 128 bits vec3 position; @@ -146,7 +149,8 @@ struct LightData { //this structure needs to be 128 bits layout(set = 0, binding = 5, std140) uniform Lights { LightData data[MAX_LIGHT_DATA_STRUCTS]; -} lights; +} +lights; struct ReflectionData { @@ -162,7 +166,8 @@ struct ReflectionData { layout(set = 0, binding = 6, std140) uniform ReflectionProbeData { ReflectionData data[MAX_REFLECTION_DATA_STRUCTS]; -} reflections; +} +reflections; struct DirectionalLightData { vec3 direction; @@ -184,7 +189,8 @@ struct DirectionalLightData { layout(set = 0, binding = 7, std140) uniform DirectionalLights { DirectionalLightData data[MAX_DIRECTIONAL_LIGHT_DATA_STRUCTS]; -} directional_lights; +} +directional_lights; struct GIProbeData { mat4 xform; @@ -204,7 +210,8 @@ struct GIProbeData { layout(set = 0, binding = 8, std140) uniform GIProbes { GIProbeData data[MAX_GI_PROBES]; -} gi_probes; +} +gi_probes; layout(set = 0, binding = 9) uniform texture3D gi_probe_textures[MAX_GI_PROBE_TEXTURES]; @@ -216,7 +223,8 @@ layout(set = 0, binding = 10) uniform utexture3D cluster_texture; layout(set = 0, binding = 11, std430) buffer ClusterData { uint indices[]; -} cluster_data; +} +cluster_data; layout(set = 0, binding = 12) uniform texture2D directional_shadow_atlas; @@ -234,7 +242,6 @@ layout(set = 1, binding = 0) uniform textureCube radiance_cubemap; #endif - /* Set 2, Reflection and Shadow Atlases (view dependant) */ layout(set = 2, binding = 0) uniform textureCubeArray reflection_atlas; @@ -253,6 +260,7 @@ layout(set = 3, binding = 4) uniform texture2D ao_buffer; layout(set = 4, binding = 0, std430) buffer Transforms { vec4 data[]; -} transforms; +} +transforms; /* Set 5 User Material */ diff --git a/servers/visual/rasterizer_rd/shaders/sky.glsl b/servers/visual/rasterizer_rd/shaders/sky.glsl index 2de865383a..28fd2883c3 100644 --- a/servers/visual/rasterizer_rd/shaders/sky.glsl +++ b/servers/visual/rasterizer_rd/shaders/sky.glsl @@ -15,7 +15,8 @@ layout(push_constant, binding = 1, std430) uniform Params { float alpha; float depth; float pad; -} params; +} +params; void main() { @@ -45,7 +46,8 @@ layout(push_constant, binding = 1, std430) uniform Params { float alpha; float depth; float pad; -} params; +} +params; vec4 texturePanorama(sampler2D pano, vec3 normal) { diff --git a/servers/visual/rasterizer_rd/shaders/ssao.glsl b/servers/visual/rasterizer_rd/shaders/ssao.glsl index 95a5c41d39..c9d7134610 100644 --- a/servers/visual/rasterizer_rd/shaders/ssao.glsl +++ b/servers/visual/rasterizer_rd/shaders/ssao.glsl @@ -1,11 +1,12 @@ /* clang-format off */ [compute] -/* clang-format on */ + #version 450 VERSION_DEFINES layout(local_size_x = 8, local_size_y = 8, local_size_z = 1) in; +/* clang-format on */ #define TWO_PI 6.283185307179586476925286766559 @@ -76,9 +77,8 @@ layout(push_constant, binding = 1, std430) uniform Params { vec2 pixel_size; float proj_scale; uint pad; - -} params; - +} +params; vec3 reconstructCSPosition(vec2 S, float z) { if (params.orthogonal) { @@ -157,7 +157,6 @@ vec3 getOffsetPosition(ivec2 ssP, float ssR) { // Offset to pixel center P = reconstructCSPosition(vec2(ssP) + vec2(0.5), P.z); - return P; } @@ -178,7 +177,7 @@ float sampleAO(in ivec2 ssC, in vec3 C, in vec3 n_C, in float ssDiskRadius, in f ivec2 ssP = ivec2(ssR * unitOffset) + ssC; - if (any(lessThan(ssP,ivec2(0))) || any(greaterThanEqual(ssP,params.screen_size))) { + if (any(lessThan(ssP, ivec2(0))) || any(greaterThanEqual(ssP, params.screen_size))) { return 0.0; } @@ -213,25 +212,21 @@ float sampleAO(in ivec2 ssC, in vec3 C, in vec3 n_C, in float ssDiskRadius, in f void main() { // Pixel being shaded ivec2 ssC = ivec2(gl_GlobalInvocationID.xy); - if (any(greaterThan(ssC,params.screen_size))) { //too large, do nothing + if (any(greaterThan(ssC, params.screen_size))) { //too large, do nothing return; } // World space point being shaded vec3 C = getPosition(ssC); - - #ifdef USE_HALF_SIZE - vec3 n_C = texelFetch(source_normal,ssC<<1,0).xyz * 2.0 - 1.0; + vec3 n_C = texelFetch(source_normal, ssC << 1, 0).xyz * 2.0 - 1.0; #else - vec3 n_C = texelFetch(source_normal,ssC,0).xyz * 2.0 - 1.0; + vec3 n_C = texelFetch(source_normal, ssC, 0).xyz * 2.0 - 1.0; #endif n_C = normalize(n_C); n_C.y = -n_C.y; //because this code reads flipped - - // Hash function used in the HPG12 AlchemyAO paper float randomPatternRotationAngle = mod(float((3 * ssC.x ^ ssC.y + ssC.x * ssC.y) * 10), TWO_PI); @@ -253,5 +248,5 @@ void main() { float A = max(0.0, 1.0 - sum * params.intensity_div_r6 * (5.0 / float(NUM_SAMPLES))); - imageStore(dest_image,ssC,vec4(A)); + imageStore(dest_image, ssC, vec4(A)); } diff --git a/servers/visual/rasterizer_rd/shaders/ssao_blur.glsl b/servers/visual/rasterizer_rd/shaders/ssao_blur.glsl index 51ecef9bd9..e90c788e08 100644 --- a/servers/visual/rasterizer_rd/shaders/ssao_blur.glsl +++ b/servers/visual/rasterizer_rd/shaders/ssao_blur.glsl @@ -1,13 +1,12 @@ /* clang-format off */ [compute] -/* clang-format on */ #version 450 VERSION_DEFINES layout(local_size_x = 8, local_size_y = 8, local_size_z = 1) in; - +/* clang-format on */ layout(set = 0, binding = 0) uniform sampler2D source_ssao; layout(set = 1, binding = 0) uniform sampler2D source_depth; @@ -31,9 +30,8 @@ layout(push_constant, binding = 1, std430) uniform Params { uint pad2; ivec2 axis; /** (1, 0) or (0, 1) */ ivec2 screen_size; -} params; - - +} +params; /** Filter radius in pixels. This will be multiplied by SCALE. */ #define R (4) @@ -47,14 +45,11 @@ const float gaussian[R + 1] = float[](0.153170, 0.144893, 0.122649, 0.092902, 0.062970); // stddev = 2.0 //float[](0.111220, 0.107798, 0.098151, 0.083953, 0.067458, 0.050920, 0.036108); // stddev = 3.0 - - - void main() { // Pixel being shaded ivec2 ssC = ivec2(gl_GlobalInvocationID.xy); - if (any(greaterThan(ssC,params.screen_size))) { //too large, do nothing + if (any(greaterThan(ssC, params.screen_size))) { //too large, do nothing return; } @@ -73,22 +68,22 @@ void main() { vec2 pixel_size = 1.0 / vec2(params.screen_size); vec2 closest_uv = vec2(ssC) * pixel_size + pixel_size * 0.5; vec2 from_uv = closest_uv; - vec2 ps2 = pixel_size;// * 2.0; + vec2 ps2 = pixel_size; // * 2.0; - float closest_depth = abs(textureLod(source_depth_mipmaps,closest_uv,0.0).r-depth); + float closest_depth = abs(textureLod(source_depth_mipmaps, closest_uv, 0.0).r - depth); - vec2 offsets[4]=vec2[](vec2(ps2.x,0),vec2(-ps2.x,0),vec2(0,ps2.y),vec2(0,-ps2.y)); - for(int i=0;i<4;i++) { + vec2 offsets[4] = vec2[](vec2(ps2.x, 0), vec2(-ps2.x, 0), vec2(0, ps2.y), vec2(0, -ps2.y)); + for (int i = 0; i < 4; i++) { vec2 neighbour = from_uv + offsets[i]; - float neighbour_depth = abs(textureLod(source_depth_mipmaps,neighbour,0.0).r-depth); - if (neighbour_depth < closest_depth ) { + float neighbour_depth = abs(textureLod(source_depth_mipmaps, neighbour, 0.0).r - depth); + if (neighbour_depth < closest_depth) { closest_uv = neighbour; closest_depth = neighbour_depth; } } - float visibility = textureLod(source_ssao,closest_uv,0.0).r; - imageStore(dest_image,ssC,vec4(visibility)); + float visibility = textureLod(source_ssao, closest_uv, 0.0).r; + imageStore(dest_image, ssC, vec4(visibility)); #else float depth = texelFetch(source_depth, ssC, 0).r; @@ -132,7 +127,6 @@ void main() { float value = texelFetch(source_ssao, clamp(ppos, ivec2(0), clamp_limit), 0).r; ivec2 rpos = clamp(ppos, ivec2(0), clamp_limit); - float temp_depth = texelFetch(source_depth, rpos, 0).r; #ifdef MODE_FULL_SIZE temp_depth = temp_depth * 2.0 - 1.0; @@ -158,6 +152,6 @@ void main() { const float epsilon = 0.0001; float visibility = sum / (totalWeight + epsilon); - imageStore(dest_image,ssC,vec4(visibility)); + imageStore(dest_image, ssC, vec4(visibility)); #endif } diff --git a/servers/visual/rasterizer_rd/shaders/ssao_minify.glsl b/servers/visual/rasterizer_rd/shaders/ssao_minify.glsl index 0e6f8b7d9a..8728154347 100644 --- a/servers/visual/rasterizer_rd/shaders/ssao_minify.glsl +++ b/servers/visual/rasterizer_rd/shaders/ssao_minify.glsl @@ -1,12 +1,12 @@ /* clang-format off */ [compute] -/* clang-format on */ #version 450 VERSION_DEFINES layout(local_size_x = 8, local_size_y = 8, local_size_z = 1) in; +/* clang-format on */ layout(push_constant, binding = 1, std430) uniform Params { vec2 pixel_size; @@ -15,8 +15,8 @@ layout(push_constant, binding = 1, std430) uniform Params { ivec2 source_size; bool orthogonal; uint pad; -} params; - +} +params; #ifdef MINIFY_START layout(set = 0, binding = 0) uniform sampler2D source_texture; @@ -29,21 +29,20 @@ void main() { ivec2 pos = ivec2(gl_GlobalInvocationID.xy); - if (any(greaterThan(pos,params.source_size>>1))) { //too large, do nothing + if (any(greaterThan(pos, params.source_size >> 1))) { //too large, do nothing return; } #ifdef MINIFY_START - float depth = texelFetch(source_texture,pos<<1,0).r * 2.0 - 1.0; + float depth = texelFetch(source_texture, pos << 1, 0).r * 2.0 - 1.0; if (params.orthogonal) { depth = ((depth + (params.z_far + params.z_near) / (params.z_far - params.z_near)) * (params.z_far - params.z_near)) / 2.0; } else { depth = 2.0 * params.z_near * params.z_far / (params.z_far + params.z_near - depth * (params.z_far - params.z_near)); } #else - float depth = imageLoad(source_image,pos<<1).r; + float depth = imageLoad(source_image, pos << 1).r; #endif - imageStore(dest_image,pos,vec4(depth)); - + imageStore(dest_image, pos, vec4(depth)); } diff --git a/servers/visual/rasterizer_rd/shaders/tonemap.glsl b/servers/visual/rasterizer_rd/shaders/tonemap.glsl index ee6ced0a55..524ca5e2ea 100644 --- a/servers/visual/rasterizer_rd/shaders/tonemap.glsl +++ b/servers/visual/rasterizer_rd/shaders/tonemap.glsl @@ -48,7 +48,8 @@ layout(push_constant, binding = 1, std430) uniform Params { float exposure; float white; float auto_exposure_grey; -} params; +} +params; layout(location = 0) out vec4 frag_color; @@ -270,8 +271,7 @@ void main() { if (params.use_glow && params.glow_mode == GLOW_MODE_MIX) { vec3 glow = gather_glow(source_glow, uv_interp); - color.rgb = mix(color.rgb,glow,params.glow_intensity); - + color.rgb = mix(color.rgb, glow, params.glow_intensity); } color = apply_tonemapping(color, params.white); |