Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Draw points in Metal

I use drawIndexedPrimitives function to draw points in Metal, but I don't know where should I adjust the point size. In OpenGL ES, I can adjust the point size in the shader: gl_PointSize = 10.0f; How does this work in Metal?

By the way, for draw points from a file, I have a las file(3d point cloud data: a sequential binary format used to store data from sensors and as intermediate processing storage by some applications), and I want to import it to Xcode and render those points using Metal for iOS, anyone knows how to implement with the las file using Metal? Should I transform it to OBJ or PLY before importing it?

Draw points function(swift):

commandEncoder.drawIndexedPrimitives(.Point,
                                     indexCount:indexCount,
                                     indexType:.UInt16,
                                     indexBuffer:indexBuffer,
                                     indexBufferOffset: 0)
like image 721
Eleanor Avatar asked Apr 28 '16 11:04

Eleanor


1 Answers

I found out that define the point size in the shader.

set up a var in the struct for vertex shader

 struct VertexOut{
...
    float pointsize[[point_size]];
...}

and set the value for the var:

VertexOut.pointsize = 10.0;

then use the Draw points function in the main code:

commandEncoder.drawIndexedPrimitives(.Point,
                                     indexCount:indexCount,
                                     indexType:.UInt16,
                                     indexBuffer:indexBuffer,
                                     indexBufferOffset: 0)

But still stuck with the las file...don't know how to render it with Metal...

like image 81
Eleanor Avatar answered Oct 24 '22 20:10

Eleanor