Sign in to follow this  

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

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

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this