• Advertisement
Sign in to follow this  

How to store 2 shorts in 1 float?

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

I need to send 2 short integers(2 byte) per vertex to vertex shader. I decided to pack them in 1 float and then unpack and use in shader. How can I do that? Languages: C# & HLSL

Share this post


Link to post
Share on other sites
Advertisement
Why not use shorts directly with a D3DDECLTYPE_SHORT2 declaration? It's available on all modern cards (GeForce FX and up, Radeon 9x00 and up).

Share this post


Link to post
Share on other sites
I working in C# and there is some already declared vertex types (such as PositionTextured, TransformedColored etc.). I don't want to declare my own type and if I learn how to store 2 shorts in float I will be able to use PositionOnly type.

Share this post


Link to post
Share on other sites
I'm sorry, but you're solving this in the wrong way.

Creating a new vertex type and declaration is really quite simple once you look into it, whereas the route you're taking is overly complex and not likely to be best for performance either. Use the right tool for the right job [smile]

D3D9 has no integer instruction set in the shader, so you're forced to do some obscure mathematical approximations to pack/unpack data.

hth
Jack

Share this post


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

  • Advertisement