Skip to content

Commit aac4d2d

Browse files
committed
tracking 7.4
1 parent e1a4fb4 commit aac4d2d

File tree

1 file changed

+10
-2
lines changed
  • articles/tutorials/advanced/2d_shaders/07_sprite_vertex_effect

1 file changed

+10
-2
lines changed

articles/tutorials/advanced/2d_shaders/07_sprite_vertex_effect/index.md

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -96,18 +96,26 @@ The default sprite vertex shader uses this line:
9696

9797
[!code-hlsl[](./snippets/snippet-7-07.hlsl)]
9898

99-
The reason this line exists is to convert the vertices from world-space to clip-space. A vertex is a 3d coordinate in "world-space". But a monitor is a 2d display. Often, the screen's 2d coordinate system is called "clip-space". The vertex shader is converting the 3d world-space coordinate into a 2d clip-space coordinate. That conversion is a vector and matrix multiplication, using the `MatrixTransform`.
99+
The reason this line exists is to convert the vertices from world-space to clip-space.
100+
101+
> [!tip]
102+
> A vertex is a 3d coordinate in "world-space". But a monitor is a 2d display. Often, the screen's 2d coordinate system is called "clip-space". The vertex shader is converting the 3d world-space coordinate into a 2d clip-space coordinate. That conversion is a vector and matrix multiplication, using the `MatrixTransform`.
103+
>
104+
> Read more about clip space on [wikipedia](https://en.wikipedia.org/wiki/Clip_coordinates).
105+
> We will cover more about _how_ the conversion happens later in this chapter, in the perspective projection section.
100106
101107
The `MatrixTransform` is computed by the [`SpriteEffect`](xref:Microsoft.Xna.Framework.Graphics.SpriteEffect) class. The full source is available, [`here`](https://github.com/MonoGame/MonoGame/blob/develop/MonoGame.Framework/Graphics/Effect/SpriteEffect.cs#L63). The relevant lines are copied below:
102108

103109
[!code-csharp[](./snippets/snippet-7-08.cs)]
104110

105111
There are two common types of project matrices,
106-
1. Orthographic,
112+
1. Orthographic (The default used by `SpriteBatch`),
107113
2. Perspective
108114

109115
The orthographic projection matrix produces the classic 2d sprite effect, where sprites have no perspective when they are on the sides of the screen.
110116

117+
> [!tip]
118+
> Read more about these projection matrixes on [MonoGame's Camera Article](https://docs.monogame.net/articles/getting_to_know/whatis/graphics/WhatIs_Camera.html).
111119
112120
## Custom Vertex Shader
113121

0 commit comments

Comments
 (0)