Transformation Sequence: Projective Texturing (HLSL)

When I read this article about Projective Texturing (9.3.2) on nvidia, I came across this graph:

http://http.developer.nvidia.com/CgTutorial/elementLinks/252equ01.jpg

The order of writing transformations confused me. This is because I learned to read matrix multiplication from left to right, and also because I thought that the sequence of transformations should go in the following order:

http://http.developer.nvidia.com/CgTutorial/elementLinks/fig4_1.jpg

Now my questions are:

Since Matrix multiplication is not commutative, what is the order in which I should do the multiplications?

And if it really is in the same order as the sequence of transformations of normal objects, why is it written like this?

In the same order of sequence, I mean something like this hlsl code:

float4 worldPosition = mul(input.Position, World); float4 viewPosition = mul(worldPosition, View); output.Position = mul(viewPosition, Projection); 

Finally (and this is optional, but may be useful if others are wondering the same thing), how would you write HLSL code to perform this projective texture multiplication, or how would you do the transformations if you were to pass the full matrix through XNA.

+6
source share
1 answer

Your conversion can be written symbolically as

y = TPVW x

Where:

x = (x0, y0, z0, w0) T : object coordinates (column vector 4x1)
y = (s, t, r, q) T : window space coordinates (4x1 column vector)
W : World Modeling Model (4x4)
V : view the modeling matrix (4x4)
P : projection matrix (4x4)
T : view transformation matrix (4x4)

The calculation is performed as:

y = T (P (V (W x)))

i.e. from right to left. HLSL Code:

 float4 worldPosition = mul(World, input.Position); // W x float4 viewPosition = mul(View, worldPosition); // V (W x) float4 projPosition = mul(Projection, viewPosition); // P (V (W x)) float4 vportPosition = mul(Viewport, projPosition); // T (P (V (W x))) 
+4
source

Source: https://habr.com/ru/post/891886/


All Articles