0 votes

I'm using a work-around to display 320x200 backgrounds without pixel deformation, in a 2d game. (Game display width & height is also 320x200)
Simplified script:

func _ready():

This makes shaders turn black when stretching above screen size (in my case 1366x768) which is problematic since fullscreen needs 4x zoom (1280x800) in order to scale pixels properly.
Stretching it to 1280x[screenheight] will get shaders working again but that will also cut off bits of the background and requires moving the GUI.
Can anyone think of a better way of doing this?

in Engine by (46 points)

Where and how are you writing your shaders? What do you want to achieve?

I'm not entirely sure what you mean but the shader I am using (although the black effect occurs with other shaders as well) is the BCS script shader from the screen_shaders demo:

uniform float brightness=0.8;
uniform float contrast=1.5;
uniform float saturation=1.8;

vec3 c = texscreen(SCREEN_UV);

c.rgb = mix(vec3(0.0),c.rgb,brightness);
c.rgb = mix(vec3(0.5),c.rgb,contrast);
c.rgb = mix(vec3(dot(vec3(1.0),c.rgb)*0.33333),c.rgb,saturation);


Adding the shader to different types of nodes (sprites, texture frames, texture buttons etc.) or in different canvas layers makes no difference. (Note that it does, in fact, work when stretching within the actual screen resolution.)

The work-around described in my original post is needed to display the pixel art without distorted or skewed pixels. The shader is intended to allow brightness settings.

Please log in or register to answer this question.

Welcome to Godot Engine Q&A, where you can ask questions and receive answers from other members of the community.

Please make sure to read How to use this Q&A? before posting your first questions.
Social login is currently unavailable. If you've previously logged in with a Facebook or GitHub account, use the I forgot my password link in the login box to set a password for your account. If you still can't access your account, send an email to webmaster@godotengine.org with your username.