question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

All vertex colors are white if BufferAttribute is backed by Uint8Array

See original GitHub issue
Description of the problem

I am trying to render a point cloud from a Kinect device. My colors are coming from a Uint8Array of RGBA data. However all my points are always white. I adopted the example at https://threejs.org/examples/?q=points#webgl_buffergeometry_points and managed to get it to work with the vertex positions but cannot get the colors from my Uint8Array.

I found this bug #8358 which has been closed as fixed. The jsfiddle mentioned in that bugreport has the same problem I am seeing.

https://jsfiddle.net/huningxin/594jjzb9/3/ (original fiddle from bug #8358) https://jsfiddle.net/h3c62gs5/ (version which also sets normalized to false)

The fiddle has code for both Float32Array and Uint8Array and if I switch back and forth the vertices get colors (float32) or turns all white (Uin8t).

Three.js version
  • Dev
  • r111
Browser
  • Electron 7.1.1
  • Edge Insider (based on Chromium)
OS
  • All of them
  • Windows
  • macOS
  • Linux
  • Android
  • iOS

Issue Analytics

  • State:closed
  • Created 4 years ago
  • Comments:6 (1 by maintainers)

github_iconTop GitHub Comments

1reaction
Mugen87commented, Jan 9, 2020

Closing. Please use the fourm if you need more help.

0reactions
Mugen87commented, Jan 9, 2020

@Mugen87 isnt []= flooring it any way, since this is integers array?

Yes, but I just want to highlight that this type of array represents integers. It seems more right to me to provide integers to the array in the first place.

hy do I need to set geometry.attributes.color.normalized = true; if my data is non-normalized?

Uint8Array holds (integers) values in the range of [0,255]. You need to normalized this data into the range of [0,1] (floats) so the shader is able to correctly process the color values. Please read the docs for more information about this topic:

https://threejs.org/docs/index.html#api/en/core/BufferAttribute

Read more comments on GitHub >

github_iconTop Results From Across the Web

Color each point in different color Threejs - Stack Overflow
Thank you:) First of all, I need to use colors from 0 to 1 (not 0 to 255). Then I needed to get...
Read more >
Points are not shown with colors in bufferGeometry - Questions
I created “Points”. and added to the scene. but all points are white colored. In console, color attributes has Uint8Array. function pointCloudfromBuffer(point, ...
Read more >
How To Assign Different Color For Each Vertex In A Buffer ...
If a buffer attribute exists already, then it will be marked as needing an ... All vertex colors are white if BufferAttribute is...
Read more >
Uint8Array for vertex colors - CodePen Embed
... but if I try to enter a color (e.g. 174, 58, 105) I get white //...oh. passing "true" as the third param...
Read more >
Using shaders to apply color in WebGL - Web APIs | MDN
Previously, our vertex shader didn't apply any specific colors to the vertices. Between this and the fragment shader assigning the fixed color of...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found