• Advertisement
Sign in to follow this  

Send single float to a vertex shader

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

Hi there !

When using instancing, is it possible to send a single float to a vertex shader like this ?

C++

struct InstanceData
{
XMFLOAT4X4 World;
float IsSelected;
};


HLSL

struct VertexIn
{
float3 PosL : POSITION;
float3 NormalL : NORMAL;
float2 Tex : TEXCOORD0;
float isSelected : DEPTH; // Instance data
row_major float4x4 World : WORLD; // Instance data
};



I tried but it did not work, the only way i can have it working now is to put use something like TEXTCOORD1 and put my float in one of the two component, i thought DEPTH would be more appropriate as it seems to be just for a single float, but it does not seem to work with instancing.

So i guess my question is what is the most efficient way to send to each instance a single float ?

Thanks !

Share this post


Link to post
Share on other sites
Advertisement
Why you have different variable order in C++ and HLSL? Probably that's why it doesn't work.
float is 4 bytes in size, so use R32_FLOAT or similar format for this data.

Share this post


Link to post
Share on other sites
Wow, i did not know the order mattered unsure.png
I guess this explains many things ... when i tried with the float2 TEXTCOORD, i probably declared it after the world matrix which made me think single float transfer was not possible.

Thanks a lot !

Share this post


Link to post
Share on other sites
there is many bug(??) at declaration...

It's depend on hardware system..

I think it's suck..

If there is other problem at this issue..

I better recommend just using Tex or pack one float to other coordination..( like tex)

Share this post


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

  • Advertisement