Advertisement

Directx camera world positions

Started by January 03, 2018 09:44 AM
5 comments, last by haegarr 7 years, 1 month ago

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?

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.

Advertisement
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.

 

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).

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.

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

This topic is closed to new replies.

Advertisement