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

Godot freezing when trying to load shader #69855

Open
Tracked by #71929
Atermnus opened this issue Dec 10, 2022 · 6 comments
Open
Tracked by #71929

Godot freezing when trying to load shader #69855

Atermnus opened this issue Dec 10, 2022 · 6 comments

Comments

@Atermnus
Copy link

Godot version

4.0 (beta 7)

System information

Windows 10

Issue description

Godot freezes when trying to open a scene that has a specific shader.

The shader is the following

shader_type canvas_item;

uniform float random_number = 1.0;
uniform sampler2D noise_tex : repeat_enable;
uniform vec4 color : source_color = vec4(0.5,0.3,0.3,1.0);

void fragment(){
    vec4 noise = texture(noise_tex ,UV + vec2(0.4,0.4) * TIME random_number) + vec4(0.2,0.2,0.2,0.2);
    vec4 ctex = texture(TEXTURE,UV) color;
    COLOR = noise * ctex;
}

Adding the shader to a scene works fine, trying to load a scene with the shader (either at start-up or afterwards) causes a freeze.

Steps to reproduce

  1. Create a scene and add a sprite
  2. Add the shader to the sprite
  3. Save as main scene
  4. Close Godot
  5. Re-open the project

Minimal reproduction project

N/A

@TokisanGames
Copy link
Contributor

I'm able to use this shader on Beta 7 & 8 on a sprite or texturerect just fine, including restarting and opening the scene, once it is corrected so that it compiles:

    vec4 noise = texture(noise_tex ,UV + vec2(0.4,0.4) * TIME random_number) + vec4(0.2,0.2,0.2,0.2);
    vec4 noise = texture(noise_tex ,UV + vec2(0.4,0.4) * TIME * random_number) + vec4(0.2,0.2,0.2,0.2);

    vec4 ctex = texture(TEXTURE,UV) color;
    vec4 ctex = texture(TEXTURE,UV) * color;

If you turn on your console it can provide clues, such as dumping shaders that it can't compile it.

@Atermnus
Copy link
Author

With console open, the error I get is the following :

ERROR: Condition "err" is true. Returning: ERR_CANT_CREATE
   at: swap_buffers (drivers/vulkan/vulkan_context.cpp:2301)
ERROR: Condition "err" is true. Returning: ERR_CANT_CREATE
   at: swap_buffers (drivers/vulkan/vulkan_context.cpp:2301)

@TokisanGames
Copy link
Contributor

Is it a freeze or a crash?

Is the freeze permanent or temporary?

What freezes? Your mouse, the viewport, all of Godot, your OS? What do you do to recover?

What kind of card?

Have you updated your drivers?

Does this shader work for you on any other version of Godot 3 or 4?

Do you have problems with other shaders?

Do you have problems with the standard material (which is a shader)?

Can you run any of the demo scenes?

Beta 7 and 8 have problems, but not with this shader. It works fine, when the errors are corrected. But your system may have particular issues that have nothing to do with this shader.

That error your can search for. There are many issues with more information. This is likely a duplicate issue. Eg this small sampling, but there are more
#69696
#67404
#60979
#59699

@Atermnus
Copy link
Author

A complete freeze.

Godot freezes. I use Task Manager to terminate Godot, and I delete the scene from file explorer to be able to re-open the project.

My card is a GTX 1060.

Yes, drivers are updated, this problem only seems to happen with this shader.

I tried multiple versions of Godot 4, I will download once I am able Godot 3.5 and try there as well.

No other Shaders (the project currently doesn't have a lot of them tbh).

No problems with the standard material.

Yea, I can run them.

I've tried searching and I've found similar problems, but unfortunately no answer so far.

@TokisanGames
Copy link
Contributor

You can divide and conquer to determine what part of this shader your system has an issue with to simplify it. Then you can vary your usage of that problem to test it. Eg if it's time, pulling it out of your uv calculation, or clamping or fmod your uvs. If it's texture lookups, experimenting with standard materials converted to shaders and their texture lookups. And Clamp your color values.

@ptome
Copy link

ptome commented Jan 23, 2023

I found this issue because I had the same problem. I have a GTX 1070 and I'm using Godot 4 beta 14. I wasn't running the most recent drivers, because they introduced other issues.

After upgrading to NVIDIA drivers 527.56 (with clean install), the problem is gone. There are more recent drivers, but again, I want to avoid other problems.

Some additional information about the problem follows.

Initially, the project would hang when pressing play, and I had to force close the window. I could Alt-tab to the editor and see the Vulkan error (ERR_CANT_CREATE) in the debugger output. But the shader was displaying correctly in the editor window.

Then I tried to restart Godot and it would hang on loading the project. Nothing would show. I had to force close.

I created a new project with OpenGL rendering and imported all assets. The shader would work in OpenGL. After the driver update, it works in Vulkan again.

I never had any problems with the previous drivers in other Vulkan games, but the sample is small anyway.

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

5 participants