小编APr*_*mer的帖子

OpenGL:透明纹理问题

我在 OpenGL 中遇到纹理透明度问题。正如您在下图中看到的,它不太有效。值得注意的是,黑色实际上是 ClearColor,我用来清除屏幕。

在此输入图像描述

我使用以下代码来实现混合:

glEnable(GL_BLEND);
glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
Run Code Online (Sandbox Code Playgroud)

这是我的片段着色器:

#version 330 core

in vec2 tex_coords;

out vec4 color;

uniform vec4 spritecolor;
uniform sampler2D image;

void main(void)
{
    color = spritecolor * texture(image, tex_coords);
}
Run Code Online (Sandbox Code Playgroud)

这是线框模式下场景的屏幕截图,以防它有助于绘制顶点:

线框模式下的场景

如果还有什么需要的,可以问我,我会补充的。

opengl transparency blending

3
推荐指数
1
解决办法
1468
查看次数

标签 统计

blending ×1

opengl ×1

transparency ×1