test other scenes and fix

This commit is contained in:
2026-04-02 15:39:06 +02:00
parent 8883699886
commit 9e261d8d37
33 changed files with 515 additions and 62 deletions

View File

@@ -1,6 +1,6 @@
[gd_resource type="ShaderMaterial" format=3 uid="uid://2p8yqqg44ci3"]
[ext_resource type="Shader" uid="uid://cs0xl7pc6e26h" path="res://docs/museums/daynight/scenes/grain_test/tree_leaves.gdshader" id="1_etun4"]
[ext_resource type="Shader" uid="uid://cs0xl7pc6e26h" path="res://core/daynight/tree_leaves.gdshader" id="1_etun4"]
[ext_resource type="Texture2D" uid="uid://c0lkmyonx88hc" path="res://docs/museums/daynight/scenes/grain_test/grass_thin.png" id="2_grain"]
[resource]

File diff suppressed because one or more lines are too long

View File

@@ -1,7 +1,7 @@
[gd_resource type="ShaderMaterial" format=3 uid="uid://b1ej1sak6omli"]
[ext_resource type="Shader" uid="uid://co2jw3fnyc6aa" path="res://docs/museums/daynight/scenes/grain_test/tree_leaves.gdshader" id="1_2uy3m"]
[ext_resource type="Texture2D" uid="uid://b7sqjhecpoyoh" path="res://docs/museums/daynight/scenes/grain_test/leaf_test.png" id="2_2uy3m"]
[ext_resource type="Shader" uid="uid://cs0xl7pc6e26h" path="res://core/daynight/tree_leaves.gdshader" id="1_2uy3m"]
[ext_resource type="Texture2D" uid="uid://c3grftlmap4q5" path="res://docs/museums/daynight/scenes/grain_test/leaf_test.png" id="2_2uy3m"]
[resource]
render_priority = 0
@@ -14,7 +14,6 @@ shader_parameter/leaves_scale = 1.375
shader_parameter/rotation_degrees = 180.0
shader_parameter/texture_offset = Vector2(0, 0)
shader_parameter/opacity = 1.0
shader_parameter/snow_color = Color(0.85, 0.9, 0.95, 1)
shader_parameter/height_min = 6.0
shader_parameter/height_max = 11.0
shader_parameter/shadow_intensity = 0.800000038
@@ -22,3 +21,4 @@ shader_parameter/highlight_intensity = 0.0
shader_parameter/light_steps = 10.0
shader_parameter/random_mix = 0.0
shader_parameter/cast_shadow_strength = 0.0
shader_parameter/wetness_darkening = 0.25

View File

@@ -1,115 +0,0 @@
shader_type spatial;
render_mode specular_disabled, cull_disabled, ambient_light_disabled;
global uniform float global_wind_speed;
global uniform vec2 global_wind_direction;
global uniform float global_wind_scale;
global uniform float global_wind_strength;
global uniform float global_snow_start_time;
global uniform float global_snow_accumulation_speed;
global uniform float global_snow_melt_time;
global uniform float global_snow_melt_speed;
global uniform vec4 global_snow_color;
uniform sampler2D wind_noise : filter_linear_mipmap;
uniform bool billboard_enabled = true;
uniform bool wind_enabled = true;
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;
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;
uniform float cast_shadow_strength : hint_range(0.0, 1.0) = 0.6;
varying vec3 v_final_color;
varying float v_shade_factor;
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;
float total_angle = radians(rotation_degrees);
if (wind_enabled) {
float time = TIME * global_wind_speed;
vec2 noise_uv = (instance_pos.xz * global_wind_scale) + (time * global_wind_direction * 0.5);
float noise_val = textureLod(wind_noise, noise_uv, 2.0).r;
float sway = sin(time + (noise_val * 10.0));
total_angle += (sway * global_wind_strength);
}
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;
v_shade_factor = combined_factor;
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);
if (billboard_enabled) {
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 {
float c = cos(total_angle);
float s = sin(total_angle);
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;
}
}
void fragment() {
vec2 shifted_uv = UV + texture_offset;
vec4 tex = texture(alpha_texture, shifted_uv);
// Snow accumulation
float snow_amount = 0.0;
if (global_snow_start_time >= 0.0) {
snow_amount = clamp((TIME - global_snow_start_time) * global_snow_accumulation_speed, 0.0, 1.0);
}
if (global_snow_melt_time >= 0.0) {
float melt = clamp((TIME - global_snow_melt_time) * global_snow_melt_speed, 0.0, 1.0);
snow_amount *= (1.0 - melt);
}
float top_mask = 1.0 - shifted_uv.y;
float snow_mask = smoothstep(1.0 - snow_amount, 1.2 - snow_amount, top_mask);
snow_mask *= step(0.01, snow_amount);
vec3 dark_snow = global_snow_color.rgb * (1.0 - shadow_intensity);
vec3 shaded_snow = mix(dark_snow, global_snow_color.rgb, v_shade_factor);
vec3 final_albedo = mix(v_final_color, shaded_snow, snow_mask);
ALBEDO = final_albedo;
ALPHA = tex.r * opacity;
ALPHA_SCISSOR_THRESHOLD = 0.5;
ROUGHNESS = 0.02;
}
void light() {
float shadow_factor = mix(1.0 - cast_shadow_strength, 1.0, ATTENUATION);
float cutoff_mask = smoothstep(0.0, 0.05, ATTENUATION);
DIFFUSE_LIGHT += (shadow_factor * LIGHT_COLOR) * cutoff_mask;
}

View File

@@ -1 +0,0 @@
uid://cs0xl7pc6e26h

View File

@@ -1,9 +1,9 @@
[gd_scene format=3 uid="uid://d12t04rs47jq3"]
[ext_resource type="PackedScene" uid="uid://cqlsf7plpx1tf" path="res://core/daynight/scenes/grain_test/tree_v1.fbx" id="1_8jt4o"]
[ext_resource type="Shader" uid="uid://do0tct77dfhef" path="res://core/daynight/snow.gdshader" id="3_h6257"]
[ext_resource type="Material" uid="uid://b2lg2y1k7grmo" path="res://core/daynight/scenes/grain_test/legno.tres" id="3_imfiy"]
[ext_resource type="Material" uid="uid://b1ej1sak6omli" path="res://core/daynight/scenes/grain_test/leaves2_mat.tres" id="4_8rfui"]
[ext_resource type="PackedScene" uid="uid://e1an0215p6k2" path="res://docs/museums/daynight/scenes/grain_test/tree_v1.fbx" id="1_8jt4o"]
[ext_resource type="Shader" uid="uid://do8puw7u8dvry" path="res://core/daynight/weather_plain_shader.gdshader" id="3_h6257"]
[ext_resource type="Material" path="res://docs/museums/daynight/scenes/grain_test/legno.tres" id="3_imfiy"]
[ext_resource type="Material" uid="uid://b1ej1sak6omli" path="res://docs/museums/daynight/scenes/grain_test/leaves2_mat.tres" id="4_8rfui"]
[sub_resource type="QuadMesh" id="QuadMesh_7kj6q"]
@@ -16,14 +16,17 @@ buffer = PackedFloat32Array(0.076886, 0.99803585, 0.0037512842, 1.8624028, 0.268
[sub_resource type="ShaderMaterial" id="ShaderMaterial_kpc41"]
render_priority = 0
shader = ExtResource("3_h6257")
shader_parameter/snow_color = Color(0.95, 0.98, 1, 1)
shader_parameter/snow_edge_softness = 0.15
shader_parameter/snow_color_variation = 0.05
shader_parameter/wetness_darkening = 0.25
shader_parameter/wet_roughness = 0.05
[sub_resource type="CylinderMesh" id="CylinderMesh_8rfui"]
[node name="TreeTest3" unique_id=838519336 instance=ExtResource("1_8jt4o")]
[node name="TreeTest3" unique_id=838519336 groups=["weather_node", "wind_node"] instance=ExtResource("1_8jt4o")]
transform = Transform3D(1.7, 0, 0, 0, 1.7, 0, 0, 0, 1.7, 0, 0, 0)
[node name="Leaf" parent="." index="0" unique_id=395059449]
[node name="Leaf" parent="." index="0" unique_id=770569390]
transform = Transform3D(100, 0, 0, 0, -4.3711384e-06, 99.99999, 0, -99.99999, -4.3711384e-06, 0, 0, 0)
cast_shadow = 3
@@ -34,7 +37,7 @@ material_override = ExtResource("4_8rfui")
cast_shadow = 0
multimesh = SubResource("MultiMesh_8rfui")
[node name="tree" parent="." index="1" unique_id=1568362771]
[node name="tree" parent="." index="1" unique_id=2045551637]
material_overlay = SubResource("ShaderMaterial_kpc41")
surface_material_override/0 = ExtResource("3_imfiy")

View File

@@ -1,103 +0,0 @@
shader_type spatial;
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);
uniform float palette_shift_y : hint_range(0.0, 1.0) = 0.0;
group_uniforms Height_Gradient;
global uniform vec4 global_gradient_color_top;
global uniform vec4 global_gradient_color_bot;
global uniform float global_gradient_intensity;
uniform float gradient_start_y = 0.0;
uniform float gradient_end_y = 10.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;
uniform float cast_shadow_strength : hint_range(0.0, 1.0) = 0.6;
// ---> NUOVO SISTEMA: GHIBLI DIRECTIONAL GLINT <---
group_uniforms Ghibli_Directional_Glint;
uniform bool use_ghibli_glint = true;
// Colore del bagliore (consigliato: panna caldo o albicocca desaturato)
uniform vec4 glint_color : source_color = vec4(1.0, 0.95, 0.85, 1.0);
// Quanta luce extra vogliamo (es: 1.0 = colora, >1.0 = fa brillare, ideale per Bloom)
uniform float glint_intensity : hint_range(0.0, 10.0) = 1.0;
// DEFINIZIONE DELL'ANGOLO: Più è alto, più la fascia di luce è stretta e netta (HArd Step)
uniform float glint_sharpness : hint_range(1.0, 128.0) = 32.0;
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;
varying float world_y;
void vertex() {
world_y = (MODEL_MATRIX * vec4(VERTEX, 1.0)).y;
}
void fragment() {
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;
float grad_factor = smoothstep(gradient_start_y, gradient_end_y, world_y);
vec3 current_gradient_color = mix(global_gradient_color_bot.rgb, global_gradient_color_top.rgb, grad_factor);
base_color = mix(base_color, current_gradient_color, global_gradient_intensity);
ALBEDO = base_color;
EMISSION = emission_color.rgb * emission_energy;
}
void light() {
// GESTIONE ATTENUAZIONE E OMBRE (Anti-frittura con dither)
float shadow_factor = mix(1.0 - cast_shadow_strength, 1.0, ATTENUATION);
float cutoff_mask = smoothstep(0.0, 0.1, ATTENUATION);
float n_dot_l = dot(NORMAL, LIGHT);
// Anti-frittura dither
float dither = fract(sin(dot(FRAGCOORD.xy, vec2(12.9898, 78.233))) * 43758.5453);
float intensity = (clamp(n_dot_l, 0.0, 1.0) * shadow_factor) + (dither - 0.5) * 0.02;
float raw_step = (intensity + shadow_offset) * light_steps;
float lower_step = floor(raw_step);
float fract_step = fract(raw_step);
float soft_lerp = smoothstep(0.5 - step_softness, 0.5 + step_softness, fract_step);
float stepped_intensity = (lower_step + soft_lerp) / light_steps;
// Colori finali Toon
vec3 light_color_final = mix(shadow_color.rgb, vec3(1.1), clamp(stepped_intensity, 0.0, 1.0));
DIFFUSE_LIGHT += (light_color_final * LIGHT_COLOR) * cutoff_mask;
// ---> GHIBLI DIRECTIONAL GLINT (Il segreto dei tetti) <---
// Sfrutta solo la direzione del sole e la normale dell'oggetto, NON la telecamera.
if (use_ghibli_glint) {
// Calcoliamo un'area di "massima luce" molto aggressiva rivolta perpendicolarmente al sole
// Più 'glint_sharpness' è alto, più la fascia si stringe e diventa selettiva
float glint_raw = pow(max(0.0, n_dot_l), glint_sharpness);
// Toon-ifichiamo l'area con un taglio netto ma pulito
float glint_mask = smoothstep(0.5 - step_softness*0.5, 0.5 + step_softness*0.5, glint_raw);
// Mascheriamo per evitare che appaia nelle ombre proiettate dagli alberi (ATTENUATION)
// e puliamo i bordi laterali (cutoff a 0.0)
glint_mask *= smoothstep(0.0, 0.1, n_dot_l);
// Calcoliamo la luce extra finale
vec3 extra_sun_glint = glint_mask * glint_color.rgb * LIGHT_COLOR * glint_intensity * ATTENUATION;
// Aggiungiamo questa "botta" di luce extra direzionale
DIFFUSE_LIGHT += extra_sun_glint;
}
}

View File

@@ -1 +0,0 @@
uid://d0ch5ofrgf7y6