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

44 lines
1.6 KiB
Plaintext
Raw Normal View History

2025-01-03 12:09:23 +00:00
// NOTE: Shader automatically converted from Godot Engine 4.3.rc.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/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"
#include "res://addons/rokojori_action_library/Runtime/Shading/Library/Textures.gdshaderinc"
uniform vec4 albedo : source_color;
uniform sampler2D texture_albedo : source_color, filter_linear_mipmap, repeat_enable;
varying vec3 uv_triplanar_pos;
uniform float uv_blend_sharpness : hint_range(0.0, 150.0, 0.001);
varying vec3 uv_power_normal;
uniform vec3 uv_scale;
uniform vec3 uv_offset;
uniform vec3 uvMovement;
void vertex()
{
vec3 normal = NORMAL;
uv_power_normal = pow( abs (NORMAL ), vec3( uv_blend_sharpness ) );
uv_power_normal /= dot( uv_power_normal, vec3( 1.0 ) );
vec3 scaledVertex = VERTEX * extractScale( MODEL_NORMAL_MATRIX );
uv_triplanar_pos = scaledVertex * uv_scale + uv_offset + uvMovement * TIME;
uv_triplanar_pos *= vec3( 1.0, -1.0, 1.0 );
}
void fragment()
{
vec4 albedo_tex = triplanarTexture( texture_albedo, uv_power_normal, uv_triplanar_pos );
ALBEDO = albedo.rgb * albedo_tex.rgb;
ALPHA *= albedo.a * albedo_tex.a;
}