Jump to content
  • Advertisement
IAS2000

DX11 Directx camera world positions

Recommended Posts

Hi guys. 

I'm trying to move my shadow map with the camera. I need world positions of camera frustum points to implement this.

How can I calculate the world positions of 8 camera frustum vertices?

Share this post


Link to post
Share on other sites
Advertisement
2 hours ago, IAS2000 said:

How can I calculate the world positions of 8 camera frustum vertices?

That depends on the co-ordinate space in which the said vertices are given. In general you just have to apply the transformation matrices that change the space relation of the vertices from the given one up to the world space. When chaining transformation matrices the correct order has to be obeyed, of course.

Assuming that the vertices are given in camera local space, you have to apply the usually so-called camera matrix (equal to the inverse view matrix), because that matrix describes the relation of the camera local space in world space. If otherwise the vertices are given in normalized device co-ordinate space, you have to apply the inverse projection first before using the camera matrix.

Share this post


Link to post
Share on other sites
1 hour ago, haegarr said:

you have to apply the usually so-called camera matrix (equal to the inverse view matrix), because that matrix describes the relation of the camera local space in world space. If otherwise the vertices are given in normalized device co-ordinate space, you have to apply the inverse projection first before using the camera matrix.

Thank you for replying.

 

But to what should I apply the camera matrix?(what should I multiply with the camera matrix to get the positions of 8 vertices)

Camera's position? but it doesn't give 8 vectors.

 

Share this post


Link to post
Share on other sites
59 minutes ago, IAS2000 said:

But to what should I apply the camera matrix?(what should I multiply with the camera matrix to get the positions of 8 vertices)

The vertices you're interested in are the corners of a view frustum. They are give as the corners where the 6 view clipping planes meet. In normalized device co-ordinates they are the 6 sides of the unit cube, i.e. the cube with their sides at x = +1/-1, y = +1/-1, and z = +1/-1 or z = 0/+1 (all possible combinations in a vector [x,y,z] give you the 8 corners; notice that some APIs use z = +1/-1 while others use z = 0/+1). On the other hand, in camera space the frustum is limited by the near and far clipping plane and 4 other planes which depend on the projection mode (orthogonal or perspective) and its parametrization (view size and perhaps view angle).

Share this post


Link to post
Share on other sites
30 minutes ago, haegarr said:

The vertices you're interested in are the corners of a view frustum. They are give as the corners where the 6 view clipping planes meet. In normalized device co-ordinates they are the 6 sides of the unit cube, i.e. the cube with their sides at x = +1/-1, y = +1/-1, and z = +1/-1 or z = 0/+1 (all possible combinations in a vector [x,y,z] give you the 8 corners; notice that some APIs use z = +1/-1 while others use z = 0/+1). On the other hand, in camera space the frustum is limited by the near and far clipping plane and 4 other planes which depend on the projection mode (orthogonal or perspective) and its parametrization (view size and perhaps view angle).

Thank you so much. I was looking for this.

Share this post


Link to post
Share on other sites

Since the title mentioned DirectX (as I've noticed just now): AFAIK it uses z = 0/+1 as normalized depth range.

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

  • Advertisement
×

Important Information

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

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!