How to get a ray in view space in volume rendering

Started by
4 comments, last by YixunLiu 7 years, 1 month ago

Hi,

In PS, I want to get a ray in view space to do volume rendering.

Let's say I have the camera position in the view space. I want to get the other end of the ray corresponding with the screen position. So I can define the ray.

My question is how to convert the screen position to view space in PS?

Thanks a lot.

YL

Advertisement
The camera position in view space ? It is the origin : float3(0,0,0) :)

The viewspace ray can be determine from the screen coordinate normalize to -1..1, add a fake z that represent something like the far plane (value depends on the kind of projection you use), w set to 1 and multiply by the inverse projection. Divide the result by w, normalize the float3, and you have your viewdirection

Thanks.

Can I use any value between near plane and far plane as fake z?

I think I can use any value between [0, 1] as fake z, right?

You gonna normalize the vector so yes, any z value should be good.

Thanks!

This topic is closed to new replies.

Advertisement