开发者

Sequence of transformations: Projective Texturing (HLSL)

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

Sequence of transformations: Projective Texturing (HLSL)

(source: nvidia.com)

The order in which the transformations are written confused me. This is because I learned to read matrix multiplication from left to right and also because I thought the sequence of transformations should go in this order:

Sequence of transformations: Projective Texturing (HLSL)

(source: nvidia.com)

Now my questions are the following:

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

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

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

float4 worldPosition        = mul(input.Position, World);
float4 viewPositi开发者_JAVA百科on         = mul(worldPosition, View);
output.Position             = mul(viewPosition, Projection);

Finally (and this is optional but might be usefull for others wondering the same), how would you write the HLSL code to do this projective texturing multiplication or how would you do the transformations if you passed the complete Matrix via XNA.


Your transformation can be written symbolically as

y = T P V W x

where:

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

The calculation is performed as:

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

i.e. from right to left. The HLSL code would be:

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

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜