|
|
程序的目的是: 把场景的z值存入到一texture中,然后再取出来显示它的z值
存在的问题 : 把z值存入到texture中,检查无误; 而重新取出的数据和存入的数据却不一致
可以由程序显示出来看到错误,请问,这里面可能是什么问题呢?
//*********************
//****存入的时候代码*****
//*********************
//-----------------------------------------------------------------------------
// c12 - range scale
// v0...v4 - world-view-proj matrix
//-----------------------------------------------------------------------------
vs.1.1
dcl_position v0
// Transform and output position
m4x4 r0, v0, c0
mov oPos, r0
// Output depth
mul oT0.x, r0.z,c12.x
//-----------------------------------------------------------------------------
// Output depth to the texture
//-----------------------------------------------------------------------------
ps.2.0
// Incoming depth
dcl t0.x
// Output depth
mov r0, t0.x
mov oC0, r0
//*********************
//****取texture数据代码**
//*********************
//-----------------------------------------------------------------------------
// c0..3 ——这里的c0...c3和存入的时候的用到的矩阵c0..c3完全一样
//-----------------------------------------------------------------------------
vs.1.1
dcl_position v0
//other program omit
....
// transform
m4x4 oT0, v0, c0
//-----------------------------------------------------------------------------
//PS
//-----------------------------------------------------------------------------
ps.2.0
dcl t0.xyzw
dcl_2d s0
texld r0, t0, s0
mov oC0,r0 |
|