porting starlight shader to godot4
This commit is contained in:
parent
ea1c88a0cd
commit
510c121568
Binary file not shown.
Binary file not shown.
|
|
@ -34,6 +34,18 @@ _subresources={
|
|||
"use_external/enabled": true,
|
||||
"use_external/path": "res://base-environments/youth_room/import/materials/starlight_shader.material"
|
||||
}
|
||||
},
|
||||
"meshes": {
|
||||
"starlight-mesh_room001": {
|
||||
"generate/lightmap_uv": 0,
|
||||
"generate/lods": 0,
|
||||
"generate/shadow_meshes": 0,
|
||||
"lods/normal_merge_angle": 60.0,
|
||||
"lods/normal_split_angle": 25.0,
|
||||
"save_to_file/enabled": true,
|
||||
"save_to_file/make_streamable": "",
|
||||
"save_to_file/path": "res://base-environments/youth_room/shaders/starlight-mesh.res"
|
||||
}
|
||||
}
|
||||
}
|
||||
gltf/embedded_image_handling=1
|
||||
|
|
|
|||
Binary file not shown.
Binary file not shown.
|
Before Width: | Height: | Size: 1.0 MiB After Width: | Height: | Size: 1.0 MiB |
|
|
@ -3,23 +3,24 @@
|
|||
importer="texture"
|
||||
type="CompressedTexture2D"
|
||||
uid="uid://bdyg065h8vcdi"
|
||||
path="res://.godot/imported/starlight-textures.png-4ddade130465fa71fbca6304c0a7a75a.ctex"
|
||||
path.bptc="res://.godot/imported/starlight-textures.png-4ddade130465fa71fbca6304c0a7a75a.bptc.ctex"
|
||||
metadata={
|
||||
"vram_texture": false
|
||||
"imported_formats": ["s3tc_bptc"],
|
||||
"vram_texture": true
|
||||
}
|
||||
|
||||
[deps]
|
||||
|
||||
source_file="res://base-environments/youth_room/shaders/starlight-textures.png"
|
||||
dest_files=["res://.godot/imported/starlight-textures.png-4ddade130465fa71fbca6304c0a7a75a.ctex"]
|
||||
dest_files=["res://.godot/imported/starlight-textures.png-4ddade130465fa71fbca6304c0a7a75a.bptc.ctex"]
|
||||
|
||||
[params]
|
||||
|
||||
compress/mode=3
|
||||
compress/mode=2
|
||||
compress/high_quality=true
|
||||
compress/lossy_quality=0.7
|
||||
compress/hdr_compression=1
|
||||
compress/normal_map=0
|
||||
compress/normal_map=1
|
||||
compress/channel_pack=0
|
||||
mipmaps/generate=true
|
||||
mipmaps/limit=-1
|
||||
|
|
|
|||
|
|
@ -1,9 +1,37 @@
|
|||
shader_type spatial;
|
||||
render_mode unshaded;
|
||||
render_mode blend_add, specular_disabled;
|
||||
|
||||
uniform float nebula_brightness = 4;
|
||||
uniform vec2 nebula_scale = vec2(1.5);
|
||||
uniform sampler2D starlight_noise;
|
||||
uniform sampler2D starlight_textures;
|
||||
uniform float rotation_speed = 0.05;
|
||||
uniform vec2 rotation_pivot = vec2(.8);
|
||||
uniform vec2 drift_compensation = vec2(0.1, -0.2);
|
||||
uniform float noise_strength = 0.2;
|
||||
|
||||
// https://gist.github.com/ayamflow/c06bc0c8a64f985dd431bd0ac5b557cd
|
||||
vec2 rotateUV(vec2 uv, vec2 pivot, float rotation)
|
||||
{
|
||||
return vec2(
|
||||
cos(rotation) * (uv.x - pivot.x) + sin(rotation) * (uv.y - pivot.y) + pivot.x,
|
||||
cos(rotation) * (uv.y - pivot.y) - sin(rotation) * (uv.x - pivot.x) + pivot.y
|
||||
);
|
||||
}
|
||||
|
||||
//clamp(, .0, 1.0
|
||||
|
||||
void fragment() {
|
||||
ALBEDO = vec3(.0, .0, texture(starlight_textures, UV + texture(starlight_noise, UV).xz).z);
|
||||
ALBEDO = vec3(.0,
|
||||
texture(starlight_textures,UV).x * max(sin(TIME + 10.0 * texture(starlight_textures,UV).y), .0),
|
||||
texture(starlight_textures,
|
||||
clamp(
|
||||
UV / nebula_scale + drift_compensation + 1.0 *
|
||||
texture(starlight_noise, rotateUV(
|
||||
UV / nebula_scale + noise_strength * texture(starlight_noise, rotateUV(UV, -rotation_pivot, TIME*rotation_speed)).yx,
|
||||
rotation_pivot, TIME*rotation_speed)
|
||||
).xz,
|
||||
.0, 1.0))
|
||||
.z * nebula_brightness);
|
||||
SPECULAR = 0.0;
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in New Issue