Jump to content
  • Advertisement
Sign in to follow this  
Desarrollo3D

DX11 World*View*Project in DX11 problem

This topic is 2653 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

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!!

Share this post


Link to post
Share on other sites
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);

Share this post


Link to post
Share on other sites
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!!

Share this post


Link to post
Share on other sites
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

Share this post


Link to post
Share on other sites
The * operator does not perform matrix multiplication, it performs per-component multiplication. You want to use mul(), not *.

Share this post


Link to post
Share on other sites
The * operator does not perform matrix multiplication, it performs per-component multiplication. [/quote]

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

Share this post


Link to post
Share on other sites

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....

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!