add cloud shadow - godrays

This commit is contained in:
Matteo Sonaglioni
2026-03-11 18:51:31 +01:00
parent 47380d3137
commit 609b70a114
44 changed files with 532 additions and 157 deletions

View File

@@ -1,7 +1,7 @@
[gd_scene format=4 uid="uid://xebpudhewwwj"]
[ext_resource type="PackedScene" uid="uid://bxnd5v67eaypf" path="res://Assets/Meshes/Chunk/Bioma_C/Test_Chunk_C_L_2.fbx" id="1_xe3ww"]
[ext_resource type="Script" uid="uid://byluxssk112ca" path="res://Test_Procedurale/info_chunk.gd" id="2_qr4wy"]
[ext_resource type="Script" uid="uid://byluxssk112ca" path="res://Scripts/info_chunk.gd" id="2_qr4wy"]
[ext_resource type="Material" uid="uid://couj6glsrm6h3" path="res://Materials/Sentiero.tres" id="2_xlq82"]
[ext_resource type="PackedScene" uid="uid://jj15telqu3rp" path="res://Scenes/Test/Grass_Test.tscn" id="3_eyx8o"]
[ext_resource type="Texture2D" uid="uid://3ot7glyivagg" path="res://Assets/Textures/Texture_Sentiero.png" id="3_odndq"]

View File

@@ -1,7 +1,7 @@
[gd_scene format=3 uid="uid://botm0dqtr5whb"]
[ext_resource type="PackedScene" uid="uid://d3loscamahf5y" path="res://Assets/Meshes/Chunk/Bioma_C/Chunk_C_E_1.fbx" id="1_hycya"]
[ext_resource type="Script" uid="uid://byluxssk112ca" path="res://Test_Procedurale/info_chunk.gd" id="2_0urj0"]
[ext_resource type="Script" uid="uid://byluxssk112ca" path="res://Scripts/info_chunk.gd" id="2_0urj0"]
[ext_resource type="Material" uid="uid://cit5uciejjoou" path="res://Materials/Grass_Chunk.tres" id="2_oixxl"]
[node name="Chunk_C_E_1" unique_id=1874739368 instance=ExtResource("1_hycya")]

View File

@@ -1,7 +1,7 @@
[gd_scene format=4 uid="uid://givg3dyrxsk5"]
[ext_resource type="PackedScene" uid="uid://d3loscamahf5y" path="res://Assets/Meshes/Chunk/Bioma_C/Chunk_C_E_1.fbx" id="1_jpp2r"]
[ext_resource type="Script" uid="uid://byluxssk112ca" path="res://Test_Procedurale/info_chunk.gd" id="2_02kkq"]
[ext_resource type="Script" uid="uid://byluxssk112ca" path="res://Scripts/info_chunk.gd" id="2_02kkq"]
[ext_resource type="Material" uid="uid://cit5uciejjoou" path="res://Materials/Grass_Chunk.tres" id="3_sf2c4"]
[ext_resource type="PackedScene" uid="uid://8jtrp8ckqf1a" path="res://Scenes/Chunk_Scene/House/House_muraglione.tscn" id="4_lunjj"]
[ext_resource type="PackedScene" uid="uid://5sod22d0vnip" path="res://Scenes/Chunk_Scene/House/House_XL_4.tscn" id="5_tf2ul"]

View File

@@ -1,7 +1,7 @@
[gd_scene format=3 uid="uid://birttctl11th8"]
[ext_resource type="PackedScene" uid="uid://deqp06tkp4orv" path="res://Assets/Meshes/Chunk/Bioma_C/Chunk_C_L_1.fbx" id="1_xwass"]
[ext_resource type="Script" uid="uid://byluxssk112ca" path="res://Test_Procedurale/info_chunk.gd" id="2_ib4lo"]
[ext_resource type="Script" uid="uid://byluxssk112ca" path="res://Scripts/info_chunk.gd" id="2_ib4lo"]
[ext_resource type="Material" uid="uid://cit5uciejjoou" path="res://Materials/Grass_Chunk.tres" id="3_3x6ti"]
[ext_resource type="Material" uid="uid://couj6glsrm6h3" path="res://Materials/Sentiero.tres" id="4_kwc5e"]
[ext_resource type="Material" uid="uid://cd34mgvhj1d0r" path="res://Materials/GrassBlockout.tres" id="5_ag87g"]

View File

@@ -1,7 +1,7 @@
[gd_scene format=3 uid="uid://badmwcxptjfvo"]
[ext_resource type="PackedScene" uid="uid://bign7y2duatrm" path="res://Assets/Meshes/Chunk/Bioma_C/Chunk_C_R_1.fbx" id="1_c6sxq"]
[ext_resource type="Script" uid="uid://byluxssk112ca" path="res://Test_Procedurale/info_chunk.gd" id="2_thhmo"]
[ext_resource type="Script" uid="uid://byluxssk112ca" path="res://Scripts/info_chunk.gd" id="2_thhmo"]
[ext_resource type="Material" uid="uid://cit5uciejjoou" path="res://Materials/Grass_Chunk.tres" id="3_0cnk2"]
[ext_resource type="Material" uid="uid://couj6glsrm6h3" path="res://Materials/Sentiero.tres" id="4_moww1"]
[ext_resource type="Material" uid="uid://df1ghvw3d61x8" path="res://Materials/Treno1.tres" id="5_ccs0r"]

View File

@@ -1,7 +1,7 @@
[gd_scene format=3 uid="uid://r7gp3qvjpehw"]
[ext_resource type="PackedScene" uid="uid://c7ax77lnixftt" path="res://Assets/Meshes/Chunk/Bioma_C/Chunk_C_T1_1.fbx" id="1_rjil6"]
[ext_resource type="Script" uid="uid://byluxssk112ca" path="res://Test_Procedurale/info_chunk.gd" id="2_2ckt0"]
[ext_resource type="Script" uid="uid://byluxssk112ca" path="res://Scripts/info_chunk.gd" id="2_2ckt0"]
[ext_resource type="Material" uid="uid://cit5uciejjoou" path="res://Materials/Grass_Chunk.tres" id="3_vcefh"]
[ext_resource type="Material" uid="uid://couj6glsrm6h3" path="res://Materials/Sentiero.tres" id="4_hu7g2"]
[ext_resource type="Material" uid="uid://df1ghvw3d61x8" path="res://Materials/Treno1.tres" id="5_dfedt"]

View File

@@ -1,7 +1,7 @@
[gd_scene format=3 uid="uid://b3l7mu5ompcb6"]
[ext_resource type="PackedScene" uid="uid://0fj7s2vhg2vl" path="res://Assets/Meshes/Chunk/Bioma_C/Chunk_C_T3_1.fbx" id="1_fgokx"]
[ext_resource type="Script" uid="uid://byluxssk112ca" path="res://Test_Procedurale/info_chunk.gd" id="2_bmm2h"]
[ext_resource type="Script" uid="uid://byluxssk112ca" path="res://Scripts/info_chunk.gd" id="2_bmm2h"]
[ext_resource type="Material" uid="uid://couj6glsrm6h3" path="res://Materials/Sentiero.tres" id="3_0yqxy"]
[ext_resource type="Material" uid="uid://cd34mgvhj1d0r" path="res://Materials/GrassBlockout.tres" id="4_umpqw"]

View File

@@ -1,7 +1,7 @@
[gd_scene format=3 uid="uid://cor3j8w3wewl5"]
[ext_resource type="PackedScene" uid="uid://bgbmyk84rks48" path="res://Assets/Meshes/Chunk/Bioma_C/Chunk_C_T3_2.fbx" id="1_d8gt8"]
[ext_resource type="Script" uid="uid://byluxssk112ca" path="res://Test_Procedurale/info_chunk.gd" id="2_ojveg"]
[ext_resource type="Script" uid="uid://byluxssk112ca" path="res://Scripts/info_chunk.gd" id="2_ojveg"]
[ext_resource type="Material" uid="uid://cit5uciejjoou" path="res://Materials/Grass_Chunk.tres" id="2_q2qw3"]
[ext_resource type="Material" uid="uid://couj6glsrm6h3" path="res://Materials/Sentiero.tres" id="3_ojveg"]
[ext_resource type="Material" uid="uid://cd34mgvhj1d0r" path="res://Materials/GrassBlockout.tres" id="4_qts5w"]

View File

@@ -1,7 +1,7 @@
[gd_scene format=3 uid="uid://bqc1txstk8y5v"]
[ext_resource type="PackedScene" uid="uid://bbe7lqa1ayf51" path="res://Assets/Meshes/Chunk/Bioma_C/Chunk_C_T3_3.fbx" id="1_ig2h0"]
[ext_resource type="Script" uid="uid://byluxssk112ca" path="res://Test_Procedurale/info_chunk.gd" id="2_o43cy"]
[ext_resource type="Script" uid="uid://byluxssk112ca" path="res://Scripts/info_chunk.gd" id="2_o43cy"]
[ext_resource type="Material" uid="uid://cit5uciejjoou" path="res://Materials/Grass_Chunk.tres" id="2_ywcu1"]
[ext_resource type="Material" uid="uid://couj6glsrm6h3" path="res://Materials/Sentiero.tres" id="3_o43cy"]
[ext_resource type="Material" uid="uid://cd34mgvhj1d0r" path="res://Materials/GrassBlockout.tres" id="4_o4cox"]

View File

@@ -2,7 +2,7 @@
[ext_resource type="PackedScene" uid="uid://bhpk5c2ydvf3m" path="res://Assets/Meshes/Chunk/Bioma_C/Chunk_C_X_1.fbx" id="1_voing"]
[ext_resource type="Material" uid="uid://cit5uciejjoou" path="res://Materials/Grass_Chunk.tres" id="2_0cv2v"]
[ext_resource type="Script" uid="uid://byluxssk112ca" path="res://Test_Procedurale/info_chunk.gd" id="2_oqrjr"]
[ext_resource type="Script" uid="uid://byluxssk112ca" path="res://Scripts/info_chunk.gd" id="2_oqrjr"]
[ext_resource type="Material" uid="uid://couj6glsrm6h3" path="res://Materials/Sentiero.tres" id="3_oqrjr"]
[ext_resource type="Material" uid="uid://cd34mgvhj1d0r" path="res://Materials/GrassBlockout.tres" id="4_kcdhn"]

View File

@@ -1,7 +1,7 @@
[gd_scene format=4 uid="uid://cpebna545ihfh"]
[ext_resource type="PackedScene" uid="uid://bxnd5v67eaypf" path="res://Assets/Meshes/Chunk/Bioma_C/Test_Chunk_C_L_2.fbx" id="1_sr7sh"]
[ext_resource type="Script" uid="uid://byluxssk112ca" path="res://Test_Procedurale/info_chunk.gd" id="2_5cl6b"]
[ext_resource type="Script" uid="uid://byluxssk112ca" path="res://Scripts/info_chunk.gd" id="2_5cl6b"]
[ext_resource type="Material" uid="uid://couj6glsrm6h3" path="res://Materials/Sentiero.tres" id="3_hj70d"]
[ext_resource type="Texture2D" uid="uid://3ot7glyivagg" path="res://Assets/Textures/Texture_Sentiero.png" id="4_g8efw"]
[ext_resource type="Material" uid="uid://cufolpn48xxmv" path="res://Materials/Treno2.tres" id="5_wgav2"]

View File

@@ -1,7 +1,7 @@
[gd_scene format=3 uid="uid://bi12g5nj421jv"]
[ext_resource type="PackedScene" uid="uid://d3loscamahf5y" path="res://Assets/Meshes/Chunk/Bioma_C/Chunk_C_E_1.fbx" id="1_anwxh"]
[ext_resource type="Script" uid="uid://byluxssk112ca" path="res://Test_Procedurale/info_chunk.gd" id="2_scq5d"]
[ext_resource type="Script" uid="uid://byluxssk112ca" path="res://Scripts/info_chunk.gd" id="2_scq5d"]
[ext_resource type="PackedScene" uid="uid://ddupqq1tx1jxu" path="res://Scenes/Test/Tree_Sad.tscn" id="4_cdmr2"]
[ext_resource type="PackedScene" uid="uid://d12t04rs47jq3" path="res://Scenes/Test/Tree_V1.tscn" id="5_vyg4h"]

View File

@@ -1,7 +1,7 @@
[gd_scene format=4 uid="uid://boxnrd3pwpjx5"]
[ext_resource type="PackedScene" uid="uid://d3loscamahf5y" path="res://Assets/Meshes/Chunk/Bioma_C/Chunk_C_E_1.fbx" id="1_453cn"]
[ext_resource type="Script" uid="uid://byluxssk112ca" path="res://Test_Procedurale/info_chunk.gd" id="2_fas56"]
[ext_resource type="Script" uid="uid://byluxssk112ca" path="res://Scripts/info_chunk.gd" id="2_fas56"]
[ext_resource type="Material" uid="uid://cit5uciejjoou" path="res://Materials/Grass_Chunk.tres" id="3_kllpc"]
[ext_resource type="PackedScene" uid="uid://8jtrp8ckqf1a" path="res://Scenes/Chunk_Scene/House/House_muraglione.tscn" id="4_kg6th"]
[ext_resource type="PackedScene" uid="uid://5sod22d0vnip" path="res://Scenes/Chunk_Scene/House/House_XL_4.tscn" id="5_gvooa"]

View File

@@ -1,7 +1,7 @@
[gd_scene format=3 uid="uid://uc4lteo7ebjb"]
[ext_resource type="PackedScene" uid="uid://deqp06tkp4orv" path="res://Assets/Meshes/Chunk/Bioma_C/Chunk_C_L_1.fbx" id="1_t2h3f"]
[ext_resource type="Script" uid="uid://byluxssk112ca" path="res://Test_Procedurale/info_chunk.gd" id="2_mx3ua"]
[ext_resource type="Script" uid="uid://byluxssk112ca" path="res://Scripts/info_chunk.gd" id="2_mx3ua"]
[ext_resource type="Material" uid="uid://couj6glsrm6h3" path="res://Materials/Sentiero.tres" id="4_l5m85"]
[ext_resource type="Material" uid="uid://cd34mgvhj1d0r" path="res://Materials/GrassBlockout.tres" id="5_l352o"]

View File

@@ -1,7 +1,7 @@
[gd_scene format=3 uid="uid://51n0mv0hpnu0"]
[ext_resource type="PackedScene" uid="uid://bign7y2duatrm" path="res://Assets/Meshes/Chunk/Bioma_C/Chunk_C_R_1.fbx" id="1_w4ilb"]
[ext_resource type="Script" uid="uid://byluxssk112ca" path="res://Test_Procedurale/info_chunk.gd" id="2_0ctfe"]
[ext_resource type="Script" uid="uid://byluxssk112ca" path="res://Scripts/info_chunk.gd" id="2_0ctfe"]
[ext_resource type="Material" uid="uid://couj6glsrm6h3" path="res://Materials/Sentiero.tres" id="4_tgve8"]
[ext_resource type="Material" uid="uid://df1ghvw3d61x8" path="res://Materials/Treno1.tres" id="5_e2fgg"]
[ext_resource type="Material" uid="uid://cd34mgvhj1d0r" path="res://Materials/GrassBlockout.tres" id="6_iyerk"]

View File

@@ -1,7 +1,7 @@
[gd_scene format=3 uid="uid://c0trecscea4xr"]
[ext_resource type="PackedScene" uid="uid://c7ax77lnixftt" path="res://Assets/Meshes/Chunk/Bioma_C/Chunk_C_T1_1.fbx" id="1_i7r44"]
[ext_resource type="Script" uid="uid://byluxssk112ca" path="res://Test_Procedurale/info_chunk.gd" id="2_177li"]
[ext_resource type="Script" uid="uid://byluxssk112ca" path="res://Scripts/info_chunk.gd" id="2_177li"]
[ext_resource type="Material" uid="uid://couj6glsrm6h3" path="res://Materials/Sentiero.tres" id="4_gocca"]
[ext_resource type="Material" uid="uid://df1ghvw3d61x8" path="res://Materials/Treno1.tres" id="5_u17b2"]
[ext_resource type="Material" uid="uid://cd34mgvhj1d0r" path="res://Materials/GrassBlockout.tres" id="6_iaosl"]

View File

@@ -1,7 +1,7 @@
[gd_scene format=3 uid="uid://bkgfmga5y03wo"]
[ext_resource type="PackedScene" uid="uid://0fj7s2vhg2vl" path="res://Assets/Meshes/Chunk/Bioma_C/Chunk_C_T3_1.fbx" id="1_4jfhy"]
[ext_resource type="Script" uid="uid://byluxssk112ca" path="res://Test_Procedurale/info_chunk.gd" id="2_0bnc8"]
[ext_resource type="Script" uid="uid://byluxssk112ca" path="res://Scripts/info_chunk.gd" id="2_0bnc8"]
[ext_resource type="Material" uid="uid://couj6glsrm6h3" path="res://Materials/Sentiero.tres" id="3_vf36v"]
[ext_resource type="Material" uid="uid://cd34mgvhj1d0r" path="res://Materials/GrassBlockout.tres" id="4_vlk7m"]

View File

@@ -1,7 +1,7 @@
[gd_scene format=3 uid="uid://doa52qwel85w3"]
[ext_resource type="PackedScene" uid="uid://bgbmyk84rks48" path="res://Assets/Meshes/Chunk/Bioma_C/Chunk_C_T3_2.fbx" id="1_u7do2"]
[ext_resource type="Script" uid="uid://byluxssk112ca" path="res://Test_Procedurale/info_chunk.gd" id="2_ruqbe"]
[ext_resource type="Script" uid="uid://byluxssk112ca" path="res://Scripts/info_chunk.gd" id="2_ruqbe"]
[ext_resource type="Material" uid="uid://couj6glsrm6h3" path="res://Materials/Sentiero.tres" id="4_dkigq"]
[ext_resource type="Material" uid="uid://cd34mgvhj1d0r" path="res://Materials/GrassBlockout.tres" id="5_j3d8l"]
[ext_resource type="Material" uid="uid://df1ghvw3d61x8" path="res://Materials/Treno1.tres" id="6_5nlrv"]

View File

@@ -1,7 +1,7 @@
[gd_scene format=3 uid="uid://d16askvk5gdjy"]
[ext_resource type="PackedScene" uid="uid://bbe7lqa1ayf51" path="res://Assets/Meshes/Chunk/Bioma_C/Chunk_C_T3_3.fbx" id="1_b25ct"]
[ext_resource type="Script" uid="uid://byluxssk112ca" path="res://Test_Procedurale/info_chunk.gd" id="2_t8uks"]
[ext_resource type="Script" uid="uid://byluxssk112ca" path="res://Scripts/info_chunk.gd" id="2_t8uks"]
[ext_resource type="Material" uid="uid://couj6glsrm6h3" path="res://Materials/Sentiero.tres" id="4_3l5th"]
[ext_resource type="Material" uid="uid://cd34mgvhj1d0r" path="res://Materials/GrassBlockout.tres" id="5_3xark"]
[ext_resource type="Material" uid="uid://cufolpn48xxmv" path="res://Materials/Treno2.tres" id="6_ckigp"]

View File

@@ -1,7 +1,7 @@
[gd_scene format=3 uid="uid://c7tntbuu6xauu"]
[ext_resource type="PackedScene" uid="uid://bhpk5c2ydvf3m" path="res://Assets/Meshes/Chunk/Bioma_C/Chunk_C_X_1.fbx" id="1_krvni"]
[ext_resource type="Script" uid="uid://byluxssk112ca" path="res://Test_Procedurale/info_chunk.gd" id="2_8bqar"]
[ext_resource type="Script" uid="uid://byluxssk112ca" path="res://Scripts/info_chunk.gd" id="2_8bqar"]
[ext_resource type="Material" uid="uid://couj6glsrm6h3" path="res://Materials/Sentiero.tres" id="4_d4n6v"]
[ext_resource type="Material" uid="uid://cd34mgvhj1d0r" path="res://Materials/GrassBlockout.tres" id="5_dss04"]

View File

@@ -1,113 +0,0 @@
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);
}

View File

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

View File

@@ -2,13 +2,16 @@
[ext_resource type="Script" uid="uid://dcaxomfkulrig" path="res://Scripts/Day_night_Cycle.gd" id="1_cr3ar"]
[ext_resource type="Material" uid="uid://dknvdsov2jrg6" path="res://Materials/Fog.tres" id="2_4xv0h"]
[ext_resource type="Material" uid="uid://cwbxvmtih5wsc" path="res://Materials/GodRays.tres" id="2_vpybn"]
[ext_resource type="Material" uid="uid://7bu5f4o0v8vw" path="res://Materials/Rain.tres" id="3_4wepm"]
[ext_resource type="Material" uid="uid://cknq8qhom7ral" path="res://Materials/ShadowPostProcess.tres" id="4_00nhk"]
[ext_resource type="Texture2D" uid="uid://v4gyjc8j7ygj" path="res://Assets/Textures/Lightingl.png" id="4_gffi5"]
[ext_resource type="Shader" uid="uid://l6rkqonic7dj" path="res://Shaders/Sky.gdshader" id="5_bedag"]
[ext_resource type="FastNoiseLite" uid="uid://c0mtwrkptjcuw" path="res://Assets/Textures/Noise_Clouds.tres" id="6_00nhk"]
[ext_resource type="Texture2D" uid="uid://dxahudyvihk8b" path="res://Assets/Textures/Stars.png" id="6_jawsd"]
[ext_resource type="Script" uid="uid://brcimd12tx3dm" path="res://Scripts/edge_detection_compositor.gd" id="7_4xv0h"]
[ext_resource type="Texture2D" uid="uid://dey5onb6mwp3f" path="res://Assets/Textures/leaf_particle.png" id="7_vufuq"]
[ext_resource type="Script" uid="uid://c5xr1w2tvcxl1" path="res://Scenes/generatore_bioma.gd" id="8_7j5hj"]
[ext_resource type="Script" uid="uid://c5xr1w2tvcxl1" path="res://Scripts/generatore_bioma.gd" id="8_7j5hj"]
[ext_resource type="Script" uid="uid://b8x6nf7u6iopv" path="res://Scripts/CameraMove.gd" id="8_17jdd"]
[ext_resource type="PackedScene" uid="uid://bx2amm4q66ei" path="res://Scenes/MainMap.tscn" id="8_bedag"]
[ext_resource type="Script" uid="uid://bhdoxc2oak88u" path="res://Scripts/palette_manager.gd" id="8_gffi5"]
@@ -58,13 +61,8 @@
[ext_resource type="PackedScene" uid="uid://bhcut7ndtdo2w" path="res://Assets/Test/SK_Mannequin.FBX" id="34_3nw1o"]
[ext_resource type="PackedScene" uid="uid://xebpudhewwwj" path="res://Scenes/Chunk_Scene/Chunk/Campagna/Chunk_C_L_2.tscn" id="35_n33lw"]
[sub_resource type="FastNoiseLite" id="FastNoiseLite_jfpsf"]
fractal_lacunarity = 1.915
fractal_gain = 0.53
fractal_weighted_strength = 0.35
[sub_resource type="NoiseTexture2D" id="NoiseTexture2D_10fbe"]
noise = SubResource("FastNoiseLite_jfpsf")
noise = ExtResource("6_00nhk")
seamless = true
[sub_resource type="ShaderMaterial" id="ShaderMaterial_h0pi8"]
@@ -130,6 +128,9 @@ metadata/_custom_type_script = "uid://brcimd12tx3dm"
[sub_resource type="Compositor" id="Compositor_17jdd"]
compositor_effects = Array[CompositorEffect]([SubResource("CompositorEffect_vufuq")])
[sub_resource type="QuadMesh" id="QuadMesh_00nhk"]
size = Vector2(2, 2)
[sub_resource type="Curve" id="Curve_o35ae"]
_limits = [-360.0, 360.0, 0.0, 1.0]
_data = [Vector2(0, 1), 0.0, 0.0, 0, 0, Vector2(1, 1), 0.0, 0.0, 0, 0]
@@ -229,6 +230,9 @@ material = SubResource("ShaderMaterial_gpe07")
subdivide_depth = 3
orientation = 1
[sub_resource type="PlaneMesh" id="PlaneMesh_vpybn"]
size = Vector2(2, 10)
[sub_resource type="ParticleProcessMaterial" id="ParticleProcessMaterial_qqnw7"]
particle_flag_align_y = true
emission_shape_scale = Vector3(70, 70, 70)
@@ -247,12 +251,13 @@ material = ExtResource("3_4wepm")
size = Vector2(0.05, 1)
[sub_resource type="Curve3D" id="Curve3D_bedag"]
closed = true
bake_interval = 50.0
_data = {
"points": PackedVector3Array(0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 20, 0, 0, 0, 0, 0, 0, 0, 0, 40, 0, 0, 0, 0, 0, 0, 0, 0, 60, 0, 0, 0, 0, 0, 0, 0, 0, 80, 0, 0, 0, 0, 0, 0, 0, 0, 100, 0, 0, 0, 0, 0, 0, 0, 0, 120, 0, 0, 0, 0, 0, 0, -4.372, 0, 140, 0, 0, 0, 0, 0, 0, -20.963, 0, 160, 0, 0, 0, 0, 0, 0, -40.62518, 0, 168.52754, 0, 0, 0, 0, 0, 0, -60, 0, 170, 0, 0, 0, 0, 0, 0, -80, 0, 170, 0, 0, 0, 0, 0, 0, -100, 0, 170, 0, 0, 0, 0, 0, 0, -120.42937, 0, 171.50279, 0, 0, 0, 0, 0, 0, -141.41747, 7.6293945e-06, 180.5982, 0, 0, 0, 0, 0, 0, -155.77005, 7.6293945e-06, 198.35184, 0, 0, 0, 0, 0, 0, -160.14105, 7.6293945e-06, 219.80951, 0, 0, 0, 0, 0, 0, -163.99007, 7.6293945e-06, 239.36005, 0, 0, 0, 0, 0, 0, -175.77509, 7.6293945e-06, 256.16028, 0, 0, 0, 0, 0, 0, -195.62283, 7.6293945e-06, 267.46912, 0, 0, 0, 0, 0, 0, -219.9999, 7.6293945e-06, 270.11758, 0, 0, 0, 0, 0, 0, -240, 0, 270.118, 0, 0, 0, 0, 0, 0, -260, 0, 270.118, 0, 0, 0, 0, 0, 0, -275.19666, 7.6293945e-06, 270.55228, 0, 0, 0, 0, 0, 0, -294.2925, 7.6293945e-06, 276.05307, 0, 0, 0, 0, 0, 0, -307.19006, 7.6293945e-06, 286.9095, 0, 0, 0, 0, 0, 0, -317.32443, 7.6293945e-06, 303.14682, 0, 0, 0, 0, 0, 0, -320, 0, 320, 0, 0, 0, 0, 0, 0, -320, 0, 340, 0, 0, 0, 0, 0, 0, -320, 0, 360, 0, 0, 0, 0, 0, 0, -320, 0, 380, 0, 0, 0, 0, 0, 0, -316.78876, 7.6293945e-06, 396.91193, 0, 0, 0, 0, 0, 0, -307.68207, 7.6293945e-06, 412.70596, 0, 0, 0, 0, 0, 0, -291.08273, 7.6293945e-06, 424.7491, 0, 0, 0, 0, 0, 0, -270, 0, 429.994, 0, 0, 0, 0, 0, 0, -250, 0, 429.994),
"tilts": PackedFloat32Array(0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0)
"points": PackedVector3Array(0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 20, 0, 0, 0, 0, 0, 0, 0, 0, 40, 0, 0, 0, 0, 0, 0, 0, 0, 60, 0, 0, 0, 0, 0, 0, 0, 0, 80, 0, 0, 0, 0, 0, 0, 0, 0, 100, 0, 0, 0, 0, 0, 0, 0, 0, 120, 0, 0, 0, 0, 0, 0, -4.372, 0, 140, 0, 0, 0, 0, 0, 0, -20.963, 0, 160, 0, 0, 0, 0, 0, 0, -40.62518, 0, 168.52754, 0, 0, 0, 0, 0, 0, -60, 0, 170, 0, 0, 0, 0, 0, 0, -80, 0, 170, 0, 0, 0, 0, 0, 0, -100, 0, 170, 0, 0, 0, 0, 0, 0, -120.42937, 0, 171.50279, 0, 0, 0, 0, 0, 0, -141.41747, 7.6293945e-06, 180.5982, 0, 0, 0, 0, 0, 0, -155.77005, 7.6293945e-06, 198.35184, 0, 0, 0, 0, 0, 0, -160.14105, 7.6293945e-06, 219.80951, 0, 0, 0, 0, 0, 0, -163.99007, 7.6293945e-06, 239.36005, 0, 0, 0, 0, 0, 0, -175.77509, 7.6293945e-06, 256.16028, 0, 0, 0, 0, 0, 0, -195.62283, 7.6293945e-06, 267.46912, 0, 0, 0, 0, 0, 0, -219.9999, 7.6293945e-06, 270.11758, 0, 0, 0, 0, 0, 0, -240, 0, 270.118, 0, 0, 0, 0, 0, 0, -260, 0, 270.118, 0, 0, 0, 0, 0, 0, -275.19666, 7.6293945e-06, 270.55228, 0, 0, 0, 0, 0, 0, -294.2925, 7.6293945e-06, 276.05307, 0, 0, 0, 0, 0, 0, -307.19006, 7.6293945e-06, 286.9095, 0, 0, 0, 0, 0, 0, -317.32443, 7.6293945e-06, 303.14682, 0, 0, 0, 0, 0, 0, -320, 0, 320, 0, 0, 0, 0, 0, 0, -320, 0, 340, 0, 0, 0, 0, 0, 0, -320, 0, 360, 0, 0, 0, 0, 0, 0, -320, 0, 380, 0, 0, 0, 0, 0, 0, -316.78876, 7.6293945e-06, 396.91193, 0, 0, 0, 0, 0, 0, -307.68207, 7.6293945e-06, 412.70596, 0, 0, 0, 0, 0, 0, -291.08273, 7.6293945e-06, 424.7491, 0, 0, 0, 0, 0, 0, -270, 0, 429.994, 0, 0, 0, 0, 0, 0, -250, 0, 429.994, 0, 0, 0, 0, 0, 0, -229.90146, 7.6293945e-06, 433.90823, 0, 0, 0, 0, 0, 0, -217.15442, 7.6293945e-06, 442.98242, 0, 0, 0, 0, 0, 0, -204.60803, 7.6293945e-06, 459.93704, 0, 0, 0, 0, 0, 0, -200, 0, 480, 0, 0, 0, 0, 0, 0, -200, 0, 500, 0, 0, 0, 0, 0, 0, -195.5338, 7.6293945e-06, 520.0368, 0, 0, 0, 0, 0, 0, -184.9173, 7.6293945e-06, 535.07776, 0, 0, 0, 0, 0, 0, -170.36423, 7.6293945e-06, 545.0799, 0, 0, 0, 0, 0, 0, -150.56184, 0, 549.8127, 0, 0, 0, 0, 0, 0, -130, 0, 550, 0, 0, 0, 0, 0, 0, -110, 0, 550, 0, 0, 0, 0, 0, 0, -90, 0, 550, 0, 0, 0, 0, 0, 0, -70, 0, 550, 0, 0, 0, 0, 0, 0, -50, 0, 550, 0, 0, 0, 0, 0, 0, -29.862535, 7.6293945e-06, 545.3371, 0, 0, 0, 0, 0, 0, -13.215244, 7.6293945e-06, 533.0626, 0, 0, 0, 0, 0, 0, -4.098665, 7.6293945e-06, 519.6814, 0, 0, 0, 0, 0, 0, -0.048213482, 7.6293945e-06, 500.107, 0, 0, 0, 0, 0, 0, 3.7920675, 7.6293945e-06, 480.64902, 0, 0, 0, 0, 0, 0, 13.513225, 7.6293945e-06, 465.9133, 0, 0, 0, 0, 0, 0, 29.76715, 7.6293945e-06, 454.41486, 0, 0, 0, 0, 0, 0, 49.711926, 7.6293945e-06, 450.12488, 0, 0, 0, 0, 0, 0, 70, 0, 450, 0, 0, 0, 0, 0, 0, 90, 0, 450, 0, 0, 0, 0, 0, 0, 110.055405, 7.6293945e-06, 445.42627, 0, 0, 0, 0, 0, 0, 126.975784, 7.6293945e-06, 432.8683, 0, 0, 0, 0, 0, 0, 136.95703, 7.6293945e-06, 417.5506, 0, 0, 0, 0, 0, 0, 140, 0, 400, 0, 0, 0, 0, 0, 0, 140, 0, 380, 0, 0, 0, 0, 0, 0, 140, 0, 360, 0, 0, 0, 0, 0, 0, 140, 0, 340, 0, 0, 0, 0, 0, 0, 140, 0, 320, 0, 0, 0, 0, 0, 0, 140, 0, 300, 0, 0, 0, 0, 0, 0, 140, 0, 280, 0, 0, 0, 0, 0, 0, 140, 0, 260, 0, 0, 0, 0, 0, 0, 140, 0, 240, 0, 0, 0, 0, 0, 0, 140, 0, 220, 0, 0, 0, 0, 0, 0, 140, 0, 200, 0, 0, 0, 0, 0, 0, 140, 0, 180, 0, 0, 0, 0, 0, 0, 140, 0, 160, 0, 0, 0, 0, 0, 0, 140, 0, 140, 0, 0, 0, 0, 0, 0, 140, 0, 120, 0, 0, 0, 0, 0, 0, 140, 0, 100, 0, 0, 0, 0, 0, 0, 140, 0, 80, 0, 0, 0, 0, 0, 0, 140, 0, 60, 0, 0, 0, 0, 0, 0, 140, 0, 40, 0, 0, 0, 0, 0, 0, 140, 0, 20, 0, 0, 0, 0, 0, 0, 140, 0, 0, 0, 0, 0, 0, 0, 0, 136.2151, 7.6293945e-06, -18.930761, 0, 0, 0, 0, 0, 0, 124.47424, 7.6293945e-06, -35.771675, 0, 0, 0, 0, 0, 0, 109.556854, 7.6293945e-06, -45.911987, 0, 0, 0, 0, 0, 0, 90, 0, -50, 0, 0, 0, 0, 0, 0, 70, 0, -50, 0, 0, 0, 0, 0, 0, 50, 0, -50, 0, 0, 0, 0, 0, 0, 30.626865, 7.6293945e-06, -46.35706, 0, 0, 0, 0, 0, 0, 14.519331, 7.6293945e-06, -35.468895, 0, 0, 0, 0, 0, 0, 3.52941, 7.6293945e-06, -19.590664),
"tilts": PackedFloat32Array(0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0)
}
point_count = 36
point_count = 93
[sub_resource type="PlaneMesh" id="PlaneMesh_gsfny"]
@@ -679,6 +684,12 @@ sky_horizon_pomeriggio = Color(0.58704865, 0.36022854, 0.09941775, 1)
energia_luce_notte = 0.998
materiale_nebbia = ExtResource("2_4xv0h")
materiale_pioggia_gocce = ExtResource("3_4wepm")
materiale_nuvole = ExtResource("4_00nhk")
colore_fulmine = Color(0.99999946, 0.9857114, 0.46342158, 1)
fulmini_min = 2
fulmini_max = 4
scala_min_fulmine = 2.0
scala_max_fulmine = 5.0
[node name="CanvasLayer" type="CanvasLayer" parent="." unique_id=427161585]
@@ -699,13 +710,6 @@ grow_vertical = 0
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, -21.428604, -6.3361816, 43.268837)
size = Vector3(51.92697, 11.827637, 85.98999)
[node name="SpriteFulmine" type="Sprite3D" parent="." unique_id=1820121693]
transform = Transform3D(4, 0, 0, 0, 7.32, 0, 0, 0, 7.3, 0, 17.324, 30.411049)
modulate = Color(1, 1, 1, 0)
billboard = 2
alpha_cut = 1
texture = ExtResource("4_gffi5")
[node name="LuceLampo" type="DirectionalLight3D" parent="." unique_id=2067456343]
transform = Transform3D(-0.6238797, -0.342596, 0.7024259, 0, 0.89879405, 0.43837115, -0.7815204, 0.27349085, -0.56073934, 0, 0, 30.411049)
light_color = Color(0.8, 1, 1, 1)
@@ -716,7 +720,7 @@ shadow_enabled = true
transform = Transform3D(0.4848096, 0.6108477, 0.62595904, -6.256785e-08, -0.71569276, 0.6984152, 0.8746197, -0.33859846, -0.34697473, 0, 4.540125, 24.469929)
shadow_enabled = true
shadow_bias = 0.2
shadow_opacity = 0.9
shadow_opacity = 0.8
shadow_blur = 0.0
directional_shadow_mode = 0
directional_shadow_fade_start = 0.9
@@ -746,11 +750,17 @@ render_target_update_mode = 4
[node name="World" type="Node3D" parent="SubViewportContainer/SubViewport" unique_id=735268770]
[node name="FiltroOmbreGlobali" type="MeshInstance3D" parent="SubViewportContainer/SubViewport/World" unique_id=605840663]
extra_cull_margin = 16384.0
mesh = SubResource("QuadMesh_00nhk")
surface_material_override/0 = ExtResource("4_00nhk")
[node name="GeneratoreBioma" type="Node3D" parent="SubViewportContainer/SubViewport/World" unique_id=757461529 node_paths=PackedStringArray("path_treno")]
script = ExtResource("8_7j5hj")
path_treno = NodePath("../Path3D")
bioma_campagna = Array[PackedScene]([ExtResource("9_u10x4"), ExtResource("10_l1dl0"), ExtResource("35_n33lw"), ExtResource("12_kjb07"), ExtResource("13_on20a"), ExtResource("14_6k3cw"), ExtResource("15_16mw0"), ExtResource("16_qdxup"), ExtResource("17_tbvi6")])
bioma_foresta = Array[PackedScene]([ExtResource("18_4udcq"), ExtResource("19_vj0n5"), ExtResource("20_00nhk"), ExtResource("21_vpybn"), ExtResource("22_5lko7"), ExtResource("23_j2rq4"), ExtResource("24_eyx0r"), ExtResource("25_vmtna"), ExtResource("26_am4st")])
scala_distretti = 0.08
[node name="MainMap" parent="SubViewportContainer/SubViewport/World" unique_id=1895741703 instance=ExtResource("8_bedag")]
transform = Transform3D(-4.371139e-08, 0, 1, 0, 1, 0, -1, 0, -4.371139e-08, 0, 0, 0)
@@ -781,6 +791,20 @@ draw_pass_1 = SubResource("QuadMesh_twefy")
[node name="Camere" type="Node3D" parent="SubViewportContainer/SubViewport/World" unique_id=1348180511]
[node name="MeshInstance3D" type="MeshInstance3D" parent="SubViewportContainer/SubViewport/World/Camere" unique_id=70247470]
transform = Transform3D(2.9879434, -2.3589852, 4.245042, -2.4571407, -1.9655121e-07, 5.760314, -1.0171789, -6.929473, -1.4451305, 18.895258, 25.821028, 0)
visible = false
mesh = SubResource("PlaneMesh_vpybn")
skeleton = NodePath("../SpriteFulmine")
surface_material_override/0 = ExtResource("2_vpybn")
[node name="SpriteFulmine" type="Sprite3D" parent="SubViewportContainer/SubViewport/World/Camere" unique_id=1820121693]
transform = Transform3D(4, 0, 0, 0, 7.32, 0, 0, 0, 7.3, 0, 17.324, 30.411049)
modulate = Color(1, 1, 1, 0)
billboard = 2
alpha_cut = 1
texture = ExtResource("4_gffi5")
[node name="PioggiaCadente" type="GPUParticles3D" parent="SubViewportContainer/SubViewport/World/Camere" unique_id=1150140046]
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 0, 30.411049)
cast_shadow = 0
@@ -791,7 +815,7 @@ process_material = SubResource("ParticleProcessMaterial_qqnw7")
draw_pass_1 = SubResource("QuadMesh_54p3t")
[node name="CameraFrontale" type="Camera3D" parent="SubViewportContainer/SubViewport/World/Camere" unique_id=1311130431]
transform = Transform3D(-1, 0, 8.742278e-08, 0, 1, 0, -8.742278e-08, 0, -1, 0, 2.55, 7.5862045)
transform = Transform3D(-1, 0, 8.742278e-08, 0, 1, 0, -8.742278e-08, 0, -1, 0, 2.55, 7.102539)
fov = 86.0
size = 8.692
near = 0.001
@@ -805,12 +829,12 @@ near = 0.001
far = 5000.0
[node name="CameraLaterale" type="Camera3D" parent="SubViewportContainer/SubViewport/World/Camere" unique_id=1451175697]
transform = Transform3D(-0.18395132, 0, 0.98293537, 0, 1, 0, -0.98293537, 0, -0.18395132, -0.68400574, 2.257, 2.8508348)
transform = Transform3D(-0.18395132, 0, 0.98293537, 0, 1, 0, -0.98293537, 0, -0.18395132, -0.57942104, 2.257, 2.7764177)
fov = 60.0
size = 8.692
[node name="CameraLaterale2" type="Camera3D" parent="SubViewportContainer/SubViewport/World/Camere" unique_id=1248525079]
transform = Transform3D(-4.371139e-08, 0.005235964, -0.9999863, 0, 0.9999863, 0.005235964, 1, 2.2887126e-10, -4.3710788e-08, 0.41860962, 2.207, 2.814024)
transform = Transform3D(-4.371139e-08, 0.005235964, -0.9999863, 0, 0.9999863, 0.005235964, 1, 2.2887126e-10, -4.3710788e-08, 0.89004993, 2.207, 2.814024)
fov = 96.6
size = 15.0
far = 5000.0
@@ -876,7 +900,7 @@ skeleton = NodePath("../../../../..")
surface_material_override/0 = ExtResource("2_4xv0h")
[node name="MeshInstance3D24" type="MeshInstance3D" parent="SubViewportContainer/SubViewport/World/Fog" unique_id=1013039618]
transform = Transform3D(-0.0005423392, -0.37123534, 6.900085e-09, -5.620008e-23, -1.6227206e-08, -0.15785554, 1.0714161, -0.00018791536, 3.4927482e-12, -0.17415822, 0.027557772, 2.2087526)
transform = Transform3D(-0.0005423392, -0.37123534, 6.900085e-09, -5.620008e-23, -1.6227206e-08, -0.15785554, 1.0714161, -0.00018791536, 3.4927482e-12, -0.11607209, 0.027557772, 2.2087526)
mesh = SubResource("PlaneMesh_gsfny")
skeleton = NodePath("../../../../..")
surface_material_override/0 = ExtResource("2_4xv0h")
@@ -1042,7 +1066,7 @@ skeleton = NodePath("../../../../..")
surface_material_override/0 = SubResource("ShaderMaterial_xjipq")
[node name="MeshInstance3D17" type="MeshInstance3D" parent="SubViewportContainer/SubViewport/World/Fondali" unique_id=969086818]
transform = Transform3D(-0.01834004, 0, 1.0015494, 0, 0.08176457, 0, -0.2723837, 0, -0.06743593, 0.0008721038, -0.34356952, 0.57443184)
transform = Transform3D(-0.01834004, 0, 1.0015494, 0, 0.08176457, 0, -0.27238372, 0, -0.067435935, 0.08823083, -0.34356952, 0.57443184)
mesh = SubResource("QuadMesh_jfpsf")
skeleton = NodePath("../../../../..")
surface_material_override/0 = SubResource("ShaderMaterial_xjipq")

View File

@@ -1,29 +0,0 @@
extends Camera3D
@export var pixel_art_resolution := Vector2(320, 180) # Change to your low-res viewport size
func _process(_delta: float) -> void:
if projection != Camera3D.PROJECTION_ORTHOGONAL:
push_warning("Camera snapping script requires Orthogonal projection!")
return
# 1. Reset offsets to 0 first so they don't compound from the last frame
h_offset = 0.0
v_offset = 0.0
# 2. Get the exact 2D screen position of the camera's 3D origin
var exact_screen_pos := unproject_position(global_position)
# 3. Find the nearest perfect integer pixel coordinate
var snapped_screen_pos := exact_screen_pos.round()
# 4. Calculate the sub-pixel difference (the floating-point remainder)
var subpixel_diff := exact_screen_pos - snapped_screen_pos
# 5. Convert 1 pixel into 3D world units based on your orthogonal size
var units_per_pixel: float = size / pixel_art_resolution.y
# 6. Counteract the movement by shifting the camera's rendering frustum
# (Y is inverted because Godot's 2D screen Y goes down, but 3D world Y goes up)
h_offset = subpixel_diff.x * units_per_pixel
v_offset = -subpixel_diff.y * units_per_pixel

View File

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

View File

@@ -1,240 +0,0 @@
extends Node3D
@export_group("Riferimenti Base")
@export var path_treno: Path3D
@export_group("I 3 Biomi Principali")
@export var bioma_campagna: Array[PackedScene]
@export var bioma_foresta: Array[PackedScene]
@export var bioma_altro: Array[PackedScene]
@export_group("Impostazioni Griglia e Aree")
@export var dimensione_chunk: float = 20.0
@export var raggio_visivo: int = 3
@export var scala_distretti: float = 0.05
var scacchiera: Dictionary = {}
var ultima_pos_griglia_treno: Vector2i = Vector2i(999999, 999999)
var generatore_rumore: FastNoiseLite
# Variabile per il Toggle del terzo bioma
var usa_terzo_bioma: bool = true
func _ready() -> void:
if bioma_campagna.is_empty() or path_treno == null:
print("❌ ERRORE: Assegna almeno il 'Bioma Campagna' e il 'Path Treno' nell'Inspector!")
return
generatore_rumore = FastNoiseLite.new()
generatore_rumore.noise_type = FastNoiseLite.TYPE_PERLIN
generatore_rumore.seed = randi()
generatore_rumore.frequency = scala_distretti
print("✅ Generatore a Distretti Dinamici Pronto.")
print("Premere il tasto 'B' per abilitare/disabilitare il terzo bioma.")
func _input(event: InputEvent) -> void:
if event is InputEventKey and event.pressed and not event.echo:
if event.keycode == KEY_B:
usa_terzo_bioma = !usa_terzo_bioma
if usa_terzo_bioma:
print("🌍 Terzo Bioma: ATTIVATO")
else:
print("🌍 Terzo Bioma: DISATTIVATO (La mappa si ferma alla Foresta)")
func _physics_process(_delta: float) -> void:
if path_treno == null or path_treno.treno_istanziato == null: return
var pos_treno = path_treno.treno_istanziato.global_position
var grid_x = roundi(pos_treno.x / dimensione_chunk)
var grid_z = roundi(pos_treno.z / dimensione_chunk)
var pos_attuale = Vector2i(grid_x, grid_z)
if pos_attuale != ultima_pos_griglia_treno:
ultima_pos_griglia_treno = pos_attuale
_genera_attorno_al_treno(pos_attuale)
# Accendiamo il GPS
_radar_bioma_treno()
func _genera_attorno_al_treno(centro: Vector2i) -> void:
for x in range(-raggio_visivo, raggio_visivo + 1):
for z in range(-raggio_visivo, raggio_visivo + 1):
var pos_griglia = centro + Vector2i(x, z)
if not scacchiera.has(pos_griglia):
var ce_ostacolo = _registra_cella_con_laser(pos_griglia)
if not ce_ostacolo:
_piazza_bioma_compatibile(pos_griglia)
# --- SCELTA DEI CATALOGHI CON IL 50/50 MATEMATICO ---
func _scegli_catalogo_per_cella(pos_griglia: Vector2i) -> Array[PackedScene]:
var valore = generatore_rumore.get_noise_2d(pos_griglia.x, pos_griglia.y)
var nome_bioma_scelto = _get_nome_bioma(valore)
var catalogo_scelto: Array[PackedScene] = []
if nome_bioma_scelto == "Campagna":
catalogo_scelto = bioma_campagna
elif nome_bioma_scelto == "Misto Campagna-Foresta":
# Lancia la moneta: 50% Campagna, 50% Foresta
catalogo_scelto = bioma_campagna if randf() > 0.5 else bioma_foresta
elif nome_bioma_scelto == "Foresta":
catalogo_scelto = bioma_foresta
elif nome_bioma_scelto == "Misto Foresta-Altro":
# Lancia la moneta: 50% Foresta, 50% Altro
catalogo_scelto = bioma_foresta if randf() > 0.5 else bioma_altro
else:
catalogo_scelto = bioma_altro
if catalogo_scelto.is_empty():
catalogo_scelto = bioma_campagna
nome_bioma_scelto += " (FALLBACK)"
print("🌱 Generato: [", nome_bioma_scelto, "] in cella ", pos_griglia)
return catalogo_scelto
# --- IL LASER INTELLIGENTE ---
func _registra_cella_con_laser(pos_griglia: Vector2i) -> bool:
if scacchiera.has(pos_griglia): return true
var pos_mondo = Vector3(pos_griglia.x * dimensione_chunk, 0, pos_griglia.y * dimensione_chunk)
var space_state = get_world_3d().direct_space_state
var origine_raggio = Vector3(pos_mondo.x, 50.0, pos_mondo.z)
var fine_raggio = Vector3(pos_mondo.x, -10.0, pos_mondo.z)
var query = PhysicsRayQueryParameters3D.create(origine_raggio, fine_raggio)
var result = space_state.intersect_ray(query)
if result.size() > 0:
var collider = result["collider"]
var nodo_corrente = collider
var uscite_trovate = {"nord": false, "est": false, "sud": false, "ovest": false}
while nodo_corrente != null and nodo_corrente != get_tree().root:
if nodo_corrente.has_method("get_uscite_ruotate"):
var scatti_rotazione = roundi(rad_to_deg(nodo_corrente.global_rotation.y) / -90.0)
uscite_trovate = nodo_corrente.get_uscite_ruotate(scatti_rotazione)
break
nodo_corrente = nodo_corrente.get_parent()
scacchiera[pos_griglia] = {"tipo": "ostacolo", "uscite": uscite_trovate}
return true
return false
# --- WAVE FUNCTION COLLAPSE ---
func _piazza_bioma_compatibile(pos_griglia: Vector2i) -> void:
var req_nord = _richiede_connessione(pos_griglia + Vector2i(0, -1), "sud")
var req_est = _richiede_connessione(pos_griglia + Vector2i(1, 0), "ovest")
var req_sud = _richiede_connessione(pos_griglia + Vector2i(0, 1), "nord")
var req_ovest = _richiede_connessione(pos_griglia + Vector2i(-1, 0), "est")
var catalogo_zona = _scegli_catalogo_per_cella(pos_griglia)
var candidati = []
for scena in catalogo_zona:
var test_chunk = scena.instantiate()
if test_chunk.has_method("get_uscite_ruotate"):
for rot in range(4):
var u = test_chunk.get_uscite_ruotate(rot)
var match_n = (req_nord == -1) or ((req_nord == 1) == u["nord"])
var match_e = (req_est == -1) or ((req_est == 1) == u["est"])
var match_s = (req_sud == -1) or ((req_sud == 1) == u["sud"])
var match_o = (req_ovest == -1) or ((req_ovest == 1) == u["ovest"])
if match_n and match_e and match_s and match_o:
candidati.append({
"scena": scena,
"rotazione": rot,
"uscite": u
})
test_chunk.queue_free()
if candidati.size() > 0:
var scelto = candidati.pick_random()
var nuovo_chunk = scelto.scena.instantiate()
add_child(nuovo_chunk)
nuovo_chunk.position = Vector3(pos_griglia.x * dimensione_chunk, 0, pos_griglia.y * dimensione_chunk)
nuovo_chunk.rotation.y = scelto.rotazione * (-PI / 2.0)
scacchiera[pos_griglia] = {"tipo": "bioma", "uscite": scelto.uscite}
else:
var backup = catalogo_zona[0].instantiate()
add_child(backup)
backup.position = Vector3(pos_griglia.x * dimensione_chunk, 0, pos_griglia.y * dimensione_chunk)
scacchiera[pos_griglia] = {"tipo": "bioma", "uscite": {"nord":false, "est":false, "sud":false, "ovest":false}}
func _richiede_connessione(pos_vicino: Vector2i, lato_richiesto: String) -> int:
if not scacchiera.has(pos_vicino):
_registra_cella_con_laser(pos_vicino)
if scacchiera.has(pos_vicino):
if scacchiera[pos_vicino]["uscite"][lato_richiesto] == true:
return 1
else:
return 0
return -1
# --- DIZIONARIO DEI BIOMI (SOGLIE RIGOROSE PER EVITARE SALTI) ---
func _get_nome_bioma(valore: float) -> String:
# Convertiamo il valore da [-1.0 a 1.0] a un percorso continuo
# per assicurare la presenza dei mix
if valore < -0.4:
return "Campagna"
elif valore < -0.15:
return "Misto Campagna-Foresta"
if not usa_terzo_bioma:
return "Foresta"
if valore < 0.15:
return "Foresta"
elif valore < 0.4:
return "Misto Foresta-Altro"
else:
return "Altro (Deserto/Neve)"
# --- IL GPS DEL TRENO ---
func _radar_bioma_treno() -> void:
if path_treno == null or path_treno.curve == null: return
var pos_treno = path_treno.treno_istanziato.global_position
var grid_x = roundi(pos_treno.x / dimensione_chunk)
var grid_z = roundi(pos_treno.z / dimensione_chunk)
var valore_attuale = generatore_rumore.get_noise_2d(grid_x, grid_z)
var bioma_attuale = _get_nome_bioma(valore_attuale)
var progresso_attuale = path_treno.progresso_treno
var lunghezza_totale = path_treno.curve.get_baked_length()
var distanza_cambio = 0.0
var prossimo_bioma = ""
for step in range(1, 31):
var progresso_futuro = wrapf(progresso_attuale + (step * dimensione_chunk), 0.0, lunghezza_totale)
var pos_futura_locale = path_treno.curve.sample_baked(progresso_futuro, true)
var pos_futura_globale = path_treno.to_global(pos_futura_locale)
var f_x = roundi(pos_futura_globale.x / dimensione_chunk)
var f_z = roundi(pos_futura_globale.z / dimensione_chunk)
var valore_futuro = generatore_rumore.get_noise_2d(f_x, f_z)
var bioma_futuro = _get_nome_bioma(valore_futuro)
if bioma_futuro != bioma_attuale:
distanza_cambio = step * dimensione_chunk
prossimo_bioma = bioma_futuro
break
if prossimo_bioma != "":
print("🚂 [GPS TRENO] Sei in: ", bioma_attuale, " | Tra circa ", distanza_cambio, " metri entrerai in: ", prossimo_bioma)
else:
print("🚂 [GPS TRENO] Sei in: ", bioma_attuale, " | Nessun cambio in vista per 600m.")

View File

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