rj-action-library/Runtime/Shading/Shaders/Effects/ScanGradient/ScanGradient.gdshader

58 lines
2.2 KiB
Plaintext

// NOTE: Shader automatically converted from Godot Engine 4.3.rc.mono's StandardMaterial3D.
shader_type spatial;
render_mode blend_add, depth_draw_opaque, cull_back, diffuse_burley, specular_schlick_ggx, unshaded, shadows_disabled;
#include "res://addons/rokojori_action_library/Runtime/Shading/Library/Light.gdshaderinc"
#include "res://addons/rokojori_action_library/Runtime/Shading/Library/Transform.gdshaderinc"
#include "res://addons/rokojori_action_library/Runtime/Shading/Library/Math.gdshaderinc"
#include "res://addons/rokojori_action_library/Runtime/Shading/Library/Time.gdshaderinc"
#include "res://addons/rokojori_action_library/Runtime/Shading/Library/Noise.gdshaderinc"
uniform vec4 albedo : source_color;
uniform sampler2D texture_albedo : source_color, filter_linear_mipmap, repeat_enable;
uniform float grow : hint_range(-16.0, 16.0, 0.001);
uniform sampler2D scanTexture : source_color, filter_linear_mipmap, repeat_enable;
uniform float range;
uniform float offset;
uniform float rangeWobble = 0.1;
uniform float rangeWobbleDuration = 1;
uniform float offsetWobble = 0.1;
uniform float offsetWobbleDuration = 1;
uniform float noiseScale = 1;
uniform vec3 noiseOffset = vec3( 1, 1, 1 );
uniform float noiseAmount: hint_range(0, 1) = 0.5;
uniform float rgbScale = 1;
uniform float alphaScale = 1;
varying vec3 localVertex;
void vertex()
{
VERTEX += NORMAL * grow;
localVertex = VERTEX * ( MODEL_NORMAL_MATRIX );
}
void fragment()
{
vec2 uv = UV;
float rangeWobbleValue = timeSine( TIME, rangeWobbleDuration );
float offsetWobbleValue = timeSine( TIME, offsetWobbleDuration );
float animatedRange = range + rangeWobbleValue * rangeWobble;
float animatedOffset = - ( offset + offsetWobbleValue * offsetWobble );
vec4 albedo_tex = texture( texture_albedo, uv );
float scanUV = normalizeToRange01( localVertex.y, animatedOffset - animatedRange, animatedOffset + animatedRange );
vec4 scanColor = texture( scanTexture, vec2( scanUV, 0 ) );
float noise = perlin3D( localVertex * noiseScale + noiseOffset * TIME );
noise = mix( 1, noise, noiseAmount );
ALBEDO = albedo.rgb * scanColor.rgb * rgbScale;
ALPHA *= albedo.a * albedo_tex.a * scanColor.a * alphaScale * noise;
}