How about :

float4 pos4 = float4(input.Position.xyz, 1); //just to verify that it isn't question of syntax.

the w-component needs to 1 for the projection matrix multiplication to work correctly. If the w component is 0 then the result will be 0 too which isn't good.

By the standard, if your position is defined as 3-component vector from the program side and float4 in the shader side, the 4th component is automatically given value of 1.0.

float3 center = mul(input.Position, World); // There is nothing fishy here. The input.Position is multiplied by the 4x4 world matrix which doesn't affect the w-component typically. The cast of float4 to float3 works as intended ie. the xyz components are copied.

Cheers!

### Show differencesHistory of post edits

### #4kauna

Posted 13 November 2012 - 03:25 PM

How about :

float4 pos4 = float4(input.Position.xyz, 1); //just to verify that it isn't question of syntax.

the w-component needs to 1 for the projection matrix multiplication to have desired output work correctly. If the w component is 0 then the result will be 0 too which isn't good.

By the standard, if your position is defined as 3-component vector from the program side and float4 in the shader side, the 4th component is automatically given value of 1.0.

float3 center = mul(input.Position, World); // There is nothing fishy here. The input.Position is multiplied by the 4x4 world matrix which doesn't affect the w-component typically. The cast of float4 to float3 works as intended ie. the xyz components are copied.

Cheers!

float4 pos4 = float4(input.Position.xyz, 1); //just to verify that it isn't question of syntax.

the w-component needs to 1 for the projection matrix multiplication to have desired output work correctly. If the w component is 0 then the result will be 0 too which isn't good.

By the standard, if your position is defined as 3-component vector from the program side and float4 in the shader side, the 4th component is automatically given value of 1.0.

float3 center = mul(input.Position, World); // There is nothing fishy here. The input.Position is multiplied by the 4x4 world matrix which doesn't affect the w-component typically. The cast of float4 to float3 works as intended ie. the xyz components are copied.

Cheers!

### #3kauna

Posted 13 November 2012 - 03:06 PM

How about :

float4 pos4 = float4(input.Position.xyz, 1); //just to verify that it isn't question of syntax.

the w-component needs to 1 for the projection matrix multiplication to have desired output work correctly. If the w component is 0 then the result will be 0 too which isn't good.

By the standard, if your position is defined as 3-component vector from the program side and float4 in the shader side, the 4th component is automatically given value of 1.0.

float3 center = mul(input.Position, World); // There is nothing fishy here. The input.Position is multiplied by the 4x4 world matrix which doensn't affect the w-component typically. The cast of float4 to float3 works as intended ie. the xyz components are copied.

Cheers!

float4 pos4 = float4(input.Position.xyz, 1); //just to verify that it isn't question of syntax.

the w-component needs to 1 for the projection matrix multiplication to have desired output work correctly. If the w component is 0 then the result will be 0 too which isn't good.

By the standard, if your position is defined as 3-component vector from the program side and float4 in the shader side, the 4th component is automatically given value of 1.0.

float3 center = mul(input.Position, World); // There is nothing fishy here. The input.Position is multiplied by the 4x4 world matrix which doensn't affect the w-component typically. The cast of float4 to float3 works as intended ie. the xyz components are copied.

Cheers!

### #2kauna

Posted 13 November 2012 - 03:05 PM

How about :

float4 pos4 = float4(input.Position.xyz, 1); //just to verify that it isn't question of syntax.

the w-component needs to 1 for the projection matrix multiplication to have desired output work correctly. If the w component is 0 then the result will be 0 too which isn't good.

By the standard, if your position is defined as 3-component vector from the program side and float4 in the shader side, the 4th component is automatically given value of 1.0.

float3 center = mul(input.Position, World); // There is nothing fishy here. The input.Position is multiplied by the 4x4 world matrix which doensn't affect the w-component typically. The cast of float4 to float3 works as intended ie. the xyz components are copied.

Cheers!

float4 pos4 = float4(input.Position.xyz, 1); //just to verify that it isn't question of syntax.

the w-component needs to 1 for the projection matrix multiplication to have desired output work correctly. If the w component is 0 then the result will be 0 too which isn't good.

By the standard, if your position is defined as 3-component vector from the program side and float4 in the shader side, the 4th component is automatically given value of 1.0.

float3 center = mul(input.Position, World); // There is nothing fishy here. The input.Position is multiplied by the 4x4 world matrix which doensn't affect the w-component typically. The cast of float4 to float3 works as intended ie. the xyz components are copied.

Cheers!

### #1kauna

Posted 13 November 2012 - 03:03 PM

How about :

float4 pos4 = float4(input.Position.xyz, 1); //just to verify that it isn't question of syntax.

the w-component needs to 1 for the view / projection matrix multiplications for them to work correctly.

By the standard, if your position is defined as 3-component vector from the program side and float4 in the shader side, the 4th component is automatically given value of 1.0.

float3 center = mul(input.Position, World); // There is nothing fishy here. The input.Position is multiplied by the 4x4 world matrix which doensn't affect the w-component typically. The cast of float4 to float3 works as intended ie. the xyz components are copied.

Cheers!

float4 pos4 = float4(input.Position.xyz, 1); //just to verify that it isn't question of syntax.

the w-component needs to 1 for the view / projection matrix multiplications for them to work correctly.

By the standard, if your position is defined as 3-component vector from the program side and float4 in the shader side, the 4th component is automatically given value of 1.0.

float3 center = mul(input.Position, World); // There is nothing fishy here. The input.Position is multiplied by the 4x4 world matrix which doensn't affect the w-component typically. The cast of float4 to float3 works as intended ie. the xyz components are copied.

Cheers!