【问题标题】:Draw points in Metal在 Metal 中绘制点
【发布时间】:2016-04-28 11:12:04
【问题描述】:

我使用 drawIndexedPrimitives 函数在 Metal 中绘制点,但我不知道应该在哪里调整点的大小。在 OpenGL ES 中,我可以在着色器中调整点大小:gl_PointSize = 10.0f;这在 Metal 中是如何工作的?

顺便说一句,对于从文件中绘制点,我有一个 las 文件(3d 点云数据:一种顺序二进制格式,用于存储来自传感器的数据并用作某些应用程序的中间处理存储),我想导入它到Xcode并使用Metal for iOS渲染这些点,有人知道如何使用Metal实现las文件吗?我应该在导入之前将其转换为 OBJ 还是 PLY?

画点函数(swift):

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

【问题讨论】:

    标签: point-clouds metal


    【解决方案1】:

    我发现在着色器中定义了点大小。

    在结构体中为顶点着色器设置一个变量

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

    并设置 var 的值:

    VertexOut.pointsize = 10.0;
    

    然后在主代码中使用Draw points函数:

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

    但仍然卡在 las 文件中……不知道如何用 Metal 渲染它……

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2020-01-30
      • 2022-01-02
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多