10.8 C
New York
Friday, March 14, 2025

textures – Issue for utilizing asfloat/asuint


I am attempting to transform a RGB shade to a RGB555 format to be saved as a float in a R16F or R16UNORM texture.
I’ve a way that works fairly nicely utilizing solely float maths for each kinds of floor however I’ve some loss on the pink channel and extra blue than anticipated as a result of calculation I exploit.

Alternatively I used to be attempting to transform the RGB555 shade with the common bit shift technique to finish up with a uint to be saved as a float in my texture and studying again as nicely.

sadly I am in all probability lacking one thing on how asfloat/asuint works as I can’t have the preliminary shade anticipated.

under is the code for packing and unpacking I am utilizing. I’ve seen {that a} 16 bit shift when producing the uint is required to have one thing saved. In any other case the learn offers only a black consequence. Possibly the issue is within the texture format used however I’ve checked with 32F and it is the identical.

endcode

uint3 RGB = uint3(max(31,FinalColor.xyz*31.0f));
RGB.x=RGB.x<<16; //see the textual content for explnation of this 16 bit shift
RGB.y=RGB.y<<21;
RGB.z=RGB.z<<26;
Output.Col = asfloat(RGB.x|RGB.y|RGB.z);

decode

uint R = asuint(txDepthMap.Pattern(samPoint, Enter.Tex.xy).x);
float3 RGB = float3((R>>16)&0x1F, (R>>21)&0x1F, (R>>26)&0x1F)/31;
FinalColor = float4(RGB,1);

Related Articles

LEAVE A REPLY

Please enter your comment!
Please enter your name here

Latest Articles