22 lines
677 B
Text
22 lines
677 B
Text
shader_type canvas_item;
|
|
|
|
// SUPER IMPORTANT, ELSE WE APPLY LIGHTNING TWICE!!
|
|
render_mode unshaded;
|
|
|
|
uniform sampler2D screen_texture : hint_screen_texture, repeat_disable, filter_nearest;
|
|
uniform vec2 cam_pos;// move by a "sub_pixel" which is actually a full res pixel
|
|
uniform vec2 scaling;
|
|
|
|
void fragment() {
|
|
// move by a "sub_pixel" which is actually a full res pixel
|
|
vec2 sub_uv = SCREEN_UV + (cam_pos * SCREEN_PIXEL_SIZE);
|
|
|
|
// number of downscaled pixles in UV coords
|
|
vec2 pixels = SCREEN_PIXEL_SIZE * scaling;
|
|
|
|
// round down and read in the center of the pixel
|
|
vec2 pixel_uv = floor(sub_uv / pixels) + 0.5;
|
|
|
|
COLOR = texture(screen_texture, pixel_uv * pixels) ;
|
|
}
|
|
|