# 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 on other sites
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 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.

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 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 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 on other sites

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

## Create an account

Register a new account

1. 1
Rutin
67
2. 2
3. 3
4. 4
5. 5

• 21
• 10
• 33
• 20
• 9
• ### Forum Statistics

• Total Topics
633417
• Total Posts
3011782
• ### Who's Online (See full list)

There are no registered users currently online

×