I am trying to use 16 bit floating point data in my directx 11 buffer but the data always comes back wrong are there special options i need to set on the data to pack it and read it correctly?
this is my buffer:
typedef struct VertexSplat1
{
float x, y, z;
uint16_t fOpacity;
uint16_t qImRot[4]; //imaginary parts of rotation
uint16_t vScale[3];
uint16_t vHarmonicColors[3];
uint16_t fPad;
} VertexSplat1;
and in hlsl
struct VertexSplat1
{
float3 vPos; //float4
half fAlpha;
half fQx;
half fQy; //float4
half fQz;
half fQw;
half fSx;
half fSy;
half fSz;
half fSH0_0;
half fSH0_1;
half fSH0_2; //float4
half fPad;
};
StructuredBuffer<VertexSplat1> g_SplatData : register(t0);
...
float4 clr = float4(g_SplatData[dwVert].fSH0_0,
g_SplatData[dwVert].fSH0_1,
g_SplatData[dwVert].fSH0_2,
g_SplatData[dwVert].fAlpha);
am I accessing my data wrong? it comes back incorrectly (differently as if it came from an R16_Float texture)
I am trying to use 16 bit floating point data in my directx 11 buffer but the data always comes back wrong are there special options i need to set on the data to pack it and read it correctly?
this is my buffer:
typedef struct VertexSplat1
{
float x, y, z;
uint16_t fOpacity;
uint16_t qImRot[4]; //imaginary parts of rotation
uint16_t vScale[3];
uint16_t vHarmonicColors[3];
uint16_t fPad;
} VertexSplat1;
and in hlsl
struct VertexSplat1
{
float3 vPos; //float4
half fAlpha;
half fQx;
half fQy; //float4
half fQz;
half fQw;
half fSx;
half fSy;
half fSz;
half fSH0_0;
half fSH0_1;
half fSH0_2; //float4
half fPad;
};
StructuredBuffer<VertexSplat1> g_SplatData : register(t0);
...
float4 clr = float4(g_SplatData[dwVert].fSH0_0,
g_SplatData[dwVert].fSH0_1,
g_SplatData[dwVert].fSH0_2,
g_SplatData[dwVert].fAlpha);
am I accessing my data wrong? it comes back incorrectly (differently as if it came from an R16_Float texture)
Share Improve this question asked Mar 14 at 19:22 yo76yoyo76yo 1561 silver badge7 bronze badges1 Answer
Reset to default 0why dont use half2/half3/half4 for vector, it will be a better thing to do
if alpha is color value related to color put it close (the best option half4 color and alpha)
HLSL usualy maps half to 32bits with no flags, check out this: https://github/microsoft/DirectXShaderCompiler/wiki/Buffer-Packing
hope this will help:)