Hey, so I have a list of points that make a point cloud and while i was successful in draw them, when it came to dynamically coloring them I’m getting stuck. Sometimes the vertexes would be colored and sometimes they’d just be black. I was wondering if there was something I’m missing.
I was looking at the code and I noticed that you were using ComputeNormals for your point cloud. I don’t think that this method will return the proper values that you need as all of the points are unrelated and thus, not making any kind of triangle. After talking with @syntheticmagus, I think that your best bet would be to just set the normals for each vertex to (0, 1, 0) and use that array. While that may not be the best solution, that should at least get your points to show the proper colors.
Here’s a PG with an example: https://www.babylonjs-playground.com/#PGY5FG#19
Hmmm I guess I shouldn’t copy pasta everything I see hahaha, at first I thought it was just because the vertex didn’t form a triangle that it didn’t end up getting colored but I guess it was just my normal after all.
https://www.babylonjs-playground.com/indexStable.html#PGY5FG#22 This playground case still colors vertexes that didn’t make a triangle so I’m kinda just confused on how altering the normal can affect my coloring. I’m curious why this is the case.
Anyways, thanks for the solution, it’s much better than what I did which was create a bunch of unnecessary faces to get the coloring to work, but thanks to this solution I can now continue working on my project
This is correct since a triangle has an orientation in 3D space which is given by the normal to the plane it lies on. A point on the other hand just has position and so no normal. Not assigning normals for the points in a point cloud is OK.
More examples Babylon.js Big Bang
I think it is because the shader that determines the appearance of a screen pixel uses a normal, color and light direction from the vertex data in doing this. Assigning a normal to a point can therefore affect the displayed color.