LiangliangNan / Easy3D

A lightweight, easy-to-use, and efficient C++ library for processing and rendering 3D data
GNU General Public License v3.0
1.35k stars 243 forks source link

Ambient occlusion crashes on non-manifold models & provide *real* ground for shadows #155

Closed yvanblanchard closed 11 months ago

yvanblanchard commented 1 year ago

hello,

how to activate/switch rendering mode in MAPPLE app, and in particular to set ambient occlusion and soft shadows ?

Moreover, I tried to compile the example/tutorial dedicated to ambient occlusion test, but I can't compile the easy3d libs. I get some compiler errors in 'Utils' (console_style.cpp, "s << console::styles[style];")

Severity    Code    Description Project File    Line    Suppression State
Error (active)  E0349   no operator "<<" matches these operands easy3d_util C:\YVAN\Customers\3DPrint\Easy3D-main\easy3d\util\console_style.cpp 146 

I'm using VS2017 with Win10 x64 (with QT5).

Thank you

LiangliangNan commented 1 year ago

The SSAO and shadow (and a few other effects) can be switched on through the Global rendering panel. See below: image

The compiler error is quite strange because s << console::styles[style]; simply outputs a std::string. Can you try adding #include <string> at the beginning of console_style.cpp and see if the same error still occurs? (normally has already included and thus it can be avoided) If the same error still exists, please post your entire compile log here (the error might be caused by something else)

yvanblanchard commented 1 year ago

Thank you.

I tried the shadow mode, but it looks strange that the shadow does not lie on the XY plane by default ? Is it possible to control it ? image

Moreover, I tried the SSAO (classic, etc), but it crashes (Mapple v2.5.2 on Win10 ; provided binaries).

Here is the mesh (STL file): thing_big.zip

LiangliangNan commented 1 year ago

In the current implementation, the shadow plane is placed behind the object and it is orthogonal to the light direction: image For now, no UI or parameter is provided for a user to manipulate the shadow plane. But in case you want to play with it, please check and modify the code in void Shadow::update_virtual_background() in shadow.cpp

For the SSAO, does it also crash for any other models?

yvanblanchard commented 1 year ago

I checked on the fandisk_quads.off model, and the SSAO does work fine.

One other remark about shadow: It looks strange, since it's like the shadow is "around" the mesh, and not "projected" on a plane.. image

LiangliangNan commented 1 year ago

I checked on the fandisk_quads.off model, and the SSAO does work fine.

I also tried to convert your model to another format (PLY). This conversion process also resolved the non-manifoldness in the model and it worked well. So I suspect that the non-manifoldness causes the crash. But I am quite sure. Wrote the code many years ago and couldn't think of the reason. I will look into the code later this month.

One other remark about shadow: It looks strange, since it's like the shadow is "around" the mesh, and not "projected" on a plane.

It does project on a plane, but just that the plane is put behind the object (instead of serving as a "ground" plane). I may have some time this summer to improve this. Please also feel free to modify the code to have it.

LiangliangNan commented 1 year ago

ToDo:

yvanblanchard commented 1 year ago

Hello, Any updates for this ? Thank you!

LiangliangNan commented 11 months ago

Finally, I had some time to fix the bug in ambient occlusion. The reason was that normal information is not always available for points. You can test the latest code in the repository (but not in the Mapple executable) and let me know if you encounter any issue related to SSAO.

For the shadow, I will be working on it :-)