Open sommerper opened 2 weeks ago
It's a challenging bug. It does create the correct color mix (same color twice) for the exact color, and for the closest color in 16 discrete RGB steps, but for some reason in the shader that is not the mix chosen. I'll have to continue looking into it.
Color creation:
var color:Color = Color(floor(x / floor(16)) / 15.0, y / 15.0, fmod(x, 16.0) / 15.0)
var mixing_plan:Array = devise_best_mixing_plan.call(color)
for i in dither_color_count:
dither_palette_image.set_pixel(x, y + i * 16, mixing_plan[i])
Color selection in shader:
float y = (clamp(color.g * 16.0, 0.5, 15.5) + floor(dither_value * color_count) * 16.0) / palette_size.y;
float x = clamp(floor(color.r * 16.0), 0.0, 15.0) / 16.0 + clamp(color.b * 16.0, 0.5, 15.5) / 256.0;
return vec4(texture(dither_palette, vec2(x, y)).rgb, 1.0);
Ok, thanks for the clarification! At least I know it's not just on my setup. I'll see if I can find some time to have a look at it as well.
Hi again!
I made a little experiment where used a
ColorRect
and applied thecolor_dither_post_2d.gdshader
to it to get a fullscreen dither.But I noticed that some colors get dithered even though the match the colors used to generate the dither palette.
My logic tells me that only colors outside of the palette should be dithered - is that correct?
Example: