Ureader.com  
Microsoft software help and Community
   home   |   control panel login   |   archive   |  
 
Windos
win32.3rdparty
win32.directx.audio
win32.directx.ddk
win32.directx.graphics
win32.directx.input
win32.directx.managed
win32.directx.misc
win32.directx.networking
win32.directx.sdk
win32.directx.video
win32.dirx.grap.shaders
win32.gdi
win32.international
win32.kernel
win32.messaging
win32.mmedia
win32.networks
win32.ole
win32.rtc
win32.tapi
win32.tapi.beta
win32.tools
win32.ui
win32.wince
win32.wmi
windows.mediacenter
winfx.aero
winfx.announcements
winfx.avalon
winfx.collaboration
winfx.fundamentals
winfx.general
winfx.indigo
winfx.sdk
winfx.winfs
  
 
date: Sun, 29 Jun 2008 22:55:33 -0700 (PDT),    group: microsoft.public.win32.programmer.directx.graphics        back       


raycasting question   
I have a texture containing the world positions represented by every
pixel that is rendered. By rendering a fullscreen quad, for each pixel
that is rendered I extract the world position and I want to take 20
samples into the screen, thereby determining 20 world positions from
the camera to the rendered pixel, so that I can test those positions
against a shadow map. This is to hopefully achieve a basic volume
lighting effect.

I get the world position:

   float4 worldPos = texDepth.Sample(g_samPoint, input.texcoord);

and multiply by the view projection matrix:

   worldPos = mul(float4(worldPos.xyz, 1.0f), g_viewProjectionMatrix);

If I started off with worldPos in viewspace (screen space?) and wanted
to go back to world space, I would do this:

worldPos = mul(worldPos, g_inverseViewProjectionMatrix);
worldPos.xyz /= worldPos.w;

(Let me know if I am wrong about the above)

But if I want to calculate the world position using a different depth,
let's say a depth that is halfway between the camera and the pixel's
world position, how do I do this?

worldPos = mul(worldPos.xy, worldPos.z, worldPos.w*0.5f,
g_inverseViewProjectionMatrix);
worldPos.xyz /= worldPos.w;

or is it

worldPos = mul(worldPos.xy, worldPos.z * 0.5f, worldPos.w
g_inverseViewProjectionMatrix);
worldPos.xyz /= worldPos.w;

I can't seem to find the correct formula. Either I've hit upon the
correct formula and the rest of my shader is wrong, or the initial
calculation is wrong.

Is anybody able to help?

Thanks,

Peter
date: Sun, 29 Jun 2008 22:55:33 -0700 (PDT)   author:   unknown

Google
 
Web ureader.com


    COPYRIGHT 2007, YARDI TECHNOLOGY LIMITED, ALL RIGHT RESERVE  |   contact us