Expose BestColor() to ZScript

Remember, just because you request it, that doesn't mean you'll get it.

Moderator: GZDoom Developers

argv
Posts: 184
Joined: Tue Aug 30, 2016 4:47 pm

Expose BestColor() to ZScript

Post by argv »

DTA_FillColor is exposed to ZScript, but computing the correct palette color for it requires a color-matching function. Since there already is one in C++ (BestColor), please consider exposing it to ZScript as well.
User avatar
Graf Zahl
Lead GZDoom+Raze Developer
Lead GZDoom+Raze Developer
Posts: 49067
Joined: Sat Jul 19, 2003 10:19 am
Location: Germany

Re: Expose BestColor() to ZScript

Post by Graf Zahl »

I think it'd be better to make the entire interface palette agnostic throughout instead of exposing this.
User avatar
Rachael
Posts: 13561
Joined: Tue Jan 13, 2004 1:31 pm
Preferred Pronouns: She/Her
Contact:

Re: Expose BestColor() to ZScript

Post by Rachael »

Is it possible, maybe, for the 3.3 version of ZScript the Palette color arguments to be removed completely for these commands, and be calculated in their VM hooks instead?
User avatar
Graf Zahl
Lead GZDoom+Raze Developer
Lead GZDoom+Raze Developer
Posts: 49067
Joined: Sat Jul 19, 2003 10:19 am
Location: Germany

Re: Expose BestColor() to ZScript

Post by Graf Zahl »

I don't think it's that easy to change the signature of an existing function, this will require maintaining different variants.
argv
Posts: 184
Joined: Tue Aug 30, 2016 4:47 pm

Re: Expose BestColor() to ZScript

Post by argv »

You might simply ignore the alpha channel given to DTA_FillColor, and always use a palette search. I doubt anyone would use it to intentionally draw completely different colors in paletted mode.

This would come at a performance penalty, though, since then the search would be done every time that draw call is made, even if the fill color is the same every time. Unless the VM can optimize this away somehow?
User avatar
Rachael
Posts: 13561
Joined: Tue Jan 13, 2004 1:31 pm
Preferred Pronouns: She/Her
Contact:

Re: Expose BestColor() to ZScript

Post by Rachael »

There is no search done if you simply use the RGB256k table, and that would be the ideal way to do it, because inevitably someone will be calling this function a thousand times per frame and we'll have to account for that.

The call would simply be something like "palcolor = RGB256k.All[(r&0xfc)<<10|(g&0xfc)<<4|(b&0xfc)>>2];" - modified, obviously, accounting for rgb being a uint32_t variable (I'd do it myself if I remembered in what order it stores those values).

That is actually how I did stencil draw calls in the palette renderer, anyhow, since that was originally broken in the true-color merge.
Post Reply

Return to “Feature Suggestions [GZDoom]”