GLSL从

时间:2016-04-26 10:08:40

标签: opengl glsl geometry-shader tesselation

解决方案:Drawing tessallated LineLoops in OpenGL/GLSL

我正在使用OpenGL和GLSL在球体上绘制LineLoops(行星上的边框)。

由于定义线条的点是由用户输入给出的,因此它们没有足够高的精度来防止在球体内部进行裁剪。

我想使用Tesselation和/或几何着色器在现有点之间创建额外的点,这样点之间的距离不会超过某个值(线条不再在球体内部剪切)。

在: enter image description here

在: enter image description here

可悲的是,没有太多关于Tesselation着色器的信息,所以我不太确定它们是如何工作的,但我知道我可以用它们细分基元。

这是我当前的vertexShader:

#version 400

in layout(location = 0) vec3 position;

uniform float maxDist;
uniform float sphereRadius;
uniform mat4 view;
uniform mat4 projection;

void main()
{
    gl_Position = projection * view * vec4(position, 1.0);
}

如何使用Tessalation / Geometry Shaders在点之间创建更多顶点并偏移新创建的顶点,使它们具有sphereRadius制服的给定长度。

我不是在寻找能为每一行做一次细分的解决方案。我寻找一种解决方案,根据需要进行尽可能多的细分,以获得不超过maxDist的点之间的特定距离。

我目前正在画这样:

glBindVertexArray(_vao);
glDrawArrays(GL_LINE_LOOP, 0, _size);
glBindVertexArray(0);

0 个答案:

没有答案