How to use binary data to render points

I get compressed data from the network (pitch angle, horizontal angle, radius, etc.) and I want to pass it directly to the shader and manually parse it into xyz there, but I can’t pass it to material.position because there are NaN values
Q1: How can I avoid
THREE.BufferGeometry.computeBoundingSphere(): Computed radius is NaN. The "position" attribute is likely to have NaN values.

Q2: Can’t I use GL_POINTS directly? I have very high performance requirements.
I have tried Babylonjs before, and the performance is about twice that of three.

Would be great to provide a working live code example of what and how you do. :thinking:

Yes, you can pass binary data into a BufferAttribute. You’ll have to compute the bounding radius manually if you’ve mixed NaN values in there, or remove those values. I don’t think anyone will be able to advise you on performance without more concrete details (code and demo) about what you’re doing.

2 Likes

Below is my vertexShader(Actually this doesn’t work because I don’t know yet how to set version 300 es)

  precision highp float;
  attribute vec3 position;
  attribute vec3 color;

  uniform mat4 projectionMatrix;
  uniform mat4 viewMatrix;
  uniform mat4 modelMatrix;

  int h = int(position.x & 0xffffu); 
  int v = int(position.x & 0xffff0000u) >>16;
  v = v < 32768 ? v : v - 65536;
  h = h < 32768 ? h : h - 65536;
  uint r = position.y & 0xffffu; 
  ...

You can see that what I want to pass to position attr is not a float, but uses the same memory saves Integer fields. I want the GPU to do this calculation to save nearly a million times of trigonometric function CPU calculation time.

So I can’t delete the bounds or calculate the bounds manually

You may want to set mesh.frustumCulled = false and set some dummy value for the bounding box, in that case.

Thank you.
Another question, how can I pursue the highest performance, because I only need to display a large number of point clouds, regardless of other interactions

It’s a fairly broad question — performance optimization is usually about finding the bottlenecks in your specific application, and then trying to address them.

If you’ve narrowed it down enough to feel sure that the GPU cannot process your vertex data fast enough, you might look at libraries like meshoptimizer, which provides functionality to sort the vertex stream for better GPU cache locality.

Note that GPUs tend not to perform as well if drawing more vertices than there are pixels on screen, it’s better to have a lower vertices-to-pixels ratio. Avoid reversing the ratio if you can.