Skip to content

Commit db7cabb

Browse files
committed
Ported snow shader to Godot 4
1 parent aff94e1 commit db7cabb

27 files changed

+582
-645
lines changed

tutorials/snow-shader/snow-shader-complete/Main.tscn

+243-292
Large diffs are not rendered by default.
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
1-
[gd_resource type="Environment" load_steps=2 format=2]
1+
[gd_resource type="Environment" load_steps=2 format=3 uid="uid://cfcle2b7mdwty"]
22

3-
[sub_resource type="ProceduralSky" id=1]
3+
[sub_resource type="Sky" id="1"]
44

55
[resource]
66
background_mode = 2
7-
background_sky = SubResource( 1 )
7+
sky = SubResource("1")
Original file line numberDiff line numberDiff line change
@@ -1,34 +1,34 @@
11
[remap]
22

33
importer="texture"
4-
type="StreamTexture"
5-
path="res://.import/icon.png-487276ed1e3a0c39cad0279d744ee560.stex"
4+
type="CompressedTexture2D"
5+
uid="uid://dykw3ap4yd3mw"
6+
path="res://.godot/imported/icon.png-487276ed1e3a0c39cad0279d744ee560.ctex"
67
metadata={
78
"vram_texture": false
89
}
910

1011
[deps]
1112

1213
source_file="res://icon.png"
13-
dest_files=[ "res://.import/icon.png-487276ed1e3a0c39cad0279d744ee560.stex" ]
14+
dest_files=["res://.godot/imported/icon.png-487276ed1e3a0c39cad0279d744ee560.ctex"]
1415

1516
[params]
1617

1718
compress/mode=0
19+
compress/high_quality=false
1820
compress/lossy_quality=0.7
19-
compress/hdr_mode=0
20-
compress/bptc_ldr=0
21+
compress/hdr_compression=1
2122
compress/normal_map=0
22-
flags/repeat=0
23-
flags/filter=true
24-
flags/mipmaps=false
25-
flags/anisotropic=false
26-
flags/srgb=2
23+
compress/channel_pack=0
24+
mipmaps/generate=false
25+
mipmaps/limit=-1
26+
roughness/mode=0
27+
roughness/src_normal=""
2728
process/fix_alpha_border=true
2829
process/premult_alpha=false
29-
process/HDR_as_SRGB=false
30-
process/invert_color=false
31-
stream=false
32-
size_limit=0
33-
detect_3d=true
34-
svg/scale=1.0
30+
process/normal_map_invert_y=false
31+
process/hdr_as_srgb=false
32+
process/hdr_clamp_exposure=false
33+
process/size_limit=0
34+
detect_3d/compress_to=1

tutorials/snow-shader/snow-shader-complete/materials/snow_branch.tres

+5-5
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
11
[gd_resource type="ShaderMaterial" load_steps=6 format=2]
22

3-
[ext_resource path="res://shaders/snow_branch.shader" type="Shader" id=1]
4-
[ext_resource path="res://textures/tree/branch.png" type="Texture" id=2]
5-
[ext_resource path="res://textures/snow/snow_02_nor_gl_1k.jpg" type="Texture" id=3]
6-
[ext_resource path="res://textures/snow/snow_02_diff_2k.jpg" type="Texture" id=4]
7-
[ext_resource path="res://textures/tree/branch_normal.jpg" type="Texture" id=5]
3+
[ext_resource path="res://shaders/snow_branch.gdshader" type="Shader" id=1]
4+
[ext_resource path="res://textures/tree/branch.png" type="Texture2D" id=2]
5+
[ext_resource path="res://textures/snow/snow_02_nor_gl_1k.jpg" type="Texture2D" id=3]
6+
[ext_resource path="res://textures/snow/snow_02_diff_2k.jpg" type="Texture2D" id=4]
7+
[ext_resource path="res://textures/tree/branch_normal.jpg" type="Texture2D" id=5]
88

99
[resource]
1010
shader = ExtResource( 1 )
Binary file not shown.

tutorials/snow-shader/snow-shader-complete/project.godot

+3-2
Original file line numberDiff line numberDiff line change
@@ -6,12 +6,13 @@
66
; [section] ; section goes between []
77
; param=value ; assign values to parameters
88

9-
config_version=4
9+
config_version=5
1010

1111
[application]
1212

1313
config/name="Snow Shader Tutorial (Complete)"
1414
run/main_scene="res://Main.tscn"
15+
config/features=PackedStringArray("4.2")
1516
config/icon="res://icon.png"
1617

1718
[physics]
@@ -20,4 +21,4 @@ common/enable_pause_aware_picking=true
2021

2122
[rendering]
2223

23-
environment/default_environment="res://default_env.tres"
24+
environment/defaults/default_environment="res://default_env.tres"

tutorials/snow-shader/snow-shader-complete/shaders/basic_snow.shader tutorials/snow-shader/snow-shader-complete/shaders/basic_snow.gdshader

+9-9
Original file line numberDiff line numberDiff line change
@@ -7,14 +7,14 @@ uniform float snow_blend_range : hint_range(0, 0.9) = 0.1;
77
uniform float specular = 0.5;
88
uniform float metallic = 0.0;
99

10-
uniform vec4 albedo : hint_color;
11-
uniform sampler2D texture_albedo : hint_albedo;
10+
uniform vec4 albedo : source_color;
11+
uniform sampler2D texture_albedo : source_color;
1212
uniform sampler2D texture_normal : hint_normal;
1313
uniform float normal_scale : hint_range(-16,16) = 1.0;
1414
uniform float roughness : hint_range(0,1) = 0.9;
1515

16-
uniform vec4 albedo_snow : hint_color;
17-
uniform sampler2D texture_albedo_snow : hint_albedo;
16+
uniform vec4 albedo_snow : source_color;
17+
uniform sampler2D texture_albedo_snow : source_color;
1818
uniform sampler2D texture_normal_snow : hint_normal;
1919
uniform float normal_scale_snow : hint_range(-16,16) = 1.0;
2020
uniform float roughness_snow : hint_range(0,1) = 0.75;
@@ -51,9 +51,9 @@ void fragment() {
5151

5252
/// Calculation including the normal map
5353
// Get TBN matrix
54-
vec3 T = (vec4(TANGENT, 0.0) * INV_CAMERA_MATRIX).xyz;
55-
vec3 B = (vec4(BINORMAL, 0.0) * INV_CAMERA_MATRIX).xyz;
56-
vec3 N = (vec4(NORMAL, 0.0) * INV_CAMERA_MATRIX).xyz;
54+
vec3 T = (vec4(TANGENT, 0.0) * VIEW_MATRIX).xyz;
55+
vec3 B = (vec4(BINORMAL, 0.0) * VIEW_MATRIX).xyz;
56+
vec3 N = (vec4(NORMAL, 0.0) * VIEW_MATRIX).xyz;
5757
mat3 TBN = mat3(T, B, -N);
5858

5959
// Calculate blend factor
@@ -68,7 +68,7 @@ void fragment() {
6868

6969
// Apply final blended textures
7070
ALBEDO = final_albedo;
71-
NORMALMAP = final_normal;
72-
NORMALMAP_DEPTH = final_normal_scale;
71+
NORMAL_MAP = final_normal;
72+
NORMAL_MAP_DEPTH = final_normal_scale;
7373
ROUGHNESS = final_roughness;
7474
}

tutorials/snow-shader/snow-shader-complete/shaders/snow_branch.shader tutorials/snow-shader/snow-shader-complete/shaders/snow_branch.gdshader

+11-11
Original file line numberDiff line numberDiff line change
@@ -7,16 +7,16 @@ uniform float snow_blend_range : hint_range(0, 0.9) = 0.1;
77
uniform float specular = 0.5;
88
uniform float metallic = 0.0;
99

10-
uniform vec4 albedo : hint_color;
11-
uniform sampler2D texture_albedo : hint_albedo;
10+
uniform vec4 albedo : source_color;
11+
uniform sampler2D texture_albedo : source_color;
1212
uniform float alpha_cutout : hint_range(0, 1);
1313
uniform float transmission : hint_range(0, 1) = 0.5;
1414
uniform sampler2D texture_normal : hint_normal;
1515
uniform float normal_scale : hint_range(-16,16) = 1.0;
1616
uniform float roughness : hint_range(0,1) = 0.9;
1717

18-
uniform vec4 albedo_snow : hint_color;
19-
uniform sampler2D texture_albedo_snow : hint_albedo;
18+
uniform vec4 albedo_snow : source_color;
19+
uniform sampler2D texture_albedo_snow : source_color;
2020
uniform sampler2D texture_normal_snow : hint_normal;
2121
uniform float normal_scale_snow : hint_range(-16,16) = 1.0;
2222
uniform float roughness_snow : hint_range(0,1) = 0.75;
@@ -53,9 +53,9 @@ void fragment() {
5353

5454
/// Calculation including the normal map
5555
// Get TBN matrix
56-
vec3 T = (vec4(TANGENT, 0.0) * INV_CAMERA_MATRIX).xyz;
57-
vec3 B = (vec4(BINORMAL, 0.0) * INV_CAMERA_MATRIX).xyz;
58-
vec3 N = (vec4(NORMAL, 0.0) * INV_CAMERA_MATRIX).xyz;
56+
vec3 T = (vec4(TANGENT, 0.0) * VIEW_MATRIX).xyz;
57+
vec3 B = (vec4(BINORMAL, 0.0) * VIEW_MATRIX).xyz;
58+
vec3 N = (vec4(NORMAL, 0.0) * VIEW_MATRIX).xyz;
5959
mat3 TBN = mat3(T, B, -N);
6060

6161
// Calculate blend factor
@@ -70,10 +70,10 @@ void fragment() {
7070

7171
// Apply final blended textures
7272
ALBEDO = final_albedo;
73-
NORMALMAP = final_normal;
74-
NORMALMAP_DEPTH = final_normal_scale;
73+
NORMAL_MAP = final_normal;
74+
NORMAL_MAP_DEPTH = final_normal_scale;
7575
ROUGHNESS = final_roughness;
7676
ALPHA = albedo_tex.a;
77-
ALPHA_SCISSOR = alpha_cutout;
78-
TRANSMISSION = vec3(transmission);
77+
ALPHA_SCISSOR_THRESHOLD = alpha_cutout;
78+
BACKLIGHT = vec3(transmission);
7979
}
Original file line numberDiff line numberDiff line change
@@ -1,36 +1,35 @@
11
[remap]
22

33
importer="texture"
4-
type="StreamTexture"
5-
path.s3tc="res://.import/rocks_ground_02_col_1k.jpg-093f801c940121d1ab4dcc7f85b9143a.s3tc.stex"
6-
path.etc2="res://.import/rocks_ground_02_col_1k.jpg-093f801c940121d1ab4dcc7f85b9143a.etc2.stex"
4+
type="CompressedTexture2D"
5+
uid="uid://c6jgewudkeyfd"
6+
path.s3tc="res://.godot/imported/rocks_ground_02_col_1k.jpg-093f801c940121d1ab4dcc7f85b9143a.s3tc.ctex"
77
metadata={
8-
"imported_formats": [ "s3tc", "etc2" ],
8+
"imported_formats": ["s3tc_bptc"],
99
"vram_texture": true
1010
}
1111

1212
[deps]
1313

1414
source_file="res://textures/rocks/rocks_ground_02_col_1k.jpg"
15-
dest_files=[ "res://.import/rocks_ground_02_col_1k.jpg-093f801c940121d1ab4dcc7f85b9143a.s3tc.stex", "res://.import/rocks_ground_02_col_1k.jpg-093f801c940121d1ab4dcc7f85b9143a.etc2.stex" ]
15+
dest_files=["res://.godot/imported/rocks_ground_02_col_1k.jpg-093f801c940121d1ab4dcc7f85b9143a.s3tc.ctex"]
1616

1717
[params]
1818

1919
compress/mode=2
20+
compress/high_quality=false
2021
compress/lossy_quality=0.7
21-
compress/hdr_mode=0
22-
compress/bptc_ldr=0
22+
compress/hdr_compression=1
2323
compress/normal_map=0
24-
flags/repeat=true
25-
flags/filter=true
26-
flags/mipmaps=true
27-
flags/anisotropic=false
28-
flags/srgb=1
24+
compress/channel_pack=0
25+
mipmaps/generate=true
26+
mipmaps/limit=-1
27+
roughness/mode=0
28+
roughness/src_normal=""
2929
process/fix_alpha_border=true
3030
process/premult_alpha=false
31-
process/HDR_as_SRGB=false
32-
process/invert_color=false
33-
stream=false
34-
size_limit=0
35-
detect_3d=false
36-
svg/scale=1.0
31+
process/normal_map_invert_y=false
32+
process/hdr_as_srgb=false
33+
process/hdr_clamp_exposure=false
34+
process/size_limit=0
35+
detect_3d/compress_to=0
Original file line numberDiff line numberDiff line change
@@ -1,36 +1,35 @@
11
[remap]
22

33
importer="texture"
4-
type="StreamTexture"
5-
path.s3tc="res://.import/rocks_ground_02_nor_gl_1k.jpg-53a26a7010b976545b1e1b1dd050d7a0.s3tc.stex"
6-
path.etc2="res://.import/rocks_ground_02_nor_gl_1k.jpg-53a26a7010b976545b1e1b1dd050d7a0.etc2.stex"
4+
type="CompressedTexture2D"
5+
uid="uid://dlr85y85nydyg"
6+
path.s3tc="res://.godot/imported/rocks_ground_02_nor_gl_1k.jpg-53a26a7010b976545b1e1b1dd050d7a0.s3tc.ctex"
77
metadata={
8-
"imported_formats": [ "s3tc", "etc2" ],
8+
"imported_formats": ["s3tc_bptc"],
99
"vram_texture": true
1010
}
1111

1212
[deps]
1313

1414
source_file="res://textures/rocks/rocks_ground_02_nor_gl_1k.jpg"
15-
dest_files=[ "res://.import/rocks_ground_02_nor_gl_1k.jpg-53a26a7010b976545b1e1b1dd050d7a0.s3tc.stex", "res://.import/rocks_ground_02_nor_gl_1k.jpg-53a26a7010b976545b1e1b1dd050d7a0.etc2.stex" ]
15+
dest_files=["res://.godot/imported/rocks_ground_02_nor_gl_1k.jpg-53a26a7010b976545b1e1b1dd050d7a0.s3tc.ctex"]
1616

1717
[params]
1818

1919
compress/mode=2
20+
compress/high_quality=false
2021
compress/lossy_quality=0.7
21-
compress/hdr_mode=0
22-
compress/bptc_ldr=0
22+
compress/hdr_compression=1
2323
compress/normal_map=1
24-
flags/repeat=true
25-
flags/filter=true
26-
flags/mipmaps=true
27-
flags/anisotropic=true
28-
flags/srgb=2
24+
compress/channel_pack=0
25+
mipmaps/generate=true
26+
mipmaps/limit=-1
27+
roughness/mode=0
28+
roughness/src_normal=""
2929
process/fix_alpha_border=true
3030
process/premult_alpha=false
31-
process/HDR_as_SRGB=false
32-
process/invert_color=false
33-
stream=false
34-
size_limit=0
35-
detect_3d=false
36-
svg/scale=1.0
31+
process/normal_map_invert_y=false
32+
process/hdr_as_srgb=false
33+
process/hdr_clamp_exposure=false
34+
process/size_limit=0
35+
detect_3d/compress_to=0
Original file line numberDiff line numberDiff line change
@@ -1,36 +1,35 @@
11
[remap]
22

33
importer="texture"
4-
type="StreamTexture"
5-
path.s3tc="res://.import/snow_02_diff_2k.jpg-e91642954032ca34728f46c89faea130.s3tc.stex"
6-
path.etc2="res://.import/snow_02_diff_2k.jpg-e91642954032ca34728f46c89faea130.etc2.stex"
4+
type="CompressedTexture2D"
5+
uid="uid://cflys2tqxkcic"
6+
path.s3tc="res://.godot/imported/snow_02_diff_2k.jpg-e91642954032ca34728f46c89faea130.s3tc.ctex"
77
metadata={
8-
"imported_formats": [ "s3tc", "etc2" ],
8+
"imported_formats": ["s3tc_bptc"],
99
"vram_texture": true
1010
}
1111

1212
[deps]
1313

1414
source_file="res://textures/snow/snow_02_diff_2k.jpg"
15-
dest_files=[ "res://.import/snow_02_diff_2k.jpg-e91642954032ca34728f46c89faea130.s3tc.stex", "res://.import/snow_02_diff_2k.jpg-e91642954032ca34728f46c89faea130.etc2.stex" ]
15+
dest_files=["res://.godot/imported/snow_02_diff_2k.jpg-e91642954032ca34728f46c89faea130.s3tc.ctex"]
1616

1717
[params]
1818

1919
compress/mode=2
20+
compress/high_quality=false
2021
compress/lossy_quality=0.7
21-
compress/hdr_mode=0
22-
compress/bptc_ldr=0
22+
compress/hdr_compression=1
2323
compress/normal_map=0
24-
flags/repeat=true
25-
flags/filter=true
26-
flags/mipmaps=true
27-
flags/anisotropic=false
28-
flags/srgb=1
24+
compress/channel_pack=0
25+
mipmaps/generate=true
26+
mipmaps/limit=-1
27+
roughness/mode=0
28+
roughness/src_normal=""
2929
process/fix_alpha_border=true
3030
process/premult_alpha=false
31-
process/HDR_as_SRGB=false
32-
process/invert_color=false
33-
stream=false
34-
size_limit=0
35-
detect_3d=false
36-
svg/scale=1.0
31+
process/normal_map_invert_y=false
32+
process/hdr_as_srgb=false
33+
process/hdr_clamp_exposure=false
34+
process/size_limit=0
35+
detect_3d/compress_to=0

0 commit comments

Comments
 (0)