Jump to content

View more

Image of the Day

WIP title screen for #DeathOfAPartisan #screenshotsaturday #gamedev https://t.co/qJNhfZCvd4
IOTD | Top Screenshots

The latest, straight to your Inbox.

Subscribe to GameDev.net Direct to receive the latest updates and exclusive content.


Sign up now

Setting float3 vectors

4: Adsense

Old topic!

Guest, the last post of this topic is over 60 days old and at this point you may not reply in this topic. If you wish to continue this conversation start a new topic.


  • You cannot reply to this topic
4 replies to this topic

#1 george7378   Members   

1419
Like
0Likes
Like

Posted 12 April 2013 - 08:00 AM

I'm doing a shader for shadow mapping right now, and I've got a quick question: how do you set 3d vectors in the effect file? SetVector() only lets you do 4d ones, but my position vectors in the shader are defined as float3. Thanks!



#2 kauna   Members   

2922
Like
1Likes
Like

Posted 12 April 2013 - 01:17 PM

Store your 3 component vector to a 4 component vector and set the w-component to 0. In the shader side, access the float4 position with .xyz.

 

Cheers!



#3 belfegor   Members   

2833
Like
1Likes
Like

Posted 12 April 2013 - 01:26 PM

Or use  SetValue

 

 
 
D3DXVECTOR2 SomeFloat2;
effect->SetValue( "SomeFloat2", SomeFloat2, sizeof(D3DXVECTOR2) );
 
D3DXVECTOR3 SomeFloat3;
effect->SetValue( "SomeFloat3", SomeFloat3, sizeof(D3DXVECTOR3) );
 
D3DXMATRIX SomeMatrix;
effect->SetValue( "SomeFloat4x4", SomeMaxtrix, sizeof(D3DXMATRIX) );

Edited by belfegor, 12 April 2013 - 01:29 PM.


#4 george7378   Members   

1419
Like
0Likes
Like

Posted 12 April 2013 - 01:44 PM

Thanks to both of you - indeed, you can just use SetValue, which is slightly easier than adding an extra component :)



#5 mhagain   Members   

13162
Like
0Likes
Like

Posted 12 April 2013 - 04:49 PM

Or alternatively SetFloatArray.


It appears that the gentleman thought C++ was extremely difficult and he was overjoyed that the machine was absorbing it; he understood that good C++ is difficult but the best C++ is well-nigh unintelligible.





Old topic!

Guest, the last post of this topic is over 60 days old and at this point you may not reply in this topic. If you wish to continue this conversation start a new topic.