My task should be very simple: constrain the lighting caused by a Sprites normal_map to the original textures pixel resolution. reduce all lighting to the resolution of my Sprites texture. I want to get rid of smooth lights/shadows destroying the pixel look.
This is a sample of what I'd like to achieve, generated using a Viewport (sadly, I cannot use Viewports for my game):
In the docs it says
The light() processor runs per pixel too, and it runs once for every light that affects the object. [..]
So it should be easily possible to write the same LIGHT values to all screen pixels inside the respective regions of texture pixels e.g. by
void light()
{
vec2 pixel = round(UV / TEXTURE_PIXEL_SIZE);
pixel = pixel * TEXTURE_PIXEL_SIZE;
// only a test to see if we still have smooth lighting
LIGHT = vec4(pixel.x, pixel.y, 1.0, 1.0);
}
However, the lighting is still smooth. Applying "pixelate" shaders like 2 in the fragment() part cannot eliminate the smooth lighting either, although fragment() somehow also is responsible during AT_LIGHT_PASS. In fact, no code in fragment() or light() seems to be able to generate pixelated light.
Do I miss something? Where exactly in the fragment() part are the smooth sub-pixels written? And what is the architecture / design principle behind the built-in CanvasItem light shaders? Is there any official example for how to use the 2D light() processor?
I have read all the docs (3, 4) and a lot of discussion (5, 6, 7) but didn't find any satisfying answe. So any hint is highly appreciated. An example project can be found under 8.