// NOTE: Shader automatically converted from Godot Engine 4.5.stable.mono's StandardMaterial3D. shader_type spatial; render_mode blend_mix, depth_draw_opaque, cull_disabled, 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/Math.gdshaderinc" uniform float rotation : hint_range(0.0,360); uniform vec4 albedo : source_color; uniform vec4 edgeColor : source_color; uniform float edgeSharpness:hint_range(0.1,10); uniform sampler2D texture_albedo : source_color, filter_linear_mipmap, repeat_enable; uniform float alpha_scissor_threshold : hint_range(0.0, 1.0, 0.001); uniform sampler2D screen_texture : hint_screen_texture, filter_linear_mipmap_anisotropic; uniform float screenBlend: hint_range(0.0,1); uniform float screenDistorationEdge: hint_range(0.1,10); uniform float screenDistorationMax: hint_range(0.1,10); uniform sampler2D screenDistortionTexture : source_color, filter_linear_mipmap, repeat_enable; uniform float screenDistortionTextureMin = -1.0; uniform float screenDistortionTextureMax = 1.0; uniform float screenDistortionTextureScale = 1.0; uniform float screenLODOffset = 0; uniform int particles_anim_h_frames : hint_range(1, 128); uniform int particles_anim_v_frames : hint_range(1, 128); uniform bool particles_anim_loop; uniform vec3 uv1_scale; uniform vec3 uv1_offset; uniform vec3 uv2_scale; uniform vec3 uv2_offset; uniform vec3 centerWorld; void vertex() { UV = UV * uv1_scale.xy + uv1_offset.xy; vec3 particlePositionWorld = extractTranslation( MODEL_MATRIX ); vec2 particlePositionScreen = worldToScreen( particlePositionWorld, VIEW_MATRIX, PROJECTION_MATRIX ); vec2 centerScreen = worldToScreen( centerWorld, VIEW_MATRIX, PROJECTION_MATRIX ); vec2 directionScreen = ( centerScreen - particlePositionScreen ); float screenAngle = atan( -directionScreen.y, directionScreen.x ) + rotation/360.0 * PI * 2.0; // Billboard Mode: Particles mat4 mat_world = mat4( normalize(INV_VIEW_MATRIX[0]), normalize(INV_VIEW_MATRIX[1]), normalize(INV_VIEW_MATRIX[2]), MODEL_MATRIX[3]); mat_world = mat_world * mat4( vec4(cos(INSTANCE_CUSTOM.x), -sin(INSTANCE_CUSTOM.x), 0.0, 0.0), vec4(sin(INSTANCE_CUSTOM.x), cos(INSTANCE_CUSTOM.x), 0.0, 0.0), vec4(0.0, 0.0, 1.0, 0.0), vec4(0.0, 0.0, 0.0, 1.0)); MODELVIEW_MATRIX = VIEW_MATRIX * mat_world * eulerRotation(vec3( 0, 0, screenAngle ) ); // Billboard Keep Scale: Enabled MODELVIEW_MATRIX = MODELVIEW_MATRIX * mat4( vec4(length(MODEL_MATRIX[0].xyz), 0.0, 0.0, 0.0), vec4(0.0, length(MODEL_MATRIX[1].xyz), 0.0, 0.0), vec4(0.0, 0.0, length(MODEL_MATRIX[2].xyz) * 1.0, 0.0), vec4(0.0, 0.0, 0.0, 1.0)); MODELVIEW_NORMAL_MATRIX = mat3(MODELVIEW_MATRIX); float h_frames = float(particles_anim_h_frames); float v_frames = float(particles_anim_v_frames); float particle_total_frames = float(particles_anim_h_frames * particles_anim_v_frames); float particle_frame = floor(INSTANCE_CUSTOM.z * float(particle_total_frames)); if (!particles_anim_loop) { particle_frame = clamp(particle_frame, 0.0, particle_total_frames - 1.0); } else { particle_frame = mod(particle_frame, particle_total_frames); } UV /= vec2(h_frames, v_frames); UV += vec2(mod(particle_frame, h_frames) / h_frames, floor((particle_frame + 0.5) / h_frames) / v_frames); } void fragment() { ALPHA_SCISSOR_THRESHOLD = alpha_scissor_threshold; vec2 base_uv = UV; vec4 albedo_tex = texture(texture_albedo, base_uv); // Vertex Color Use as Albedo: Enabled albedo_tex *= COLOR; ALBEDO = albedo.rgb * albedo_tex.rgb; ALPHA *= albedo.a * albedo_tex.a; float edge = map( ALPHA, 1.0, alpha_scissor_threshold, 0.0, 1.0 ); float distortionAmount = mix( screenDistortionTextureMin, screenDistortionTextureMax, texture( screenDistortionTexture, UV ).r ) * screenDistortionTextureScale; float distortionEdge = pow( 1.0 - edge, screenDistorationEdge ); float distortion = mix( 1.0, screenDistorationMax, distortionEdge + distortionAmount ); edge = pow( edge, edgeSharpness ); vec4 screenColor = textureLod( screen_texture, ( SCREEN_UV - vec2( 0.5 ) ) / distortion + vec2( 0.5 ), screenLODOffset ); // vec4 screenColor = vec4( ALBEDO, 1.0 ); ALBEDO = mix( ALBEDO, ALBEDO * screenColor.rgb, screenBlend ); ALBEDO = mix( ALBEDO, edgeColor.rgb, edge * edgeColor.a ); }