add docs to clip_from_view (#16373)

more docs
This commit is contained in:
atlv 2024-11-17 19:33:37 -05:00 committed by GitHub
parent c6fe275b21
commit 701ccdec51
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
2 changed files with 87 additions and 0 deletions

View file

@ -186,6 +186,35 @@ impl Msaa {
#[derive(Component)]
pub struct ExtractedView {
/// Typically a right-handed projection matrix, one of either:
///
/// Perspective (infinite reverse z)
/// ```text
/// f = 1 / tan(fov_y_radians / 2)
///
/// ⎡ f / aspect 0 0 0 ⎤
/// ⎢ 0 f 0 0 ⎥
/// ⎢ 0 0 0 -1 ⎥
/// ⎣ 0 0 near 0 ⎦
/// ```
///
/// Orthographic
/// ```text
/// w = right - left
/// h = top - bottom
/// d = near - far
/// cw = -right - left
/// ch = -top - bottom
///
/// ⎡ 2 / w 0 0 0 ⎤
/// ⎢ 0 2 / h 0 0 ⎥
/// ⎢ 0 0 1 / d 0 ⎥
/// ⎣ cw / w ch / h near / d 1 ⎦
/// ```
///
/// `clip_from_view[3][3] == 1.0` is the standard way to check if a projection is orthographic
///
/// Custom projections are also possible however.
pub clip_from_view: Mat4,
pub world_from_view: GlobalTransform,
// The view-projection matrix. When provided it is used instead of deriving it from
@ -423,6 +452,35 @@ pub struct ViewUniform {
pub world_from_clip: Mat4,
pub world_from_view: Mat4,
pub view_from_world: Mat4,
/// Typically a right-handed projection matrix, one of either:
///
/// Perspective (infinite reverse z)
/// ```text
/// f = 1 / tan(fov_y_radians / 2)
///
/// ⎡ f / aspect 0 0 0 ⎤
/// ⎢ 0 f 0 0 ⎥
/// ⎢ 0 0 0 -1 ⎥
/// ⎣ 0 0 near 0 ⎦
/// ```
///
/// Orthographic
/// ```text
/// w = right - left
/// h = top - bottom
/// d = near - far
/// cw = -right - left
/// ch = -top - bottom
///
/// ⎡ 2 / w 0 0 0 ⎤
/// ⎢ 0 2 / h 0 0 ⎥
/// ⎢ 0 0 1 / d 0 ⎥
/// ⎣ cw / w ch / h near / d 1 ⎦
/// ```
///
/// `clip_from_view[3][3] == 1.0` is the standard way to check if a projection is orthographic
///
/// Custom projections are also possible however.
pub clip_from_view: Mat4,
pub view_from_clip: Mat4,
pub world_position: Vec3,

View file

@ -19,6 +19,35 @@ struct View {
world_from_clip: mat4x4<f32>,
world_from_view: mat4x4<f32>,
view_from_world: mat4x4<f32>,
// Typically a right-handed projection matrix, one of either:
//
// Perspective (infinite reverse z)
// ```
// f = 1 / tan(fov_y_radians / 2)
//
// f / aspect 0 0 0
// 0 f 0 0
// 0 0 0 -1
// 0 0 near 0
// ```
//
// Orthographic
// ```
// w = right - left
// h = top - bottom
// d = near - far
// cw = -right - left
// ch = -top - bottom
//
// 2 / w 0 0 0
// 0 2 / h 0 0
// 0 0 1 / d 0
// cw / w ch / h near / d 1
// ```
//
// `clip_from_view[3][3] == 1.0` is the standard way to check if a projection is orthographic
//
// Custom projections are also possible however.
clip_from_view: mat4x4<f32>,
view_from_clip: mat4x4<f32>,
world_position: vec3<f32>,