diff options
author | Rémi Verschelde <rverschelde@gmail.com> | 2020-05-14 13:23:58 +0200 |
---|---|---|
committer | Rémi Verschelde <rverschelde@gmail.com> | 2020-05-14 16:54:55 +0200 |
commit | 0be6d925dc3c6413bce7a3ccb49631b8e4a6e67a (patch) | |
tree | a27e497da7104dd0a64f98a04fa3067668735e91 /modules/lightmapper_rd | |
parent | 710b34b70227becdc652b4ae027fe0ac47409642 (diff) |
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.
Diffstat (limited to 'modules/lightmapper_rd')
-rw-r--r-- | modules/lightmapper_rd/lightmapper_rd.cpp | 39 | ||||
-rw-r--r-- | modules/lightmapper_rd/lightmapper_rd.h | 1 | ||||
-rw-r--r-- | modules/lightmapper_rd/lm_blendseams.glsl | 2 | ||||
-rw-r--r-- | modules/lightmapper_rd/lm_compute.glsl | 7 | ||||
-rw-r--r-- | modules/lightmapper_rd/lm_raster.glsl | 2 | ||||
-rw-r--r-- | modules/lightmapper_rd/register_types.cpp | 1 |
6 files changed, 0 insertions, 52 deletions
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<TriangleSort> &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<Ref<Image>> &albedo_images, Vector<Ref<Image>> &emission_images, AABB &bounds, Size2i &atlas_size, int &atlas_slices, BakeStepFunc p_step_function, void *p_bake_userdata) { - Vector<Size2i> 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<Vector2i> source_sizes = sizes; Vector<int> 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<Vector3i> offsets = Geometry::partial_pack_rects(source_sizes, atlas_size); Vector<int> new_indices; Vector<Vector2i> 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> &probe_positions, GenerateProbes p_generate_probes, Vector<int> &slice_triangle_count, Vector<int> &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, uint32_t, VertexHash> 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<TriangleSort> 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<int> slice_triangle_count, RID position_tex, RID unocclude_tex, RID normal_tex, RID raster_depth_buffer, RID rasterize_shader, RID raster_base_uniform) { - Vector<RID> 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<Image> &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<RD::Uniform> 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<RD::Uniform> 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<RD::Uniform> 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<RD::Uniform> 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<RD::Uniform> 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<RD::Uniform> 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<RD::Uniform> 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<Color> 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); |