Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Follow the default texture filter project setting in 2D shaders if no filtering hint is specified #57679

Open
rakkarage opened this issue Feb 5, 2022 · 13 comments

Comments

@rakkarage
Copy link
Contributor

rakkarage commented Feb 5, 2022

Godot version

v4.0.alpha1.official [31a7ddb]

System information

Windows 10

Issue description

Animation
Shader

This shader which I am using to animate tiles makes them blurry in 4? Maybe not related to TileSet. Just where I noticed it. I changed the Project Settings -> Rendering -> Textures -> Default Texture Filter to get sharp pixel graphics maybe there is a way to make the shader use that setting too?

shader_type canvas_item;
render_mode unshaded;

uniform sampler2D frames: hint_albedo;
uniform float count;
uniform float duration;
uniform float width;
uniform float startX = 0;

void fragment() {
	float frame = floor(mod(TIME, count * duration) / duration);
	float offset = floor((UV.x - startX) / width);
	COLOR = texture(frames, UV + vec2((mod(offset + frame, count) - offset) * width, 0));
}

Thanks.

Steps to reproduce

  1. Open TileSetShader.tscn, blurry animations
  2. Open TileSetAnimation.tscn, clear animations

Minimal reproduction project

https://github.com/rakkarage/NewTileMapTest

@Calinou
Copy link
Member

Calinou commented Feb 5, 2022

Since filter modes are no longer stored in the texture itself but in the usage, you need to add filter_nearest to your frames sampler as follows:

uniform sampler2D frames : filter_nearest, hint_albedo;

We should probably figure out a way to make shaders obey the default texture filter configured in 2D if no hint is provided. For 3D however, we don't have a default texture filter option yet.

@jdellinger

This comment was marked as resolved.

@clayjohn

This comment was marked as resolved.

@jdellinger

This comment was marked as resolved.

@clayjohn

This comment was marked as resolved.

@groud

This comment was marked as resolved.

@groud

This comment was marked as resolved.

@jdellinger

This comment was marked as resolved.

@arkology
Copy link
Contributor

arkology commented Nov 1, 2024

Is this issue still valid?

@clayjohn
Copy link
Member

clayjohn commented Nov 1, 2024

Is this issue still valid?

Yes. The user is asking for the rendering/textures/canvas_textures/default_texture_repeat project setting to affect all samplers on canvas_item shaders which isn't what it does now. It is the default only for the built in TEXTURE of canvas items.

The other comments are about an unrelated issue that has been resolved.

@arkology
Copy link
Contributor

arkology commented Nov 2, 2024

@clayjohn Thanks for the answer!
Please take a look again. The whole issue is only about filtering.
But of course it will be also great to expand this issue for repeat.

@clayjohn
Copy link
Member

clayjohn commented Nov 2, 2024

Sorry, I just copy-pasted the wrong property! It is directly below filter

@arkology
Copy link
Contributor

arkology commented Nov 2, 2024

Related to #74332

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

6 participants