深度缓冲区仅显示蓝色

发布于 2024-09-09 02:26:13 字数 234 浏览 3 评论 0原文

我正在尝试在 RenderMonkey 中实现 Light Prepass 渲染。到目前为止,在法线+深度通道中,法线缓冲区似乎得到了正确的结果,但深度缓冲区仅显示一种颜色。如何检查我的深度缓冲区是否正确? 工作区下载链接:http://www.mediafire.com/?jq3jmantyxw

I'm trying to implement Light Prepass rendering in RenderMonkey. So far, in Normal+Depth pass, it seems like Normal buffer is getting correct result, but Depth buffer only show one color. How can I check if my Depth buffer is correct or not?
Workspace download link: http://www.mediafire.com/?jq3jmantyxw

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

分開簡單 2024-09-16 02:26:13

浅蓝色实际上是 RGB 值 0.0, 1.0, 1.0。由于深度(通常)是代表 Z 的单个通道,因此当从纹理采样时,它会在第一个通道(红色)中返回。缺少的绿色、蓝色和 Alpha 通道将由硬件替换为 1.0。

你的下载链接不起作用,因为我怀疑已经有两年了。

您应该确保您的像素着色器同时返回 COLOR0COLOR1 语义(请注意,尽管输出是单通道纹理,但深度是 float4) :

struct PS_OUT { float4 color : COLOR0; float4 depth : COLOR1; };

PS_OUT ps_main( PS_INPUT Input )
{
    PS_OUT Output;
    // your color shader here
    Output.color = myFinalColor;
    Output.depth = myFinalDepth;  // e.g. Input.posz / Input.posw from your vertex shader
    return Output;
}

根据您的相机设置,您可能会得到如下内容:

在此处输入图像描述

The light blue is actually RGB values 0.0, 1.0, 1.0. Since depth is (usually) a single channel representing Z, when sampled from texture it's returned in the first channel, red. Missing channels green, blue and alpha will have 1.0 substituted by the hardware.

Your download link is non-functional, since it's been 2 years I suspect.

You should ensure your pixel shader is returning both COLOR0 and COLOR1 semantics (note that depth is a float4 despite the output being a single channel texture):

struct PS_OUT { float4 color : COLOR0; float4 depth : COLOR1; };

PS_OUT ps_main( PS_INPUT Input )
{
    PS_OUT Output;
    // your color shader here
    Output.color = myFinalColor;
    Output.depth = myFinalDepth;  // e.g. Input.posz / Input.posw from your vertex shader
    return Output;
}

Depending on your camera settings, you could get something like:

enter image description here

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文