Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Quality lose by using BakedLightmap with Gridmap and many tiles. #14876

Closed
kakoeimon opened this issue Dec 20, 2017 · 17 comments
Closed

Quality lose by using BakedLightmap with Gridmap and many tiles. #14876

kakoeimon opened this issue Dec 20, 2017 · 17 comments

Comments

@kakoeimon
Copy link

Godot version:

master

OS/device including version:

Manjaro 64bit, GT540M NVIDIA Driver Version: 384.90

Issue description:

The more meshes in the gridmap less quality.

Two meshes.
quality_3

Seven meshes.
quality_2

Too many mashes.
quality_1

Steps to reproduce:

Minimal reproduction project:

You will have to bake test\test.tscn (the one with too many meshes) cause there is a limitation of 10mb in github upload.
Other test are test\test_small\test_smal.tscn the one with seven meshes.
And test\test_1\test_1.tscn the test with two meshes.
gridtest.zip

@ghost ghost added the topic:rendering label Dec 20, 2017
@ghost
Copy link

ghost commented Dec 20, 2017

I don't really know how BakedLightmap works, but it's expected to me as the BakedLightmap's area is larger in the large scene.

@reduz
Copy link
Member

reduz commented Dec 20, 2017 via email

@kakoeimon
Copy link
Author

Ahhh ok I thought that subdivision was just if you have a diferent scale or something.

@ghost ghost added the archived label Dec 20, 2017
@reduz
Copy link
Member

reduz commented Dec 20, 2017 via email

@kakoeimon
Copy link
Author

I am not trying to blame, but right now it looks almost unusable.
I mean to get the same quality for all the stage you have to create several BakedLightmaps or GIProbes with the exac parameters (of course with different translations) also to get rid of all the "seems" created in the edge of the extends you have to make them overlapping too.
Plus the performance gets damaged when a dynamic objects are inside two or more BakedLightmaps.

Even thought I read the docs for GIProbe, for some reason I thought that subdivision was something like a point of reference of how much it subdivides the original extends and that afterwards it does the calculations (hidden from the user) to get the subdivision right for the modified extents.
Even thought docs do not implies this :

Subdiv Subdivision used for the probe. The default (128) is generally good for small to medium size areas. Bigger subdivisions use more memory.

Anyway, sorry for the long post and my bad English, but I thought it will be good to inform you with my observations as an end user.

@reduz
Copy link
Member

reduz commented Dec 21, 2017

As mentioned, for baked lightmaps, will definitely change it to a cell size, as it's pretty difficult to guess by subdivision what willt he resulting quality be.

@reduz
Copy link
Member

reduz commented Dec 21, 2017

Ok, I changed baked lightmaps to use a cell size instead of a subdivision. This should make it work and look the same no matter the size of the region being baked. Please give it a try.

@kakoeimon
Copy link
Author

@reduz I just got a segmentation fault with the big testcase (test/test.tscn).
Here is the output from the gdb

ERROR: resize: Condition ' !_ptrnew ' is true. returned: ERR_OUT_OF_MEMORY
   At: core/vector.h:295.

Thread 1 "godot.x11.tools" received signal SIGSEGV, Segmentation fault.
0x00005555576a6bc9 in Vector<VoxelLightBaker::Cell>::size (this=0x7fffffffc770)
    at core/vector.h:114
114				return *size;

By the way I have 6gb memory and GT540M 2gb

Here it is the bt

#0  0x00005555576a6bc9 in Vector<VoxelLightBaker::Cell>::size (
    this=0x7fffffffc770) at core/vector.h:114
#1  0x00005555576a6b03 in Vector<VoxelLightBaker::Cell>::operator[] (
    this=0x7fffffffc770, p_index=26843545) at core/vector.h:137
#2  0x000055555769806b in VoxelLightBaker::_plot_face (this=0x7fffffffc770, 
    p_idx=26843544, p_level=13, p_x=154, p_y=524, p_z=12306, 
    p_vtx=0x7fffffffc430, p_normal=0x7fffffffc460, p_uv=0x7fffffffc410, 
    p_material=..., p_aabb=...) at scene/3d/voxel_light_baker.cpp:472
#3  0x00005555576980fa in VoxelLightBaker::_plot_face (this=0x7fffffffc770, 
    p_idx=26843533, p_level=12, p_x=152, p_y=524, p_z=12304, 
    p_vtx=0x7fffffffc430, p_normal=0x7fffffffc460, p_uv=0x7fffffffc410, 
    p_material=..., p_aabb=...) at scene/3d/voxel_light_baker.cpp:475
#4  0x00005555576980fa in VoxelLightBaker::_plot_face (this=0x7fffffffc770, 
    p_idx=26843511, p_level=11, p_x=152, p_y=520, p_z=12304, 
    p_vtx=0x7fffffffc430, p_normal=0x7fffffffc460, p_uv=0x7fffffffc410, 
    p_material=..., p_aabb=...) at scene/3d/voxel_light_baker.cpp:475
#5  0x00005555576980fa in VoxelLightBaker::_plot_face (this=0x7fffffffc770, 
    p_idx=26843425, p_level=10, p_x=144, p_y=512, p_z=12304, 
    p_vtx=0x7fffffffc430, p_normal=0x7fffffffc460, p_uv=0x7fffffffc410, 
    p_material=..., p_aabb=...) at scene/3d/voxel_light_baker.cpp:475
#6  0x00005555576980fa in VoxelLightBaker::_plot_face (this=0x7fffffffc770, 
    p_idx=26842742, p_level=9, p_x=128, p_y=512, p_z=12288, 
    p_vtx=0x7fffffffc430, p_normal=0x7fffffffc460, p_uv=0x7fffffffc410, 
---Type <return> to continue, or q <return> to quit---
    p_material=..., p_aabb=...) at scene/3d/voxel_light_baker.cpp:475
#7  0x00005555576980fa in VoxelLightBaker::_plot_face (this=0x7fffffffc770, 
    p_idx=26842741, p_level=8, p_x=128, p_y=512, p_z=12288, 
    p_vtx=0x7fffffffc430, p_normal=0x7fffffffc460, p_uv=0x7fffffffc410, 
    p_material=..., p_aabb=...) at scene/3d/voxel_light_baker.cpp:475
#8  0x00005555576980fa in VoxelLightBaker::_plot_face (this=0x7fffffffc770, 
    p_idx=26830761, p_level=7, p_x=128, p_y=512, p_z=12288, 
    p_vtx=0x7fffffffc430, p_normal=0x7fffffffc460, p_uv=0x7fffffffc410, 
    p_material=..., p_aabb=...) at scene/3d/voxel_light_baker.cpp:475
#9  0x00005555576980fa in VoxelLightBaker::_plot_face (this=0x7fffffffc770, 
    p_idx=26830760, p_level=6, p_x=0, p_y=512, p_z=12288, 
    p_vtx=0x7fffffffc430, p_normal=0x7fffffffc460, p_uv=0x7fffffffc410, 
    p_material=..., p_aabb=...) at scene/3d/voxel_light_baker.cpp:475
#10 0x00005555576980fa in VoxelLightBaker::_plot_face (this=0x7fffffffc770, 
    p_idx=26830759, p_level=5, p_x=0, p_y=512, p_z=12288, 
    p_vtx=0x7fffffffc430, p_normal=0x7fffffffc460, p_uv=0x7fffffffc410, 
    p_material=..., p_aabb=...) at scene/3d/voxel_light_baker.cpp:475
#11 0x00005555576980fa in VoxelLightBaker::_plot_face (this=0x7fffffffc770, 
    p_idx=26815576, p_level=4, p_x=0, p_y=0, p_z=12288, p_vtx=0x7fffffffc430, 
    p_normal=0x7fffffffc460, p_uv=0x7fffffffc410, p_material=..., p_aabb=...)
    at scene/3d/voxel_light_baker.cpp:475
#12 0x00005555576980fa in VoxelLightBaker::_plot_face (this=0x7fffffffc770, 
    p_idx=2245377, p_level=3, p_x=0, p_y=0, p_z=12288, p_vtx=0x7fffffffc430, 
---Type <return> to continue, or q <return> to quit---
    p_normal=0x7fffffffc460, p_uv=0x7fffffffc410, p_material=..., p_aabb=...)
    at scene/3d/voxel_light_baker.cpp:475
#13 0x00005555576980fa in VoxelLightBaker::_plot_face (this=0x7fffffffc770, 
    p_idx=2, p_level=2, p_x=0, p_y=0, p_z=12288, p_vtx=0x7fffffffc430, 
    p_normal=0x7fffffffc460, p_uv=0x7fffffffc410, p_material=..., p_aabb=...)
    at scene/3d/voxel_light_baker.cpp:475
#14 0x00005555576980fa in VoxelLightBaker::_plot_face (this=0x7fffffffc770, 
    p_idx=1, p_level=1, p_x=0, p_y=0, p_z=8192, p_vtx=0x7fffffffc430, 
    p_normal=0x7fffffffc460, p_uv=0x7fffffffc410, p_material=..., p_aabb=...)
    at scene/3d/voxel_light_baker.cpp:475
#15 0x00005555576980fa in VoxelLightBaker::_plot_face (this=0x7fffffffc770, 
    p_idx=0, p_level=0, p_x=0, p_y=0, p_z=0, p_vtx=0x7fffffffc430, 
    p_normal=0x7fffffffc460, p_uv=0x7fffffffc410, p_material=..., p_aabb=...)
    at scene/3d/voxel_light_baker.cpp:475
#16 0x00005555576996ee in VoxelLightBaker::plot_mesh (this=0x7fffffffc770, 
    p_xform=..., p_mesh=..., p_materials=..., p_override_material=...)
    at scene/3d/voxel_light_baker.cpp:648
#17 0x0000555557286154 in BakedLightmap::bake (this=0x555563276060, 
    p_from_node=0x555561309270, p_create_visual_debug=false)
    at scene/3d/baked_lightmap.cpp:374
#18 0x0000555556b45de9 in BakedLightmapEditorPlugin::_bake (
    this=0x55555de09930) at editor/plugins/baked_lightmap_editor_plugin.cpp:10
#19 0x00005555561dff8d in MethodBind0::call (this=0x55555de0ac40, 
---Type <return> to continue, or q <return> to quit---
    p_object=0x55555de09930, p_args=0x7fffffffcb60, p_arg_count=0, r_error=...)
    at core/method_bind.gen.inc:54
#20 0x0000555557ac637b in Object::call (this=0x55555de09930, p_method=..., 
    p_args=0x7fffffffcb60, p_argcount=0, r_error=...) at core/object.cpp:913
#21 0x0000555557ac7d21 in Object::emit_signal (this=0x55555de09bf0, 
    p_name=..., p_args=0x7fffffffcb60, p_argcount=0) at core/object.cpp:1194
#22 0x0000555557ac82b4 in Object::emit_signal (this=0x55555de09bf0, 
    p_name=..., p_arg1=..., p_arg2=..., p_arg3=..., p_arg4=..., p_arg5=...)
    at core/object.cpp:1239
#23 0x0000555556fc5ca3 in BaseButton::_gui_input (this=0x55555de09bf0, 
    p_event=...) at scene/gui/base_button.cpp:138
#24 0x0000555556b2055e in MethodBind1<Ref<InputEvent> >::call (
    this=0x555559c053f0, p_object=0x55555de09bf0, p_args=0x7fffffffce40, 
    p_arg_count=1, r_error=...) at core/method_bind.gen.inc:729
#25 0x0000555557ac5647 in Object::call_multilevel (this=0x55555de09bf0, 
    p_method=..., p_args=0x7fffffffce40, p_argcount=1) at core/object.cpp:747
#26 0x0000555557ac5f50 in Object::call_multilevel (this=0x55555de09bf0, 
    p_name=..., p_arg1=..., p_arg2=..., p_arg3=..., p_arg4=..., p_arg5=...)
    at core/object.cpp:853
#27 0x0000555556f32925 in Viewport::_gui_call_input (this=0x555559fc8eb0, 
    p_control=0x5555444ccccd, p_input=...) at scene/main/viewport.cpp:1466
#28 0x0000555556f341d8 in Viewport::_gui_input_event (this=0x555559fc8eb0, 
    p_event=...) at scene/main/viewport.cpp:1820
---Type <return> to continue, or q <return> to quit---
#29 0x0000555556f37c0a in Viewport::input (this=0x555559fc8eb0, p_event=...)
    at scene/main/viewport.cpp:2437
#30 0x0000555556f31b53 in Viewport::_vp_input (this=0x555559fc8eb0, p_ev=...)
    at scene/main/viewport.cpp:1311
#31 0x000055555641df12 in MethodBind1<Ref<InputEvent> const&>::call (
    this=0x555559bc9510, p_object=0x555559fc8eb0, p_args=0x7fffffffd3c0, 
    p_arg_count=1, r_error=...) at core/method_bind.gen.inc:729
#32 0x0000555557ac637b in Object::call (this=0x555559fc8eb0, p_method=..., 
    p_args=0x7fffffffd3c0, p_argcount=1, r_error=...) at core/object.cpp:913
#33 0x0000555557ac5e7c in Object::call (this=0x555559fc8eb0, p_name=..., 
    p_arg1=..., p_arg2=..., p_arg3=..., p_arg4=..., p_arg5=...)
    at core/object.cpp:837
#34 0x0000555556f835e7 in SceneTree::call_group_flags (this=0x555559af1700, 
    p_call_flags=2, p_group=..., p_function=..., p_arg1=..., p_arg2=..., 
    p_arg3=..., p_arg4=..., p_arg5=...) at scene/main/scene_tree.cpp:247
#35 0x0000555556f843a2 in SceneTree::input_event (this=0x555559af1700, 
    p_event=...) at scene/main/scene_tree.cpp:404
#36 0x000055555616b997 in InputDefault::parse_input_event (
    this=0x555559a116f0, p_event=...) at main/input_default.cpp:345
#37 0x0000555556149006 in OS_X11::process_xevents (this=0x7fffffffda10)
    at platform/x11/os_x11.cpp:1706
#38 0x000055555614bfa9 in OS_X11::run (this=0x7fffffffda10)
    at platform/x11/os_x11.cpp:2290
---Type <return> to continue, or q <return> to quit---
#39 0x0000555556140d2f in main (argc=2, argv=0x7fffffffdf18)
    at platform/x11/godot_x11.cpp:54

@kakoeimon
Copy link
Author

Forgot to mention that this happened on the plotting (Plotting Meshes: (10/11))

@reduz
Copy link
Member

reduz commented Dec 21, 2017 via email

@reduz
Copy link
Member

reduz commented Dec 21, 2017

seems like it's a really big level from the backtrace, so would like to see if there is anything strange in the testcase

@kakoeimon
Copy link
Author

The testcase is the gridtest.zip on the first post of this issue. The scene in test/test.tscn

@reduz
Copy link
Member

reduz commented Dec 21, 2017

Ah, I see, that scene is way too big, so it' s likely running out of memory for baking. In a real game level, you can use multiple BakedLightmap nodes for the different regions and it should work fine

@kakoeimon
Copy link
Author

Ok... it was just a test anyway.

@reduz
Copy link
Member

reduz commented Dec 21, 2017

An alternative, if the level is too big, is to increase the bake cell size. By default it' s 0.1 (10cm). I changed it to 0.5 and it baked really quickly.

@reduz
Copy link
Member

reduz commented Dec 21, 2017

btw, here's how it looks with 0.5 as cell size, i think it's still pretty good:
image

@kakoeimon
Copy link
Author

Looks ok, but eventually a solution or a warning to the user must be raised.

Here is my the comparison now.
All BakedLightmaps are setted to
Cell Size: 0.5
Capture Size: 0.5
Everything else to default.

(1) The one with 2 cells. (testt/tset_1/test_1.tscn)
extends 10.0, 10.0, 10.0
bake subdiv: 8 capture subdiv:8
q_3

(2) The small one with seven cells. (test/test_small/test_smal.scn)
extends 10.0, 10.0, 34.195751
bake subdiv: 10 capture subdiv:10
q_2

(3) The huge on. (test/test.scn)
extends 10.0, 10.0, 262.574005
bake subdiv: 13 capture subdiv: 13
q_1

And the project modified (bake textures of the big level was removed to keep the size under 10mb)
gridtest.zip

Some comments
1 and 3 looks very similar, but it is visible that 1 is little bit better especialy if you look to the emission of the blue ray at the right.
2 is very strange, for some reason the pink emission painted half the stage.

btw I closed the issue before you add the cell size, if you want me to reopen it just tell me.

I am very disapointed to the fact that not many users are testing this great addition, I will try to attract some more users in discord and etc. but I will be away till monday to try to test it a little bit more.

Other from that, the issue #14795 must be resolved cause without gdb we have no ability to stop the looping error and we get a computer freeze. It is also not just to the use of BakedLightmap with Gridmap but a general problem using BakedLightmap in general. If I remember well it happened when you commited the ability to use Gridmap with BakedLightmap.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants