-
Notifications
You must be signed in to change notification settings - Fork 33
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
pointcloud buffer update_color_with_indices does not apply alpha value into color #141
Comments
Would love to hear about this too. I also couldn’t adjust alpha for mesh as well. |
What coloring scheme are you using? |
Hi Koide, If I understand this correctly, does that mean that the alpha value of guik::VertexColor can't be changed once it is set? Since I created the color point cloud buffer with color and then use the update_color_with_indices (basically all indices) with a vector of Eigen::Vector4f (with a same transparent color), and it didn't work. I remember this function does change the vertex color of the point cloud, right? Thanks again! |
You can still change the transparency of objects registered with I think a confusing point is that there are several states to control the object transparency. To clarify:
#include <numeric>
#include <iostream>
#include <glk/pointcloud_buffer.hpp>
#include <glk/primitives/icosahedron.hpp>
#include <guik/viewer/light_viewer.hpp>
int main(int argc, char** argv) {
auto viewer = guik::viewer();
viewer->disable_xy_grid();
viewer->update_cube("bg_plate", guik::FlatBlue().translate(0.0f, 0.0f, -5.0f).scale(5.0f, 5.0f, 0.1f));
// Random vertices
glk::Icosahedron icosa;
icosa.subdivide();
icosa.subdivide();
// Green vertices with alpha = 0.25
float vertex_alpha = 0.25f;
std::vector<Eigen::Vector4f> colors(icosa.vertices.size());
std::fill(colors.begin(), colors.end(), Eigen::Vector4f(0.0f, 1.0f, 0.0f, vertex_alpha));
auto cloud_buffer = std::make_shared<glk::PointCloudBuffer>(icosa.vertices);
cloud_buffer->add_color(colors);
// 2. Draw the vertices without transparency (without make_transparent())
viewer->update_drawable("points", cloud_buffer, guik::VertexColor());
viewer->spin_until_click();
// 3. Draw the vertices with transparency (with make_transparent())
viewer->update_drawable("points", cloud_buffer, guik::VertexColor().make_transparent());
viewer->spin_until_click();
// 2. Update the color of the vertices with alpha = 0.95
vertex_alpha = 0.95f;
std::fill(colors.begin(), colors.end(), Eigen::Vector4f(0.0f, 1.0f, 0.0f, vertex_alpha));
std::vector<unsigned int> indices(colors.size());
std::iota(indices.begin(), indices.end(), 0);
cloud_buffer->update_color_with_indices(colors, indices);
viewer->spin_until_click();
// 3. set_alpha() doesn't change the object transparency here because guik::VertexColor prioritizes vertex alpha
viewer->update_drawable("points", cloud_buffer, guik::VertexColor().set_alpha(0.2f));
viewer->spin_until_click();
// 4. guik::FlatColor prioritizes material alpha (set_alpha) over vertex alpha
viewer->update_drawable("points", cloud_buffer, guik::FlatGreen().set_alpha(0.2f));
viewer->spin_until_click();
return 0;
} |
Thanks for your detailed instructions! Now, it works on my end. |
Hi Koide,
I just found that the alpha value (transparent) value was not correctly rendering (can't change the transparency). Did I miss any setup? If not, can you test it on your end?
Thanks!
The text was updated successfully, but these errors were encountered: