Jump to content
  • Advertisement
Sign in to follow this  
diduk

A problem is in the calculation of difference of zBuffer and Z of position of point.

This topic is 3865 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

I get depthBuffer, through depth texture: CreateTexture(dx.caps.buf_w,dx.caps.buf_h,1,D3DUSAGE_DEPTHSTENCIL,(D3DFORMAT)MAKEFOURCC('R','A','W','Z'),D3DPOOL_DEFAULT,&bufz,0); I write down a depth in texture: CreateTexture(dx.caps.buf_w,dx.caps.buf_h,1,D3DUSAGE_RENDERTARGET,D3DFMT_R32F,D3DPOOL_DEFAULT,&buf,0); ---------pixel shader-------- // B is stencil, ARG are depth bits, A is MSB, G is LSB float screenDepth = dot(screenDepthARGB, float4(1/255.0, 1/255.0/255.0, 0, 1)); OUT.col = float4(screenDepth,0,0,1); texture correct!!! Then for soft particle in pixel shader I try to find a difference on Z: ---------vertex shader-------- ... OUT.position = mul(IN.position, worldViewProj); ... OUT.coord.z = OUT.position.z; OUT.coord.w = OUT.position.w; ---------pixel shader-------- float depthColor = tex2D(depthMap, IN.сoord.xy).x; float depthFactor = saturate(depthColor - IN.сoord.z / IN.сoord.w); and in result the value of depthFactor depends on distance of point to the camera. I am approached or move away from an object and the value of depthFactor changes so much :-( Such impression that values (depthColor) and (IN.сoord.z / IN.сoord.w) not much not comparable... Who can does know that it can be?

Share this post


Link to post
Share on other sites
Advertisement
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

Participate in the game development conversation and more when you create an account on GameDev.net!

Sign me up!