Sonar Effect Shader

Sonar Effect Shader.

Shader code
/*
	水中探査装置シェーダー by あるる(きのもと 結衣)
	Sonar Shader by Yui Kinomoto @arlez80

	MIT License
*/
shader_type spatial;
render_mode unshaded;

uniform vec4 color : hint_color = vec4( 0.02, 1.0, 0.2, 1.0 );
uniform float shift_dist = 0.0;
uniform float speed = 20.0;
uniform float interval = 70.0;
uniform float residual = 2.0;

void fragment( )
{
	ALBEDO = color.rgb;
	DEPTH = 0.0;

	float depth = textureLod( DEPTH_TEXTURE, SCREEN_UV, 0.0 ).x;
	vec4 pos = INV_PROJECTION_MATRIX * vec4( 0.0, 0.0, depth * 2.0 - 1.0, 1.0 );
	float d = -pos.z / pos.w;
	float dist = shift_dist + mod( TIME * speed, interval );
	ALPHA = clamp(
		float( ( dist - residual < d ) && ( d < dist ) ) * ( ( d - ( dist - residual ) ) / residual )
	,	0.0
	,	1.0
	);
}
Tags
Post Effect, sonar
The shader code and all code snippets in this post are under MIT license and can be used freely. Images and videos, and assets depicted in those, do not fall under this license. For more info, see our License terms.

More from arlez80

Halftone CMYK Shader

Hex Line Shader

Outline Silhouette Shader

Related shaders

2D Sonar

Mech Gunfire Effect – Smoke Shader

Voronoi Guard Effect Shader

Subscribe
Notify of
guest

0 Comments
Oldest
Newest Most Voted
Inline Feedbacks
View all comments