Merge branch 'main' into aleajactaest

This commit is contained in:
AleaJactaEst 2022-04-15 22:31:06 +02:00
commit ac36931140
9 changed files with 289 additions and 5 deletions

View file

@ -10,7 +10,7 @@ Project to have a basic third person scene for Godot 4 where to move a character
## Godot version used
Use only the official Alpha 5 Godot release : https://downloads.tuxfamily.org/godotengine/4.0/alpha5/
Use only the official Alpha 5 Godot release : https://downloads.tuxfamily.org/godotengine/4.0/alpha6/
## Tips & tricks

View file

@ -1,8 +1,12 @@
[gd_scene load_steps=20 format=3 uid="uid://b8p2h0rmwy7qn"]
[gd_scene load_steps=24 format=3 uid="uid://b8p2h0rmwy7qn"]
[ext_resource type="Material" uid="uid://dpegsmygxcfmv" path="res://maps/materials/basic_ground.material" id="1_lodye"]
[ext_resource type="Shader" path="res://maps/shaders/khanat_sky.gdshader" id="1_mheqi"]
[ext_resource type="Texture2D" uid="uid://b5jer2nm17ld" path="res://maps/textures/samayun_tex_001.png" id="1_thm7k"]
[ext_resource type="PackedScene" uid="uid://cveshwnu272vf" path="res://maps/objects/ramp-complex.tscn" id="2_4eueh"]
[ext_resource type="Texture2D" uid="uid://y0ka7tysfp6b" path="res://maps/textures/zabr_tex_001.png" id="3_bgghj"]
[ext_resource type="PackedScene" uid="uid://omess6wwwwcq" path="res://maps/objects/ramp-moving.tscn" id="3_bvbgo"]
[ext_resource type="Texture2D" uid="uid://dlxp52r0wnwlq" path="res://maps/textures/stigi_tex_001.png" id="3_jqgsm"]
[ext_resource type="PackedScene" uid="uid://dvsl8x3lb1h4e" path="res://maps/objects/moutain.tscn" id="3_rbp35"]
[ext_resource type="PackedScene" path="res://maps/objects/cave.tscn" id="4_pc85h"]
[ext_resource type="PackedScene" uid="uid://b61edh0bre65c" path="res://maps/objects/ramp.tscn" id="5_dfm8h"]
@ -15,10 +19,30 @@
[ext_resource type="PackedScene" uid="uid://bfo13c5k8xu0x" path="res://maps/natural_ground.tscn" id="12_r7x73"]
[ext_resource type="PackedScene" uid="uid://mdsxnqsijdqv" path="res://maps/dispensaire_01.tscn" id="13_ald41"]
[sub_resource type="PhysicalSkyMaterial" id="PhysicalSkyMaterial_615c2"]
[sub_resource type="ShaderMaterial" id="ShaderMaterial_s2q0l"]
shader = ExtResource( "1_mheqi" )
shader_param/rayleigh = 2.0
shader_param/rayleigh_color = Color(0.3, 0.405, 0.6, 1)
shader_param/mie = 0.005
shader_param/mie_eccentricity = 0.8
shader_param/mie_color = Color(0.69, 0.729, 0.812, 1)
shader_param/turbidity = 10.0
shader_param/sun_disk_scale = 1.0
shader_param/ground_color = Color(0.1, 0.07, 0.034, 1)
shader_param/exposure = 0.1
shader_param/dither_strength = 1.0
shader_param/samayun_arc = 45.681
shader_param/samayun_position = Vector3(2.038, 0.695, -0.237)
shader_param/zabr_arc = 8.0
shader_param/zabr_position = Vector3(1.755, 0.599, 0.613)
shader_param/stigi_arc = 8.381
shader_param/stigi_position = Vector3(1.209, 0.444, 0.332)
shader_param/samayun = ExtResource( "1_thm7k" )
shader_param/zabr = ExtResource( "3_bgghj" )
shader_param/stigi = ExtResource( "3_jqgsm" )
[sub_resource type="Sky" id="Sky_fa16p"]
sky_material = SubResource( "PhysicalSkyMaterial_615c2" )
sky_material = SubResource( "ShaderMaterial_s2q0l" )
[sub_resource type="Environment" id="Environment_n5kgx"]
background_mode = 2
@ -37,7 +61,7 @@ data = PackedVector3Array(-0.5, 0.5, 0.5, 0.5, 0.5, 0.5, -0.5, -0.5, 0.5, 0.5, 0
[node name="basic_setup" type="Node3D"]
[node name="sunlight" type="DirectionalLight3D" parent="."]
transform = Transform3D(1, 0, 0, 0, 0.634731, 0.772734, 0, -0.772734, 0.634731, -1.75049, 15.9707, 4.39927)
transform = Transform3D(1, 0, 0, 0, 0.278991, 0.960294, 0, -0.960294, 0.278991, -1.75049, 15.9707, 4.39927)
light_color = Color(0.988235, 0.960784, 1, 1)
light_energy = 0.75
shadow_enabled = true

View file

@ -0,0 +1,155 @@
// NOTE: Shader automatically converted from Godot Engine 4.0.alpha5's PhysicalSkyMaterial.
// And then augmented with a few tweaks
shader_type sky;
uniform float rayleigh : hint_range(0, 64) = 2.0;
uniform vec4 rayleigh_color : hint_color = vec4(0.3, 0.405, 0.6, 1.0);
uniform float mie : hint_range(0, 1) = 0.005;
uniform float mie_eccentricity : hint_range(-1, 1) = 0.8;
uniform vec4 mie_color : hint_color = vec4(0.69, 0.729, 0.812, 1.0);
uniform float turbidity : hint_range(0, 1000) = 10.0;
uniform float sun_disk_scale : hint_range(0, 360) = 1.0;
uniform vec4 ground_color : hint_color = vec4(0.1, 0.07, 0.034, 1.0);
uniform float exposure : hint_range(0, 128) = 0.1;
uniform float dither_strength : hint_range(0, 10) = 1.0;
uniform sampler2D night_sky : hint_black_albedo;
uniform sampler2D samayun : hint_albedo;
uniform float samayun_arc = 45 ;
uniform vec3 samayun_position = vec3( 0.0, 0.5, 0.0 );
uniform sampler2D zabr : hint_albedo;
uniform float zabr_arc = 15 ;
uniform vec3 zabr_position = vec3( 0.0, 0.7, 0.0 );
uniform sampler2D stigi : hint_albedo;
uniform float stigi_arc = 8 ;
uniform vec3 stigi_position = vec3( 0.0, 0.8, 0.0 );
const vec3 UP = vec3( 0.0, 1.0, 0.0 );
// Sun constants
const float SUN_ENERGY = 1000.0;
// Optical length at zenith for molecules.
const float rayleigh_zenith_size = 8.4e3;
const float mie_zenith_size = 1.25e3;
float henyey_greenstein(float cos_theta, float g) {
const float k = 0.0795774715459;
return k * (1.0 - g * g) / (pow(1.0 + g * g - 2.0 * g * cos_theta, 1.5));
}
// From: https://www.shadertoy.com/view/4sfGzS credit to iq
float hash(vec3 p) {
p = fract( p * 0.3183099 + 0.1 );
p *= 17.0;
return fract(p.x * p.y * p.z * (p.x + p.y + p.z));
}
// Function to create projection plane for texture at a specific position
vec2 place_object(vec3 position, vec3 eyedir){
//We define a local plane tangent to the skydome at the given position
//We work with everything normalized
vec3 n1 = normalize(cross(position,vec3(0.0,1.0,0.0))) ;
vec3 n2 = normalize(cross(position,n1)) ;
//We project EYEDIR on this plane with an approximate correction for projection
float x = dot(eyedir,n1) * 0.9 ;
float y = dot(eyedir,n2) * 0.9 ;
return vec2(x, y);
}
void sky() {
if (LIGHT0_ENABLED) {
float zenith_angle = clamp( dot(UP, normalize(LIGHT0_DIRECTION)), -1.0, 1.0 );
float sun_energy = max(0.0, 1.0 - exp(-((PI * 0.5) - acos(zenith_angle)))) * SUN_ENERGY * LIGHT0_ENERGY;
float sun_fade = 1.0 - clamp(1.0 - exp(LIGHT0_DIRECTION.y), 0.0, 1.0);
// Rayleigh coefficients.
float rayleigh_coefficient = rayleigh - ( 1.0 * ( 1.0 - sun_fade ) );
vec3 rayleigh_beta = rayleigh_coefficient * rayleigh_color.rgb * 0.0001;
// mie coefficients from Preetham
vec3 mie_beta = turbidity * mie * mie_color.rgb * 0.000434;
// Optical length.
float zenith = acos(max(0.0, dot(UP, EYEDIR)));
float optical_mass = 1.0 / (cos(zenith) + 0.15 * pow(93.885 - degrees(zenith), -1.253));
float rayleigh_scatter = rayleigh_zenith_size * optical_mass;
float mie_scatter = mie_zenith_size * optical_mass;
// Light extinction based on thickness of atmosphere.
vec3 extinction = exp(-(rayleigh_beta * rayleigh_scatter + mie_beta * mie_scatter));
// In scattering.
float cos_theta = dot(EYEDIR, normalize(LIGHT0_DIRECTION));
float rayleigh_phase = (3.0 / (16.0 * PI)) * (1.0 + pow(cos_theta * 0.5 + 0.5, 2.0));
vec3 betaRTheta = rayleigh_beta * rayleigh_phase;
float mie_phase = henyey_greenstein(cos_theta, mie_eccentricity);
vec3 betaMTheta = mie_beta * mie_phase;
vec3 Lin = pow(sun_energy * ((betaRTheta + betaMTheta) / (rayleigh_beta + mie_beta)) * (1.0 - extinction), vec3(1.5));
// Hack from https://github.com/mrdoob/three.js/blob/master/examples/jsm/objects/Sky.js
Lin *= mix(vec3(1.0), pow(sun_energy * ((betaRTheta + betaMTheta) / (rayleigh_beta + mie_beta)) * extinction, vec3(0.5)), clamp(pow(1.0 - zenith_angle, 5.0), 0.0, 1.0));
// Hack in the ground color.
Lin *= mix(ground_color.rgb, vec3(1.0), smoothstep(-0.1, 0.1, dot(UP, EYEDIR)));
// Solar disk and out-scattering.
float sunAngularDiameterCos = cos(LIGHT0_SIZE * sun_disk_scale);
float sunAngularDiameterCos2 = cos(LIGHT0_SIZE * sun_disk_scale*0.5);
float sundisk = smoothstep(sunAngularDiameterCos, sunAngularDiameterCos2, cos_theta);
vec3 L0 = (sun_energy * 1900.0 * extinction) * sundisk * LIGHT0_COLOR;
L0 += texture(night_sky, SKY_COORDS).xyz * extinction;
vec3 color = (Lin + L0) * 0.04;
COLOR = pow(color, vec3(1.0 / (1.2 + (1.2 * sun_fade))));
COLOR *= exposure;
// Make optional, eliminates banding.
COLOR += (hash(EYEDIR * 1741.9782) * 0.08 - 0.04) * 0.016 * dither_strength;
} else {
// There is no sun, so display night_sky and nothing else.
COLOR = texture(night_sky, SKY_COORDS).xyz * 0.04;
COLOR *= exposure;
}
// Calculate respective scales of celestial objects
float samayun_scale = radians(samayun_arc) ;
float zabr_scale = radians(zabr_arc) ;
float stigi_scale = radians(stigi_arc) ;
// Calculate respective plane with UV to place celestial object textures
vec2 samayun_uv = place_object(samayun_position, EYEDIR) ;
vec2 zabr_uv = place_object(zabr_position, EYEDIR) ;
vec2 stigi_uv = place_object(stigi_position, EYEDIR) ;
// Adding the celestial objects from the nearest to the farest
// Adding stigi
if (length(EYEDIR - normalize(stigi_position)) < stigi_scale / 2.0){ // we are in the area of the sky where stigi is placed
COLOR += texture(stigi, stigi_uv / stigi_scale + vec2(0.5)).rgb * texture(stigi, stigi_uv / stigi_scale + vec2(0.5)).a;
}
// Adding samayun
if (length(EYEDIR - normalize(samayun_position)) < samayun_scale / 2.0) { // we are in the area of the sky where samayun is placed
if (length(EYEDIR - normalize(stigi_position)) < stigi_scale / 2.0){ // if stigi is in front of samayun, dont draw where stigi alpha is > 0
COLOR += texture(samayun, samayun_uv / samayun_scale + vec2(0.5)).rgb * max((texture(samayun, samayun_uv / samayun_scale + vec2(0.5)).a - texture(stigi, stigi_uv / stigi_scale + vec2(0.5)).a), 0.0) ;
} else {
COLOR += texture(samayun, samayun_uv / samayun_scale + vec2(0.5)).rgb * texture(samayun, samayun_uv / samayun_scale + vec2(0.5)).a;
}
}
// Adding zabr
if (length(EYEDIR - normalize(zabr_position)) < zabr_scale / 2.0) { // we are in the area of the sky where zabr is placed
if (length(EYEDIR - normalize(samayun_position)) < samayun_scale / 2.0){ // if samayun is in front of zabr, dont draw where samayun alpha is > 0
COLOR += texture(zabr, zabr_uv / zabr_scale + vec2(0.5)).rgb * max((texture(zabr, zabr_uv / zabr_scale + vec2(0.5)).a - texture(samayun, samayun_uv / samayun_scale + vec2(0.5)).a), 0.0) ;
} else {
if (length(EYEDIR - normalize(stigi_position)) < stigi_scale / 2.0){ // if stigi is in front of zabr, dont draw where its alpha is > 0
COLOR += texture(zabr, zabr_uv / zabr_scale + vec2(0.5)).rgb * max((texture(zabr, zabr_uv / zabr_scale + vec2(0.5)).a - texture(stigi, stigi_uv / stigi_scale + vec2(0.5)).a), 0.0) ;
} else {
COLOR += texture(zabr, zabr_uv / zabr_scale + vec2(0.5)).rgb * texture(zabr, zabr_uv / zabr_scale + vec2(0.5)).a;
}
}
}
}

Binary file not shown.

After

Width:  |  Height:  |  Size: 284 KiB

View file

@ -0,0 +1,35 @@
[remap]
importer="texture"
type="CompressedTexture2D"
uid="uid://b5jer2nm17ld"
path.s3tc="res://.godot/imported/samayun_tex_001.png-4e3e72c86a1ead24f9cc9afcb2d3aafa.s3tc.ctex"
path.etc2="res://.godot/imported/samayun_tex_001.png-4e3e72c86a1ead24f9cc9afcb2d3aafa.etc2.ctex"
metadata={
"imported_formats": ["s3tc", "etc2"],
"vram_texture": true
}
[deps]
source_file="res://maps/textures/samayun_tex_001.png"
dest_files=["res://.godot/imported/samayun_tex_001.png-4e3e72c86a1ead24f9cc9afcb2d3aafa.s3tc.ctex", "res://.godot/imported/samayun_tex_001.png-4e3e72c86a1ead24f9cc9afcb2d3aafa.etc2.ctex"]
[params]
compress/mode=2
compress/lossy_quality=0.7
compress/hdr_compression=1
compress/bptc_ldr=0
compress/normal_map=0
compress/channel_pack=0
mipmaps/generate=true
mipmaps/limit=-1
roughness/mode=0
roughness/src_normal=""
process/fix_alpha_border=true
process/premult_alpha=false
process/normal_map_invert_y=false
process/hdr_as_srgb=false
process/size_limit=0
detect_3d/compress_to=0

Binary file not shown.

After

Width:  |  Height:  |  Size: 913 KiB

View file

@ -0,0 +1,35 @@
[remap]
importer="texture"
type="CompressedTexture2D"
uid="uid://dlxp52r0wnwlq"
path.s3tc="res://.godot/imported/stigi_tex_001.png-422a9b36925acddfd148694fe140318a.s3tc.ctex"
path.etc2="res://.godot/imported/stigi_tex_001.png-422a9b36925acddfd148694fe140318a.etc2.ctex"
metadata={
"imported_formats": ["s3tc", "etc2"],
"vram_texture": true
}
[deps]
source_file="res://maps/textures/stigi_tex_001.png"
dest_files=["res://.godot/imported/stigi_tex_001.png-422a9b36925acddfd148694fe140318a.s3tc.ctex", "res://.godot/imported/stigi_tex_001.png-422a9b36925acddfd148694fe140318a.etc2.ctex"]
[params]
compress/mode=2
compress/lossy_quality=0.7
compress/hdr_compression=1
compress/bptc_ldr=0
compress/normal_map=0
compress/channel_pack=0
mipmaps/generate=true
mipmaps/limit=-1
roughness/mode=0
roughness/src_normal=""
process/fix_alpha_border=true
process/premult_alpha=false
process/normal_map_invert_y=false
process/hdr_as_srgb=false
process/size_limit=0
detect_3d/compress_to=0

Binary file not shown.

After

Width:  |  Height:  |  Size: 57 KiB

View file

@ -0,0 +1,35 @@
[remap]
importer="texture"
type="CompressedTexture2D"
uid="uid://y0ka7tysfp6b"
path.s3tc="res://.godot/imported/zabr_tex_001.png-79bb3a642b1072453481cdab29affd71.s3tc.ctex"
path.etc2="res://.godot/imported/zabr_tex_001.png-79bb3a642b1072453481cdab29affd71.etc2.ctex"
metadata={
"imported_formats": ["s3tc", "etc2"],
"vram_texture": true
}
[deps]
source_file="res://maps/textures/zabr_tex_001.png"
dest_files=["res://.godot/imported/zabr_tex_001.png-79bb3a642b1072453481cdab29affd71.s3tc.ctex", "res://.godot/imported/zabr_tex_001.png-79bb3a642b1072453481cdab29affd71.etc2.ctex"]
[params]
compress/mode=2
compress/lossy_quality=0.7
compress/hdr_compression=1
compress/bptc_ldr=0
compress/normal_map=0
compress/channel_pack=0
mipmaps/generate=true
mipmaps/limit=-1
roughness/mode=0
roughness/src_normal=""
process/fix_alpha_border=true
process/premult_alpha=false
process/normal_map_invert_y=false
process/hdr_as_srgb=false
process/size_limit=0
detect_3d/compress_to=0