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():
 OS.set_window_fullscreen(true)
 get_tree().set_screen_stretch(2,1,Vector2(1280,800))
 Camera2D.set_zoom(Vector2(0.25,0.25))
 Camera2D.set_pos(Vector2(320/2,200/2-(ydiff/8)))
 GUILayer.set_scale(Vector2(4,4))
 get_node("/root").set_render_target_filter(true)

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);

COLOR.rgb=c;

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.

Categories