From 710b34b70227becdc652b4ae027fe0ac47409642 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?R=C3=A9mi=20Verschelde?= Date: Thu, 14 May 2020 13:20:05 +0200 Subject: Style: Fix missing/invalid copyright headers --- modules/lightmapper_rd/lightmapper_rd.cpp | 30 ++++++++++++++++++++++++++++++ modules/lightmapper_rd/lightmapper_rd.h | 30 ++++++++++++++++++++++++++++++ 2 files changed, 60 insertions(+) (limited to 'modules/lightmapper_rd') diff --git a/modules/lightmapper_rd/lightmapper_rd.cpp b/modules/lightmapper_rd/lightmapper_rd.cpp index 6983c222c0..10f8512237 100644 --- a/modules/lightmapper_rd/lightmapper_rd.cpp +++ b/modules/lightmapper_rd/lightmapper_rd.cpp @@ -1,3 +1,33 @@ +/*************************************************************************/ +/* lightmapper_rd.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 "lightmapper_rd.h" #include "core/math/geometry.h" #include "core/project_settings.h" diff --git a/modules/lightmapper_rd/lightmapper_rd.h b/modules/lightmapper_rd/lightmapper_rd.h index cb98efbeaa..c6f1b0e710 100644 --- a/modules/lightmapper_rd/lightmapper_rd.h +++ b/modules/lightmapper_rd/lightmapper_rd.h @@ -1,3 +1,33 @@ +/*************************************************************************/ +/* lightmapper_rd.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 LIGHTMAPPER_RD_H #define LIGHTMAPPER_RD_H -- cgit v1.2.3 From 0be6d925dc3c6413bce7a3ccb49631b8e4a6e67a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?R=C3=A9mi=20Verschelde?= Date: Thu, 14 May 2020 13:23:58 +0200 Subject: Style: clang-format: Disable KeepEmptyLinesAtTheStartOfBlocks Which means that reduz' beloved style which we all became used to will now be changed automatically to remove the first empty line. This makes us lean closer to 1TBS (the one true brace style) instead of hybridating it with some Allman-inspired spacing. There's still the case of braces around single-statement blocks that needs to be addressed (but clang-format can't help with that, but clang-tidy may if we agree about it). Part of #33027. --- modules/lightmapper_rd/lightmapper_rd.cpp | 39 ------------------------------- modules/lightmapper_rd/lightmapper_rd.h | 1 - modules/lightmapper_rd/lm_blendseams.glsl | 2 -- modules/lightmapper_rd/lm_compute.glsl | 7 ------ modules/lightmapper_rd/lm_raster.glsl | 2 -- modules/lightmapper_rd/register_types.cpp | 1 - 6 files changed, 52 deletions(-) (limited to 'modules/lightmapper_rd') diff --git a/modules/lightmapper_rd/lightmapper_rd.cpp b/modules/lightmapper_rd/lightmapper_rd.cpp index 10f8512237..cf54754a16 100644 --- a/modules/lightmapper_rd/lightmapper_rd.cpp +++ b/modules/lightmapper_rd/lightmapper_rd.cpp @@ -81,7 +81,6 @@ void LightmapperRD::add_omni_light(bool p_static, const Vector3 &p_position, con lights.push_back(l); } void LightmapperRD::add_spot_light(bool p_static, const Vector3 &p_position, const Vector3 p_direction, const Color &p_color, float p_energy, float p_range, float p_attenuation, float p_spot_angle, float p_spot_attenuation, float p_size) { - Light l; l.type = LIGHT_TYPE_SPOT; l.position[0] = p_position.x; @@ -113,11 +112,9 @@ void LightmapperRD::add_probe(const Vector3 &p_position) { } void LightmapperRD::_plot_triangle_into_triangle_index_list(int p_size, const Vector3i &p_ofs, const AABB &p_bounds, const Vector3 p_points[3], uint32_t p_triangle_index, LocalVector &triangles, uint32_t p_grid_size) { - int half_size = p_size / 2; for (int i = 0; i < 8; i++) { - AABB aabb = p_bounds; aabb.size *= 0.5; Vector3i n = p_ofs; @@ -157,11 +154,9 @@ void LightmapperRD::_plot_triangle_into_triangle_index_list(int p_size, const Ve } Lightmapper::BakeError LightmapperRD::_blit_meshes_into_atlas(int p_max_texture_size, Vector> &albedo_images, Vector> &emission_images, AABB &bounds, Size2i &atlas_size, int &atlas_slices, BakeStepFunc p_step_function, void *p_bake_userdata) { - Vector sizes; for (int m_i = 0; m_i < mesh_instances.size(); m_i++) { - MeshInstance &mi = mesh_instances.write[m_i]; Size2i s = Size2i(mi.data.albedo_on_uv2->get_width(), mi.data.albedo_on_uv2->get_height()); sizes.push_back(s); @@ -189,7 +184,6 @@ Lightmapper::BakeError LightmapperRD::_blit_meshes_into_atlas(int p_max_texture_ //determine best texture array atlas size by bruteforce fitting while (atlas_size.x <= p_max_texture_size && atlas_size.y <= p_max_texture_size) { - Vector source_sizes = sizes; Vector source_indices; source_indices.resize(source_sizes.size()); @@ -202,7 +196,6 @@ Lightmapper::BakeError LightmapperRD::_blit_meshes_into_atlas(int p_max_texture_ int slices = 0; while (source_sizes.size() > 0) { - Vector offsets = Geometry::partial_pack_rects(source_sizes, atlas_size); Vector new_indices; Vector new_sources; @@ -266,7 +259,6 @@ Lightmapper::BakeError LightmapperRD::_blit_meshes_into_atlas(int p_max_texture_ //assign uv positions for (int m_i = 0; m_i < mesh_instances.size(); m_i++) { - MeshInstance &mi = mesh_instances.write[m_i]; mi.offset.x = best_atlas_offsets[m_i].x; mi.offset.y = best_atlas_offsets[m_i].y; @@ -279,7 +271,6 @@ Lightmapper::BakeError LightmapperRD::_blit_meshes_into_atlas(int p_max_texture_ } void LightmapperRD::_create_acceleration_structures(RenderingDevice *rd, Size2i atlas_size, int atlas_slices, AABB &bounds, int grid_size, Vector &probe_positions, GenerateProbes p_generate_probes, Vector &slice_triangle_count, Vector &slice_seam_count, RID &vertex_buffer, RID &triangle_buffer, RID &box_buffer, RID &lights_buffer, RID &triangle_cell_indices_buffer, RID &probe_positions_buffer, RID &grid_texture, RID &grid_texture_sdf, RID &seams_buffer, BakeStepFunc p_step_function, void *p_bake_userdata) { - HashMap vertex_map; //fill triangles array and vertex array @@ -299,7 +290,6 @@ void LightmapperRD::_create_acceleration_structures(RenderingDevice *rd, Size2i bounds = AABB(); for (int m_i = 0; m_i < mesh_instances.size(); m_i++) { - if (p_step_function) { float p = float(m_i + 1) / mesh_instances.size() * 0.1; p_step_function(0.3 + p, vformat(TTR("Plotting mesh into acceleration structure %d/%d"), m_i + 1, mesh_instances.size()), p_bake_userdata, false); @@ -316,7 +306,6 @@ void LightmapperRD::_create_acceleration_structures(RenderingDevice *rd, Size2i } for (int i = 0; i < mi.data.points.size(); i += 3) { - Vector3 vtxs[3] = { mi.data.points[i + 0], mi.data.points[i + 1], mi.data.points[i + 2] }; Vector2 uvs[3] = { mi.data.uv2[i + 0] * uv_scale + uv_offset, mi.data.uv2[i + 1] * uv_scale + uv_offset, mi.data.uv2[i + 2] * uv_scale + uv_offset }; Vector3 normal[3] = { mi.data.normal[i + 0], mi.data.normal[i + 1], mi.data.normal[i + 2] }; @@ -325,7 +314,6 @@ void LightmapperRD::_create_acceleration_structures(RenderingDevice *rd, Size2i Triangle t; t.slice = mi.slice; for (int k = 0; k < 3; k++) { - bounds.expand_to(vtxs[k]); Vertex v; @@ -427,7 +415,6 @@ void LightmapperRD::_create_acceleration_structures(RenderingDevice *rd, Size2i //fill list of triangles in grid LocalVector triangle_sort; for (uint32_t i = 0; i < triangles.size(); i++) { - const Triangle &t = triangles[i]; Vector3 face[3] = { Vector3(vertex_array[t.indices[0]].position[0], vertex_array[t.indices[0]].position[1], vertex_array[t.indices[0]].position[2]), @@ -571,7 +558,6 @@ void LightmapperRD::_create_acceleration_structures(RenderingDevice *rd, Size2i } void LightmapperRD::_raster_geometry(RenderingDevice *rd, Size2i atlas_size, int atlas_slices, int grid_size, AABB bounds, float p_bias, Vector slice_triangle_count, RID position_tex, RID unocclude_tex, RID normal_tex, RID raster_depth_buffer, RID rasterize_shader, RID raster_base_uniform) { - Vector framebuffers; for (int i = 0; i < atlas_slices; i++) { @@ -594,7 +580,6 @@ void LightmapperRD::_raster_geometry(RenderingDevice *rd, Size2i atlas_size, int RID raster_pipeline = rd->render_pipeline_create(rasterize_shader, rd->framebuffer_get_format(framebuffers[0]), RD::INVALID_FORMAT_ID, RD::RENDER_PRIMITIVE_TRIANGLES, RD::PipelineRasterizationState(), RD::PipelineMultisampleState(), ds, RD::PipelineColorBlendState::create_disabled(3), 0); RID raster_pipeline_wire; { - RD::PipelineRasterizationState rw; rw.wireframe = true; raster_pipeline_wire = rd->render_pipeline_create(rasterize_shader, rd->framebuffer_get_format(framebuffers[0]), RD::INVALID_FORMAT_ID, RD::RENDER_PRIMITIVE_TRIANGLES, rw, RD::PipelineMultisampleState(), ds, RD::PipelineColorBlendState::create_disabled(3), 0); @@ -607,7 +592,6 @@ void LightmapperRD::_raster_geometry(RenderingDevice *rd, Size2i atlas_size, int clear_colors.push_back(Color(0, 0, 0, 0)); for (int i = 0; i < atlas_slices; i++) { - RasterPushConstant raster_push_constant; raster_push_constant.atlas_size[0] = atlas_size.x; raster_push_constant.atlas_size[1] = atlas_size.y; @@ -644,7 +628,6 @@ void LightmapperRD::_raster_geometry(RenderingDevice *rd, Size2i atlas_size, int } LightmapperRD::BakeError LightmapperRD::bake(BakeQuality p_quality, bool p_use_denoiser, int p_bounces, float p_bias, int p_max_texture_size, bool p_bake_sh, GenerateProbes p_generate_probes, const Ref &p_environment_panorama, const Basis &p_environment_transform, BakeStepFunc p_step_function, void *p_bake_userdata) { - if (p_step_function) { p_step_function(0.0, TTR("Begin Bake"), p_bake_userdata, true); } @@ -840,7 +823,6 @@ LightmapperRD::BakeError LightmapperRD::bake(BakeQuality p_quality, bool p_use_d Vector base_uniforms; { { - RD::Uniform u; u.type = RD::UNIFORM_TYPE_STORAGE_BUFFER; u.binding = 1; @@ -975,7 +957,6 @@ LightmapperRD::BakeError LightmapperRD::bake(BakeQuality p_quality, bool p_use_d compute_shader.instance(); err = compute_shader->parse_versions_from_text(lm_compute_shader_glsl, p_bake_sh ? "\n#define USE_SH_LIGHTMAPS\n" : ""); if (err != OK) { - FREE_TEXTURES FREE_BUFFERS FREE_RASTER_RESOURCES @@ -1062,11 +1043,9 @@ LightmapperRD::BakeError LightmapperRD::bake(BakeQuality p_quality, bool p_use_d /* UNOCCLUDE */ { - Vector uniforms; { { - RD::Uniform u; u.type = RD::UNIFORM_TYPE_IMAGE; u.binding = 0; @@ -1104,11 +1083,9 @@ LightmapperRD::BakeError LightmapperRD::bake(BakeQuality p_quality, bool p_use_d /* PRIMARY (direct) LIGHT PASS */ { - Vector uniforms; { { - RD::Uniform u; u.type = RD::UNIFORM_TYPE_IMAGE; u.binding = 0; @@ -1186,11 +1163,9 @@ LightmapperRD::BakeError LightmapperRD::bake(BakeQuality p_quality, bool p_use_d } if (p_bounces > 0) { - Vector uniforms; { { - RD::Uniform u; u.type = RD::UNIFORM_TYPE_IMAGE; u.binding = 0; @@ -1286,7 +1261,6 @@ LightmapperRD::BakeError LightmapperRD::bake(BakeQuality p_quality, bool p_use_d for (int i = 0; i < x_regions; i++) { for (int j = 0; j < y_regions; j++) { - int x = i * max_region_size; int y = j * max_region_size; int w = MIN((i + 1) * max_region_size, atlas_size.width) - x; @@ -1298,7 +1272,6 @@ LightmapperRD::BakeError LightmapperRD::bake(BakeQuality p_quality, bool p_use_d group_size = Vector3i((w - 1) / 8 + 1, (h - 1) / 8 + 1, 1); for (int k = 0; k < ray_iterations; k++) { - RD::ComputeListID compute_list = rd->compute_list_begin(); rd->compute_list_bind_compute_pipeline(compute_list, compute_shader_secondary_pipeline); rd->compute_list_bind_uniform_set(compute_list, compute_base_uniform_set, 0); @@ -1332,7 +1305,6 @@ LightmapperRD::BakeError LightmapperRD::bake(BakeQuality p_quality, bool p_use_d RID light_probe_buffer; if (probe_positions.size()) { - light_probe_buffer = rd->storage_buffer_create(sizeof(float) * 4 * 9 * probe_positions.size()); if (p_step_function) { @@ -1341,9 +1313,7 @@ LightmapperRD::BakeError LightmapperRD::bake(BakeQuality p_quality, bool p_use_d Vector uniforms; { - { - RD::Uniform u; u.type = RD::UNIFORM_TYPE_STORAGE_BUFFER; u.binding = 0; @@ -1396,7 +1366,6 @@ LightmapperRD::BakeError LightmapperRD::bake(BakeQuality p_quality, bool p_use_d int ray_iterations = (push_constant.ray_count - 1) / max_rays + 1; for (int i = 0; i < ray_iterations; i++) { - RD::ComputeListID compute_list = rd->compute_list_begin(); rd->compute_list_bind_compute_pipeline(compute_list, compute_shader_light_probes_pipeline); rd->compute_list_bind_uniform_set(compute_list, compute_base_uniform_set, 0); @@ -1486,13 +1455,11 @@ LightmapperRD::BakeError LightmapperRD::bake(BakeQuality p_quality, bool p_use_d /* DILATE LIGHTMAP */ { - SWAP(light_accum_tex, light_accum_tex2); Vector uniforms; { { - RD::Uniform u; u.type = RD::UNIFORM_TYPE_IMAGE; u.binding = 0; @@ -1567,7 +1534,6 @@ LightmapperRD::BakeError LightmapperRD::bake(BakeQuality p_quality, bool p_use_d rd->free(blendseams_triangle_raster_shader); { - //pre copy for (int i = 0; i < atlas_slices * (p_bake_sh ? 4 : 1); i++) { rd->texture_copy(light_accum_tex, light_accum_tex2, Vector3(), Vector3(), Vector3(atlas_size.width, atlas_size.height, 1), 0, 0, i, i, true); @@ -1585,7 +1551,6 @@ LightmapperRD::BakeError LightmapperRD::bake(BakeQuality p_quality, bool p_use_d Vector uniforms; { { - RD::Uniform u; u.type = RD::UNIFORM_TYPE_TEXTURE; u.binding = 0; @@ -1615,10 +1580,8 @@ LightmapperRD::BakeError LightmapperRD::bake(BakeQuality p_quality, bool p_use_d Vector clear_colors; clear_colors.push_back(Color(0, 0, 0, 1)); for (int i = 0; i < atlas_slices; i++) { - int subslices = (p_bake_sh ? 4 : 1); for (int k = 0; k < subslices; k++) { - RasterSeamsPushConstant seams_push_constant; seams_push_constant.slice = uint32_t(i * subslices + k); seams_push_constant.debug = debug; @@ -1668,7 +1631,6 @@ LightmapperRD::BakeError LightmapperRD::bake(BakeQuality p_quality, bool p_use_d rd->draw_list_bind_render_pipeline(draw_list, blendseams_line_raster_pipeline); for (int j = 1; j < uv_offset_count; j++) { - seams_push_constant.base_index = seam_offset; seams_push_constant.uv_offset[0] = uv_offsets[j].x / float(atlas_size.width); seams_push_constant.uv_offset[1] = uv_offsets[j].y / float(atlas_size.height); @@ -1750,7 +1712,6 @@ Variant LightmapperRD::get_bake_mesh_userdata(int p_index) const { return mesh_instances[p_index].data.userdata; } Rect2 LightmapperRD::get_bake_mesh_uv_scale(int p_index) const { - ERR_FAIL_COND_V(bake_textures.size() == 0, Rect2()); Rect2 uv_ofs; Vector2 atlas_size = Vector2(bake_textures[0]->get_width(), bake_textures[0]->get_height()); diff --git a/modules/lightmapper_rd/lightmapper_rd.h b/modules/lightmapper_rd/lightmapper_rd.h index c6f1b0e710..6cb3ecbe9e 100644 --- a/modules/lightmapper_rd/lightmapper_rd.h +++ b/modules/lightmapper_rd/lightmapper_rd.h @@ -198,7 +198,6 @@ class LightmapperRD : public Lightmapper { }; struct RasterSeamsPushConstant { - uint32_t base_index; uint32_t slice; float uv_offset[2]; diff --git a/modules/lightmapper_rd/lm_blendseams.glsl b/modules/lightmapper_rd/lm_blendseams.glsl index ef1ece8ea1..8a9ea91311 100644 --- a/modules/lightmapper_rd/lm_blendseams.glsl +++ b/modules/lightmapper_rd/lm_blendseams.glsl @@ -26,7 +26,6 @@ VERSION_DEFINES layout(location = 0) out vec3 uv_interp; void main() { - #ifdef MODE_TRIANGLES uint triangle_idx = params.base_index + gl_VertexIndex / 3; @@ -103,7 +102,6 @@ layout(location = 0) out vec4 dst_color; layout(set = 1, binding = 0) uniform texture2DArray src_color_tex; void main() { - if (params.debug) { #ifdef MODE_TRIANGLES dst_color = vec4(1, 0, 1, 1); diff --git a/modules/lightmapper_rd/lm_compute.glsl b/modules/lightmapper_rd/lm_compute.glsl index a178bd9b2e..5a1f1ceda3 100644 --- a/modules/lightmapper_rd/lm_compute.glsl +++ b/modules/lightmapper_rd/lm_compute.glsl @@ -97,7 +97,6 @@ params; //check it, but also return distance and barycentric coords (for uv lookup) bool ray_hits_triangle(vec3 from, vec3 dir, float max_dist, vec3 p0, vec3 p1, vec3 p2, out float r_distance, out vec3 r_barycentric) { - const vec3 e0 = p1 - p0; const vec3 e1 = p0 - p2; vec3 triangleNormal = cross(e1, e0); @@ -146,7 +145,6 @@ bool trace_ray(vec3 p_from, vec3 p_to uint iters = 0; while (all(greaterThanEqual(icell, ivec3(0))) && all(lessThan(icell, ivec3(params.grid_size))) && iters < 1000) { - uvec2 cell_data = texelFetch(usampler3D(grid, linear_sampler), icell, 0).xy; if (cell_data.x > 0) { //triangles here @@ -258,7 +256,6 @@ float quick_hash(vec2 pos) { } void main() { - #ifdef MODE_LIGHT_PROBES int probe_index = int(gl_GlobalInvocationID.x); if (probe_index >= params.atlas_size.x) { //too large, do nothing @@ -294,7 +291,6 @@ void main() { #endif for (uint i = 0; i < params.light_count; i++) { - vec3 light_pos; float attenuation; if (lights.data[i].type == LIGHT_TYPE_DIRECTIONAL) { @@ -313,7 +309,6 @@ void main() { attenuation = pow(max(1.0 - d, 0.0), lights.data[i].attenuation); if (lights.data[i].type == LIGHT_TYPE_SPOT) { - vec3 rel = normalize(position - light_pos); float angle = acos(dot(rel, lights.data[i].direction)); if (angle > lights.data[i].spot_angle) { @@ -512,7 +507,6 @@ void main() { vec3 norm; if (trace_ray(base_pos, ray_to, d, norm)) { - if (d < min_d) { vertex_pos = base_pos + rays[i] * d + norm * params.bias * 10.0; //this bias needs to be greater than the regular bias, because otherwise later, rays will go the other side when pointing back. min_d = d; @@ -561,7 +555,6 @@ void main() { light = textureLod(sampler2DArray(source_light, linear_sampler), uvw, 0.0).rgb; light += textureLod(sampler2DArray(source_direct_light, linear_sampler), uvw, 0.0).rgb; } else { - //did not hit a triangle, reach out for the sky vec3 sky_dir = normalize(mat3(params.env_transform) * ray_dir); diff --git a/modules/lightmapper_rd/lm_raster.glsl b/modules/lightmapper_rd/lm_raster.glsl index ae3038aead..41b3e89a3f 100644 --- a/modules/lightmapper_rd/lm_raster.glsl +++ b/modules/lightmapper_rd/lm_raster.glsl @@ -31,7 +31,6 @@ params; /* clang-format on */ void main() { - uint triangle_idx = params.base_triangle + gl_VertexIndex / 3; uint triangle_subidx = gl_VertexIndex % 3; @@ -95,7 +94,6 @@ layout(location = 1) out vec4 normal; layout(location = 2) out vec4 unocclude; void main() { - vec3 vertex_pos = vertex_interp; { diff --git a/modules/lightmapper_rd/register_types.cpp b/modules/lightmapper_rd/register_types.cpp index f3938f3190..0e6d7590cc 100644 --- a/modules/lightmapper_rd/register_types.cpp +++ b/modules/lightmapper_rd/register_types.cpp @@ -41,7 +41,6 @@ static Lightmapper *create_lightmapper_rd() { #endif void register_lightmapper_rd_types() { - GLOBAL_DEF("rendering/gpu_lightmapper/quality/low_quality_ray_count", 16); GLOBAL_DEF("rendering/gpu_lightmapper/quality/medium_quality_ray_count", 64); GLOBAL_DEF("rendering/gpu_lightmapper/quality/high_quality_ray_count", 256); -- cgit v1.2.3 From 07bc4e2f96f8f47991339654ff4ab16acc19d44f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?R=C3=A9mi=20Verschelde?= Date: Thu, 14 May 2020 14:29:06 +0200 Subject: Style: Enforce separation line between function definitions I couldn't find a tool that enforces it, so I went the manual route: ``` find -name "thirdparty" -prune \ -o -name "*.cpp" -o -name "*.h" -o -name "*.m" -o -name "*.mm" \ -o -name "*.glsl" > files perl -0777 -pi -e 's/\n}\n([^#])/\n}\n\n\1/g' $(cat files) misc/scripts/fix_style.sh -c ``` This adds a newline after all `}` on the first column, unless they are followed by `#` (typically `#endif`). This leads to having lots of places with two lines between function/class definitions, but clang-format then fixes it as we enforce max one line of separation. This doesn't fix potential occurrences of function definitions which are indented (e.g. for a helper class defined in a .cpp), but it's better than nothing. Also can't be made to run easily on CI/hooks so we'll have to be careful with new code. Part of #33027. --- modules/lightmapper_rd/lightmapper_rd.cpp | 7 +++++++ modules/lightmapper_rd/lm_common_inc.glsl | 7 +++++++ modules/lightmapper_rd/lm_compute.glsl | 2 ++ modules/lightmapper_rd/lm_raster.glsl | 1 + 4 files changed, 17 insertions(+) (limited to 'modules/lightmapper_rd') diff --git a/modules/lightmapper_rd/lightmapper_rd.cpp b/modules/lightmapper_rd/lightmapper_rd.cpp index cf54754a16..b55c73e9bc 100644 --- a/modules/lightmapper_rd/lightmapper_rd.cpp +++ b/modules/lightmapper_rd/lightmapper_rd.cpp @@ -64,6 +64,7 @@ void LightmapperRD::add_directional_light(bool p_static, const Vector3 &p_direct l.size = p_angular_distance; lights.push_back(l); } + void LightmapperRD::add_omni_light(bool p_static, const Vector3 &p_position, const Color &p_color, float p_energy, float p_range, float p_attenuation, float p_size) { Light l; l.type = LIGHT_TYPE_OMNI; @@ -80,6 +81,7 @@ void LightmapperRD::add_omni_light(bool p_static, const Vector3 &p_position, con l.size = p_size; lights.push_back(l); } + void LightmapperRD::add_spot_light(bool p_static, const Vector3 &p_position, const Vector3 p_direction, const Color &p_color, float p_energy, float p_range, float p_attenuation, float p_spot_angle, float p_spot_attenuation, float p_size) { Light l; l.type = LIGHT_TYPE_SPOT; @@ -1700,17 +1702,21 @@ LightmapperRD::BakeError LightmapperRD::bake(BakeQuality p_quality, bool p_use_d int LightmapperRD::get_bake_texture_count() const { return bake_textures.size(); } + Ref LightmapperRD::get_bake_texture(int p_index) const { ERR_FAIL_INDEX_V(p_index, bake_textures.size(), Ref()); return bake_textures[p_index]; } + int LightmapperRD::get_bake_mesh_count() const { return mesh_instances.size(); } + Variant LightmapperRD::get_bake_mesh_userdata(int p_index) const { ERR_FAIL_INDEX_V(p_index, mesh_instances.size(), Variant()); return mesh_instances[p_index].data.userdata; } + Rect2 LightmapperRD::get_bake_mesh_uv_scale(int p_index) const { ERR_FAIL_COND_V(bake_textures.size() == 0, Rect2()); Rect2 uv_ofs; @@ -1719,6 +1725,7 @@ Rect2 LightmapperRD::get_bake_mesh_uv_scale(int p_index) const { uv_ofs.size = Vector2(mesh_instances[p_index].data.albedo_on_uv2->get_width(), mesh_instances[p_index].data.albedo_on_uv2->get_height()) / atlas_size; return uv_ofs; } + int LightmapperRD::get_bake_mesh_texture_slice(int p_index) const { ERR_FAIL_INDEX_V(p_index, mesh_instances.size(), Variant()); return mesh_instances[p_index].slice; diff --git a/modules/lightmapper_rd/lm_common_inc.glsl b/modules/lightmapper_rd/lm_common_inc.glsl index 0ff455936e..15946d5327 100644 --- a/modules/lightmapper_rd/lm_common_inc.glsl +++ b/modules/lightmapper_rd/lm_common_inc.glsl @@ -11,6 +11,7 @@ struct Vertex { layout(set = 0, binding = 1, std430) restrict readonly buffer Vertices { Vertex data[]; } + vertices; struct Triangle { @@ -21,6 +22,7 @@ struct Triangle { layout(set = 0, binding = 2, std430) restrict readonly buffer Triangles { Triangle data[]; } + triangles; struct Box { @@ -33,11 +35,13 @@ struct Box { layout(set = 0, binding = 3, std430) restrict readonly buffer Boxes { Box data[]; } + boxes; layout(set = 0, binding = 4, std430) restrict readonly buffer GridIndices { uint data[]; } + grid_indices; #define LIGHT_TYPE_DIRECTIONAL 0 @@ -66,6 +70,7 @@ struct Light { layout(set = 0, binding = 5, std430) restrict readonly buffer Lights { Light data[]; } + lights; struct Seam { @@ -76,11 +81,13 @@ struct Seam { layout(set = 0, binding = 6, std430) restrict readonly buffer Seams { Seam data[]; } + seams; layout(set = 0, binding = 7, std430) restrict readonly buffer Probes { vec4 data[]; } + probe_positions; layout(set = 0, binding = 8) uniform utexture3D grid; diff --git a/modules/lightmapper_rd/lm_compute.glsl b/modules/lightmapper_rd/lm_compute.glsl index 5a1f1ceda3..a442016969 100644 --- a/modules/lightmapper_rd/lm_compute.glsl +++ b/modules/lightmapper_rd/lm_compute.glsl @@ -36,6 +36,7 @@ layout(local_size_x = 8, local_size_y = 8, local_size_z = 1) in; layout(set = 1, binding = 0, std430) restrict buffer LightProbeData { vec4 data[]; } + light_probes; layout(set = 1, binding = 1) uniform texture2DArray source_light; @@ -93,6 +94,7 @@ layout(push_constant, binding = 0, std430) uniform Params { mat3x4 env_transform; } + params; //check it, but also return distance and barycentric coords (for uv lookup) diff --git a/modules/lightmapper_rd/lm_raster.glsl b/modules/lightmapper_rd/lm_raster.glsl index 41b3e89a3f..36b706bcd5 100644 --- a/modules/lightmapper_rd/lm_raster.glsl +++ b/modules/lightmapper_rd/lm_raster.glsl @@ -26,6 +26,7 @@ layout(push_constant, binding = 0, std430) uniform Params { ivec3 grid_size; uint pad2; } + params; /* clang-format on */ -- cgit v1.2.3