Jump to content

  • Log In with Google      Sign In   
  • Create Account

Send single float to a vertex shader


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
3 replies to this topic

#1 Yann ALET   Members   -  Reputation: 224

Like
0Likes
Like

Posted 13 December 2012 - 07:57 PM

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 !

Sponsor:

#2 Zaoshi Kaba   Crossbones+   -  Reputation: 4567

Like
1Likes
Like

Posted 14 December 2012 - 02:29 AM

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.

#3 Yann ALET   Members   -  Reputation: 224

Like
0Likes
Like

Posted 14 December 2012 - 06:19 AM

Wow, i did not know the order mattered Posted Image
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 !

#4 GeniusPooh   Members   -  Reputation: 157

Like
0Likes
Like

Posted 16 December 2012 - 11:05 PM

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)

Beauty is only skin deep , ugly goes to bones

 

World's only 3D engine tunner and 3D engine guru.

 

and real genius inventor :) but very kind warm heart .. and having serious depression for suffering in Korea

 

www.polygonart.co.kr ( currently out dated and only Korean will change to English and new stuff when I get better condition :) sorry for that)





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.



PARTNERS