Godot Version
godot beta 1
Question
I have a pulse shader that has been running normally, but it has failed in 4.3beta
this is shader code(Camera3D → MeshInstance3D):
shader_type spatial;
render_mode unshaded;
// Settings to play with
uniform vec3 start_point = vec3(0.0);
uniform float pulse_width = 2.0;
uniform vec4 color : source_color;
// Updated by Script
uniform float radius = 5.0;
// Not sure this is actually needed, but used in Documentation.
varying mat4 CAMERA;
uniform sampler2D SCREEN_TEXTURE: hint_screen_texture, filter_linear_mipmap;
uniform sampler2D DEPTH_TEXTURE: hint_depth_texture, filter_linear_mipmap;
void vertex() {
// POSITION = vec4(UV*2.0-1.0, 0.0, 1.0);
POSITION = vec4(VERTEX, 1.0);
CAMERA = INV_VIEW_MATRIX;
}
void fragment() {
// Get the original screen rendered texture at the screen uv coordinates.
vec4 original = texture(SCREEN_TEXTURE, SCREEN_UV);
float depth = texture(DEPTH_TEXTURE, SCREEN_UV).x;
vec3 ndc = vec3(SCREEN_UV * 2.0-1.0, depth);
vec4 world = CAMERA * INV_PROJECTION_MATRIX * vec4(ndc, 1.0);
vec3 world_position = world.xyz / world.w;
float dist = distance(world_position, start_point);
float mix_ratio = 0.0;
if (dist < radius && dist > radius-pulse_width){
mix_ratio = 1.0-(radius-dist);
// Clamp the mix ratio because you can get some unintential visuals
mix_ratio = clamp(mix_ratio, 0.0, 1.0);
}
ALBEDO = mix(original.rgb, color.rgb, mix_ratio);
}
It runs well in 4.2: