White Tunnel/Fake Light

Based off of this tunnel shader, but retooled to be fading white light, useful for faking light holes in a ceiling or whatever

Just put it on a plane mesh 3d and apply the shader, edit the hole depth and make sure the mesh is rotated the correct way and you’re good to go

Shader code
shader_type spatial;
render_mode unshaded, blend_mix;

uniform sampler2D depth_texture : hint_depth_texture;
uniform float hole_depth : hint_range(0.1, 10.0, 0.1) = 1.0;

void fragment() {
	
	float depth = texture(depth_texture, SCREEN_UV).r;
	
	
	float linear_depth = 1.0 / (depth * INV_PROJECTION_MATRIX[2].w + INV_PROJECTION_MATRIX[3].w);
	
	
	linear_depth = linear_depth + VERTEX.z;
	
	
	float fade = clamp(linear_depth / hole_depth, 0.0, 1.0);
	
	
	ALBEDO = vec3(1.0);
	
	
	ALPHA = fade;
}
Live Preview
Tags
lighting
The shader code and all code snippets in this post are under CC0 license and can be used freely without the author's permission. Images and videos, and assets depicted in those, do not fall under this license. For more info, see our License terms.

More from adamduehring

Related shaders

guest

1 Comment
Oldest
Newest Most Voted
ShulkerShader
11 hours ago

Cool variation! Was awesome to see this on the front page.
Keep it up!