Jump to content
  • Advertisement
Sign in to follow this  
bababooey

Point Sprite Rotation

This topic is 3077 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

Is it possible?

I have a particle system that's working well with the advantage of only dealing with 1 vertex for a quad always facing the screen instead of 4, to which you would have to do costly transformations in them to always face the screen.

I'd just like to be able to rotate the 2D sprite on the screen to create spinning triangles and the like. With D3DRS_POINTSPRITEENABLE, how can this be done?

Thanks.

(D3D 9.0c SDK, VC++ 2008 Express, XP Pro, Inspiron e1505, i945g display)

--
Bababooey

Share this post


Link to post
Share on other sites
Advertisement
The best you can do is apply a rotation to the texture coordinates in the pixel shader. The geometry that is rendered will always be aligned to the camera X/Y.

Share this post


Link to post
Share on other sites
It sounds like you're looking for a billboard and not a point sprite, in which case you would have to go the 4-vertex option, unless you're okay with doing the texture coordinate transform in the shader as MJP mentioned.

How many of these do you have that you're worried about the transformations? Lining up a billboard does take some programming effort, but for the CPU they're not too bad; don't be put off by 4x the vertices and trig and whatnot. You used to have to worry about that. Now speed is cheeeeeeeap...woohoo!

Share this post


Link to post
Share on other sites
just send the camera billboard matrix down to the shader (simple looking back at the camera matrix.)

in the shader:

do the simple trig to rotate the verts by whatever angle, then
its same as always...local * WVP = RHW.

as an easy trick, i index the verts so i know which corner they are (sneak
0-3 into the .w of each vertex in the VB when i build it.)


OUT.Position = mul ( float4 ( vPos.xyz, 1.0f ), mul ( matCameraBillboard, matViewProj ) ); // Transform to RWH space, output to Position.

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.

GameDev.net is your game development community. Create an account for your GameDev Portfolio and participate in the largest developer community in the games industry.

Sign me up!