Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- shader_type canvas_item;
- const float PaletteRGBSize = 4.;
- const float ResolutionDivisor = 2.;
- float quantize(float inp, float period)
- {
- return floor((inp+period/2.)/period)*period;
- }
- float bayer8x8(vec2 uvScreenSpace, sampler2D image_texture)
- {
- return texture(image_texture, uvScreenSpace/(ResolutionDivisor*8.)).r;
- }
- vec3 getSceneColor(vec2 uv, sampler2D screen_texture)
- {
- return texture(screen_texture, uv).rgb;
- }
- void fragment()
- {
- vec3 quantizationPeriod = vec3(1./(PaletteRGBSize-1.));
- vec2 uvPixellated = floor(FRAGCOORD.xy / ResolutionDivisor)*ResolutionDivisor;
- vec3 dc = getSceneColor(uvPixellated / SCREEN_PIXEL_SIZE.xy, SCREEN_TEXTURE);
- dc += (bayer8x8(FRAGCOORD.xy, TEXTURE)-.5)*(quantizationPeriod);
- dc = vec3(
- quantize(dc.r, quantizationPeriod.r),
- quantize(dc.g, quantizationPeriod.g),
- quantize(dc.b, quantizationPeriod.b)
- );
- COLOR = vec4(dc, 1.);
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement