[gd_resource type="Shader" format=3 uid="uid://bvjycr2yn7tks"] [resource] code = "// NOTE: Shader automatically converted from Godot Engine 4.3.stable.mono's StandardMaterial3D. shader_type spatial; render_mode blend_mix, depth_draw_opaque, cull_back, diffuse_burley, specular_schlick_ggx, unshaded; #include \"res://addons/rokojori_action_library/Runtime/Shading/Library/Transform.gdshaderinc\" #include \"res://addons/rokojori_action_library/Runtime/Shading/Library/Line3.gdshaderinc\" uniform vec4 albedo : source_color; uniform sampler2D texture_albedo : source_color, filter_linear_mipmap, repeat_enable; uniform vec2 scale = vec2(1, 1 ); uniform float rotation = 0; uniform float velocity = 1; uniform float width = 1; uniform float feather = 1; varying vec3 worldStart; varying vec3 worldEnd; varying vec3 worldVertex; uniform float size = 1.0; uniform float power = 1.0; void vertex() { /*worldStart = applyMatrix( -velocity, MODEL_MATRIX ); worldEnd = applyMatrix( velocity, MODEL_MATRIX ); worldVertex = applyMatrix( vec3( 0, 0, 0 ), MODEL_MATRIX ); */ //worldStart.z = 0.0; //worldEnd.z = 0.0; 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_MATRIX *= rotationZ_m4( rotation ); MODELVIEW_NORMAL_MATRIX = mat3(MODELVIEW_MATRIX); vec2 scaledUV = ( UV * 2.0 - vec2( 1, 1 ) ) * scale * 0.5; VERTEX += vec3( -scaledUV.x,scaledUV.y, 0 ); //worldVertex.z = 0.0; } float ember( vec2 uv ) { uv = uv * 2.0 - vec2( 1, 1 ); uv.x *= velocity + width; uv.y *= width; vec2 v = vec2( 2.0 * velocity, 0 ); vec2 p = uv - vec2( velocity, 0 ); float r = width; float a = dot( v, v ); float b = dot( v, p ); float c = dot( p, p ) - r * r; float d = b * b - a * c; // edge fade float h = clamp( -b / a, 0, 1); float dist = length( p + h * v); float alpha = smoothstep( 0, feather * width, width - dist ); if ( d > 0.0 ) { d = sqrt( d ); float t0 = max( 0, (-b - d) / a ); float t1 = min( 1, (-b + d) / a ); alpha *= clamp( 2.0 * ( t1 - t0 ), 0, 1 ); } return alpha; } void fragment() { vec2 base_uv = UV; /* vec3 world = VERTEX; Line3 line; line.start = applyMatrix( worldStart, VIEW_MATRIX ); line.end = applyMatrix( worldEnd, VIEW_MATRIX ); //line.start.z = world.z; //line.end.z = world.z; float d = Line3_getDistance( line, world ); */ ALBEDO = albedo.rgb; ALPHA *= albedo.a * ember( UV ); } "