Repository: godotengine/godot (language: cpp)

Issue:
Vulkan: VoxelGI and LightmapGI incorrectly calculating the light for the same object
**Godot version:**
master (495b28765d03aa9459bc312ebba190ec208979e7)

**OS/device including version:**
Arch 5.6.4-arch1-1

**Issue description:**
GIProbe are generating different results depending on the position of the object inside giprobe's cage:
![Captura de tela de 2020-04-19 15-48-10](https://user-images.githubusercontent.com/1387165/79696965-513d6d80-8256-11ea-896e-3cfb4135d7da.png)
Rotating the object also affects the calc (happens in 3.2.1 as well, maybe is related to #35200):
![Captura de tela de 2020-04-19 15-51-00](https://user-images.githubusercontent.com/1387165/79696968-53073100-8256-11ea-8d57-279d329bfd0d.png)
![Captura de tela de 2020-04-19 15-50-43](https://user-images.githubusercontent.com/1387165/79696970-54385e00-8256-11ea-941b-0746bba5365b.png)
*cube was rotated and rebaked*

**Steps to reproduce:**
I exported a cube with inverted normals from blender.
I setup 3 spot lights for each cube.
Then I bake giprobe with interior on and light intensity to 8.

**Minimal reproduction project:**
[giprobe_test.zip](https://github.com/godotengine/godot/files/4499964/giprobe_test.zip)



Discussion / hints:
CC @clayjohn 
Yea that looks like the same issue. I will press reduz about it more, as I still don't understand what is broken and why my PR fixes it. 
Just a note, BakedLighmap is also affected:
![Captura de tela de 2020-05-01 10-34-35](https://user-images.githubusercontent.com/1387165/80809113-6344d780-8b97-11ea-808e-347dd8e513a1.png)

@guilhermefelipecgs Can you still reproduce this in the latest `master` branch with VoxelGI, and with the new GPU lightmapper (LightmapGI)? You can download a nightly build [here](https://hugo.pro/projects/godot-builds/).
Closing due to lack of response. Please comment if you can still reproduce this bug.

PS: If no [minimal reproduction project](https://github.com/godotengine/godot/blob/master/CONTRIBUTING.md#provide-a-simple-example-project) was included in the original bug report, please upload one as well to ease troubleshooting.
The bug is still there (VoxelGI), even worse when entering in orthogonal view now.


https://user-images.githubusercontent.com/1387165/152700307-4baa2bc6-7a03-4b79-83e0-32e231c3e700.mp4



Minimal reproduction project updated to v4.0.alpha1.official [giprobe_test.zip](https://github.com/godotengine/godot/files/8011187/giprobe_test.zip)



On the other hand, looks like the LightmapGI has been fixed.

https://user-images.githubusercontent.com/1387165/152700147-4242ecd5-2cf4-49d5-b38f-1dd26ba8aca9.mp4


Fix patch:
diff --git a/scene/3d/voxelizer.cpp b/scene/3d/voxelizer.cpp
index 1074cad11e5a..711b265bb641 100644
--- a/scene/3d/voxelizer.cpp
+++ b/scene/3d/voxelizer.cpp
@@ -871,7 +871,7 @@ Voxelizer::BakeResult Voxelizer::get_sdf_3d_image(Vector<uint8_t> &r_image, Bake
 		uint32_t cell_count = bake_cells.size();
 
 		for (uint32_t i = 0; i < cell_count; i++) {
-			if (cells[i].level < (cell_subdiv - 1)) {
+			if (cells[i].level < cell_subdiv) {
 				continue; //do not care about this level
 			}
 


Test patch: