Shader works beautifully in Engine but fails in build

:information_source: Attention Topic was automatically imported from the old Question2Answer platform.
:bust_in_silhouette: Asked By BytePlayer

The following 2D shader is used to distort a 2D object as seen is this video:

Sample image at: Dropbox - File Deleted - Simplify your life

shader_type canvas_item;

render_mode blend_mix;

uniform float speed = 2.0;
uniform float minStrength : hint_range(0.0, 1.0) = 0.5;
uniform float maxStrength : hint_range(0.0, 1.0) = 1.0;
uniform float strengthScale = 100.0;
uniform float interval = 3.5;
uniform float detail = 1.0;
uniform float distortion : hint_range(0.0, 1.0) = 0.5;
uniform float heightOffset = 0;

float getWind(vec2 vertex, vec2 uv, float timer){
	vec2 pos = mix(vec2(1.0), vertex, distortion).xy;
	float time = timer * speed + pos.x * pos.y;
	float diff = pow(maxStrength - minStrength, 2.0);
	float strength = clamp(minStrength + diff + sin(time / interval) * diff, minStrength, maxStrength) * strengthScale;
	float wind = (sin(time) + cos(time * detail)) * strength * max(0.0, (1.0-uv.y) - heightOffset);
	
	return wind;
	}

void vertex() {
	VERTEX.y += getWind(VERTEX.xy, UV, TIME);
}

It is working great on-screen in the editor when I play an animation that turns the shader on by setting the HeightOffset from 1.0 to 0.1, and then a character interacts with the object being distorted by the shader.

However, when I run the scene using F6 to test it externally, or do an export build, the shader starts appropriately, then stutters and freezes though there are no errors shown in the console window.

I tried increasing the shader render priority but it did not make any difference.

Very odd… did you tried deactivate the shader and reactivate it gradually? This will show you where it breaks.

frankiezafe | 2021-07-06 10:37