World*View*Project in DX11 problem

Started by
6 comments, last by MJP 12 years, 8 months ago
This is the starting shader code:

float4 Pos0 : POSITION0...

matrix WorldViewProjection=World*View*Projection;

output.Pos = mul( Pos0, World );
output.Pos = mul( output.Pos, View );
output.Pos = mul( output.Pos, Projection );

and it works.

But if i change my code to: ( it should be the same...)


matrix WorldViewProjection=World*View*Projection;
output.Pos = mul( Pos0, WorldViewProjection );

i can see nothing!!! How it's possible?

Thanks!!
Advertisement

This is the starting shader code:

float4 Pos0 : POSITION0...

matrix WorldViewProjection=World*View*Projection;

output.Pos = mul( Pos0, World );
output.Pos = mul( output.Pos, View );
output.Pos = mul( output.Pos, Projection );

and it works.

But if i change my code to: ( it should be the same...)


matrix WorldViewProjection=World*View*Projection;
output.Pos = mul( Pos0, WorldViewProjection );

i can see nothing!!! How it's possible?

Thanks!!


No, those are not the same
I don't see why you want to change your original approach since it's just fine as it is

If you really insist on calculating your wvp-matrix in a single line you should use this:
matrix WorldViewProjection = mul(mul(World, View), Projection);

I gets all your texture budgets!

Great!!! I thought that World*View*Projection resolved this way:

World * View then result * Projection;

Another Question why do you say that i should not change the original code?


Thanks a lot!!
Because this:

output.Pos = mul( Pos0, World );
output.Pos = mul( output.Pos, View );
output.Pos = mul( output.Pos, Projection );



is exactly the same as this:

matrix WorldViewProjection=mul(mul(World,View),Projection)
output.Pos = mul( Pos0, WorldViewProjection );


The first option is more flexible for if you would need to do calculations with your view-space position for example

I gets all your texture budgets!

The * operator does not perform matrix multiplication, it performs per-component multiplication. You want to use mul(), not *.
Thanks a lot!!!! I was wrong with the * operator!!! unsure.gif
The * operator does not perform matrix multiplication, it performs per-component multiplication. [/quote]

Pity, in C++, the * operator does exactly this.

The * operator does not perform matrix multiplication, it performs per-component multiplication.


Pity, in C++, the * operator does exactly this.
[/quote]

That depends on which math library you're using....

This topic is closed to new replies.

Advertisement