first commit
This commit is contained in:
29
Shaders/Day_Night.gdshader
Normal file
29
Shaders/Day_Night.gdshader
Normal file
@@ -0,0 +1,29 @@
|
||||
shader_type canvas_item;
|
||||
render_mode blend_mul;
|
||||
|
||||
// Colori esposti nell'Inspector
|
||||
uniform vec4 color_mattina : source_color = vec4(1.0, 0.9, 0.8, 1.0);
|
||||
uniform vec4 color_pomeriggio : source_color = vec4(1.0, 0.6, 0.2, 1.0);
|
||||
uniform vec4 color_notte : source_color = vec4(0.1, 0.1, 0.3, 1.0);
|
||||
|
||||
// Parametro fluido: 1.0 = Mattina, 2.0 = Pomeriggio, 3.0 = Notte
|
||||
uniform float tempo_giorno : hint_range(1.0, 3.0) = 1.0;
|
||||
|
||||
void fragment() {
|
||||
vec4 tex_color = texture(TEXTURE, UV);
|
||||
vec4 final_tint;
|
||||
|
||||
if (tempo_giorno <= 2.0) {
|
||||
// Transizione tra Mattina (1.0) e Pomeriggio (2.0)
|
||||
// mix(A, B, t) dove t va da 0 a 1
|
||||
float t = tempo_giorno - 1.0;
|
||||
final_tint = mix(color_mattina, color_pomeriggio, t);
|
||||
} else {
|
||||
// Transizione tra Pomeriggio (2.0) e Notte (3.0)
|
||||
float t = tempo_giorno - 2.0;
|
||||
final_tint = mix(color_pomeriggio, color_notte, t);
|
||||
}
|
||||
|
||||
// Applica il colore finale con blend_mul (moltiplicazione)
|
||||
COLOR = tex_color * final_tint;
|
||||
}
|
||||
1
Shaders/Day_Night.gdshader.uid
Normal file
1
Shaders/Day_Night.gdshader.uid
Normal file
@@ -0,0 +1 @@
|
||||
uid://4n16lkrav6bj
|
||||
113
Shaders/Edge.gdshader
Normal file
113
Shaders/Edge.gdshader
Normal file
@@ -0,0 +1,113 @@
|
||||
shader_type spatial;
|
||||
render_mode specular_disabled, ambient_light_disabled;
|
||||
|
||||
uniform sampler2D DEPTH_TEXTURE : hint_depth_texture, filter_linear_mipmap;
|
||||
uniform sampler2D SCREEN_TEXTURE : hint_screen_texture, filter_nearest;
|
||||
uniform sampler2D NORMAL_TEXTURE : hint_normal_roughness_texture, filter_nearest;
|
||||
|
||||
uniform float lightIntensity = 1.25;
|
||||
uniform float lineAlpha = 0.7;
|
||||
uniform bool useLighting = true;
|
||||
uniform float lineHighlight = 0.2;
|
||||
uniform float lineShadow = 0.55;
|
||||
|
||||
varying vec2 screenUV;
|
||||
varying float lineMask;
|
||||
|
||||
|
||||
float GetLinearDepth(vec2 sUV, sampler2D depthTexture, mat4 invProjectionMat, float mask){
|
||||
// Raw depth to linear depth code from:
|
||||
// https://docs.godotengine.org/en/latest/tutorials/shaders/advanced_postprocessing.html
|
||||
float depth = texture(depthTexture, sUV).x * mask;
|
||||
vec3 ndc = vec3(sUV * 2.0 - 1.0, depth);
|
||||
vec4 view = invProjectionMat * vec4(ndc, 1.0);
|
||||
view.xyz /= view.w;
|
||||
return -view.z;
|
||||
}
|
||||
|
||||
vec3 GetNormal(vec2 uv, sampler2D normalTexture, float mask){
|
||||
vec3 normal = texture(normalTexture, uv).rgb;
|
||||
normal = normal * 2.0 - 1.0 * mask;
|
||||
return normal;
|
||||
}
|
||||
|
||||
float NormalEdgeIndicator(vec3 normalEdgeBias, vec3 normal, vec3 neighborNormal, float depthDifference){
|
||||
//From Kody King: https://threejs.org/examples/webgl_postprocessing_pixel.html
|
||||
float normalDifference = dot(normal - neighborNormal, normalEdgeBias);
|
||||
float normalIndicator = clamp(smoothstep(-.01, .01, normalDifference), 0.0, 1.0);
|
||||
float depthIndicator = clamp(sign(depthDifference * .25 + .0025), 0.0, 1.0);
|
||||
return (1.0 - dot(normal, neighborNormal)) * depthIndicator * normalIndicator;
|
||||
}
|
||||
|
||||
void vertex(){
|
||||
POSITION = vec4(VERTEX.xy, 1.0, 1.0);
|
||||
}
|
||||
|
||||
void fragment() {
|
||||
vec2 texelSize = 1.0 / VIEWPORT_SIZE.xy;
|
||||
screenUV = SCREEN_UV;
|
||||
|
||||
// UV offsets
|
||||
vec2 UVOffsets[4];
|
||||
UVOffsets[0] = SCREEN_UV + vec2(0.0, -1.0) * texelSize;
|
||||
UVOffsets[1] = SCREEN_UV + vec2(0.0, 1.0) * texelSize;
|
||||
UVOffsets[2] = SCREEN_UV + vec2(1.0, 0.0) * texelSize;
|
||||
UVOffsets[3] = SCREEN_UV + vec2(-1.0, 0.0) * texelSize;
|
||||
|
||||
// Using alpha channel (screen roughness) to mask objects to not receive outlines
|
||||
float outlineMask = texture(NORMAL_TEXTURE, SCREEN_UV).a;
|
||||
outlineMask = ceil(outlineMask); // Objects with Roughness = 0 will not have and outline
|
||||
|
||||
// Edge detection with Depth
|
||||
float depthDifference = 0.0;
|
||||
float invDepthDifference = 0.5;
|
||||
float depth = GetLinearDepth(SCREEN_UV, DEPTH_TEXTURE, INV_PROJECTION_MATRIX, outlineMask);
|
||||
|
||||
for (int i = 0; i < UVOffsets.length(); i++){
|
||||
float dOff = GetLinearDepth(UVOffsets[i],DEPTH_TEXTURE, INV_PROJECTION_MATRIX, outlineMask);
|
||||
depthDifference += clamp(dOff - depth, 0.0, 1.0);
|
||||
invDepthDifference += depth - dOff;
|
||||
}
|
||||
invDepthDifference = clamp(invDepthDifference, 0.0, 1.0);
|
||||
invDepthDifference = clamp(smoothstep(0.9, 0.9, invDepthDifference) * 10.0 , 0.0, 1.0);
|
||||
depthDifference = smoothstep(0.25, 0.3, depthDifference);
|
||||
|
||||
// Edge detection with Normals
|
||||
float normalDifference = 0.;
|
||||
vec3 normalEdgeBias = vec3(1.0, 1.0, 1.0);
|
||||
vec3 normal = GetNormal(SCREEN_UV, NORMAL_TEXTURE, outlineMask);
|
||||
|
||||
for (int i = 0; i < UVOffsets.length(); i++){
|
||||
vec3 nOff = GetNormal(UVOffsets[i],NORMAL_TEXTURE, outlineMask);
|
||||
normalDifference += NormalEdgeIndicator(normalEdgeBias, normal, nOff, depthDifference);
|
||||
}
|
||||
normalDifference = smoothstep(0.2, 0.2, normalDifference);
|
||||
normalDifference = clamp(normalDifference - invDepthDifference, 0.0, 1.0);
|
||||
|
||||
|
||||
ALBEDO = texture(SCREEN_TEXTURE, SCREEN_UV).rgb;
|
||||
lineMask = clamp(0.1, lineAlpha, (depthDifference + normalDifference * 5.0));
|
||||
|
||||
|
||||
if (!useLighting){
|
||||
ALBEDO += clamp((normalDifference - depthDifference), 0.0, 1.0) * lineHighlight;
|
||||
ALBEDO -= ALBEDO * depthDifference * lineShadow;
|
||||
}
|
||||
}
|
||||
|
||||
void light (){
|
||||
if (useLighting){
|
||||
vec4 normal = texture(NORMAL_TEXTURE, screenUV);
|
||||
normal = normal * 2.0 - 1.0;
|
||||
|
||||
// Calculate light direction
|
||||
float dotNL = dot(normal.rgb, LIGHT);
|
||||
dotNL = pow(dotNL, 2.5);
|
||||
dotNL = clamp(dotNL, 0.0, 1.0);
|
||||
|
||||
if(LIGHT_IS_DIRECTIONAL)
|
||||
DIFFUSE_LIGHT += mix(vec3(1.0), dotNL * LIGHT_COLOR * lightIntensity, lineMask);
|
||||
}
|
||||
else
|
||||
DIFFUSE_LIGHT = vec3(1.0);
|
||||
}
|
||||
1
Shaders/Edge.gdshader.uid
Normal file
1
Shaders/Edge.gdshader.uid
Normal file
@@ -0,0 +1 @@
|
||||
uid://vfm72f8fcvup
|
||||
45
Shaders/Fog.gdshader
Normal file
45
Shaders/Fog.gdshader
Normal file
@@ -0,0 +1,45 @@
|
||||
shader_type spatial;
|
||||
render_mode unshaded, depth_draw_never, cull_disabled, blend_mix;
|
||||
|
||||
group_uniforms TextureCheck;
|
||||
uniform sampler2D fog_noise : repeat_enable, filter_linear_mipmap;
|
||||
uniform bool use_red_as_alpha = true;
|
||||
|
||||
group_uniforms Settings;
|
||||
uniform vec4 fog_color : source_color = vec4(0.8, 0.85, 0.9, 0.5);
|
||||
uniform vec2 scroll_speed = vec2(0.05, 0.01);
|
||||
uniform vec2 texture_scale = vec2(1.0, 1.0);
|
||||
|
||||
group_uniforms Edges;
|
||||
uniform float edge_softness_y : hint_range(0.0, 0.5) = 0.2;
|
||||
uniform float edge_softness_x : hint_range(0.0, 0.5) = 0.1;
|
||||
|
||||
group_uniforms Illuminazione;
|
||||
uniform float night_intensity : hint_range(0.0, 1.0) = 0.0;
|
||||
uniform vec3 sun_color : source_color = vec3(1.0);
|
||||
|
||||
void fragment() {
|
||||
vec2 moving_uv = UV * texture_scale + (TIME * scroll_speed);
|
||||
vec4 noise_tex = texture(fog_noise, moving_uv);
|
||||
|
||||
float noise_alpha = noise_tex.a;
|
||||
if (use_red_as_alpha) {
|
||||
noise_alpha = noise_tex.r;
|
||||
}
|
||||
|
||||
float fade_y = smoothstep(0.0, edge_softness_y, UV.y) * smoothstep(1.0, 1.0 - edge_softness_y, UV.y);
|
||||
float fade_x = smoothstep(0.0, edge_softness_x, UV.x) * smoothstep(1.0, 1.0 - edge_softness_x, UV.x);
|
||||
float edge_mask = fade_x * fade_y;
|
||||
|
||||
// Tingiamo la nebbia con il colore del sole (che di notte è già blu scuro)
|
||||
vec3 tinted_fog = fog_color.rgb * sun_color;
|
||||
|
||||
// Opzionale: scuriamo appena appena un po' di più la nebbia di notte
|
||||
// per evitare che sembri "luminosa" al buio
|
||||
vec3 dark_fog = tinted_fog * 0.5;
|
||||
ALBEDO = mix(tinted_fog, dark_fog, night_intensity);
|
||||
|
||||
// --- MODIFICA: L'Alpha non svanisce più di notte! ---
|
||||
// La nebbia rimane visibile, cambia solo il suo colore (ALBEDO)
|
||||
ALPHA = fog_color.a * noise_alpha * edge_mask;
|
||||
}
|
||||
1
Shaders/Fog.gdshader.uid
Normal file
1
Shaders/Fog.gdshader.uid
Normal file
@@ -0,0 +1 @@
|
||||
uid://b164wpqylv5fo
|
||||
96
Shaders/Grain_Test.gdshader
Normal file
96
Shaders/Grain_Test.gdshader
Normal file
@@ -0,0 +1,96 @@
|
||||
shader_type spatial;
|
||||
|
||||
// Rimosso 'unshaded' per ricevere le ombre.
|
||||
// Aggiunto 'ambient_light_disabled' per proteggere la tua palette dai riflessi del cielo.
|
||||
render_mode specular_disabled, cull_disabled, ambient_light_disabled;
|
||||
|
||||
// --- GLOBAL UNIFORMS (Vento) ---
|
||||
global uniform float wind_scale;
|
||||
global uniform float wind_speed;
|
||||
global uniform float wind_strength;
|
||||
global uniform vec3 wind_direction;
|
||||
global uniform sampler2D wind_noise : filter_linear_mipmap;
|
||||
|
||||
// --- PARAMETRI ESTETICI ---
|
||||
uniform vec4 base_color : source_color = vec4(0.2, 0.6, 0.3, 1.0);
|
||||
uniform sampler2D alpha_texture : source_color, filter_nearest;
|
||||
uniform float leaves_scale = 1.0;
|
||||
uniform float rotation_degrees = 0.0;
|
||||
|
||||
// --- CONTROLLO GRADIENTE E RANDOM ---
|
||||
uniform float height_min = 0.0;
|
||||
uniform float height_max = 5.0;
|
||||
uniform float shadow_intensity : hint_range(0.0, 1.0) = 0.5;
|
||||
uniform float highlight_intensity : hint_range(0.0, 1.0) = 0.3;
|
||||
uniform float light_steps : hint_range(1.0, 10.0) = 4.0;
|
||||
uniform float random_mix : hint_range(0.0, 1.0) = 0.3;
|
||||
|
||||
// NUOVO: Regola quanto è scura l'ombra proiettata (es. dal tronco) sull'erba
|
||||
uniform float cast_shadow_strength : hint_range(0.0, 1.0) = 0.6;
|
||||
|
||||
varying vec3 v_final_color;
|
||||
|
||||
// Funzione hash per generare casualità basata sulla posizione
|
||||
float hash(vec3 p) {
|
||||
p = fract(p * 0.1031);
|
||||
p += dot(p, p.yzx + 33.33);
|
||||
return fract((p.x + p.y) * p.z);
|
||||
}
|
||||
|
||||
void vertex() {
|
||||
// 1. POSIZIONE DELL'ISTANZA
|
||||
vec3 instance_pos = MODEL_MATRIX[3].xyz;
|
||||
|
||||
// --- 2. LOGICA VENTO ---
|
||||
float time = TIME * wind_speed;
|
||||
vec2 noise_uv = (instance_pos.xz * wind_scale) + (time * wind_direction.xz * 0.5);
|
||||
float noise_val = textureLod(wind_noise, noise_uv, 2.0).r;
|
||||
float sway = sin(time + (noise_val * 10.0));
|
||||
float total_angle = radians(rotation_degrees) + (sway * wind_strength);
|
||||
|
||||
// --- 3. CALCOLO COLORE (LOGICA MIXATA) ---
|
||||
float h_factor = clamp((instance_pos.y - height_min) / (height_max - height_min), 0.0, 1.0);
|
||||
float leaf_rand = hash(instance_pos);
|
||||
float combined_factor = mix(h_factor, leaf_rand, random_mix);
|
||||
|
||||
combined_factor = ceil(combined_factor * light_steps) / light_steps;
|
||||
|
||||
vec3 dark_color = base_color.rgb * (1.0 - shadow_intensity);
|
||||
vec3 light_color = base_color.rgb + (vec3(1.0) - base_color.rgb) * highlight_intensity;
|
||||
|
||||
v_final_color = mix(dark_color, light_color, combined_factor);
|
||||
|
||||
// --- 4. LOGICA BILLBOARD ---
|
||||
vec3 view_pos_origin = (VIEW_MATRIX * vec4(instance_pos, 1.0)).xyz;
|
||||
vec2 offset = (UV - 0.5) * leaves_scale;
|
||||
|
||||
float c = cos(total_angle);
|
||||
float s = sin(total_angle);
|
||||
vec2 rotated_offset = vec2(offset.x * c - offset.y * s, offset.x * s + offset.y * c);
|
||||
|
||||
vec3 final_pos = view_pos_origin + vec3(rotated_offset.x, rotated_offset.y, 0.0);
|
||||
|
||||
MODELVIEW_MATRIX = mat4(1.0);
|
||||
MODELVIEW_MATRIX[3].xyz = final_pos;
|
||||
VERTEX = vec3(0.0);
|
||||
}
|
||||
|
||||
void fragment() {
|
||||
vec4 tex = texture(alpha_texture, UV);
|
||||
|
||||
ALBEDO = v_final_color;
|
||||
ALPHA = tex.r;
|
||||
ALPHA_SCISSOR_THRESHOLD = 0.5;
|
||||
|
||||
|
||||
}
|
||||
|
||||
// NUOVO: Calcolo luce custom che simula l'effetto "unshaded" (e ora fixa i quadrati!)
|
||||
void light() {
|
||||
float shadow_factor = mix(1.0 - cast_shadow_strength, 1.0, ATTENUATION);
|
||||
|
||||
// Maschera morbida per nascondere i quadrati
|
||||
float cutoff_mask = smoothstep(0.0, 0.05, ATTENUATION);
|
||||
|
||||
DIFFUSE_LIGHT += (shadow_factor * LIGHT_COLOR) * cutoff_mask;
|
||||
}
|
||||
1
Shaders/Grain_Test.gdshader.uid
Normal file
1
Shaders/Grain_Test.gdshader.uid
Normal file
@@ -0,0 +1 @@
|
||||
uid://cw7lu2soglhqu
|
||||
99
Shaders/Grass_Test.gdshader
Normal file
99
Shaders/Grass_Test.gdshader
Normal file
@@ -0,0 +1,99 @@
|
||||
shader_type spatial;
|
||||
|
||||
// Rimosso 'unshaded' per ricevere le ombre.
|
||||
// Aggiunto 'ambient_light_disabled' per proteggere la tua palette dai riflessi del cielo.
|
||||
render_mode specular_disabled, cull_disabled, ambient_light_disabled;
|
||||
|
||||
// --- GLOBAL UNIFORMS (Vento) ---
|
||||
global uniform float wind_scale;
|
||||
global uniform float wind_speed;
|
||||
global uniform float wind_strength;
|
||||
global uniform vec3 wind_direction;
|
||||
global uniform sampler2D wind_noise : filter_linear_mipmap;
|
||||
|
||||
// --- PARAMETRI ESTETICI ---
|
||||
uniform vec4 base_color : source_color = vec4(0.2, 0.6, 0.3, 1.0);
|
||||
uniform sampler2D alpha_texture : source_color, filter_nearest;
|
||||
uniform float leaves_scale = 1.0;
|
||||
uniform float rotation_degrees = 0.0;
|
||||
|
||||
// --- CONTROLLO GRADIENTE E RANDOM ---
|
||||
uniform float height_min = 0.0;
|
||||
uniform float height_max = 5.0;
|
||||
uniform float shadow_intensity : hint_range(0.0, 1.0) = 0.5;
|
||||
uniform float highlight_intensity : hint_range(0.0, 1.0) = 0.3;
|
||||
uniform float light_steps : hint_range(1.0, 10.0) = 4.0;
|
||||
uniform float random_mix : hint_range(0.0, 1.0) = 0.3;
|
||||
|
||||
// NUOVO: Regola quanto è scura l'ombra proiettata (es. dal tronco) sull'erba
|
||||
uniform float cast_shadow_strength : hint_range(0.0, 1.0) = 0.6;
|
||||
|
||||
varying vec3 v_final_color;
|
||||
|
||||
// Funzione hash per generare casualità basata sulla posizione
|
||||
float hash(vec3 p) {
|
||||
p = fract(p * 0.1031);
|
||||
p += dot(p, p.yzx + 33.33);
|
||||
return fract((p.x + p.y) * p.z);
|
||||
}
|
||||
|
||||
void vertex() {
|
||||
// 1. POSIZIONE DELL'ISTANZA
|
||||
vec3 instance_pos = MODEL_MATRIX[3].xyz;
|
||||
|
||||
// --- 2. LOGICA VENTO ---
|
||||
float time = TIME * wind_speed;
|
||||
vec2 noise_uv = (instance_pos.xz * wind_scale) + (time * wind_direction.xz * 0.5);
|
||||
float noise_val = textureLod(wind_noise, noise_uv, 2.0).r;
|
||||
float sway = sin(time + (noise_val * 10.0));
|
||||
float total_angle = radians(rotation_degrees) + (sway * wind_strength);
|
||||
|
||||
// --- 3. CALCOLO COLORE (LOGICA MIXATA) ---
|
||||
float h_factor = clamp((instance_pos.y - height_min) / (height_max - height_min), 0.0, 1.0);
|
||||
float leaf_rand = hash(instance_pos);
|
||||
float combined_factor = mix(h_factor, leaf_rand, random_mix);
|
||||
|
||||
combined_factor = ceil(combined_factor * light_steps) / light_steps;
|
||||
|
||||
vec3 dark_color = base_color.rgb * (1.0 - shadow_intensity);
|
||||
vec3 light_color = base_color.rgb + (vec3(1.0) - base_color.rgb) * highlight_intensity;
|
||||
|
||||
v_final_color = mix(dark_color, light_color, combined_factor);
|
||||
|
||||
// --- 4. LOGICA BILLBOARD ---
|
||||
vec3 view_pos_origin = (VIEW_MATRIX * vec4(instance_pos, 1.0)).xyz;
|
||||
vec2 offset = (UV - 0.5) * leaves_scale;
|
||||
|
||||
float c = cos(total_angle);
|
||||
float s = sin(total_angle);
|
||||
vec2 rotated_offset = vec2(offset.x * c - offset.y * s, offset.x * s + offset.y * c);
|
||||
|
||||
vec3 final_pos = view_pos_origin + vec3(rotated_offset.x, rotated_offset.y, 0.0);
|
||||
|
||||
MODELVIEW_MATRIX = mat4(1.0);
|
||||
MODELVIEW_MATRIX[3].xyz = final_pos;
|
||||
VERTEX = vec3(0.0);
|
||||
}
|
||||
|
||||
void fragment() {
|
||||
vec4 tex = texture(alpha_texture, UV);
|
||||
|
||||
ALBEDO = v_final_color;
|
||||
ALPHA = tex.r;
|
||||
ALPHA_SCISSOR_THRESHOLD = 0.5;
|
||||
|
||||
// --- IL TRUCCO MAGICO PER L'EDGE DETECTOR ---
|
||||
// Impostiamo la roughness esattamente al 2%.
|
||||
// Il Compute Shader leggerà questo valore e non disegnerà i bordi neri qui sopra!
|
||||
ROUGHNESS = 0.02;
|
||||
}
|
||||
|
||||
// NUOVO: Calcolo luce custom che simula l'effetto "unshaded" (e ora fixa i quadrati!)
|
||||
void light() {
|
||||
float shadow_factor = mix(1.0 - cast_shadow_strength, 1.0, ATTENUATION);
|
||||
|
||||
// Maschera morbida per nascondere i quadrati
|
||||
float cutoff_mask = smoothstep(0.0, 0.05, ATTENUATION);
|
||||
|
||||
DIFFUSE_LIGHT += (shadow_factor * LIGHT_COLOR) * cutoff_mask;
|
||||
}
|
||||
1
Shaders/Grass_Test.gdshader.uid
Normal file
1
Shaders/Grass_Test.gdshader.uid
Normal file
@@ -0,0 +1 @@
|
||||
uid://e3teyipsokeg
|
||||
66
Shaders/Palette_Cel.gdshader
Normal file
66
Shaders/Palette_Cel.gdshader
Normal file
@@ -0,0 +1,66 @@
|
||||
shader_type spatial;
|
||||
render_mode specular_disabled;
|
||||
|
||||
// --- TEXTURE E COLORE BASE ---
|
||||
uniform sampler2D albedo_texture : source_color, filter_nearest_mipmap;
|
||||
uniform vec4 color_tint : source_color = vec4(1.0);
|
||||
|
||||
// --- CORREZIONE IMMAGINE ---
|
||||
uniform float saturation : hint_range(0.0, 2.0) = 1.0;
|
||||
uniform float brightness : hint_range(0.0, 2.0) = 1.0;
|
||||
|
||||
// --- LUCE E OMBRA ---
|
||||
uniform float light_steps = 4.0; // Gradini di luce
|
||||
uniform float shadow_intensity : hint_range(0.0, 1.0) = 0.5; // Quanto è scura l'ombra (0=nera)
|
||||
|
||||
// *** NUOVO PARAMETRO ***
|
||||
// Colore con cui tingere le ombre. Default: Grigio-Bluastro (Cool shadows)
|
||||
uniform vec4 shadow_tint : source_color = vec4(0.6, 0.6, 0.7, 1.0);
|
||||
|
||||
void vertex() {
|
||||
// Vuoto per prop statici
|
||||
}
|
||||
|
||||
void fragment() {
|
||||
vec4 tex_color = texture(albedo_texture, UV);
|
||||
vec3 base_rgb = tex_color.rgb * color_tint.rgb;
|
||||
|
||||
// --- SATURAZIONE ---
|
||||
float luminance = dot(base_rgb, vec3(0.299, 0.587, 0.114));
|
||||
vec3 saturated_color = mix(vec3(luminance), base_rgb, saturation);
|
||||
|
||||
// --- LUMINOSITA' ---
|
||||
ALBEDO = saturated_color * brightness;
|
||||
|
||||
ROUGHNESS = 1.0;
|
||||
SPECULAR = 0.0;
|
||||
}
|
||||
|
||||
void light() {
|
||||
// --- CEL SHADING ---
|
||||
float NdotL = dot(NORMAL, LIGHT);
|
||||
float light_amount = clamp(NdotL, 0.0, 1.0);
|
||||
|
||||
// Gradini
|
||||
light_amount = ceil(light_amount * light_steps) / light_steps;
|
||||
|
||||
// Ombre proiettate (attenuazione)
|
||||
float shadow = ATTENUATION;
|
||||
shadow = ceil(shadow * light_steps) / light_steps;
|
||||
|
||||
// Calcolo quanta luce totale riceve il pixel (0.0 = ombra totale, 1.0 = luce piena)
|
||||
float final_light_factor = light_amount * shadow;
|
||||
|
||||
// --- IL TRUCCO DEL HUE SHIFT ---
|
||||
// Invece di moltiplicare solo per la luce, facciamo un mix tra:
|
||||
// A) Colore in Ombra (Albedo * Tinta Ombra * Intensità minima)
|
||||
// B) Colore Illuminato (Albedo * Colore Luce)
|
||||
|
||||
vec3 lit_color = ALBEDO * LIGHT_COLOR;
|
||||
vec3 shadowed_color = ALBEDO * shadow_tint.rgb * shadow_intensity; // L'ombra si colora!
|
||||
|
||||
// Mischiamo i due stati in base alla luce ricevuta
|
||||
vec3 final_color = mix(shadowed_color, lit_color, final_light_factor);
|
||||
|
||||
DIFFUSE_LIGHT += final_color / PI;
|
||||
}
|
||||
1
Shaders/Palette_Cel.gdshader.uid
Normal file
1
Shaders/Palette_Cel.gdshader.uid
Normal file
@@ -0,0 +1 @@
|
||||
uid://c8b30c87lfclb
|
||||
19
Shaders/Palette_Cel.tres
Normal file
19
Shaders/Palette_Cel.tres
Normal file
@@ -0,0 +1,19 @@
|
||||
[gd_resource type="ShaderMaterial" format=3 uid="uid://da8erd0d83kog"]
|
||||
|
||||
[ext_resource type="Shader" uid="uid://c0dy1aqj1b4q3" path="res://Shaders/trunk_shader.gdshader" id="1_bjiey"]
|
||||
[ext_resource type="Texture2D" uid="uid://cdlgd0h5qeb7k" path="res://Assets/Textures/Palette_train.png" id="2_e8nia"]
|
||||
|
||||
[resource]
|
||||
render_priority = 0
|
||||
shader = ExtResource("1_bjiey")
|
||||
shader_parameter/albedo_color = Color(1, 1, 1, 1)
|
||||
shader_parameter/albedo_texture = ExtResource("2_e8nia")
|
||||
shader_parameter/use_texture = true
|
||||
shader_parameter/uv_scale = Vector2(1, 1)
|
||||
shader_parameter/light_direction = Vector3(0.5, 1, 0.5)
|
||||
shader_parameter/light_steps = 4.0
|
||||
shader_parameter/step_softness = 0.1
|
||||
shader_parameter/shadow_color = Color(0.4, 0.4, 0.6, 1)
|
||||
shader_parameter/shadow_offset = 0.0
|
||||
shader_parameter/emission_color = Color(1, 1, 1, 1)
|
||||
shader_parameter/emission_energy = 0.0
|
||||
146
Shaders/PostProcessing/edge_detection_shader.glsl
Normal file
146
Shaders/PostProcessing/edge_detection_shader.glsl
Normal file
@@ -0,0 +1,146 @@
|
||||
#[compute]
|
||||
#version 450
|
||||
// FOR THIS PROJECT THE INNER LINES MADE WITH THE SCREEN NORMAL IS NOT BEING USED, BUT THE CODE IS STILL AVAILABLE IN THE FILE
|
||||
|
||||
layout(local_size_x = 8, local_size_y = 8, local_size_z = 1) in;
|
||||
|
||||
layout(set = 0, binding = 0, std430) readonly buffer Params {
|
||||
vec2 raster_size;
|
||||
vec2 reserved;
|
||||
mat4 inv_proj_mat;
|
||||
} params;
|
||||
|
||||
layout(rgba16f, set = 0, binding = 1) uniform image2D color_image;
|
||||
layout(set = 0, binding = 2) uniform sampler2D depth_texture;
|
||||
layout(set = 0, binding = 3) uniform sampler2D normal_texture;
|
||||
|
||||
|
||||
const vec2 offset = vec2(0.0001);
|
||||
const float line_highlight = 0.1;
|
||||
const float line_shadow = 0.55;
|
||||
|
||||
|
||||
float GetLinearDepth(vec2 uv, float mask) {
|
||||
float raw_depth = texture(depth_texture, uv).r * mask;
|
||||
vec3 ndc = vec3(uv * 2.0 - 1.0, raw_depth);
|
||||
vec4 view = params.inv_proj_mat * vec4(ndc, 1.0);
|
||||
view.xyz /= view.w;
|
||||
return -view.z;
|
||||
}
|
||||
|
||||
|
||||
vec4 GetNormal(vec2 uv, float mask){
|
||||
vec4 normal = texture(normal_texture, uv + offset) * mask;
|
||||
return normal;
|
||||
}
|
||||
|
||||
|
||||
vec4 NormalRoughnessCompatibility(vec4 p_normal_roughness) {
|
||||
float roughness = p_normal_roughness.w;
|
||||
if (roughness > 0.5) {
|
||||
roughness = 1.0 - roughness;
|
||||
}
|
||||
roughness /= (127.0 / 255.0);
|
||||
vec4 normal_comp = vec4(normalize(p_normal_roughness.xyz * 2.0 - 1.0) * 0.5 + 0.5, roughness);
|
||||
normal_comp = normal_comp * 2.0 - 1.0;
|
||||
return normal_comp;
|
||||
}
|
||||
|
||||
|
||||
float NormalEdgeIndicator(vec3 normal_edge_bias, vec3 normal, vec3 neighbor_normal, float depth_difference){
|
||||
float normal_difference = dot(normal - neighbor_normal, normal_edge_bias);
|
||||
float normal_indicator = clamp(smoothstep(-.01, .01, normal_difference), 0.0, 1.0);
|
||||
float depth_indicator = clamp(sign(depth_difference * .25 + .0025), 0.0, 1.0);
|
||||
return (1.0 - dot(normal, neighbor_normal)) * depth_indicator * normal_indicator;
|
||||
}
|
||||
|
||||
|
||||
void main() {
|
||||
vec2 size = params.raster_size;
|
||||
ivec2 uv = ivec2(gl_GlobalInvocationID.xy);
|
||||
|
||||
if (uv.x >= size.x || uv.y >= size.y) {
|
||||
return;
|
||||
}
|
||||
|
||||
vec2 uv_normalized = uv / size;
|
||||
vec2 texel_size = 1.0 / size.xy;
|
||||
|
||||
// 1. Leggiamo subito il canale Alpha (che in Godot contiene la Roughness codificata)
|
||||
float raw_roughness = texture(normal_texture, uv_normalized + offset).a;
|
||||
|
||||
// --- INIZIO TRUCCO ESCLUSIONE ERBA ---
|
||||
// Decodifichiamo la roughness esattamente come fa Godot (preso dalla tua funzione in alto)
|
||||
float actual_roughness = raw_roughness;
|
||||
if (actual_roughness > 0.5) {
|
||||
actual_roughness = 1.0 - actual_roughness;
|
||||
}
|
||||
actual_roughness /= (127.0 / 255.0);
|
||||
|
||||
// Controlliamo se la roughness è quella "magica" dell'erba (0.02)
|
||||
// Usiamo 0.005 come margine d'errore perché i float non sono mai precisi al 100%
|
||||
if (abs(actual_roughness - 0.02) < 0.005) {
|
||||
// Chiudiamo l'esecuzione per questo specifico pixel!
|
||||
// Siccome non facciamo "imageStore", l'immagine mantiene i suoi colori
|
||||
// originali senza che venga disegnata alcuna linea nera.
|
||||
return;
|
||||
}
|
||||
// --- FINE TRUCCO ---
|
||||
|
||||
// Da qui in poi, il codice prosegue normalmente solo per gli altri oggetti
|
||||
|
||||
// UV ofssets
|
||||
vec2 uv_offsets[4];
|
||||
uv_offsets[0] = uv_normalized + vec2(0.0, -1.0) * texel_size + offset;
|
||||
uv_offsets[1] = uv_normalized + vec2(0.0, 1.0) * texel_size + offset;
|
||||
uv_offsets[2] = uv_normalized + vec2(1.0, 0.0) * texel_size + offset;
|
||||
uv_offsets[3] = uv_normalized + vec2(-1.0, 0.0) * texel_size + offset;
|
||||
|
||||
float mask = ceil(raw_roughness);
|
||||
|
||||
// Depth based Outlines
|
||||
float depth_difference = 0.0;
|
||||
float inv_depth_difference = 0.5;
|
||||
float depth = GetLinearDepth(uv_normalized + offset, mask);
|
||||
|
||||
for (int i = 0; i < uv_offsets.length(); i++){
|
||||
float dOff = GetLinearDepth(uv_offsets[i], mask);
|
||||
depth_difference += clamp(dOff - depth, 0.0, 1.0);
|
||||
inv_depth_difference += depth - dOff;
|
||||
}
|
||||
|
||||
inv_depth_difference = clamp(inv_depth_difference, 0.0, 1.0);
|
||||
inv_depth_difference = clamp(smoothstep(0.9, 0.9, inv_depth_difference) * 10.0 , 0.0, 1.0);
|
||||
depth_difference = smoothstep(0.45, 0.5, depth_difference);
|
||||
|
||||
|
||||
// Normal based Innerlines
|
||||
//float normal_difference = 0.0;
|
||||
//vec3 normal_edge_bias = vec3(1.0, 1.0, 1.0);
|
||||
//vec3 normal = NormalRoughnessCompatibility(GetNormal(uv_normalized, mask)).rgb;
|
||||
|
||||
//for (int i = 0; i < uv_offsets.length(); i++){
|
||||
//vec3 n_offset = NormalRoughnessCompatibility(GetNormal(uv_offsets[i], mask)).rgb;
|
||||
//normal_difference += NormalEdgeIndicator(normal_edge_bias, normal, n_offset, depth_difference);
|
||||
//}
|
||||
//normal_difference = smoothstep(0.2, 0.2, normal_difference);
|
||||
//normal_difference = clamp(normal_difference - inv_depth_difference, 0.0, 1.0);
|
||||
|
||||
|
||||
// Combine with screen render
|
||||
|
||||
vec4 color = imageLoad(color_image, uv);
|
||||
|
||||
vec3 outline = vec3(depth_difference);
|
||||
//vec3 innerline = vec3(normal_difference) - outline;
|
||||
//innerline = clamp(innerline, vec3(0.0), vec3(1.0));
|
||||
//float line_mask = depth_difference + normal_difference;
|
||||
float line_mask = depth_difference;
|
||||
|
||||
// Combine colors with lines
|
||||
//vec4 color_with_lines = vec4(color.rgb + (innerline * line_highlight) - (color.rgb * outline * line_shadow), line_mask);
|
||||
//vec4 color_with_lines = vec4(color.rgb - (color.rgb * outline * line_shadow), line_mask);
|
||||
vec4 color_with_lines = mix(color, color * vec4(vec3(outline), 1.0) * vec4(vec3(line_shadow), 1.0), line_mask);
|
||||
|
||||
imageStore(color_image, uv, color_with_lines);
|
||||
}
|
||||
14
Shaders/PostProcessing/edge_detection_shader.glsl.import
Normal file
14
Shaders/PostProcessing/edge_detection_shader.glsl.import
Normal file
@@ -0,0 +1,14 @@
|
||||
[remap]
|
||||
|
||||
importer="glsl"
|
||||
type="RDShaderFile"
|
||||
uid="uid://bf6t4khabmln0"
|
||||
path="res://.godot/imported/edge_detection_shader.glsl-d1343af904ad9617c7e51c484de26b28.res"
|
||||
|
||||
[deps]
|
||||
|
||||
source_file="res://Shaders/PostProcessing/edge_detection_shader.glsl"
|
||||
dest_files=["res://.godot/imported/edge_detection_shader.glsl-d1343af904ad9617c7e51c484de26b28.res"]
|
||||
|
||||
[params]
|
||||
|
||||
159
Shaders/Sky.gdshader
Normal file
159
Shaders/Sky.gdshader
Normal file
@@ -0,0 +1,159 @@
|
||||
shader_type sky;
|
||||
|
||||
// --- COLORI BASE ---
|
||||
uniform vec3 sky_top_color : source_color;
|
||||
uniform vec3 sky_horizon_color : source_color;
|
||||
uniform float night_intensity : hint_range(0.0, 1.0) = 0.0;
|
||||
|
||||
// --- NUVOLE (AGGIORNATE PER GRADIENTE, OPACITÀ E SOLE) ---
|
||||
group_uniforms Nuvole;
|
||||
uniform sampler2D cloud_noise : filter_linear_mipmap, repeat_enable;
|
||||
// NUOVO: Colore del sole in tempo reale passato dallo script
|
||||
uniform vec3 sun_color : source_color = vec3(1.0);
|
||||
// Colore del "cuore" della nuvola
|
||||
uniform vec4 cloud_center_color : source_color = vec4(1.0, 1.0, 1.0, 1.0);
|
||||
// Colore del bordo esterno (es. un azzurrino o lilla)
|
||||
uniform vec4 cloud_edge_color : source_color = vec4(0.8, 0.85, 0.9, 1.0);
|
||||
uniform vec2 cloud_direction = vec2(0.5, 0.2);
|
||||
uniform float cloud_speed : hint_range(0.0, 2.0) = 0.1;
|
||||
uniform float cloud_scale = 0.5;
|
||||
// Aumenta per avere meno nuvole, diminuisci per un cielo coperto
|
||||
uniform float cloud_threshold : hint_range(0.0, 1.0) = 0.5;
|
||||
// Distanza tra il centro e il bordo (controlla il gradiente del colore)
|
||||
uniform float cloud_edge_thickness : hint_range(0.0, 0.5) = 0.1;
|
||||
// Quanto è morbido e trasparente il bordo estremo della nuvola
|
||||
uniform float cloud_edge_softness : hint_range(0.0, 0.5) = 0.05;
|
||||
|
||||
// --- STELLE FISSE ---
|
||||
group_uniforms Stelle_Fisse;
|
||||
uniform float star_density : hint_range(0.0, 2000.0) = 1500.0;
|
||||
uniform float star_rarity : hint_range(100.0, 5000.0) = 2500.0;
|
||||
uniform float star_scale_variation : hint_range(0.0, 1.0) = 0.5;
|
||||
|
||||
// --- STELLE CADENTI ---
|
||||
group_uniforms Stelle_Cadenti;
|
||||
uniform sampler2D shooting_star_texture : hint_default_black, filter_linear_mipmap;
|
||||
uniform vec4 shooting_star_color : source_color = vec4(1.0, 0.9, 0.7, 1.0);
|
||||
uniform float shooting_star_density : hint_range(0.0, 1.0) = 0.3;
|
||||
uniform float shooting_star_speed : hint_range(0.1, 3.0) = 1.0;
|
||||
uniform float shooting_star_scale : hint_range(0.1, 20.0) = 5.0;
|
||||
uniform float shooting_star_lifetime : hint_range(0.1, 1.0) = 0.5;
|
||||
uniform float shooting_star_travel_dist : hint_range(1.0, 30.0) = 15.0;
|
||||
|
||||
|
||||
// --- UTILITY FUNCTIONS ---
|
||||
float hash(vec3 p) {
|
||||
p = fract(p * 0.1031);
|
||||
p += dot(p, p.yzx + 33.33);
|
||||
return fract((p.x + p.y) * p.z);
|
||||
}
|
||||
|
||||
vec2 hash2(vec3 p) {
|
||||
float h1 = hash(p);
|
||||
float h2 = hash(p + vec3(57.1, 13.7, 9.3));
|
||||
return vec2(h1, h2);
|
||||
}
|
||||
|
||||
vec3 hash3(float seed) {
|
||||
vec3 p = fract(vec3(seed) * vec3(0.1031, 0.1030, 0.0973));
|
||||
p += dot(p, p.yzx + 33.33);
|
||||
return fract((p.xxy + p.yzz) * p.zyx);
|
||||
}
|
||||
|
||||
|
||||
void sky() {
|
||||
float sky_v = clamp(EYEDIR.y, 0.0, 1.0);
|
||||
vec3 final_sky = mix(sky_horizon_color, sky_top_color, sky_v);
|
||||
|
||||
if (night_intensity > 0.05) {
|
||||
|
||||
// 1. LOGICA STELLE FISSE
|
||||
vec3 star_pos = EYEDIR * star_density;
|
||||
vec2 rnd = hash2(star_pos);
|
||||
float star_shape = pow(rnd.x, star_rarity);
|
||||
float scale_factor = mix(1.0, (rnd.y * 0.8 + 0.2), star_scale_variation);
|
||||
star_shape *= scale_factor;
|
||||
star_shape *= pow(sky_v, 4.0);
|
||||
float twinkle_speed = TIME * (1.0 + rnd.y * 5.0);
|
||||
float twinkle_phase = rnd.x * 100.0;
|
||||
float twinkle = sin(twinkle_speed + twinkle_phase) * 0.25 + 0.75;
|
||||
star_shape *= twinkle;
|
||||
final_sky += star_shape * night_intensity;
|
||||
|
||||
// 2. LOGICA STELLE CADENTI
|
||||
if (shooting_star_density > 0.001) {
|
||||
float time_scaled = TIME * shooting_star_speed;
|
||||
float time_seed = floor(time_scaled);
|
||||
float time_progress = fract(time_scaled);
|
||||
vec3 shoot_rnd = hash3(time_seed);
|
||||
|
||||
if (shoot_rnd.z < shooting_star_density * night_intensity) {
|
||||
vec3 center = normalize(vec3(shoot_rnd.x * 2.0 - 1.0, shoot_rnd.y * 0.6 + 0.4, shoot_rnd.z * 2.0 - 1.0));
|
||||
vec3 up = vec3(0.0, 1.0, 0.0);
|
||||
vec3 tangent = normalize(cross(up, center));
|
||||
vec3 bitangent = cross(center, tangent);
|
||||
|
||||
float random_angle = hash(vec3(time_seed)) * 6.28318;
|
||||
float s = sin(random_angle);
|
||||
float c = cos(random_angle);
|
||||
|
||||
vec3 flight_axis = tangent * c - bitangent * s;
|
||||
vec3 side_axis = tangent * s + bitangent * c;
|
||||
|
||||
if (flight_axis.y > 0.0) {
|
||||
flight_axis = -flight_axis;
|
||||
side_axis = -side_axis;
|
||||
}
|
||||
|
||||
float proj_x = dot(EYEDIR, side_axis);
|
||||
float proj_y = dot(EYEDIR, flight_axis);
|
||||
float proj_z = dot(EYEDIR, center);
|
||||
|
||||
if (proj_z > 0.0) {
|
||||
vec2 uv = vec2(proj_x, -proj_y) * shooting_star_scale;
|
||||
uv.y += (time_progress - (shooting_star_lifetime * 0.5)) * shooting_star_travel_dist;
|
||||
uv.x += 0.5;
|
||||
|
||||
float bounds = step(0.0, uv.x) * step(uv.x, 1.0) * step(0.0, uv.y) * step(uv.y, 1.0);
|
||||
|
||||
if (bounds > 0.5) {
|
||||
float star_tex = texture(shooting_star_texture, uv).r;
|
||||
float fade_in = smoothstep(0.0, shooting_star_lifetime * 0.2, time_progress);
|
||||
float fade_out = 1.0 - smoothstep(shooting_star_lifetime * 0.7, shooting_star_lifetime, time_progress);
|
||||
float fade = fade_in * fade_out;
|
||||
final_sky += star_tex * shooting_star_color.rgb * night_intensity * fade;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// 3. LOGICA NUVOLE (MIGLIORATA)
|
||||
vec2 cloud_uv = EYEDIR.xz / (EYEDIR.y + 0.5);
|
||||
cloud_uv = cloud_uv * cloud_scale + (TIME * cloud_direction * cloud_speed);
|
||||
float noise = texture(cloud_noise, cloud_uv).r;
|
||||
|
||||
// A. Calcolo dell'opacità per il bordo estremo (Fade-out morbido verso il cielo trasparente)
|
||||
float cloud_alpha = smoothstep(cloud_threshold, cloud_threshold + cloud_edge_softness, noise);
|
||||
|
||||
// B. Calcolo del gradiente di colore tra il bordo e il centro
|
||||
float color_gradient = smoothstep(cloud_threshold, cloud_threshold + cloud_edge_thickness, noise);
|
||||
|
||||
// C. Creiamo il colore diurno mischiando il colore del bordo con quello centrale
|
||||
// MODIFICA: Moltiplichiamo il colore base delle nuvole per la tinta del sole/ambiente
|
||||
vec3 tinted_center = cloud_center_color.rgb * sun_color;
|
||||
vec3 tinted_edge = cloud_edge_color.rgb * sun_color;
|
||||
vec3 day_cloud_color = mix(tinted_edge, tinted_center, color_gradient);
|
||||
|
||||
// D. Di notte le nuvole diventano scure (prendono il colore scuro della cima del cielo)
|
||||
vec3 night_cloud_color = sky_top_color * 0.4;
|
||||
vec3 current_cloud_color = mix(day_cloud_color, night_cloud_color, night_intensity);
|
||||
|
||||
// E. Le nuvole si dissolvono dolcemente vicino all'orizzonte
|
||||
cloud_alpha *= smoothstep(0.1, 0.4, EYEDIR.y);
|
||||
|
||||
// F. Applichiamo la nuvola al cielo basandoci sull'Alpha calcolato
|
||||
final_sky = mix(final_sky, current_cloud_color, cloud_alpha);
|
||||
|
||||
COLOR = final_sky;
|
||||
}
|
||||
1
Shaders/Sky.gdshader.uid
Normal file
1
Shaders/Sky.gdshader.uid
Normal file
@@ -0,0 +1 @@
|
||||
uid://l6rkqonic7dj
|
||||
104
Shaders/Water.tres
Normal file
104
Shaders/Water.tres
Normal file
@@ -0,0 +1,104 @@
|
||||
[gd_resource type="VisualShader" format=3 uid="uid://dktuskj3gem52"]
|
||||
|
||||
[sub_resource type="VisualShaderNodeVectorOp" id="VisualShaderNodeVectorOp_don5s"]
|
||||
default_input_values = [0, Quaternion(0, 0, 0, 0), 1, Quaternion(0, 0, 0, 0)]
|
||||
op_type = 2
|
||||
operator = 2
|
||||
|
||||
[sub_resource type="VisualShaderNodeVectorOp" id="VisualShaderNodeVectorOp_rvu6f"]
|
||||
default_input_values = [0, Quaternion(0, 0, 0, 0), 1, Quaternion(11133, 12, 12321211, 0)]
|
||||
op_type = 2
|
||||
operator = 5
|
||||
|
||||
[sub_resource type="VisualShaderNodeVec4Constant" id="VisualShaderNodeVec4Constant_d4ljy"]
|
||||
constant = Quaternion(1.25, 1.25, 1.25, 1.25)
|
||||
|
||||
[sub_resource type="VisualShaderNodeFloatConstant" id="VisualShaderNodeFloatConstant_cc8xj"]
|
||||
constant = 0.8
|
||||
|
||||
[sub_resource type="VisualShaderNodeFloatConstant" id="VisualShaderNodeFloatConstant_lhbqr"]
|
||||
|
||||
[sub_resource type="VisualShaderNodeColorParameter" id="VisualShaderNodeColorParameter_k2ihi"]
|
||||
parameter_name = "sColorParameter"
|
||||
default_value_enabled = true
|
||||
default_value = Color(0, 0.26666668, 0.53333336, 1)
|
||||
|
||||
[sub_resource type="FastNoiseLite" id="FastNoiseLite_ttifq"]
|
||||
noise_type = 0
|
||||
fractal_type = 3
|
||||
fractal_octaves = 10
|
||||
fractal_lacunarity = 1.555
|
||||
fractal_gain = 1.445
|
||||
fractal_weighted_strength = 1.0
|
||||
cellular_jitter = 0.0
|
||||
|
||||
[sub_resource type="NoiseTexture2D" id="NoiseTexture2D_6ruds"]
|
||||
width = 1500
|
||||
height = 1500
|
||||
noise = SubResource("FastNoiseLite_ttifq")
|
||||
seamless = true
|
||||
|
||||
[sub_resource type="VisualShaderNodeTexture" id="VisualShaderNodeTexture_v5yg7"]
|
||||
texture = SubResource("NoiseTexture2D_6ruds")
|
||||
|
||||
[sub_resource type="VisualShaderNodeVectorOp" id="VisualShaderNodeVectorOp_mxguh"]
|
||||
output_port_for_preview = 0
|
||||
default_input_values = [0, Quaternion(0, 0, 0, 0), 1, Quaternion(0, 0, 0, 0)]
|
||||
op_type = 2
|
||||
|
||||
[sub_resource type="VisualShaderNodeUVFunc" id="VisualShaderNodeUVFunc_jmfs5"]
|
||||
default_input_values = [1, Vector2(0.02, 0.02), 2, Vector2(0, 0)]
|
||||
|
||||
[sub_resource type="VisualShaderNodeInput" id="VisualShaderNodeInput_kiici"]
|
||||
input_name = "time"
|
||||
|
||||
[sub_resource type="FastNoiseLite" id="FastNoiseLite_nj26y"]
|
||||
noise_type = 2
|
||||
seed = 1
|
||||
fractal_type = 0
|
||||
cellular_distance_function = 1
|
||||
|
||||
[sub_resource type="NoiseTexture2D" id="NoiseTexture2D_8egqe"]
|
||||
width = 1500
|
||||
height = 1500
|
||||
noise = SubResource("FastNoiseLite_nj26y")
|
||||
seamless = true
|
||||
|
||||
[sub_resource type="VisualShaderNodeTexture" id="VisualShaderNodeTexture_x3kgx"]
|
||||
texture = SubResource("NoiseTexture2D_8egqe")
|
||||
|
||||
[sub_resource type="VisualShaderNodeUVFunc" id="VisualShaderNodeUVFunc_4sw7m"]
|
||||
default_input_values = [1, Vector2(-0.02, -0.02), 2, Vector2(0, 0)]
|
||||
|
||||
[sub_resource type="VisualShaderNodeInput" id="VisualShaderNodeInput_itkh5"]
|
||||
input_name = "time"
|
||||
|
||||
[resource]
|
||||
nodes/fragment/0/position = Vector2(680, 200)
|
||||
nodes/fragment/2/node = SubResource("VisualShaderNodeColorParameter_k2ihi")
|
||||
nodes/fragment/2/position = Vector2(-400, 80)
|
||||
nodes/fragment/3/node = SubResource("VisualShaderNodeTexture_v5yg7")
|
||||
nodes/fragment/3/position = Vector2(-640, 360)
|
||||
nodes/fragment/4/node = SubResource("VisualShaderNodeVectorOp_mxguh")
|
||||
nodes/fragment/4/position = Vector2(80, 140)
|
||||
nodes/fragment/5/node = SubResource("VisualShaderNodeUVFunc_jmfs5")
|
||||
nodes/fragment/5/position = Vector2(-920, 460)
|
||||
nodes/fragment/6/node = SubResource("VisualShaderNodeInput_kiici")
|
||||
nodes/fragment/6/position = Vector2(-1260, 560)
|
||||
nodes/fragment/7/node = SubResource("VisualShaderNodeTexture_x3kgx")
|
||||
nodes/fragment/7/position = Vector2(-640, 720)
|
||||
nodes/fragment/8/node = SubResource("VisualShaderNodeUVFunc_4sw7m")
|
||||
nodes/fragment/8/position = Vector2(-920, 780)
|
||||
nodes/fragment/9/node = SubResource("VisualShaderNodeInput_itkh5")
|
||||
nodes/fragment/9/position = Vector2(-1260, 880)
|
||||
nodes/fragment/10/node = SubResource("VisualShaderNodeVectorOp_don5s")
|
||||
nodes/fragment/10/position = Vector2(-420, 560)
|
||||
nodes/fragment/11/node = SubResource("VisualShaderNodeVectorOp_rvu6f")
|
||||
nodes/fragment/11/position = Vector2(-200, 560)
|
||||
nodes/fragment/12/node = SubResource("VisualShaderNodeVec4Constant_d4ljy")
|
||||
nodes/fragment/12/position = Vector2(-200, 740)
|
||||
nodes/fragment/13/node = SubResource("VisualShaderNodeFloatConstant_cc8xj")
|
||||
nodes/fragment/13/position = Vector2(440, 300)
|
||||
nodes/fragment/14/node = SubResource("VisualShaderNodeFloatConstant_lhbqr")
|
||||
nodes/fragment/14/position = Vector2(440, 400)
|
||||
nodes/fragment/connections = PackedInt32Array(2, 0, 4, 0, 5, 0, 3, 0, 6, 0, 5, 2, 8, 0, 7, 0, 9, 0, 8, 2, 3, 0, 10, 0, 10, 0, 11, 0, 12, 0, 11, 1, 11, 0, 4, 1, 3, 0, 0, 0)
|
||||
86
Shaders/Water2.gdshader
Normal file
86
Shaders/Water2.gdshader
Normal file
@@ -0,0 +1,86 @@
|
||||
shader_type spatial;
|
||||
render_mode blend_mix, depth_draw_always;
|
||||
|
||||
// --- PARAMETRI COLORI ACQUA ---
|
||||
uniform vec4 deep_water_color : source_color = vec4(0.0, 0.1, 0.2, 1.0);
|
||||
uniform vec4 shallow_water_color : source_color = vec4(0.0, 0.4, 0.7, 1.0);
|
||||
uniform float beer_law_factor : hint_range(0.0, 5.0) = 2.0;
|
||||
|
||||
// --- PARAMETRI SCHIUMA (DIVISI) ---
|
||||
uniform vec4 shore_foam_color : source_color = vec4(1.0, 1.0, 1.0, 1.0); // Schiuma che tocca gli oggetti
|
||||
uniform vec4 crest_foam_color : source_color = vec4(0.9, 0.95, 1.0, 1.0); // Schiuma sulle punte delle onde
|
||||
uniform float shore_foam_distance : hint_range(0.0, 5.0) = 0.5; // Slider aumentato a 5.0
|
||||
|
||||
// --- PARAMETRI ONDE 3D ---
|
||||
uniform float wave_rotation : hint_range(0.0, 6.28) = 0.0;
|
||||
uniform float wave_height : hint_range(0.0, 2.0) = 0.4;
|
||||
uniform float wave_frequency = 4.0;
|
||||
uniform float wave_speed = 2.0;
|
||||
uniform float wave_distortion : hint_range(0.0, 2.0) = 0.5;
|
||||
|
||||
// --- PARAMETRI NOISE E DEPTH ---
|
||||
uniform sampler2D noise_texture : hint_default_white;
|
||||
uniform sampler2D depth_texture : hint_depth_texture, filter_linear_mipmap;
|
||||
|
||||
varying float height_varying;
|
||||
varying vec2 world_pos;
|
||||
|
||||
void vertex() {
|
||||
world_pos = (MODEL_MATRIX * vec4(VERTEX, 1.0)).xz;
|
||||
|
||||
// 1. ROTAZIONE
|
||||
vec2 rotated_pos = vec2(
|
||||
world_pos.x * cos(wave_rotation) - world_pos.y * sin(wave_rotation),
|
||||
world_pos.x * sin(wave_rotation) + world_pos.y * cos(wave_rotation)
|
||||
);
|
||||
|
||||
// 2. CALCOLO ONDA
|
||||
float noise = texture(noise_texture, world_pos * 0.05 + TIME * 0.02).r;
|
||||
float wave = sin(rotated_pos.y * wave_frequency + TIME * wave_speed + (noise * wave_distortion * 5.0));
|
||||
|
||||
height_varying = (wave + 1.0) * 0.5;
|
||||
VERTEX.y += wave * wave_height;
|
||||
}
|
||||
|
||||
void fragment() {
|
||||
// --- LOGICA PROFONDITÀ ---
|
||||
float depth = texture(depth_texture, SCREEN_UV).r;
|
||||
vec3 ndc = vec3(SCREEN_UV * 2.0 - 1.0, depth);
|
||||
vec4 view = INV_PROJECTION_MATRIX * vec4(ndc, 1.0);
|
||||
view.xyz /= view.w;
|
||||
float linear_depth = -view.z;
|
||||
float depth_difference = linear_depth + VERTEX.z;
|
||||
|
||||
float water_depth_gradient = exp(-depth_difference * beer_law_factor);
|
||||
vec4 base_water = mix(deep_water_color, shallow_water_color, water_depth_gradient);
|
||||
|
||||
// --- GRADIENTE CRESTE ---
|
||||
float crest_blend = smoothstep(0.4, 0.9, height_varying);
|
||||
vec4 water_with_crests = mix(base_water, shallow_water_color * 1.3, crest_blend);
|
||||
|
||||
// --- CALCOLO SCHIUMA SEPARATA ---
|
||||
float noise_f = texture(noise_texture, world_pos * 0.1 + TIME * 0.1).r;
|
||||
|
||||
// 1. Schiuma a riva (Shoreline)
|
||||
float edge_foam_mask = smoothstep(shore_foam_distance * noise_f + 0.1, shore_foam_distance * noise_f, depth_difference);
|
||||
|
||||
// 2. Schiuma sulla cresta (Waves)
|
||||
float crest_foam_mask = smoothstep(0.8, 0.95, height_varying) * 0.8;
|
||||
|
||||
// --- MIX FINALE DEI COLORI ---
|
||||
// Applichiamo prima la schiuma delle onde
|
||||
vec3 color_with_waves = mix(water_with_crests.rgb, crest_foam_color.rgb, crest_foam_mask);
|
||||
|
||||
// Poi applichiamo la schiuma di riva sopra a tutto
|
||||
vec3 final_rgb = mix(color_with_waves, shore_foam_color.rgb, edge_foam_mask);
|
||||
|
||||
// --- OUTPUT ---
|
||||
ALBEDO = final_rgb;
|
||||
ALPHA = mix(0.98, 0.4, water_depth_gradient);
|
||||
|
||||
// Aggiungiamo un po' di opacità extra dove c'è la schiuma di riva
|
||||
ALPHA = clamp(ALPHA + edge_foam_mask, 0.0, 1.0);
|
||||
|
||||
ROUGHNESS = 0.2;
|
||||
SPECULAR = 0.5;
|
||||
}
|
||||
1
Shaders/Water2.gdshader.uid
Normal file
1
Shaders/Water2.gdshader.uid
Normal file
@@ -0,0 +1 @@
|
||||
uid://cglb64vpwpgpu
|
||||
69
Shaders/flower.gdshader
Normal file
69
Shaders/flower.gdshader
Normal file
@@ -0,0 +1,69 @@
|
||||
shader_type spatial;
|
||||
render_mode cull_disabled, specular_disabled;
|
||||
|
||||
|
||||
global uniform float wind_scale;
|
||||
global uniform float wind_speed;
|
||||
global uniform float wind_strength;
|
||||
global uniform vec3 wind_direction;
|
||||
global uniform sampler2D wind_noise : filter_linear_mipmap;
|
||||
|
||||
uniform sampler2D flower_texture : source_color, filter_nearest;
|
||||
uniform float flower_bendiness = 1.0;
|
||||
uniform float sway_back : hint_range(0.0, 1.0, 0.01) = 1.0;
|
||||
uniform float light_steps = 3.0;
|
||||
|
||||
varying vec3 node_pos_view;
|
||||
varying vec3 node_pos_world;
|
||||
varying vec4 world_pos;
|
||||
|
||||
vec4 CalculateWind(vec4 position, float speed, vec3 rotate_direction, float bend, float uv_scale, float mip_level){
|
||||
|
||||
// Scrolling Wind Noise
|
||||
vec3 noise_texture = textureLod(wind_noise, (position.xz * uv_scale) + (speed * -wind_direction.xz), mip_level).rgb;
|
||||
noise_texture = noise_texture * (1. + sway_back) - sway_back;
|
||||
|
||||
// Vertex Displacement
|
||||
vec4 displace = vec4((noise_texture * rotate_direction - noise_texture * noise_texture * vec3(0.0, 1.0, 0.0) * bend) , 0.0);
|
||||
return displace;
|
||||
}
|
||||
|
||||
void vertex() {
|
||||
// Parameters
|
||||
world_pos = MODEL_MATRIX * vec4(VERTEX, 1.0);
|
||||
node_pos_view = NODE_POSITION_VIEW;
|
||||
node_pos_world = NODE_POSITION_WORLD;
|
||||
|
||||
// Wind Animation
|
||||
float speed = TIME * wind_speed;
|
||||
float uv_scale = wind_scale;
|
||||
float wind_intensity = wind_strength * flower_bendiness;
|
||||
|
||||
vec4 direction = inverse(MODEL_MATRIX) * vec4(wind_direction, 0.0);
|
||||
|
||||
vec4 displace = CalculateWind(world_pos, speed, direction.xyz, flower_bendiness, uv_scale, 4.0);
|
||||
displace *= wind_intensity;
|
||||
|
||||
VERTEX += displace.rgb;
|
||||
}
|
||||
|
||||
void fragment() {
|
||||
|
||||
vec4 color = texture(flower_texture, UV);
|
||||
|
||||
ALBEDO = color.rgb;
|
||||
ALPHA = color.a;
|
||||
ALPHA_SCISSOR_THRESHOLD = 0.75;
|
||||
|
||||
SPECULAR = 0.0;
|
||||
ROUGHNESS = 0.0; // rougness is being used as a mask for the outline
|
||||
LIGHT_VERTEX = node_pos_view; // shade the entire mesh based on the object position(pivot) instead of the pixel position
|
||||
}
|
||||
|
||||
void light(){
|
||||
//Diffuse lighting
|
||||
float light = clamp(dot(NORMAL, LIGHT), 0.0, 1.0);
|
||||
light = round(light * light_steps) / light_steps;
|
||||
|
||||
DIFFUSE_LIGHT += light * (LIGHT_COLOR / PI) * ATTENUATION;
|
||||
}
|
||||
1
Shaders/flower.gdshader.uid
Normal file
1
Shaders/flower.gdshader.uid
Normal file
@@ -0,0 +1 @@
|
||||
uid://c7cwe7mbxco0l
|
||||
166
Shaders/grass_billboard.gdshader
Normal file
166
Shaders/grass_billboard.gdshader
Normal file
@@ -0,0 +1,166 @@
|
||||
shader_type spatial;
|
||||
|
||||
render_mode cull_back;
|
||||
|
||||
|
||||
|
||||
global uniform float wind_scale;
|
||||
|
||||
global uniform float wind_speed;
|
||||
|
||||
global uniform float wind_strength;
|
||||
|
||||
global uniform vec3 wind_direction;
|
||||
|
||||
global uniform sampler2D wind_noise : filter_linear_mipmap;
|
||||
|
||||
|
||||
|
||||
uniform vec4 grass_color : source_color;
|
||||
|
||||
uniform sampler2D grass_alpha : source_color;
|
||||
|
||||
uniform float grass_bend_amount = 1.0;
|
||||
|
||||
uniform float sway_back : hint_range(0.0, 1.0, 0.01) = 1.0;
|
||||
|
||||
uniform float light_steps = 3.0;
|
||||
|
||||
|
||||
|
||||
varying vec3 node_pos_view;
|
||||
|
||||
varying vec3 node_pos_world;
|
||||
|
||||
|
||||
|
||||
vec4 CalculateWind(vec4 uv, float speed, vec3 rotate_direction, float uv_scale, float mip_level){
|
||||
|
||||
|
||||
|
||||
// Scrolling Wind Noise
|
||||
|
||||
vec3 noise_texture = textureLod(wind_noise, (uv.xz * uv_scale) - (speed * wind_direction.xz), mip_level).rgb;
|
||||
|
||||
noise_texture = noise_texture * (1. + sway_back) - sway_back;
|
||||
|
||||
|
||||
|
||||
// Vertex Displacement
|
||||
|
||||
vec4 displace = vec4((noise_texture * rotate_direction) , 0.0);
|
||||
|
||||
return displace;
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
void vertex() {
|
||||
|
||||
// Varyings
|
||||
|
||||
node_pos_view = NODE_POSITION_VIEW;
|
||||
|
||||
node_pos_world = NODE_POSITION_WORLD;
|
||||
|
||||
|
||||
|
||||
// Wind Animation
|
||||
|
||||
vec4 world_pos = MODEL_MATRIX * vec4(VERTEX, 1.0);
|
||||
|
||||
float speed = TIME * wind_speed;
|
||||
|
||||
float displace_ammount = wind_strength * grass_bend_amount;
|
||||
|
||||
|
||||
vec4 direction = normalize(VIEW_MATRIX * vec4(wind_direction, 0.0)); //rotate the billboard in the direction of the wind
|
||||
|
||||
//vec3 direction = vec3(1.0, 0.0, 0.0); //rotate the billboard sideways to the camera
|
||||
|
||||
|
||||
|
||||
vec4 displace = CalculateWind(world_pos, speed, direction.xyz, wind_scale, 2.0);
|
||||
|
||||
float uv_mask = 1. - UV.y;
|
||||
|
||||
displace *= displace_ammount * uv_mask;
|
||||
|
||||
|
||||
|
||||
// Billboard
|
||||
|
||||
MODELVIEW_MATRIX = VIEW_MATRIX * mat4(
|
||||
|
||||
vec4(normalize(cross(vec3(0.0, 1.0, 0.0), MAIN_CAM_INV_VIEW_MATRIX[2].xyz)), 0.0),
|
||||
|
||||
vec4(0.0, 1.0, 0.0, 0.0),
|
||||
|
||||
vec4(normalize(cross(MAIN_CAM_INV_VIEW_MATRIX[0].xyz, vec3(0.0, 1.0, 0.0))), 0.0),
|
||||
|
||||
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));
|
||||
|
||||
MODELVIEW_NORMAL_MATRIX = mat3(MODELVIEW_MATRIX);
|
||||
|
||||
|
||||
|
||||
VERTEX += displace.rgb;
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
void fragment() {
|
||||
|
||||
// Color Variation
|
||||
|
||||
float noise = texture(wind_noise, node_pos_world.xz * 0.04).r;
|
||||
|
||||
noise = (noise + 2.5) / 3.5;
|
||||
|
||||
noise = ceil(noise * 5.0) / 5.0;
|
||||
|
||||
|
||||
|
||||
ALBEDO = grass_color.rgb * noise;
|
||||
|
||||
ALPHA = texture(grass_alpha, UV).r;
|
||||
|
||||
ALPHA_SCISSOR_THRESHOLD = 0.75;
|
||||
|
||||
|
||||
|
||||
SPECULAR = 0.0;
|
||||
|
||||
ROUGHNESS = 0.0; // roughness is being u sed as a mask for the outline
|
||||
|
||||
LIGHT_VERTEX = node_pos_view; // shade the entire mesh based on the object position(pivot) instead of the pixel position
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
void light(){
|
||||
|
||||
//Diffuse lighting
|
||||
|
||||
float light = clamp(dot(NORMAL, LIGHT), 0.0, 1.0);
|
||||
|
||||
DIFFUSE_LIGHT += light * (LIGHT_COLOR / PI) * ATTENUATION;
|
||||
|
||||
}
|
||||
1
Shaders/grass_billboard.gdshader.uid
Normal file
1
Shaders/grass_billboard.gdshader.uid
Normal file
@@ -0,0 +1 @@
|
||||
uid://de4s8l7jecutp
|
||||
24
Shaders/ground_shader.gdshader
Normal file
24
Shaders/ground_shader.gdshader
Normal file
@@ -0,0 +1,24 @@
|
||||
shader_type spatial;
|
||||
render_mode specular_disabled;
|
||||
|
||||
|
||||
uniform vec4 ground_color : source_color;
|
||||
uniform float outline_mask = 1.0;
|
||||
|
||||
varying vec4 world_pos;
|
||||
|
||||
void vertex() {
|
||||
world_pos = MODEL_MATRIX * vec4(VERTEX, 1.0);
|
||||
}
|
||||
|
||||
void fragment() {
|
||||
ALBEDO = ground_color.rgb;
|
||||
SPECULAR = 0.0;
|
||||
ROUGHNESS = outline_mask;
|
||||
}
|
||||
|
||||
void light() {
|
||||
float light = clamp(dot(NORMAL, LIGHT), 0.0, 1.0);
|
||||
DIFFUSE_LIGHT += light * (LIGHT_COLOR / PI) * ATTENUATION;
|
||||
|
||||
}
|
||||
1
Shaders/ground_shader.gdshader.uid
Normal file
1
Shaders/ground_shader.gdshader.uid
Normal file
@@ -0,0 +1 @@
|
||||
uid://bifltg3r6fjhh
|
||||
113
Shaders/tree_leaves.gdshader
Normal file
113
Shaders/tree_leaves.gdshader
Normal file
@@ -0,0 +1,113 @@
|
||||
shader_type spatial;
|
||||
|
||||
// Rimosso 'unshaded' per ricevere le ombre.
|
||||
// Aggiunto 'ambient_light_disabled' per proteggere i tuoi colori piatti.
|
||||
render_mode specular_disabled, cull_disabled, ambient_light_disabled;
|
||||
|
||||
// --- GLOBAL UNIFORMS (Vento) ---
|
||||
global uniform float wind_scale;
|
||||
global uniform float wind_speed;
|
||||
global uniform float wind_strength;
|
||||
global uniform vec3 wind_direction;
|
||||
global uniform sampler2D wind_noise : filter_linear_mipmap;
|
||||
|
||||
// --- PARAMETRI ESTETICI ---
|
||||
uniform bool billboard_enabled = true; // <--- PULSANTE ON/OFF BILLBOARD
|
||||
uniform bool wind_enabled = true; // <--- PULSANTE ON/OFF VENTO
|
||||
uniform vec4 base_color : source_color = vec4(0.2, 0.6, 0.3, 1.0);
|
||||
uniform sampler2D alpha_texture : source_color, filter_nearest;
|
||||
uniform float leaves_scale = 1.0;
|
||||
uniform float rotation_degrees = 0.0;
|
||||
uniform vec2 texture_offset = vec2(0.0, 0.0);
|
||||
uniform float opacity : hint_range(0.0, 1.0) = 1.0; // <--- NUOVO PARAMETRO OPACITÀ
|
||||
|
||||
// --- CONTROLLO GRADIENTE E RANDOM ---
|
||||
uniform float height_min = 0.0;
|
||||
uniform float height_max = 5.0;
|
||||
uniform float shadow_intensity : hint_range(0.0, 1.0) = 0.5;
|
||||
uniform float highlight_intensity : hint_range(0.0, 1.0) = 0.3;
|
||||
uniform float light_steps : hint_range(1.0, 10.0) = 4.0;
|
||||
uniform float random_mix : hint_range(0.0, 1.0) = 0.3;
|
||||
|
||||
// NUOVO PARAMETRO: Intensità delle ombre proiettate su questo materiale
|
||||
uniform float cast_shadow_strength : hint_range(0.0, 1.0) = 0.6;
|
||||
|
||||
varying vec3 v_final_color;
|
||||
|
||||
float hash(vec3 p) {
|
||||
p = fract(p * 0.1031);
|
||||
p += dot(p, p.yzx + 33.33);
|
||||
return fract((p.x + p.y) * p.z);
|
||||
}
|
||||
|
||||
void vertex() {
|
||||
vec3 instance_pos = MODEL_MATRIX[3].xyz;
|
||||
|
||||
// --- LOGICA VENTO ---
|
||||
float total_angle = radians(rotation_degrees);
|
||||
if (wind_enabled) {
|
||||
float time = TIME * wind_speed;
|
||||
vec2 noise_uv = (instance_pos.xz * wind_scale) + (time * wind_direction.xz * 0.5);
|
||||
float noise_val = textureLod(wind_noise, noise_uv, 2.0).r;
|
||||
float sway = sin(time + (noise_val * 10.0));
|
||||
total_angle += (sway * wind_strength);
|
||||
}
|
||||
|
||||
// --- CALCOLO COLORE ---
|
||||
float h_factor = clamp((instance_pos.y - height_min) / (height_max - height_min), 0.0, 1.0);
|
||||
float leaf_rand = hash(instance_pos);
|
||||
float combined_factor = mix(h_factor, leaf_rand, random_mix);
|
||||
combined_factor = ceil(combined_factor * light_steps) / light_steps;
|
||||
|
||||
vec3 dark_color = base_color.rgb * (1.0 - shadow_intensity);
|
||||
vec3 light_color = base_color.rgb + (vec3(1.0) - base_color.rgb) * highlight_intensity;
|
||||
v_final_color = mix(dark_color, light_color, combined_factor);
|
||||
|
||||
// --- LOGICA TRASFORMAZIONE (BILLBOARD vs STANDARD) ---
|
||||
if (billboard_enabled) {
|
||||
// Logica Billboard: guarda sempre la camera
|
||||
vec3 view_pos_origin = (VIEW_MATRIX * vec4(instance_pos, 1.0)).xyz;
|
||||
vec2 offset = (UV - 0.5) * leaves_scale;
|
||||
|
||||
float c = cos(total_angle);
|
||||
float s = sin(total_angle);
|
||||
vec2 rotated_offset = vec2(offset.x * c - offset.y * s, offset.x * s + offset.y * c);
|
||||
|
||||
vec3 final_pos = view_pos_origin + vec3(rotated_offset.x, rotated_offset.y, 0.0);
|
||||
|
||||
MODELVIEW_MATRIX = mat4(1.0);
|
||||
MODELVIEW_MATRIX[3].xyz = final_pos;
|
||||
VERTEX = vec3(0.0);
|
||||
} else {
|
||||
// Logica Standard: usa la rotazione e posizione della mesh
|
||||
// Applichiamo comunque la rotazione extra e lo scale se desiderato
|
||||
float c = cos(total_angle);
|
||||
float s = sin(total_angle);
|
||||
|
||||
// Modifichiamo il vertice locale prima della trasformazione world
|
||||
vec2 local_v = (VERTEX.xy) * leaves_scale;
|
||||
VERTEX.x = local_v.x * c - local_v.y * s;
|
||||
VERTEX.y = local_v.x * s + local_v.y * c;
|
||||
// La MODELVIEW_MATRIX rimane quella di default fornita da Godot
|
||||
}
|
||||
}
|
||||
|
||||
void fragment() {
|
||||
vec2 shifted_uv = UV + texture_offset;
|
||||
vec4 tex = texture(alpha_texture, shifted_uv);
|
||||
|
||||
ALBEDO = v_final_color;
|
||||
// Moltiplichiamo l'alpha della texture per il nuovo parametro opacity
|
||||
ALPHA = tex.r * opacity;
|
||||
ALPHA_SCISSOR_THRESHOLD = 0.5;
|
||||
}
|
||||
|
||||
// --- NUOVA LOGICA LUCE (Ombre Proiettate e Fix Quadrati) ---
|
||||
void light() {
|
||||
float shadow_factor = mix(1.0 - cast_shadow_strength, 1.0, ATTENUATION);
|
||||
|
||||
// Maschera morbida per nascondere i quadrati
|
||||
float cutoff_mask = smoothstep(0.0, 0.05, ATTENUATION);
|
||||
|
||||
DIFFUSE_LIGHT += (shadow_factor * LIGHT_COLOR) * cutoff_mask;
|
||||
}
|
||||
1
Shaders/tree_leaves.gdshader.uid
Normal file
1
Shaders/tree_leaves.gdshader.uid
Normal file
@@ -0,0 +1 @@
|
||||
uid://co2jw3fnyc6aa
|
||||
66
Shaders/tree_leaves_1.gdshader
Normal file
66
Shaders/tree_leaves_1.gdshader
Normal file
@@ -0,0 +1,66 @@
|
||||
shader_type spatial;
|
||||
render_mode specular_disabled, cull_back;
|
||||
|
||||
|
||||
global uniform float wind_scale;
|
||||
global uniform float wind_speed;
|
||||
global uniform float wind_strength;
|
||||
global uniform vec3 wind_direction;
|
||||
global uniform sampler2D wind_noise : filter_linear_mipmap;
|
||||
|
||||
uniform vec4 color: source_color;
|
||||
uniform sampler2D alpha;
|
||||
uniform float leaves_scale = 1.0;
|
||||
uniform float leaf_bend_amount = 0.7;
|
||||
uniform float light_steps = 5.0;
|
||||
|
||||
varying vec4 view_pos;
|
||||
varying vec4 world_pos;
|
||||
|
||||
void vertex() {
|
||||
world_pos = MODEL_MATRIX * vec4(VERTEX, 1.0);
|
||||
view_pos = MODELVIEW_MATRIX * vec4(VERTEX, 1.0);
|
||||
float speed = TIME * wind_speed;
|
||||
|
||||
// Noise for animation
|
||||
float noise_texture = textureLod(wind_noise, (world_pos.xz * wind_scale) - (speed * wind_direction.xz), 1.0).r;
|
||||
noise_texture = (noise_texture * 2. - 1.) * (wind_strength * leaf_bend_amount);
|
||||
|
||||
//Leaves Billboard
|
||||
vec4 new_position = vec4(UV.y, UV.x, 0.0, 1.0);
|
||||
new_position = new_position *2. - 1.;
|
||||
new_position = normalize(new_position);
|
||||
new_position *= leaves_scale;
|
||||
|
||||
// Leaves animation
|
||||
new_position += noise_texture * vec4(1.0, 0.0, 0.0, 0.0) * (UV.x * 2.0 - 1.0) - noise_texture * vec4(0.0, 1.0, 0.0, 0.0) * (UV.y * 2.0 - 1.0);
|
||||
|
||||
new_position *= MODELVIEW_MATRIX;
|
||||
|
||||
|
||||
VERTEX += new_position.xyz;
|
||||
}
|
||||
|
||||
void fragment() {
|
||||
ALBEDO = color.rgb;
|
||||
ALPHA = texture(alpha, UV).r;
|
||||
ALPHA_SCISSOR_THRESHOLD = 0.5;
|
||||
ROUGHNESS = 0.0;
|
||||
SPECULAR = 0.0;
|
||||
LIGHT_VERTEX = view_pos.xyz;
|
||||
}
|
||||
|
||||
void light() {
|
||||
// Cel shaded diffuse lighting
|
||||
float light = clamp(dot(NORMAL, LIGHT), 0.0, 1.0);
|
||||
light = ceil(light * light_steps) / light_steps;
|
||||
DIFFUSE_LIGHT += light * (LIGHT_COLOR / PI) * ATTENUATION;
|
||||
|
||||
// Rim Lighting
|
||||
float rim = 1.0 - dot(NORMAL, VIEW);
|
||||
rim *= light;
|
||||
rim = round(rim * light_steps) / light_steps;
|
||||
rim = rim * rim;
|
||||
DIFFUSE_LIGHT += rim * ATTENUATION * LIGHT_COLOR / PI;
|
||||
|
||||
}
|
||||
1
Shaders/tree_leaves_1.gdshader.uid
Normal file
1
Shaders/tree_leaves_1.gdshader.uid
Normal file
@@ -0,0 +1 @@
|
||||
uid://408vhi5dh77y
|
||||
96
Shaders/tree_leaves_Unshaded.gdshader
Normal file
96
Shaders/tree_leaves_Unshaded.gdshader
Normal file
@@ -0,0 +1,96 @@
|
||||
shader_type spatial;
|
||||
// Unshaded è essenziale per avere colori piatti e puliti
|
||||
render_mode specular_disabled, cull_disabled, unshaded;
|
||||
|
||||
// --- GLOBAL UNIFORMS (Vento) ---
|
||||
global uniform float wind_scale;
|
||||
global uniform float wind_speed;
|
||||
global uniform float wind_strength;
|
||||
global uniform vec3 wind_direction;
|
||||
global uniform sampler2D wind_noise : filter_linear_mipmap;
|
||||
|
||||
// --- PARAMETRI ESTETICI ---
|
||||
uniform bool billboard_enabled = true; // <--- PULSANTE ON/OFF BILLBOARD
|
||||
uniform bool wind_enabled = true; // <--- PULSANTE ON/OFF VENTO
|
||||
uniform vec4 base_color : source_color = vec4(0.2, 0.6, 0.3, 1.0);
|
||||
uniform sampler2D alpha_texture : source_color, filter_nearest;
|
||||
uniform float leaves_scale = 1.0;
|
||||
uniform float rotation_degrees = 0.0;
|
||||
uniform vec2 texture_offset = vec2(0.0, 0.0);
|
||||
|
||||
// --- CONTROLLO GRADIENTE E RANDOM ---
|
||||
uniform float height_min = 0.0;
|
||||
uniform float height_max = 5.0;
|
||||
uniform float shadow_intensity : hint_range(0.0, 1.0) = 0.5;
|
||||
uniform float highlight_intensity : hint_range(0.0, 1.0) = 0.3;
|
||||
uniform float light_steps : hint_range(1.0, 10.0) = 4.0;
|
||||
uniform float random_mix : hint_range(0.0, 1.0) = 0.3;
|
||||
|
||||
varying vec3 v_final_color;
|
||||
|
||||
float hash(vec3 p) {
|
||||
p = fract(p * 0.1031);
|
||||
p += dot(p, p.yzx + 33.33);
|
||||
return fract((p.x + p.y) * p.z);
|
||||
}
|
||||
|
||||
void vertex() {
|
||||
vec3 instance_pos = MODEL_MATRIX[3].xyz;
|
||||
|
||||
// --- LOGICA VENTO ---
|
||||
float total_angle = radians(rotation_degrees);
|
||||
if (wind_enabled) {
|
||||
float time = TIME * wind_speed;
|
||||
vec2 noise_uv = (instance_pos.xz * wind_scale) + (time * wind_direction.xz * 0.5);
|
||||
float noise_val = textureLod(wind_noise, noise_uv, 2.0).r;
|
||||
float sway = sin(time + (noise_val * 10.0));
|
||||
total_angle += (sway * wind_strength);
|
||||
}
|
||||
|
||||
// --- CALCOLO COLORE ---
|
||||
float h_factor = clamp((instance_pos.y - height_min) / (height_max - height_min), 0.0, 1.0);
|
||||
float leaf_rand = hash(instance_pos);
|
||||
float combined_factor = mix(h_factor, leaf_rand, random_mix);
|
||||
combined_factor = ceil(combined_factor * light_steps) / light_steps;
|
||||
|
||||
vec3 dark_color = base_color.rgb * (1.0 - shadow_intensity);
|
||||
vec3 light_color = base_color.rgb + (vec3(1.0) - base_color.rgb) * highlight_intensity;
|
||||
v_final_color = mix(dark_color, light_color, combined_factor);
|
||||
|
||||
// --- LOGICA TRASFORMAZIONE (BILLBOARD vs STANDARD) ---
|
||||
if (billboard_enabled) {
|
||||
// Logica Billboard: guarda sempre la camera
|
||||
vec3 view_pos_origin = (VIEW_MATRIX * vec4(instance_pos, 1.0)).xyz;
|
||||
vec2 offset = (UV - 0.5) * leaves_scale;
|
||||
|
||||
float c = cos(total_angle);
|
||||
float s = sin(total_angle);
|
||||
vec2 rotated_offset = vec2(offset.x * c - offset.y * s, offset.x * s + offset.y * c);
|
||||
|
||||
vec3 final_pos = view_pos_origin + vec3(rotated_offset.x, rotated_offset.y, 0.0);
|
||||
|
||||
MODELVIEW_MATRIX = mat4(1.0);
|
||||
MODELVIEW_MATRIX[3].xyz = final_pos;
|
||||
VERTEX = vec3(0.0);
|
||||
} else {
|
||||
// Logica Standard: usa la rotazione e posizione della mesh
|
||||
// Applichiamo comunque la rotazione extra e lo scale se desiderato
|
||||
float c = cos(total_angle);
|
||||
float s = sin(total_angle);
|
||||
|
||||
// Modifichiamo il vertice locale prima della trasformazione world
|
||||
vec2 local_v = (VERTEX.xy) * leaves_scale;
|
||||
VERTEX.x = local_v.x * c - local_v.y * s;
|
||||
VERTEX.y = local_v.x * s + local_v.y * c;
|
||||
// La MODELVIEW_MATRIX rimane quella di default fornita da Godot
|
||||
}
|
||||
}
|
||||
|
||||
void fragment() {
|
||||
vec2 shifted_uv = UV + texture_offset;
|
||||
vec4 tex = texture(alpha_texture, shifted_uv);
|
||||
|
||||
ALBEDO = v_final_color;
|
||||
ALPHA = tex.r;
|
||||
ALPHA_SCISSOR_THRESHOLD = 0.5;
|
||||
}
|
||||
1
Shaders/tree_leaves_Unshaded.gdshader.uid
Normal file
1
Shaders/tree_leaves_Unshaded.gdshader.uid
Normal file
@@ -0,0 +1 @@
|
||||
uid://cvgukw0n6aw74
|
||||
67
Shaders/trunk_shader.gdshader
Normal file
67
Shaders/trunk_shader.gdshader
Normal file
@@ -0,0 +1,67 @@
|
||||
shader_type spatial;
|
||||
|
||||
// Aggiunto 'ambient_light_disabled' per proteggere i colori piatti
|
||||
// Mantenuto 'diffuse_toon' per ottimizzare i calcoli della luce interna di Godot
|
||||
render_mode diffuse_toon, specular_disabled, ambient_light_disabled;
|
||||
|
||||
group_uniforms Albedo_Settings;
|
||||
uniform vec4 albedo_color : source_color = vec4(1.0);
|
||||
uniform sampler2D albedo_texture : source_color, filter_nearest;
|
||||
uniform bool use_texture = true;
|
||||
uniform vec2 uv_scale = vec2(1.0, 1.0);
|
||||
// NUOVO PARAMETRO: Slider per scorrere la palette in verticale
|
||||
uniform float palette_shift_y : hint_range(0.0, 1.0) = 0.0;
|
||||
|
||||
group_uniforms Toon_Lighting;
|
||||
uniform float light_steps : hint_range(1.0, 10.0, 1.0) = 3.0;
|
||||
uniform float step_softness : hint_range(0.01, 1.0) = 0.1;
|
||||
uniform vec4 shadow_color : source_color = vec4(0.4, 0.4, 0.6, 1.0);
|
||||
uniform float shadow_offset : hint_range(-1.0, 1.0) = 0.0;
|
||||
|
||||
// NUOVO PARAMETRO IMPORTATO: Intensità delle ombre proiettate su questo materiale
|
||||
uniform float cast_shadow_strength : hint_range(0.0, 1.0) = 0.6;
|
||||
|
||||
group_uniforms Emission_Settings;
|
||||
uniform vec4 emission_color : source_color = vec4(0.0, 0.0, 0.0, 1.0);
|
||||
uniform float emission_energy : hint_range(0.0, 16.0) = 0.0;
|
||||
|
||||
void fragment() {
|
||||
// 1. Albedo (Colore base dell'oggetto)
|
||||
// APPLICATO LO SHIFT SULL'ASSE Y SULLE UV
|
||||
vec2 final_uv = (UV * uv_scale) + vec2(0.0, palette_shift_y);
|
||||
vec4 tex = texture(albedo_texture, final_uv);
|
||||
|
||||
vec3 base_color = albedo_color.rgb;
|
||||
if (use_texture) base_color *= tex.rgb;
|
||||
|
||||
// Passiamo il colore crudo a Godot.
|
||||
// Godot si occuperà di moltiplicarlo per la luce alla fine.
|
||||
ALBEDO = base_color;
|
||||
|
||||
// 2. Emission
|
||||
EMISSION = emission_color.rgb * emission_energy;
|
||||
}
|
||||
|
||||
// --- NUOVA LOGICA LUCE INTEGRATA ---
|
||||
void light() {
|
||||
float shadow_factor = mix(1.0 - cast_shadow_strength, 1.0, ATTENUATION);
|
||||
float n_dot_l = dot(NORMAL, LIGHT);
|
||||
|
||||
float intensity = clamp((n_dot_l * shadow_factor) + shadow_offset, 0.0, 1.0);
|
||||
|
||||
float raw_step = intensity * light_steps;
|
||||
float lower_step = floor(raw_step);
|
||||
float fract_step = fract(raw_step);
|
||||
float lerp_step = smoothstep(0.5 - step_softness, 0.5 + step_softness, fract_step);
|
||||
float stepped_intensity = (lower_step + lerp_step) / light_steps;
|
||||
|
||||
vec3 light_part = vec3(1.2);
|
||||
vec3 shaded_part = shadow_color.rgb;
|
||||
|
||||
vec3 final_toon_light = mix(shaded_part, light_part, clamp(stepped_intensity, 0.0, 1.0));
|
||||
|
||||
// Porchiddio Michele
|
||||
float cutoff_mask = smoothstep(0.0, 0.05, ATTENUATION);
|
||||
|
||||
DIFFUSE_LIGHT += (final_toon_light * LIGHT_COLOR) * cutoff_mask;
|
||||
}
|
||||
1
Shaders/trunk_shader.gdshader.uid
Normal file
1
Shaders/trunk_shader.gdshader.uid
Normal file
@@ -0,0 +1 @@
|
||||
uid://c0dy1aqj1b4q3
|
||||
50
Shaders/trunk_shader_unshaded.gdshader
Normal file
50
Shaders/trunk_shader_unshaded.gdshader
Normal file
@@ -0,0 +1,50 @@
|
||||
shader_type spatial;
|
||||
render_mode unshaded;
|
||||
|
||||
group_uniforms Albedo_Settings;
|
||||
uniform vec4 albedo_color : source_color = vec4(1.0);
|
||||
uniform sampler2D albedo_texture : source_color, filter_nearest;
|
||||
uniform bool use_texture = true;
|
||||
uniform vec2 uv_scale = vec2(1.0, 1.0);
|
||||
|
||||
group_uniforms Toon_Lighting;
|
||||
uniform vec3 light_direction = vec3(0.5, 1.0, 0.5);
|
||||
uniform float light_steps : hint_range(1.0, 10.0, 1.0) = 3.0;
|
||||
uniform float step_softness : hint_range(0.01, 1.0) = 0.1;
|
||||
uniform vec4 shadow_color : source_color = vec4(0.4, 0.4, 0.6, 1.0);
|
||||
uniform float shadow_offset : hint_range(-1.0, 1.0) = 0.0;
|
||||
|
||||
group_uniforms Emission_Settings;
|
||||
uniform vec4 emission_color : source_color = vec4(0.0, 0.0, 0.0, 1.0); // Nero di default
|
||||
uniform float emission_energy : hint_range(0.0, 16.0) = 0.0; // A 0 l'emissione è spenta
|
||||
|
||||
void fragment() {
|
||||
// 1. Albedo
|
||||
vec4 tex = texture(albedo_texture, UV * uv_scale);
|
||||
vec3 base_color = albedo_color.rgb;
|
||||
if (use_texture) base_color *= tex.rgb;
|
||||
|
||||
// 2. Luce (World Space Fix)
|
||||
vec3 world_light_dir = normalize(light_direction);
|
||||
vec3 view_light_dir = (VIEW_MATRIX * vec4(world_light_dir, 0.0)).xyz;
|
||||
float n_dot_l = dot(NORMAL, normalize(view_light_dir));
|
||||
|
||||
// 3. Toon Stepping
|
||||
float intensity = clamp(n_dot_l + shadow_offset, 0.0, 1.0);
|
||||
float raw_step = intensity * light_steps;
|
||||
float lower_step = floor(raw_step);
|
||||
float fract_step = fract(raw_step);
|
||||
float lerp_step = smoothstep(0.5 - step_softness, 0.5 + step_softness, fract_step);
|
||||
float stepped_intensity = (lower_step + lerp_step) / light_steps;
|
||||
|
||||
// 4. Mixing base
|
||||
vec3 light_part = base_color * 1.2;
|
||||
vec3 shaded_part = base_color * shadow_color.rgb;
|
||||
vec3 final_rgb = mix(shaded_part, light_part, clamp(stepped_intensity, 0.0, 1.0));
|
||||
|
||||
ALBEDO = final_rgb;
|
||||
|
||||
// 5. Emission
|
||||
// Moltiplica il colore per l'energia impostata dall'utente
|
||||
EMISSION = emission_color.rgb * emission_energy;
|
||||
}
|
||||
1
Shaders/trunk_shader_unshaded.gdshader.uid
Normal file
1
Shaders/trunk_shader_unshaded.gdshader.uid
Normal file
@@ -0,0 +1 @@
|
||||
uid://n2fjgynfljhx
|
||||
Reference in New Issue
Block a user