[HLSL][C++] Lecture du Depth Buffer dans un PS3.0
J'initialise une texture qui devra contenir mon z buffer :
Code:
1 2 3 4 5 6 7 8 9 10 11
| V( DXUTGetD3DDevice()->CreateTexture(
back_buffer_surface->Width,
back_buffer_surface->Height,
1,
D3DUSAGE_DEPTHSTENCIL,
D3DFMT_D24S8,
D3DPOOL_DEFAULT,
&z_buffer_texture,
NULL
) );
z_buffer_texture->GetSurfaceLevel(0,&z_buffer_surface); |
Ensuite, je l'utilise pendant le rendu :
Code:
V( DXUTGetD3DDevice()->SetDepthStencilSurface( z_buffer_surface ) );
En post traitement, je souhaite l'exploiter dans un pixel shader :
Code:
1 2 3 4 5 6 7 8 9 10
| V( _deferred2_effect->SetTexture( texture_depth, z_buffer_texture ) );
sampler sampler_depth = sampler_state
{
texture = <texture_depth>;
AddressU = CLAMP;
AddressV = CLAMP;
};
[...]
float depth = tex2D( sampler_depth, tex ); |
Et à ce moment là, la valeur de depth est bloqué à 1.0f ou supérieure.
Comment récupère t on correctement la valeur depth dans un pixel shader ?
Merci d'avance.
Xter.