admin管理员组文章数量:1391947
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:)
本文标签: directxhalf data in structured buffer directx11Stack Overflow
版权声明:本文标题:directx - half data in structured buffer directx11 - Stack Overflow 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1744635518a2616799.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论