• Dear Cerberus X User!

    As we prepare to transition the forum ownership from Mike to Phil (TripleHead GmbH), we need your explicit consent to transfer your user data in accordance with our amended Terms and Rules in order to be compliant with data protection laws.

    Important: If you accept the amended Terms and Rules, you agree to the transfer of your user data to the future forum owner!

    Please read the new Terms and Rules below, check the box to agree, and click "Accept" to continue enjoying your Cerberus X Forum experience. The deadline for consent is April 5, 2024.

    Do not accept the amended Terms and Rules if you do not wish your personal data to be transferred to the future forum owner!

    Accepting ensures:

    - Continued access to your account with a short break for the actual transfer.

    - Retention of your data under the same terms.

    Without consent:

    - You don't have further access to your forum user account.

    - Your account and personal data will be deleted after April 5, 2024.

    - Public posts remain, but usernames indicating real identity will be anonymized. If you disagree with a fictitious name you have the option to contact us so we can find a name that is acceptable to you.

    We hope to keep you in our community and see you on the forum soon!

    All the best

    Your Cerberus X Team

Picking Web RGB

Wingnut

Well-known member
3rd Party Module Dev
Tutorial Author
Joined
Jan 2, 2020
Messages
1,414
This evening I've been trying to find out what makes the RGB values are so inaccurate, and quiet a bit sometimes and I've come to the conclusion that this is no simple rounding errors. I've also tried to load both premultiplied and non-premultiplied pictures but as this image has no alpha it didn't make any difference whatsoever.

Trying to come up with what it could be, I went through the chain which was the matte standard shader to see if there's any gamma correction or something similar going on. Nothing.

Now I'm kind of stuck why Cerberus gives me these strange numbers? If you plot anything yourself there's absolutely never any problems in reading every bit correctly. But it can't handle anything that have been loaded?

Looking at the testchart..
000000 becomes 00000, fcfcfc becomes fcfcfc which is fine of course
but then we have 7070fc that shows up as 7f58ff
and 208800 as 009107 etc


Screenshot 2021-08-05 at 01.47.21.png


Screenshot 2021-08-05 at 02.01.03.png
 

Attachments

  • Webpicker.zip
    72.5 KB · Views: 84
Last edited:
Did you check your web.png, if all the values are correct? If I open the image inside Firefox, the color I get from the colorpicker doesn't match the numbers.
 
Did you check your web.png, if all the values are correct? If I open the image inside Firefox, the color I get from the colorpicker doesn't match the numbers.
Correct, loading that image into a graphic app gives me different hex values from what is listed in it.
 
Look how off they are in Cerberus.

In Browsers they are just minor rounding errors. I've noticed that and those rounding-errors are expected.
 
What I've found can be the issue so far is :

* You can read many people had this problem and it turned out that the GPU wanted commands to be sent to GPU before & after reading of pixels. But these commands are GLES3-only, not a problem with GLES2 I think. I had lots of hope on this one.

* Pre-multiply at load? No nothing like that. Also I avoid alpha so it shouldn't be an issue.

* Shader might process something e.g. gamma? I couldn't get it right, maybe I will try again I see even the matte shader does a lot of things but then again, why do the RGB works perfectly when it is not loaded?

* Datatype (sizes & unsigned/signed issue)? Toughie..

* The issue of /255 vs /256.0 and bit shifting? Maybe a huge step of 32 (which is what you see sometimes) along with 16 8 4 2.1..0 errors can happen depending on the shift and component..


I might've missed checking all of these throughly.. Need to do it again.
 
Last edited:
I did a sanity check, converting 0-255 into 0.0-1.0 and back to 0-255

Using all the different ways that I could come up with right now.
2 of the 4 ways are perfect.

You can have a picture and read it absolutely perfect what byte it contains.
If you compare only in the realm of bytes (with the included rounding) and never in the realm of floats, you're good.

And I can assure this is also how you can handle readpixels, as long as you don't load the picture it will never fail. It will also give byte-perfect consistent values on all platforms and devices.

So loading a picture in Cerberus creates a mystery.. I'm sure I've missed some stupid little detail.

Code:
        For Local temp:Int = 0 To 255
            Local test:Float = temp/255.0
    '        If Int((test*256.0)) <> temp Then Print "not same" ' 1 wrong
    '        If Floor((test*256.0)) <> temp  Then Print "not same" ' 1 wrong
    '        If Int((test*255.0)) <> temp  Then Print "not same"  ' all 256 value correspond perfectly when converted back to 0-255
    '        If Floor((test*255.0)) <> temp  Then Print "not same" ' all 256 value correspond perfectly when converted back to 0-255
        Next
 
Last edited:
Jimmy, with all respect. But Philipp and I told you that the values you printed on the image are not the values of the colors. And you still insist that it is a problem with cerberus .

Come back with a simple color correct example that is wrong, THEN I might take a look into this.

Reading pixel from a canvas was discussed to death in several topics and noone saw a problem there. So I dare to say, CX works fine, your code is wrong.
 
Of course, I tested it before I posted and it was spot on with the pickers I used. I used browsers and I used photoshop. I re-saved it a couple of times so that might screw the picture up. I assumed no alpha means no screwup but I can't say no to this..

I'll find a better example before this weekend. But the values are way off even on this example so it will nag the back of my head until then.. My code might be wrong of course. That's what I'm hoping for. But the fact it works 100% when not loading a picture makes me confused. It's some kind of double..

I know how stable Cerberus is when it comes to reading pixels It never got one bit wrong and it behaves the same on all platforms.
 
I know for sure for instance, that if i make and save a palette picture as a custom format and "draw it using 1x1 rectangles), and load it (from a textfile for instance,and do it manually). It will give perfect result.

But that is not much help to solve the cause of this.
 
You were right, it was the picture. I'm amazed how it could be +-20h error.
I must've done something when I saved it again in photoshop.

This one works perfectly.
Everything's good :)

And might I add, it's working perfectly.

(their black is $020408 not $000000 like they say)

palette.png
 
Last edited:
I must've done something when I saved it again in photoshop.

Getting perfect color values out of Photoshop can be tricky, due to color profiles. I think it somehow always applies some sort of color "correction" even when you tell it not to (work on a document without color profile). Make a gradient from black to white, copy it to any other image software, copy it back from there to Photoshop... The colors will have shifted a tiny bit. If not, please tell me how you did it.
 
Getting perfect color values out of Photoshop can be tricky, due to color profiles. I think it somehow always applies some sort of color "correction" even when you tell it not to (work on a document without color profile). Make a gradient from black to white, copy it to any other image software, copy it back from there to Photoshop... The colors will have shifted a tiny bit. If not, please tell me how you did it.
I'm not sure yet but I think I can do it perfectly, I hope I don't have to eat my words so I won't promise anything I will check this up on a few devices and also what techniques I've tried so far before I answer.
 
One reason why many people experience not being able to read perfect RGBA is the fact you need to shut of dithering in many GPU's before they will behave as you would expect.

In Cerberus, this is super-easy. You add this one line in mojo2's graphics.cxs and you're done!

whypixelsarereadbackwrong.png
 
Back
Top Bottom