zhangjt93 / godot-imposter

imposter plugin for godot 4.x
MIT License
71 stars 6 forks source link

Multiple objects don't seem to show up #2

Open SlashScreen opened 10 months ago

SlashScreen commented 10 months ago

It seems that multiple objects here don't seem to appear correctly in the renderer. Only the leaves appear, but not the trunk. If I select the trunk explicitly, it renders the trunk, but not the leaves.

image image

Side note: Is the camera rendering orthographically a necessary part of the process?

zhangjt93 commented 10 months ago

According to the organizational structure of the node tree you provided, I conducted a test and it seems that both child nodes are rendering correctly. Would it be possible for you to provide a test scene to my email: zzjjtt93@hotmail.com?

image

Please note that camera rendering orthographically is not a necessary part of this process. I just found it to be effective during my development process, and you can try it out. Also, make sure to modify the init_bake_scene() method in the photostudio.gd script located at res://addons/Imposter/imposter/scripts/. Specifically, look for the parameter settings related to bake_camera, which should be around lines 168-171.

SlashScreen commented 10 months ago

Sent.

zhangjt93 commented 10 months ago

After my investigation, I believe that the issue is caused by the subsurface scattering effect applied to the material of the tree leaf model's node, which affects the rendering of other opaque objects.

Currently, I haven't come up with a suitable method to handle this issue in the code. A temporary solution would be to temporarily disable the subsurface scattering effect by calling RenderingServer.sub_surface_scattering_set_quality() during plugin initialization. However, this will affect the visual representation of objects in the editor, so I need to consider a suitable place to restore this setting.

Thank you for reporting this issue. I will continue to think about how to address this problem. In the meantime, I suggest temporarily disabling the subsurface scattering effect when working with such models.

zhangjt93 commented 10 months ago

Maybe I have a good idea. I can check all the materials when setting up the baking node. If the subsurface scattering effect is enabled, I can replace it with an identical material that has the subsurface scattering effect disabled. It seems like a good solution to the issue.

SlashScreen commented 10 months ago

Perhaps you can also bake subsurface in, because the effect when subsurface is on and then turned off suddenly is rather dramatic. If you can turn it off, and read other outputs of things like ORM, perhaps you can also bake the subsurface channel. It won't be exactly correct, but it will be a good enough approximation. Or, perhaps, make an identical material with only the subsurface effect on, and have the subsurface color be something distinct, so that the subsurface effect is captured as the viewer would see it.

zhangjt93 commented 10 months ago

Thanks for your suggestion. In order to address issue as quickly as possible, I have made this temporary solution. I will continue to optimize it further until I find a suitable resolution.

SlashScreen commented 10 months ago

Also:

SlashScreen commented 10 months ago

Relevant issue: https://github.com/godotengine/godot-proposals/issues/5240

zhangjt93 commented 10 months ago

Actually, shadows are created by sampling and distorting the rendering frame of the albedo texture, and then rendering it onto another quadmesh.

Maybe you could try adjusting the "dither" and "alpha_clamp" parameters in the generated QuadMesh material.