// NOTE: Shader automatically converted from Godot Engine 4.5.stable.mono's StandardMaterial3D. shader_type spatial; render_mode blend_mix, depth_draw_never, cull_back, unshaded; #include "res://addons/rokojori_action_library/Runtime/Shading/Library/Math.gdshaderinc" #include "res://addons/rokojori_action_library/Runtime/Shading/Library/Transform.gdshaderinc" uniform vec4 albedo : source_color; uniform sampler2D texture_albedo : source_color, filter_nearest_mipmap_anisotropic, repeat_enable; uniform float alpha_scissor_threshold : hint_range(0.0, 1.0, 0.001); uniform vec3 uv1_scale; uniform vec3 uv1_offset; // [ VARIANCE ] group_uniforms variance; varying float worldSeedXZ; uniform float rotationZ = 0; uniform float rotationZSeed = 0; varying float combinedRotationZ; // [ PLAYER DEFROM ] group_uniforms playerDeform; global uniform vec3 playerPosition; uniform float playerDeformRange = 2.0; uniform float playerDeformAmount = 0.5; uniform float playerDeformPower:hint_range( 0.25, 4 ) = 1; uniform float playerDeformYStart = 0.2; uniform float playerDeformYMax = 1; varying vec2 maskUV; void vertex() { UV = UV * uv1_scale.xy + uv1_offset.xy; //maskUV = clamp01( maskUV ); worldSeedXZ = fract( 123.94444 * fract( NODE_POSITION_WORLD.x * 42130.323 ) + 3.35 * fract( NODE_POSITION_WORLD.z * 13435.124 ) ); // PLAYER DEFORM vec3 localPlayerPosition = worldToLocal( playerPosition, MODEL_MATRIX ); localPlayerPosition.y = 0.0; float positionLength = length( localPlayerPosition ); if ( positionLength == 0.0 ) { localPlayerPosition = vec3( 0.0001, 0, 0 ); } vec3 dir = normalize( localPlayerPosition ); float amount = mapClamped( positionLength, 0.0, playerDeformRange, playerDeformAmount, 0 ); amount = clamp01( pow( amount, playerDeformPower ) ); float yAmount = mapClamped( VERTEX.y, playerDeformYStart, playerDeformYMax, 0.0, 1.0 ); VERTEX += dir * - amount * yAmount; // Billboard Mode: Enabled 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]); // 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) , 0.0), vec4(0.0, 0.0, 0.0, 1.0) ); combinedRotationZ = rotationZ + ( worldSeedXZ * 2.0 - 1.0 ) * rotationZSeed; combinedRotationZ = combinedRotationZ / 180.0 * PI; MODELVIEW_MATRIX = MODELVIEW_MATRIX * rotationZ_m4( combinedRotationZ ); MODELVIEW_NORMAL_MATRIX = mat3(MODELVIEW_MATRIX); } void fragment() { vec2 base_uv = UV; vec4 albedo_tex = texture(texture_albedo, base_uv); if ( albedo_tex.a < alpha_scissor_threshold ) { discard; } ALBEDO = albedo.rgb; ALPHA *= albedo.a * albedo_tex.a; }