不能正常从深度缓冲中采样

问题描述 投票:0回答:0

There I have the cube

And it's depth values

我想得到的东西以某种方式显示出来 in renderdoc preview

But what I actually get

顶点着色器

#version 410 core

uniform vec2 bound[4] = vec2[](vec2(-1.0f, 1.0f),
vec2(-1.0f, -1.0f), vec2(1.0f, 1.0f), vec2(1.0f, -1.0f));

void main(){
    gl_Position = vec4(bound[gl_VertexID], 1.0f, 1.0f);
}

片段着色器

#version 410 core

out vec4 out_color;

uniform sampler2D depth;
uniform vec2 icoord;
uniform vec3 color;

void main(){
    float o = texture(depth, icoord * gl_FragCoord.xy).r;
    // float a = o == 1.0f ? 0.0f : 1.0f;
    if(o < 1.0f)
        out_color = vec4(color, 0.4f);
    else
        discard;
}

混合被禁用。所以为什么我不能只得到实心的橙色立方体,而是得到一个有孔的像素化立方体。

我尝试启用混合并发现问题不存在。

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