且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

PassThrough几何着色器不起作用

更新时间:2022-04-13 09:14:24

问题的核心是,在构建几何着色器"时,您不必费心检查编译错误.我知道这是因为我看到了一些语法错误.特别是:

The core of your problem is that you didn't bother to check for compilation errors when you built your Geometry Shader. I know that because I see several syntax errors for it. In particular:

in vec3 N;
in vec3 L;
in vec3 R;
in vec3 V;

in vec4 v_color;    // vertex color 
in vec4 pos_in_eye;  //vertex position in eye space 
in vec2 FtexCoord; 

几何着色器输入总是 聚集到数组中.请记住:几何体着色器在 基元 上运行,这些基元定义为一个或多个顶点的集合.因此,每个GS调用都会获得一组每个顶点的输入值,每个原始layout in限定符定义的类型.

Geometry Shader inputs are always aggregated into arrays. Remember: a geometry shader operates on primitives, which are defined as a collection of one or more vertices. Each GS invocation therefore gets a set of per-vertex input values, one for each vertex in the primitive type defined by your layout in qualifier.

注意如何遍历图元中的顶点数量,并使用gl_in[i]获取图元中每个顶点的输入值.这就是您需要访问几何着色器"输入的所有 的方式.并且您需要将每个变量写入其相应的输出变量,然后调用EmitVertex.都在那个循环中.

Notice how you loop over the number of vertices in a primitive and use gl_in[i] to get the input value for each vertex in the primitive. That's how you need to access all of your Geometry Shader inputs. And you need to write each one to its corresponding output variable, then call EmitVertex. All in that loop.