Ugh, that LUT shader is going to make me pull my hair out -_- That happens worse on some GPUs than others, but I thought I had it licked with the crummy conditional I added. You can try playing around with that part to see if there’s a value that works for you. If so, let me know and send a PR and I’ll get it merged.
Have any of you tried to set LUT size to 32 in parameter setting? 32 Lut size is needed.
I’m just using the presets that were included, which set the LUT size to 32 when you load them.
I found that the GLSL and Slang versions work if you use the LUT shader code included in the zip, which seems to be the initial version from 5/29: https://hastebin.com/raw/zucicuqolo
The Cg version found in the zip file is identical to the current one in common shader so it still has the problem. The GLSL version seems to work up until this commit:
If I put image-adjustment in the first pass and set luminance to 0.99, then it displays correctly: https://hastebin.com/raw/aruginetev
I think I found the problem. The output would be black when imgColor.b
was 1.0, it seemed to cause a problem with the color mixing.
Clamping mixer
to 1.0 seems to fix this issue. I’ll push that fix to the LUT shader in each of the PRs I have open.
EDIT: Changed the clamp to 32.0 to fix a regression with the blue channel.
I am glad that is fixed. I packed your fix .cg shader. I also did small tweaks to few colors to GBA and NDS. Both now show some small differences between each other as it’s supposed to. NDS is slightly more saturated than GBA. I’ve done several methods to do better precise to capture color spaces without having colorimeter tools as I can’t afford those in current state. I also updated the LUT textures too. This version and the one before had luminance slightly lower to have the exact yellow color and luminance as without lowering it, the red value in yellow color exceeded 255 value and so, the white is very close to maximum luminance in textures.
https://drive.google.com/file/d/0B5KxdoFEcyTkZ3I0WWZkM00zT0k/view?usp=sharing Same link as the first and last update post.
Edit: I also have the texture for the GBA without the gamma altering. “GBA-Unaltered_Gamma.png” I just have the texture incase if you want to use on other projects that doesn’t use shaders and don’t want gamma or curve alteration.
Hey Pokefan,
I’m trying to implement your color shader equations in FPGA hardware for my GBA HDMI project, https://youtu.be/pvdC2y_xwLk. The issue is, my color corrected output when compared to your GBA colors and NDS are slightly off, this is based off RGB measurements in MS paint on the images you posted and my own screen captures from my FPGA.
I started to think I messed up the processing chain in the FPGA, but then I compared your unfiltered image to my unfiltered RGB output from the GBA HDMI board. The RGB values in your unfiltered images are way off from my captured RGB output. For example, in the red DK letters on the DK King of Swing intro screen. Your unfiltered RGB values are {229,32,33}, whereas mine are {227,0,21}. Similar errors are found for all the unfiltered colors. To make sure my capture device wasn’t introducing error, I sent out known colors from the FPGA and the captured values were +/- 1 to the coded values which means it’s close enough for this purpose. All of this would definitely explain why my color corrected output is different than yours.
Did you alter the images after you captured them? Otherwise, this makes me think the emulator you’re using is introducing a color error somehow. I’m close to certain my unfiltered RGB values are correct, they are taken directly from a real GBA’s video data bus.
Is there a strategic way to modify the color correction coefficients to account for the differences in our starting unfiltered RGB values? I’ve tried tweaking it myself, but seem to always make it worse.
Thanks for any input, I really love the results of your shaders! Let me know if I can provide any data to clarify things, or to help out your own shader efforts.
I used image viewer and mgba to compare, and I put a custom image-adjustment first on mgba since the white on mgba is (255,251,255) and I had to increase the green very slightly to get correct colors. I used hunterk’s color-mangler shader which is similar to icc profile, but just adding RGB values and the shader is gamma corrected unlike the colorimeter shader.
Also, I got a new ips monitor with superior quality and got an sRGB profile to use on photoshop and reshade LUT shader. I have to redo the GBA and NDS shader in the last few weeks because my last monitor was colder and wasn’t actually sRGB standard, and its icc profile reversed the colorspace. My new one does it completely better and I redid the shader. It should come out in few days after checking few spots.
As for the pictures, my first post has pictures that was from last December, and I last updated my shaders in early August. In mGBA, all I did is capture screenshot without GPU to do raw capture, and used photoshop to have them in montage to load them in Retroarch by image viewer and just throw in my shaders.
Also before, when I load my shaders into my other devices like Shield Tablet K1, which has sRGB mode, colors are a bit different when I had my last monitor, but now are very identical with my new one.
Thanks for getting back to me so quickly.
I’ve tried tweaking the individual color channels (which is what it sounds like you initially did in mgba), this let me match your output but only for certain color tones.
I didn’t realize the pictures were from December, I’ll wait for your next shader update before I go crazy trying to make mine match
Just my luck that I would fix it right after I posted the question.
Even though our unfiltered RGB values are different, your coefficients still work great! Turns out at some point in the color correction pipeline, I accidentally assigned the blue 8-bit bus some of the green pixel data…I guess I need more sleep.
So far I’ve put in GBA-colors, VBA, NDS, PSP. I’ll probably make the 9 color coefficients user programmable, with a couple of profiles to save the coefficients.
In Color-Mangler shader, how it works is the Red, Green, and Blue primaries have rgb values in each of them. It has to be low values for other colors in RGB primaries (R:77,G: 08,B:15) to fit to 100% pure white reach without overexposing. It looks a lot dark without gamma correction (196,20,38). The color-mangler shader does have to brighten the RGB primaries and luminance (226,83,108). Display_Gamma is the one that does gamma correction in a final output. This is from my last version for the red color.
I updated my shaders for GBA and NDS to better match the sRGB and it is more accurate for many monitors and devices that calibrates to sRGB. I updated the LUT textures too. For GBA, I did curve tweaking from photoshop to darken the image with more compression, and the NDS texture is on absolute chromatic because the Red, Green, and Blue has different luminance and has a slightly cold look on both screens, and I did adjust the secondary primitives in photoshop to match the hardware. The shader is based on relative chromatic, so whites are pure white. NDS was a bit tricky to adjust and took me weeks to get it right. While GBA and NDS are less saturated, GBA has more saturated olive green than NDS, while the red in NDS is more saturated and doesn’t really changed its hue.
Links is updated at the first page. Photos will change soon.
Thanks for the great effort. I was testing the latest version of the shader but lcd-grid-v2.cg doesn’t work (timestamp of 24-10) while the former version (from 13-07) did. I tried testing with the nvidia.cg version as well without success. I admit I’m on an old retroarch version but I have many things configured to dead to now start reconfiguring everything again (I’ve been testing).
Also, do you know how I could amp the saturation a bit, I guess in gba_color.cg? I know this is not faithful to the hardware but I’m trying to settle somewhere in the middle where I can find some visual appeal.
Edit: btw I got some “nice” saturation from loading lcd-grid-v2-gba-color-motionblur.cgp and limiting the layers to 2 in rgui, rather than straight up loading a 2 layers of the same shader like lcd-grid-v2-motionblur.cgp, this intrigues me. https://postimg.org/gallery/2w06kc3os/
Back to the color space conversions again. I learned more about the hardware and games that were optimized for GBA.
I released a new version just now. It has got more better and pretty accurate. GBA shader is not as cold as it used to be, so it looks more natrual now. Nintendo DS shows more saturation difference from GBA, and the red is warmer than from GBA. I had to use multiple lights for the GBA.
I did a special trick to sample the color primaries from the screen to my monitor. I had to match the white brightness, and also add nearest 50% gray as a sample to reverse the color temperature from the systems. The gray one is how I made the color temperature more appealing to the shaders and better matches the hardware when you play a same specific colorful games for quite a while and your eyes adjusts slightly to the color temperature of the hardware, and seeing the midtone areas now matches the hardware now. The gray sample were a bit cold on the Nintendo DS, but a bit more on the GBA, and I used few lights to capture all the color samples to find the actual white balance when putting the colors to the shaders, and then I find the white color value. I used Photoshop curves to force the white exactly the white for my IPS monitor and even got the gray to have the color balance, and combining all the color samples from the light sources improves the visuals. I even play the same games on those systems to see how it looks. It seems more identical and the Nintendo DS one is pretty identical. The GBA one looks identical too, and I finally have it look more different from NDS. Also, when I sample the colors in RA with color mangler, I loaded an LUT as a last shader for the monitor to be calibrated to sRGB, and let Photoshop use the monitor’s colorspace to directly work with the color samples.
I also updated the LUT shaders and the PSP and Palm ones to brighten the color primaries a bit.
I noticed during the hiatus, I see the GBC one on the pack, and the one from Gambatte. The latter seems to not have gamma corrected, and the former’s grayscale and white one is not balanced. I haven’t gone into the GBC ones as much, but I looked a bit on the BGB one. In the BGB, the saturation and gamma seems to be put after color correction, so playing around with those are affecting the color primaries too. Without those, it looks similar to Gambatte’s color correction. I’ve look on Sameboy, but I haven’t gone much experience on that.
I did found an old tool from 2000 that tries to mainpulate the GBC color appearance. http://www.devrs.com/gb/software.php#pict2gb Gameboy hicolour convertor. It does reduce the contrast like how VBA-M and NO$GBA does it, but putting the contrast in full range, the color primaries are really the basis for the emulators for GBA. The tool does use higher gamma/curves to brighten the image. This is where the color sampling came from. Although, I am not sure which color correction is closer to GBC. I would eventually get one, but I have few GB and GBC libraries to see the color primaries.
Edit: I don’t have an option to edit my post, but here is the photos of my current shaders:
GBA games with NDS, GBA, and VBA shaders:
Another GBA games with NDS and GBA comparisons with Darken settings:
NDS games with NDS-Color shader:
PSP games with PSP-Color shader:
A comparison to a game with a help of color corrections for the original art:
Ultimate comparison and explanation on Pokemon Yellow title screen:
Last one does show how most of the color correction show how it treats yellows.
I recommend using the GBC, GBA, or NDS shaders on those games over other color corrections that are implemented on the emulators. Here is the color mangler settings that Extrems used on his Gameboy Interface for color correction: https://www.gc-forever.com/forums/viewtopic.php?f=37&t=2782&start=625#p38593
I did a lot of experiment on the color correction side on the GBC. I did use GBC-Color and did a white balance on it. I would add more shaders on the package very soon.
Link above is updated, including two GBC shaders in the package. The gbc-color is my tweak to Monroe’s shader, and I just did a white balance and have the grays have balanced colors. I put myself in the credits for slight tweaks. The gbc-dev is a close replication of Jeff Frowhein’s color correction, minus the contrast adjustment and have the red slightly higher for pure white balance. LUT of the previous shader is included, and the gamma ramp is identical to Frowhein’s program than the shader.
The latest version is v10. GBA and NDS have closer accuracy and pretty identical to the hardware. PSP, Palm, and VBA have slight adjustment. Added GBC-Dev and made a white balanced on gbc-color.
I made a conversion list for developers who are implementing color correction to their software. This is specifically about how the GBA-Color shaders or Color-Mangler shader performs. Most of the color shaders are based on Color-Mangler shader.
The top one shows how it’s converted correctly. The conversion is explained.
Color-Mangler has multiple conversions.
First, it changes the gamma to 2.2 on the image, so it is darker. It is from Target_Gamma command that darkens it.
Then, we have the color values, RGB ones, luminance, saturation, and contrast applied before reversing the gamma on the next step. It is set on a dark image from the first step.
Finally, we have Display_Gamma command that does the gamma conversion on the processed image. It does reverse the gamma, so it does divide 1 with whatever the number it is set on Display_Gamma, like 2.2. (1/2.2) = 0.4545…
This is a similar process that the .icc profiles do on applications to have correct brightness on the colors with color correction on the image. As you can see on the final image, the color primaries have better luma levels. As you can see on the final and right image, that’s how the GBA looks when I used the actual hardware.
So here are the wrong process ones:
- On the middle of the photo, it only does color correction with the same RGB values from the shaders above, but without gamma conversion involved. It is the same effect if you set both Target_Gamma and Display_Gamma to 1.0 to not have any gamma conversion.
It causes darker colors overall, and it is more noticable on the primary colors such as pure red, green, and blue. I’ve seen this conversion on apps like Gambatte and Sameboy where the converted colors are darker on colors. The latter has darker greens and yellows, making them more noticably dark. The Zelda image may not look as dark, but that’s because the colors on those snapshots are not originally showing pure RGB colors.
- For color conversion, if you want to bring the primary colors to have the exact colors from the correct solution without using gamma conversion, you would have to put different values on each color values to have it exactly on the primary colors only.
However, because of that, along with the lack of gamma conversion, it causes unstable image. It looks too bright that clips through. Also, the greyscale are not grey at all, so colors are all over the place. This is even worse solution overall.
I know by doing color conversion with gamma involved, the color primaries change because it is supposed to look darker on the process in order to look great on the image overall. The gamma conversion is needed to retain both luminance and saturation from the original display to emulate well. .icc profiles does this approach since most displays only have gamma at 2.2, so it is needed.
More info about Color Conversion:
@Pokefan531 Amazing work. The gbc_color shader is incredible. With the right combination of shader passes, like a good LCD grid and a console border, I think it allows for the definitive way to play all GBC games with the best of all worlds, to the point that I probably will never want to go back to any of the real consoles again (I can live without the nostalgic golden sheen of the GBC screen).
For the GBA, however, I am wondering if there could be a better approach, or a more balanced “set and forget” sort of color correction.
What I mean is that the gba_color shader works wonderfully for those obvious cases where the game designers overshot the colors expecting hardware compensation, such as the well known cases of Golden Sun, Wario Land 4, and Castlevania HoD (when I played this game on a backlit GBA I thought Konami was trying to go for really psychedelic colors!). The most general trend seems to be that when designers were aiming for earthy/brown colors (or light blues) the raw colors display a garish yellow (or purple).
But in testing a bunch of games for the past few days I’m noticing that a lot of what “should” be the right colors actually show with the raw colors of a backlit GBA/DS, and the gba_color shader distorts them. I base this “should” on colors used in official artwork, other games in the pertinent series, or colors used on the console from which the game was ported (usually the SNES). The general trend I see here is that, post correction, reds that “should” be a vibrant red become more of a ruby color, what “should” be blue shifts toward cyan, green shifts to teal. Also, in particular, it looks like skin tones are negatively affected, making them too red. Oh, the Capcom logo is another example.
Consider, for example, the Phoenix Wright games, the Metroid games, A Link to the Past, and even Super Mario Bros. Advance 2. Phoenix Wright’s canonical skin tone and blue suit color are distorted post correction, but look correct on backlit consoles. Samus’ yellow suit in Zero Mission as well as her fusion suit appear more accurately when played on a backlit GBA/NDS. The colors in ALttP look almost identical to the SNES colors with the aforementioned consoles (when the lowest brightness setting is used in-game), but very different with the correction shader. Super Mario Bros. Advance 2’s problem actually seems to be simply one of gamma (funnily, this game looks SNES-correct on a DS Lite when the screen is turned downwards about 10 degrees thanks to the inferior viewing angles of this TN screen!).
Even an early DS game like Super Mario 64 DS exemplifies this idea. The colors do look on the garish side when raw/on a backlit console, but they are in fact closer to the original N64 colors than with the nds_color correction shader.
Overall, I am left with the sense that the GBA (and possibly NDS) color shaders are more suitable for a minority of cases rather than for most. Perhaps I’m too greedy in hoping for a one-size-fits-all color shader for the GBA, and surely don’t know enough about color conversion to realize how unfeasible it would be, but I’m still wishing that a more general solution is available to help people move away from the real handheld consoles and their disadvantages without having to second-guess the choice of shader frequently.
My shaders got updated few months ago, but it hasn’t been updated on the repo. I did however do a lot of tweaking with how the colors are supposed to look. It is a bit tricky because to see the correct temperature on the screen with different light temperatures, I had to make the 50% grey color from the screen to set the correct temperature on multiple light source. The lights I have kinda made the whites on the screen to try to reach near 6500k. Although, the blue color is supposed to be a bit bright. The hue seems to be like this on the blue primary color.
As for GBC, I’m getting one to see how the colors actually look. It would take a few weeks to examine it. I want to see if the luminance is actually higher than the GBA. Remember, the gbc-color shader started by Monroe who tried to tweak from the gambatte implentation, with gamma correction and hue colors fixed, and I corrected the color temperature. Just to note that both Gambatte and mGBA (maybe VBA-M), the highest green value is 251.
I’ve played around with the LCD-cgwg-V2 shader. I used my phone that has native 1440p resolution and to take snapshot from my PC. I put several sizes and try to have the closest size to GBA-SP AGS-101 (backlit), and LCD-cgwg is pretty similar to how it looked on my GBA SP. The SP subpixel order is BGR instead of RGB. I did change a few settings on the shader presets in the package long time ago to make the lcd shaders be slightly bright, but I decide to leave the gain and the subpixels the default to see better white shades. I would have the black levels at 0, and gamma to 2.2, since most displays are using gamma 2.2.
Are the most updated shaders the one you linked to here (https://drive.google.com/open?id=0B5KxdoFEcyTkZ3I0WWZkM00zT0k) on your August 9 post?
I replaced the files from the repo with these, and for the gba_color shader I can see a clear improvement! Reds and skin tones in particular look much closer to natural now, and overall colors feel more balanced. I would have had no idea, I just assumed that the repo files were the most up to date! Someone should really push the new files into the repo.
I checked out the updated gbc_color also and I can’t tell as much of a difference, but once again it looks fantastic. In a couple of weeks I should have access to my non-backlit GBC, GBA, and DS consoles and will see with more attention how they compare.
I still feel that for a lot of GBA games in particular the raw colors seen in emulators and backlit consoles are what the game designers really wish could be shown, hoping for the best given what the limited GBA screen was able to display. For those colors, the color correction may be a disadvantage. The problem is when they combined those ideal colors with clearly overdone colors with the limitations of the screen in mind, sometimes overwhelmingly. In any case, for those games where they did the latter to an extraordinary extent, I think nothing will beat playing while using these shaders. I’m really glad someone put in all the work needed to make it available to handheld fans.
Yes.
I think they only updated the gbc-color ones, or it may look similar. To compare the screen and the shaders, it is tricky to see the same exact colorspace. A lot of monitors are aimed on the sRGB colorspace, but most of them are just very close to it. Monitors in a lot of cases aren’t calibrated to 6500k as often, but still looks very close. The screens on the NDS are a bit colder like above 6500k. Also, depending on the light source, the gba and gbc screen needs to be lit that is close to the standard color temperature. The best way I found to compare is to play the game on those screens as often. The eyes would adjust the color temperature on the screen. Also, unlike modern screens, the greyscale is not 100% grey or close to the white temperature of the screen, so it looks a bit colder. I had to use the curve tool on Photoshop to get the best results. This method does the best job at replicating the color temperature that your eyes see when it’s already adjusted. It is best to find a light for non-lit screens that is close to the standard temperature to see better. Just to note that those screens often show the rainbowing effect, especially if you use a flashlight on the screen. Commonly on the first party games, early games was adjusted for the screen, and they pre-calibrated the colors for the screen to see the same visual effect.
One last thing. Not sure if Woozle is available, but my last two posts involved how the colors are adjusted by using the gamma correction, or gamma-to-linear method to adjust colors on the primary so some colors don’t look dark, mainly around the primaries. I’ve seen the post for the Gambatte that added my gbc shader, and showed that it is an alternative to gambatte’s color adjustment. I’ve seen GBA HDMI clips and I want to contact him about the gamma correction method.
More info on gamma correction:
It would be great if you could get in touch with Woozle. He already has implemented color correcting shaders and gamma settings on his GBA consolizer, but shaders on his consolizer and on the Retroarch side stand to gain from some comparison and collaboration. You could try reaching out to him through this twitter account: https://twitter.com/Woozle64