Wednesday, October 5, 2022
HomeGame Developmenthlsl - Difficulties in changing RGBA to drift and again

hlsl – Difficulties in changing RGBA to drift and again


I can not get my colours again.

What I am utilizing to encode/decode:

static const float Scale = 255.0f;//or 256 not working both
static const float Scale2 = Scale*Scale;
static const float Scale3 = Scale2*Scale;
static const float Scale4 = Scale3*Scale;
static const float4 bitSh = float4( 1.0f, Scale, Scale2, Scale3);
static const float4 bitMsk = float4(1.0f/Scale, 1.0f/Scale, 1.0f/Scale, 0);
static const float4 bitShifts = float4(1.0, 1.0/Scale, 1.0/Scale2, 1.0/Scale3);

RGBA to Float to be saved as R16_FLOAT or UNORM (I’ve tried each none works high quality)

float C16 = dot(Colour, bitShifts);
Output.Colour = C16;

float to RGBA

float4 C16 = txDiffuse.Load(int3(960*Enter.Tex.x, 540*Enter.Tex.y, 0)).r*bitSh;
float4 rgba = frac(C16);
rgba -=rgba.yzww*bitMsk;
float4 Colour = rgba;

As defined right here some further modifications can be utilized to take care about preсision. What I’ve when manipulating the rgb is both a full purple or full blue scene. There’s additionally an issue with the frac end result that offers flickering random colours.

The bitXXX information will be reversed (e.g. xyzw values are in wzyx order) however the outcomes are the identical.

RELATED ARTICLES

LEAVE A REPLY

Please enter your comment!
Please enter your name here

- Advertisment -
Google search engine

Most Popular

Recent Comments