LiangliangNan / Easy3D

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

Render color alpha Settings #180

Closed Champion-zzy closed 7 months ago

Champion-zzy commented 7 months ago

The transparency parameter (the last component of vec4) does not seem to take effect when setting the model grid color. Consequently, setting semi-transparent faces may not yield the expected results.

eg: plane->add_face_property("f:color", vec4(0.6, 0.6, 0.8, 0.5));

Set the semi-transparent state of the model's faces.

LiangliangNan commented 7 months ago

Transparency is computationally heavier than the normal rendering, becasue it involved dedicated shader code. It does not make sense to alway turn on transparency. So in Easy3D (and almost all other rendering tools), transparency isdisabled by default. To enable transparency, please refer to Tutorial_504_Transparency.

Champion-zzy commented 7 months ago

"Thank you very much for Professor Nan's prompt response. I also wanted to ask how I can control the transparency of only certain faces or parts of faces without affecting other parts of the model."

LiangliangNan commented 7 months ago

You're welcome. If you want to have a subset of the faces to be transparent (or different parts having diffent transparancy), you could simply create multiple TrianglesDrawables, and set each drawable a opaque value.

Of course, it is also possible to allow a per-face transparency value using the alpha. This will require modifying the current shader code.