Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/python/310.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Python Panda3D中的深度纹理_Python_3d_Panda3d - Fatal编程技术网

Python Panda3D中的深度纹理

Python Panda3D中的深度纹理,python,3d,panda3d,Python,3d,Panda3d,在Panda3D中,我有以下代码 self.manager = FilterManager(base.win, base.cam) self.sceneTex = Texture("scene") self.depthTex = Texture("depth") self.quad = self.manager.renderSceneInto(colortex=self.sceneTex, depthtex = self.depthTex) ... 当我运行上述命令并启用视图缓冲

在Panda3D中,我有以下代码

self.manager = FilterManager(base.win, base.cam)

self.sceneTex = Texture("scene")
self.depthTex = Texture("depth")


self.quad = self.manager.renderSceneInto(colortex=self.sceneTex, depthtex = self.depthTex)

...   
当我运行上述命令并启用视图缓冲区(show buffers#t)时,“sceneTex”纹理看起来不错。但是,“depthTex”始终为空(全黑),无论我将相机移动到何处。有人知道怎么了吗


谢谢

也许您已禁用深度测试写作?即使您可能不会得到任何明显的瑕疵(取决于您的场景),您也可以在没有深度缓冲的情况下运行。查看下一页,它还告诉您一些场景使用深度排序效果更好(您可能测试了此功能,但没有还原深度缓冲区禁用代码?

我遇到了相同的问题。我必须创建一个自定义着色器来提取深度。因为我需要超过8位的深度信息,所以我必须将深度转换为3个8位字段,这些字段可以放在图像的RGB组件中

在Panda3D Python中:

# Set up Shader
dcam = loader.loadShader('Dcam.sha')
# render everything through this camera and shader
self.terrain.getRoot().setShader(dcam)
还需要设置着色器输入和输出(即vtx_位置、mat_modelproj等)。请参见Panda3D文档中的示例

在Dcam.sha中:

//Cg

void vshader(float4 vtx_position : POSITION,
             uniform float4x4 mat_modelproj,
             out float4 l_position : POSITION,
             out float4 l_pos : TEXCOORD0)
{
    float4 position = vtx_position;
    l_pos = mul(mat_modelproj, position);
    l_position = l_pos;
}

void fshader(in float4 l_pos : TEXCOORD0,
             out float4 o_color : COLOR)
{
    float z = (l_pos.z / l_pos.w) * 0.5 + 0.5;
    float zres = 16777216.0 * z;
    float v0 = round(zres / 65536.0);
    zres = zres - 65536.0 * v0;
    float v1 = round(zres / 256.0);
    zres = zres - 256.0 * v1;
    float v2 = round(zres);
    o_color = float4(v0, v1, v2, 1);
}