Godot Version
4.4.1
Question
I have a shader that works fine on the PC platform, but when I export the game to Android, it doesn’t display properly.
shader_type spatial;
render_mode unshaded,depth_draw_always;
uniform highp vec3 start_point = vec3(1.0);
uniform vec4 color : source_color = vec4(0.86,0.26,0.61,0.97);
uniform sampler2D SCREEN_TEXTURE : hint_screen_texture,filter_linear_mipmap;
uniform sampler2D DEPTH_TEXTURE : hint_depth_texture,filter_linear_mipmap;
varying highp mat4 CAMERA;
void vertex() {
POSITION = vec4(VERTEX.xy, 1.0, 1.0);
CAMERA = INV_VIEW_MATRIX;
}
void fragment() {
vec4 original = texture(SCREEN_TEXTURE, SCREEN_UV, 1.0);
//float depth = textureLod(DEPTH_TEXTURE, SCREEN_UV, 0.0).x;
float depth = texture(DEPTH_TEXTURE, SCREEN_UV).r;
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 = 1.0-(length(world_position - start_point) - 2.0);
vec3 mix1 = mix(original.rgb, color.rgb, dist);
ALBEDO = mix1;
}