Adding zabr to sky shader
This commit is contained in:
parent
cfe12a3066
commit
e9aeddbf28
4 changed files with 68 additions and 14 deletions
|
@ -1,9 +1,10 @@
|
||||||
[gd_scene load_steps=22 format=3 uid="uid://b8p2h0rmwy7qn"]
|
[gd_scene load_steps=23 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="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="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="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="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="PackedScene" uid="uid://omess6wwwwcq" path="res://maps/objects/ramp-moving.tscn" id="3_bvbgo"]
|
||||||
[ext_resource type="PackedScene" uid="uid://dvsl8x3lb1h4e" path="res://maps/objects/moutain.tscn" id="3_rbp35"]
|
[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" path="res://maps/objects/cave.tscn" id="4_pc85h"]
|
||||||
|
@ -29,9 +30,12 @@ shader_param/sun_disk_scale = 1.0
|
||||||
shader_param/ground_color = Color(0.1, 0.07, 0.034, 1)
|
shader_param/ground_color = Color(0.1, 0.07, 0.034, 1)
|
||||||
shader_param/exposure = 0.1
|
shader_param/exposure = 0.1
|
||||||
shader_param/dither_strength = 1.0
|
shader_param/dither_strength = 1.0
|
||||||
shader_param/samayun_scale = 0.201
|
shader_param/samayun_arc = 25.0
|
||||||
shader_param/samayun_position = Vector3(1.269, 0.931, -0.345)
|
shader_param/samayun_position = Vector3(2.038, 0.584, -0.185)
|
||||||
|
shader_param/zabr_arc = null
|
||||||
|
shader_param/zabr_position = Vector3(0.812, 0.345, 0.263)
|
||||||
shader_param/samayun = ExtResource( "1_thm7k" )
|
shader_param/samayun = ExtResource( "1_thm7k" )
|
||||||
|
shader_param/zabr = ExtResource( "3_bgghj" )
|
||||||
|
|
||||||
[sub_resource type="Sky" id="Sky_fa16p"]
|
[sub_resource type="Sky" id="Sky_fa16p"]
|
||||||
sky_material = SubResource( "ShaderMaterial_s2q0l" )
|
sky_material = SubResource( "ShaderMaterial_s2q0l" )
|
||||||
|
|
|
@ -1,5 +1,6 @@
|
||||||
|
|
||||||
// NOTE: Shader automatically converted from Godot Engine 4.0.alpha5's PhysicalSkyMaterial.
|
// NOTE: Shader automatically converted from Godot Engine 4.0.alpha5's PhysicalSkyMaterial.
|
||||||
|
// And then augmented with a few tweaks
|
||||||
|
|
||||||
shader_type sky;
|
shader_type sky;
|
||||||
|
|
||||||
|
@ -18,9 +19,13 @@ uniform float dither_strength : hint_range(0, 10) = 1.0;
|
||||||
uniform sampler2D night_sky : hint_black_albedo;
|
uniform sampler2D night_sky : hint_black_albedo;
|
||||||
|
|
||||||
uniform sampler2D samayun : hint_albedo;
|
uniform sampler2D samayun : hint_albedo;
|
||||||
uniform float samayun_scale : hint_range(0, 1.0) = 0.25;
|
uniform float samayun_arc = 25 ;
|
||||||
uniform vec3 samayun_position = vec3( 0.0, 0.5, 0.0 );
|
uniform vec3 samayun_position = vec3( 0.0, 0.5, 0.0 );
|
||||||
|
|
||||||
|
uniform sampler2D zabr : hint_albedo;
|
||||||
|
uniform float zabr_arc = 12 ;
|
||||||
|
uniform vec3 zabr_position = vec3( 0.0, 0.7, 0.0 );
|
||||||
|
|
||||||
const vec3 UP = vec3( 0.0, 1.0, 0.0 );
|
const vec3 UP = vec3( 0.0, 1.0, 0.0 );
|
||||||
|
|
||||||
// Sun constants
|
// Sun constants
|
||||||
|
@ -42,8 +47,6 @@ float hash(vec3 p) {
|
||||||
return fract(p.x * p.y * p.z * (p.x + p.y + p.z));
|
return fract(p.x * p.y * p.z * (p.x + p.y + p.z));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
void sky() {
|
void sky() {
|
||||||
if (LIGHT0_ENABLED) {
|
if (LIGHT0_ENABLED) {
|
||||||
float zenith_angle = clamp( dot(UP, normalize(LIGHT0_DIRECTION)), -1.0, 1.0 );
|
float zenith_angle = clamp( dot(UP, normalize(LIGHT0_DIRECTION)), -1.0, 1.0 );
|
||||||
|
@ -98,18 +101,30 @@ void sky() {
|
||||||
COLOR = texture(night_sky, SKY_COORDS).xyz * 0.04;
|
COLOR = texture(night_sky, SKY_COORDS).xyz * 0.04;
|
||||||
COLOR *= exposure;
|
COLOR *= exposure;
|
||||||
}
|
}
|
||||||
// vec2 samayun_uv = uv_moon(samayun_position, samayun_scale, SKY_COORDS);
|
// Adding Samayun
|
||||||
// COLOR += texture(samayun, samayun_uv).rgb;
|
float samayun_scale = radians(samayun_arc) ;
|
||||||
if (length(EYEDIR - normalize(samayun_position)) < 0.5 ) { // we are in the area of the sky where samayun is placed
|
if (length(EYEDIR - normalize(samayun_position)) < samayun_scale / 2.0) { // we are in the area of the sky where samayun is placed
|
||||||
//We define a local plane tangent to the skydome at samayun_position
|
//We define a local plane tangent to the skydome at samayun_position
|
||||||
//We work with everything normalized
|
//We work with everything normalized
|
||||||
vec3 n1 = normalize(cross(samayun_position,vec3(0,1,0)));
|
vec3 n1 = normalize(cross(samayun_position,vec3(0.0,1.0,0.0))) ;
|
||||||
vec3 n2 = normalize(cross(samayun_position,n1));
|
vec3 n2 = normalize(cross(samayun_position,n1)) ;
|
||||||
//We project EYEDIR on this plane
|
//We project EYEDIR on this plane
|
||||||
float x = dot(EYEDIR,n1) ;
|
float x = dot(EYEDIR,n1) ;
|
||||||
float y = dot(EYEDIR,n2) ;
|
float y = dot(EYEDIR,n2) ;
|
||||||
|
// We then add the final result to the sky
|
||||||
COLOR += texture(samayun, vec2(x,y)+vec2(0.5)).rgb * texture(samayun, vec2(x,y)+vec2(0.5)).a;
|
COLOR += texture(samayun, vec2(x,y) / samayun_scale + vec2(0.5)).rgb * texture(samayun, vec2(x,y) / samayun_scale + vec2(0.5)).a;
|
||||||
//COLOR = mix(COLOR, texture(samayun, vec2(x,y)+vec2(0.5)).rgb, clamp (samayun_position.y, 0.0, 1.0)) ;
|
|
||||||
}
|
}
|
||||||
|
// Adding zabr
|
||||||
|
float zabr_scale = radians(zabr_arc) ;
|
||||||
|
if (length(EYEDIR - normalize(zabr_position)) < zabr_scale / 2.0) { // we are in the area of the sky where zabr is placed
|
||||||
|
//We define a local plane tangent to the skydome at zabr_position
|
||||||
|
//We work with everything normalized
|
||||||
|
vec3 z_n1 = normalize(cross(zabr_position,vec3(0.0,1.0,0.0))) ;
|
||||||
|
vec3 z_n2 = normalize(cross(zabr_position,z_n1)) ;
|
||||||
|
//We project EYEDIR on this plane
|
||||||
|
float z_x = dot(EYEDIR,z_n1) ;
|
||||||
|
float z_y = dot(EYEDIR,z_n2) ;
|
||||||
|
// We then add the final result to the sky
|
||||||
|
COLOR += texture(zabr, vec2(z_x,z_y) / zabr_scale + vec2(0.5)).rgb * texture(zabr, vec2(z_x,z_y) / zabr_scale + vec2(0.5)).a;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
BIN
maps/textures/zabr_tex_001.png
Normal file
BIN
maps/textures/zabr_tex_001.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 57 KiB |
35
maps/textures/zabr_tex_001.png.import
Normal file
35
maps/textures/zabr_tex_001.png.import
Normal 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
|
Loading…
Reference in a new issue