Godot Version
4.3
Question
I got this black hole shader working, but the screen texture reads the screen infront the black hole aswell. (You can see the Fish in the blackhole)
Is there a way to only read the screen behind the black hole
The shader is on a Quad mesh instance
shader_type spatial;
render_mode blend_mix, depth_draw_opaque, cull_disabled, diffuse_burley, specular_disabled, unshaded, shadows_disabled;
uniform sampler2D SCREEN_TEXTURE : hint_screen_texture, filter_linear_mipmap;
uniform sampler2D curve;
uniform vec3 uv1_scale;
uniform vec3 uv1_offset;
uniform vec3 uv2_scale;
uniform vec3 uv2_offset;
void vertex() {
UV = UV * uv1_scale.xy + uv1_offset.xy;
// Billboard Mode: Enabled
MODELVIEW_MATRIX = VIEW_MATRIX * mat4(
MAIN_CAM_INV_VIEW_MATRIX[0],
MAIN_CAM_INV_VIEW_MATRIX[1],
MAIN_CAM_INV_VIEW_MATRIX[2],
MODEL_MATRIX[3]);
MODELVIEW_NORMAL_MATRIX = mat3(MODELVIEW_MATRIX);
}
void fragment() {
vec2 vec_to_center = vec2(0.5, 0.5) - UV;
float center_dist = length(vec_to_center);
float curve_value = texture(curve, vec2(center_dist)).r;
vec2 diff = normalize(vec_to_center) * 0.6 * curve_value;
ALBEDO = texture(SCREEN_TEXTURE, SCREEN_UV - diff).rgb;
}