表面积计算

发布于 2024-11-19 16:15:35 字数 266 浏览 2 评论 0原文

我使用 glDrawArrays(GL_POINTS,...) 来绘制谐波。 我想知道 openGL 在基于顶点渲染时生成曲面(三角形?)的顺序 并以这种方式计算表面积? 我可以做吗?如果可以的话怎么做?


我会尝试更好地解释它,

我有 2D 值数组并对其执行 uv 映射。(我生成谐波) 并使用 glDrawArrays 绘制接受的表面。 我想计算我可视化的表面积。 我认为我应该通过创建三角形网格来“翻译”问题,以便更容易进行此类计算, 适合点绘制 - 这将简化我的计算。

I use glDrawArrays(GL_POINTS,...) to draw harmonic wave.
I would like to know the order in which the surfaces (triangles?) are generated by openGL while rendering based on the vertices
and in such a way calculate the surface area?
Can I do it and if yes how.


I will try to explain it better

I have 2D array of values and perform uv-mapping on it.( i generate harmonic wave)
and draw the surface accepted using glDrawArrays.
I want to calculate the surface area,which i visualize.
I think I should "translate" the problem to be easier for such calculation by creating a grid of triangles ,
which is suitable for points drawing - this will simplify my calculation.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

小忆控 2024-11-26 16:15:35

我使用glDrawArrays(GL_POINTS,...)来绘制谐波。

点没有曲面。

我想知道openGL在基于顶点渲染时生成曲面(三角形?)的顺序,并以这种方式计算表面积?我可以做吗?如果可以的话怎么做。

OpenGL 不生成三角形。它会对您发送的三角形进行光栅化。按照您指定它们的顺序。 glDrawArrays(mode,first,count)行为

myDrawArrays(GLenum mode, GLuint first, GLuint count)
{
    GLuint *indices = malloc(count * sizeof(GLuint));
    /* just assume malloc never fails, OpenGL doesn't have to alloc here, of course) */
    for(int i=0; i<count; i++)
        indices[i] = first + i;
    glDrawElements(mode, count, GL_UNSIGNED_INT, indices);
    free(indices);
}

基元按照指定的顺序进行光栅化。

所以你想知道表面积,但要知道画点。正如已经说过的,点(在数学上)没有表面。然而,它们至少覆盖一个(子)像素。那么您是否真的想知道像素覆盖范围

然后 OpenGL 为您提供了一种称为“遮挡查询”的方法,使用该方法可以返回通过在查询中绘制图元而触摸了多少(屏幕/帧缓冲区)像素。

http://www.opengl.org/registry/specs/ARB/occlusion_query.txt

I use glDrawArrays(GL_POINTS,...) to draw harmonic wave.

Points have no surface.

I would like to know the order in which the surfaces (triangles?) are generated by openGL while rendering based on the vertices and in such a way calculate the surface area? Can I do it and if yes how.

OpenGL doesn't generate traiangles. It rasterizes the triangles you send it. In the very same order in which you specify them. glDrawArrays(mode, first, count) behaves exactly like

myDrawArrays(GLenum mode, GLuint first, GLuint count)
{
    GLuint *indices = malloc(count * sizeof(GLuint));
    /* just assume malloc never fails, OpenGL doesn't have to alloc here, of course) */
    for(int i=0; i<count; i++)
        indices[i] = first + i;
    glDrawElements(mode, count, GL_UNSIGNED_INT, indices);
    free(indices);
}

The primitives are rasterized in the order they are specified.

So you want to know a surface area, but are drawing points. As already told, points (mathematically) have no surface. However they cover at least one (sub-)pixel. So could it be that you actually want to know the pixel coverage?

Then OpenGL provides you a method called "occlusion query" using which it returns you, how many (screen/framebuffer) pixels got touched by drawing the primitives within the query.

http://www.opengl.org/registry/specs/ARB/occlusion_query.txt

蛮可爱 2024-11-26 16:15:35

几何着色阶段包含有关绘制的多边形的信息,因此您可以从那里计算表面量。为了获得其总和,您可以使用加法混合渲染到 1x1 R_32F 帧缓冲区对象中,然后将值读入系统内存。

The geometry shading stage contains the information about drawn polygon, so you can calculate the surface amount from there. In order to get the sum of it you can render into 1x1 R_32F framebuffer object with additive blending, then read the value into system memory.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文