3D Scanning Shader

This is a 3D scanning effect shader.

Shader code
/*
	走査シェーダー by あるる(きのもと 結衣)
	Scanning Shader by Yui Kinomoto @arlez80

	MIT License
*/

shader_type spatial;
render_mode unshaded;

const float PI = 3.1415926535;

uniform vec3 shift = vec3( 0.0, 0.0, 0.0 );
uniform vec3 time_shift_scale = vec3( 0.0, 0.0, 0.0 );
uniform vec4 scan_color : hint_color = vec4( 0.0, 1.0, 0.3, 1.0 );
uniform float scan_line_width : hint_range( 0.0, 1.0 ) = 0.1;
uniform float scan_line_size = 0.05;

varying vec3 local_vertex;

float get_ratio_scan_line( float p )
{
	return max(
		-sin( mod( p, scan_line_size ) / scan_line_size * PI ) + scan_line_width
	,	0.0
	) / scan_line_width;
}

void vertex( )
{
	local_vertex = VERTEX + shift + time_shift_scale * TIME;
}

void fragment( )
{
	float v = clamp(
		get_ratio_scan_line( local_vertex.x )
	+	get_ratio_scan_line( local_vertex.y )
	+	get_ratio_scan_line( local_vertex.z )
	,	0.0
	,	1.0
	);

	ALBEDO = scan_color.rgb;
	ALPHA = scan_color.a * v;
}
Tags
line, scan
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

Heat haze Shader

STN LCD Shader

Magical Shield Shader #2

Related shaders

Radar Scanning Effect Shader

2D Hologram Shader

Half-Tone Comic Shader

guest
0 Comments
Inline Feedbacks
View all comments