#version 450 layout (location = 0) out vec4 outColor; in vec3 vBC; const float lineWidth = 0.5; const vec3 color = vec3(0.7, 0.7, 0.7); float edgeFactor(){ vec3 d = fwidth(vBC); vec3 a3 = smoothstep(vec3(0.0), d*1.5, vBC); return min(min(a3.x, a3.y), a3.z); } void main(){ outColor = vec4(min(vec3(edgeFactor()), color), 1.0); }

问题描述 投票:0回答:1
顶点:

#version 450 layout (location = 0) in vec3 position; layout (location = 1) in vec3 baryCentric; out vec3 vBC; uniform mat4 T_MVP; void main() { //texCoord0 = texCoord; gl_Position = T_MVP * vec4(position, 1.0); vBC = baryCentric; }

这是渲染之前的gl准备:

wir.bind();
wir.updateUniforms(super.getTransform(), mat, engine);
GL45.glEnable(GL45.GL_SAMPLE_ALPHA_TO_COVERAGE);
GL45.glEnable(GL45.GL_BLEND);
GL45.glBlendFunc(GL45.GL_SRC_ALPHA, GL45.GL_ONE_MINUS_SRC_ALPHA);
mesh.draw("baryCentric", GL15.GL_TRIANGLES);

这是我绑定顶点属性的方式;着色器在我的旧AMD集成显卡上工作得很好。但是在我的rtx 2060超级计算机上却没有。着色器和GL版本在旧版本上:OpenGL版本:4.5.13399兼容性配置文件上下文15.200.1062.1004在新版上:4.6.0 NVIDIA 445.87

我是根据本教程中有关单遍线框渲染的本教程创建的此着色器:http://codeflow.org/entries/2012/aug/02/easy-wireframe-display-with-barycentric-coordinates/片段:#...

java opengl glsl
1个回答
0
投票

edgeFactor

调用float edgeFactor(){ // [...] return min(min(a3.x, a3.y), a3.z); } 是多余的,可以完全跳过:

min

© www.soinside.com 2019 - 2024. All rights reserved.