Facepunch / garrysmod-issues

Garry's Mod issue tracker
147 stars 56 forks source link

RGB Corruption #2807

Open 10853 opened 8 years ago

10853 commented 8 years ago

Details

On-screen RGB values do not correspond to the values specified in the Lua source files.

Failed attempts to figure this our by myself

The only way I managed to coerce the game into drawing the correct colors in DX9+ mode was by using png files containing a single pixel in the color I want to display. This kinda works, but only while drawing elements that are fully opaque. The moment I try cranking down an element's alpha value is the moment I start getting weird bugs again.

Things I didn't try

I don't have Steam installed on any of the Linux systems I have at my disposal and I doubt that trying to recreate this bug on any of them would be a particularly helpful affair, so I spared myself the time investment. I've just about zero interest in touching anything Apple-related with a six-foot pole, so I didn't look into that, either.

Steps to reproduce

Take this snippet of code:

Frame = vgui.Create( "DFrame" ) Frame:SetPos( 10, 10 ) Frame:SetSize( 400, 200 )

ColorButton = vgui.Create( "DColorButton", Frame ) ColorButton:SetPos( 50, 50 ) ColorButton:SetSize( 100, 30 ) ColorButton:SetColor( Color( 000, 110, 160 ) )

Take a screenshot, then sample the button's blue color (any other element would've done as well). Instead of 0, 110, 160 I'm getting a read-out of 0, 111, 162. Not too bad, you say? Well, yeah, in this particular instance it's merely annoying, but it gets very notable once you start mucking about with alpha values in order to draw something a little more advanced than a flat, opaque color. Low-alpha white on a dark background tends to be particularly horrifying to behold.

For what it's worth, offsets appear to be consistent from player to player.

Anything else?

Yeah. Please fix this. Frontend work is painful enough as-is - I'd really prefer not to suffer flashbacks to my HTML/CSS days every time I run out of excuses to do backend work instead. Pretty please? :camel:

thegrb93 commented 8 years ago

I see it too. Also happens with surface.drawRect in 3D contexts such as ENT:Draw().

robotboy655 commented 8 years ago

It probably happens with the entire rendering pipeline and is probably fault of Source's Rendering, which would take ages to pin point if that is even physically possible.

thegrb93 commented 8 years ago

Also I have all post processing off, so something to do with the unlitgeneric shader or surface.drawrect.

willox commented 8 years ago

If memory serves correct, this was a purposeful change from TF2 during the Garry's Mod 13 beta. Maybe somebody else remembers or can find the FP post I'm thinking of.

Kefta commented 8 years ago

I remember this as well, but I think the post was in the old Next Update section.

biorisk2 commented 3 years ago

This is a bug I ran across recently where the values I was putting in from photoshop were significantly off by a few RGB values.

WilliamVenner commented 3 years ago

Is it this?

https://developer.valvesoftware.com/wiki/$color#Gamma

biorisk2 commented 3 years ago

But. Why?

thegrb93 commented 3 years ago

Pixel color values aren't linear and don't blend linearly so they need gamma correction.

thegrb93 commented 3 years ago

https://learnopengl.com/Advanced-Lighting/Gamma-Correction