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

Vulkan: Errors related to gaussian blur when using textureLod(SCREEN_TEXTURE, ...) in a shader #50976

Closed
CsloudX opened this issue Jul 28, 2021 · 13 comments · Fixed by #56742
Closed

Comments

@CsloudX
Copy link

CsloudX commented Jul 28, 2021

Godot version

v4.0.dev.calinou [e6a544c]

System information

windows 10

Issue description

shader in editor use SCREEN_TEXTURE no any effect and, once run the scene, it will report error
Can't use the compute version of the gaussian blur with the mobile renderer.

444
In 3.3.2, it right:
捕获

Steps to reproduce

please run the reproduction project

Minimal reproduction project

ScreenTexTest.zip

@Calinou Calinou added this to the 4.0 milestone Jul 28, 2021
@Calinou Calinou changed the title [Godot4] shader SCREEN_TEXTURE error Vulkan: Errors related to gaussian blur when using textureLod(SCREEN_TEXTURE, ...) in a shader Jul 28, 2021
@DeeJayLSP
Copy link
Contributor

I would like to confirm this also happens with texture()

@nonunknown
Copy link
Contributor

nonunknown commented Nov 18, 2021

@Calinou Can confirm this still happens in: v4.0.dev.custom_build [78931aa]

As far I've understood this happens only on canvas_item shaders, yesterday I tried spatial and this doesnt happens!

Here a more detailed log:

log_shader.txt

I just placed this shader in a texture_rect with a texture applied:

shader_type canvas_item;

uniform float scale : hint_range(0.0, 2.0) = 0.5;
uniform vec2 unk = vec2(1);

void fragment(){
	vec2 res = 1.0 / SCREEN_PIXEL_SIZE;
	float s = scale * (res.x / 6e1);
	COLOR = texture(SCREEN_TEXTURE, floor( (unk + .5) / s ) * s / res.xy );
}

@Calinou
Copy link
Member

Calinou commented Nov 18, 2021

As far I've understood this happens only on canvas_item shaders, yesterday I tried spatial and this doesnt happens!

It seems gaussian mipmap generation isn't correctly reimplemented in master yet: godotengine/godot-proposals#3231

@unfa
Copy link

unfa commented Nov 22, 2021

I have the same issue using Screen texture in a 2D Canvas Visual Shader.

@nonunknown
Copy link
Contributor

@Calinou not sure it its only 2d related, because In my use case, I'm using canvas_item to modify the 3d environment!

@Calinou
Copy link
Member

Calinou commented Nov 22, 2021

@Calinou not sure it its only 2d related, because In my use case, I'm using canvas_item to modify the 3d environment!

It is still related to 2D rendering, as the errors only occur in canvas_item shaders, not spatial shaders.

@jimbeauphloyd
Copy link

As far I've understood this happens only on canvas_item shaders, yesterday I tried spatial and this doesnt happens!

It seems gaussian mipmap generation isn't correctly reimplemented in master yet: godotengine/godot-proposals#3231

If I do just a texture lookup on a regular texture (not the screen texture), I don't get errors, but I do get a blurry screen. I guess the blurriness is related to this issue since it has to do with gaussian mipmap generation? Should I open a separate ticket for the blurriness since it isn't getting errors, it just isn't pixel perfect?
Shader code:

shader_type canvas_item;

uniform sampler2D tilemap_texture : hint_albedo;

void fragment() {
	COLOR = texture(tilemap_texture, UV);
}

Image Example: https://imgur.com/a/FNj1JOe

@Calinou
Copy link
Member

Calinou commented Dec 8, 2021

If I do just a texture lookup on a regular texture (not the screen texture), I don't get errors, but I do get a blurry screen. I guess the blurriness is related to this issue since it has to do with gaussian mipmap generation? Should I open a separate ticket for the blurriness since it isn't getting errors, it just isn't pixel perfect?

Indeed, please open a separate issue for this (then I'll close godotengine/godot-proposals#3231).

@jimbeauphloyd
Copy link

If I do just a texture lookup on a regular texture (not the screen texture), I don't get errors, but I do get a blurry screen. I guess the blurriness is related to this issue since it has to do with gaussian mipmap generation? Should I open a separate ticket for the blurriness since it isn't getting errors, it just isn't pixel perfect?

Indeed, please open a separate issue for this (then I'll close godotengine/godot-proposals#3231).

Thanks, submitted issue: #55755

@saki7
Copy link
Contributor

saki7 commented Dec 30, 2021

void EffectsRD::gaussian_blur(RID p_source_rd_texture, RID p_texture, RID p_back_texture, const Rect2i &p_region, bool p_8bit_dst) {
ERR_FAIL_COND_MSG(!prefer_raster_effects, "Can't use the compute version of the gaussian blur with the mobile renderer.");

In case of non-raster effect implementation, the error condition must be prefer_raster_effects, not !prefer_raster_effects.

Similar codes:

void EffectsRD::gaussian_glow(RID p_source_rd_texture, RID p_back_texture, const Size2i &p_size, float p_strength, bool p_high_quality, bool p_first_pass, float p_luminance_cap, float p_exposure, float p_bloom, float p_hdr_bleed_threshold, float p_hdr_bleed_scale, RID p_auto_exposure, float p_auto_exposure_grey) {
ERR_FAIL_COND_MSG(prefer_raster_effects, "Can't use the compute version of the gaussian glow with the mobile renderer.");

void EffectsRD::gaussian_glow_raster(RID p_source_rd_texture, RID p_framebuffer_half, RID p_rd_texture_half, RID p_dest_framebuffer, const Vector2 &p_pixel_size, float p_strength, bool p_high_quality, bool p_first_pass, float p_luminance_cap, float p_exposure, float p_bloom, float p_hdr_bleed_threshold, float p_hdr_bleed_scale, RID p_auto_exposure, float p_auto_exposure_grey) {
ERR_FAIL_COND_MSG(!prefer_raster_effects, "Can't use the raster version of the gaussian glow with the clustered renderer.");

I guess there's nothing wrong with the graphic implementation itself, it should be an error output mistake. The error message is being shown on the inverted condition, so if we could flip the flag, then we could get rid of those false-positives.

For reference, I think it is a copy-and-paste error which was introduced in this commit: 1f69582#diff-cff00d5ca58d233af4e4590bfa182d3f6a10b10e9f9aaecbd6e8907efc259fba

@BastiaanOlij As the commit author, could you confirm that this is the valid solution?

@unfa
Copy link

unfa commented Jan 13, 2022

I am having the same problem when using Visual Shader:
image

Minimal reproduction project:
Test Project.zip

Changing the texture type from Screen will stop the error flood.

Can't use the compute version of the gaussian blur with the mobile renderer.

The project is using the Clustered renderer, and also I am not using gaussian blur anywhere.

@wizcas
Copy link

wizcas commented Oct 9, 2022

Hey guys 👋 I still encounter this error in build v4.0.beta2.mono.official [f8745f2f7]. Is the merged PR not included in the latest release, or shall I request for reopening this issue?

@akien-mga
Copy link
Member

This was fixed in January, it would be better to open a new issue if a new bug with the same symptoms reappeared. The cause and fix are likely different.

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

Successfully merging a pull request may close this issue.

9 participants