Hi forum!
I would like to write to texture 3 material parameters.
Each of the parameters are unorm 8 bit values, packed as one uint.
The idea is to write to texture R32_UINT, and read from it as R8G8B8A8_UNORM.
cbuffer PsCb { uint Mat; //Packed: RGB - material, A-not in use yet float3 pad; } struct PsOut { ... uint material : SV_TARGET2; //RGB - material, A-not in use yet }; PsOut main(float3 normalVS : NORMAL, float2 uv : TEXCOORD0) { PsOut ret; ... ret.material = Mat; //??? return ret; }
But any my attempt to create such kind of texture were errors/warnings from DX runtime like:
The Format (0x1c, R8G8B8A8_UNORM) is invalid, when creating a View; it is not a fully qualified Format castable from the Format of the Resource (0x27, R32_TYPELESS)
The only solution I can imagine – is to manually repack uint32 material data on a shader to 4 floats.
Is there an elegant way to write to texture R32_UINT, and read it as R8G8B8A8_UNORM via hardware or I should unpack uint to 4 floats?
Thanks in advance!