I am struggeling to display points with a very precise coordinates while using GL Shader for Grasshopper. Do I need to implement the WorldToScreen built-in function to display the points with the precise coordinates or what are the options while using GL Shader? Any suggestions @stevebaer please?
Thank you.

On the image you can see the enlarged preview of the points (on the left) and the precise points (on the right). Zoom in to display the precise point coordinates.

The gh file that you posted is just 50000+ vertices being sent into a very simple shader. I’m having trouble understanding what you are trying to do. Could you explain a bit more what the problem is that you are trying to solve?

Hi @stevebaer,
thank you for your reply. I am able to display the vertices with the Symbol Display component. However if I try to display the vertices with the GL Shader it does not work (probably because of the precision of the coordinates). My question is how to edit the GL Shader code to be able to display such a vertices? I wached your videos about GhGL but I was not able to solve this issue. Thank you.

@Joseph_Oster the points are not identical even it appears to be so due the formating of decimals in Grasshopper. The points are actualy very precise and if you scale them up and use Crete Set component you will see 62788 unique points with precise coordinates.

They certainly do appear to be identical. CullPt(Cull Duplicates) does not differentiate them until the ‘Tolerance’ (T) value is 1.0e-9 or smaller (0.000000001). Again, what is your point? Sounds like nonsense to be concerned about this.

@Joseph_Oster are you genuinely trying to solve the issue I am having or just label my question as irrelevant?
My aim is display the vetices with the GL Shader because the component is much more memory efficient than the Symbol Display component. I am usually working with multiple millions of vertices so I do not want to scale the points up.

Solve, no. Understand, yes. Maybe I need to get the ‘ghgl’ plugin because so far, I still don’t understand. What display device are you using that shows more that ~8 million pixels (3840 X 2160)? What sort of application uses resolution that high?

You are most likely pushing the limits of what floating precision numbers can handle. I suggest you scale the verts and move them to origin. Then everything works as expected:

Thank you @mrhe for your suggestion. I am aware that if the vertices are scaled up the GL Shader can handle the preview correctly. I know I am pushing the limits of numbers precision however the Symbol Display component can still handle such a precision without scaling up, so I was wondering if there is a built-in function in the GL Shader component which can handle this issue.

OpenGL uses single precision (float) numbers, whereas the Symbol Display component probably works with double precision numbers.

Scaling alone won’t solve your problem, you have to also shift the origin to reduce the overall number of digits. Otherwise, you will again run out of significant digits.

May I ask what’s your reason to insist on not doing this?

I though adding a scale might work, and it does for small number, but scaling to the size that you want is not supported anymore GL Shader precise point coordinates2.gh (575.4 KB)

I do not insist to not solve the issue with this approach. I just think it is just not the most efficient way how to solve the issue. And I know what you might say Rhino is not specificaly designed to handle fractals… but I am working on Chimpanzee 0.5 (plug-in for fractal generation) and considering to implement double or decimal precision to enhace even deeper zoom for the fractals. I am looking for a method be able to display such a fractals and the GL Shader component is very memory efficient. I was not yet looking into the code of Symbol Display component however the double precision might be the reason why the component can handle such a preview, that might be question for @DavidRutten?

The 53 bits of double give about 16 digits of precision. The 24 bits of float give about 7 digits of precision.

When zooming in on your fractal, you’ll eventually hit the limitation of what float can meaningfully represent. While OpenGL 410+ supports double precision coordinates, GHGL does not. The following code doesn’t throw an error, but it also doesn’t render properly. That’s because, currently you can only provide the following types as input uniforms: sampler2D, bool, mat4, vec4, vec3, float, int. Replace double with float in lines 3&4 and all works well.

You could fork the repo and introduce support for double precision uniforms, or work around the current limitations. Looking at the first 10 points from your set, scaled by 100.000.000.000, clearly, the first 9 digits are insignificant and could be safely removed without impacting the results:

By shifting your points to the origin, the redundant part can be shaved off, and only the significant digits are left:

double m = 100000000000;
Point3d moveVector = inputPoints[0] * m;
var pts = new List<Point3d>();
foreach (var pt in inputPoints)
pts.Add(new Point3d(pt.X * m - moveVector.X, pt.Y * m - moveVector.Y, 0));
scaledPoints = pts;

Maybe you could try a similar approach with your zoom-in function and manipulate the point coordinates as users zoom in?