-
-
Notifications
You must be signed in to change notification settings - Fork 19
/
test_shader.tres
87 lines (73 loc) · 3.75 KB
/
test_shader.tres
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
[gd_resource type="ShaderMaterial" load_steps=9 format=2]
[ext_resource path="res://maps/textures/ground_text/vegetation/Noise_texture.tres" type="Texture" id=1]
[ext_resource path="res://maps/textures/ground_text/vegetation/Ground037_2K_Color.png" type="Texture" id=2]
[ext_resource path="res://maps/textures/ground_text/errusion/Rock029_2K_Color.png" type="Texture" id=3]
[ext_resource path="res://maps/textures/ground_text/beach/Ground035_2K_Color.png" type="Texture" id=4]
[ext_resource path="res://maps/textures/ground_text/vegetation/Ground037_2K_Normal.png" type="Texture" id=5]
[ext_resource path="res://maps/textures/ground_text/errusion/Rock029_2K_Normal.png" type="Texture" id=6]
[ext_resource path="res://maps/terrain_import/test.png" type="Texture" id=7]
[sub_resource type="Shader" id=1]
code = "shader_type spatial;
render_mode depth_draw_opaque;
uniform sampler2D slope : hint_white;
uniform sampler2D noise : hint_white;
uniform sampler2D grass_tex : hint_albedo;
uniform sampler2D grass_tint : hint_albedo;
uniform sampler2D cliff_tex : hint_albedo;
uniform sampler2D grass_normal : hint_normal;
uniform sampler2D cliff_normal : hint_normal;
uniform sampler2D sand_tex : hint_albedo;
uniform vec4 grass_color : hint_color;
uniform vec4 snow_color : hint_color;
uniform float height_range : hint_range(0.0,100.0);
uniform float snow_intensity : hint_range(0.0, 1.0);
uniform float grass_blending : hint_range(0.0, 15.0);
uniform float road_blending : hint_range(0.5, 3.0);
uniform float scale_grass : hint_range(0.0, 60.0);
uniform float scale_cliff : hint_range(0.0, 60.0);
void vertex(){
vec2 xz = VERTEX.xy;
float h = texture(slope, UV).g * height_range;
VERTEX.y = h;
//VERTEX.y += cos(VERTEX.x + (TIME * 0.5)) * sin(VERTEX.z + (TIME * 0.5)) * 0.1;
}
void fragment(){
vec3 noise_tex = vec3(texture(noise, UV * scale_grass).xyz);
vec3 text = vec3(texture(grass_tex, UV * scale_grass).xyz) * grass_color.rgb;
vec3 text2 = vec3(texture(cliff_tex, UV * scale_cliff).xyz);
vec3 text3 = vec3(texture(sand_tex, UV * scale_grass).xyz);
vec3 text4 = vec3(texture(grass_tint, UV * scale_grass).xyz);
vec3 slope_tex = vec3(texture(slope, UV).xyz);
//vec3 col = mix(text2 * texture(slope, UV).z , text * texture(slope, UV).z , texture(slope, UV) * (texture(slope, UV).z * intensity));
//vec3 normal = texture(grass_normal, UV * scale_grass).rgb * 2.0 - 1.0;
vec3 normal = mix(texture(grass_normal, UV * scale_grass).xyz, texture(cliff_normal, UV * scale_cliff).xyz, slope_tex.z) * 2.0 - 1.0;
NORMAL = (INV_CAMERA_MATRIX * (WORLD_MATRIX * vec4(normal, 0.0))).xyz;
vec3 col;
NORMALMAP_DEPTH = 1.0;
SPECULAR = 0.9;
METALLIC = mix(texture(noise, UV * scale_grass).x, text2.x + text2.y * 0.0, 0.2);
ROUGHNESS = 0.5;
float minT = clamp(0.0, abs(6.0) * slope_tex.z, 1.0);
vec3 noise_mix = mix(text, text4, noise_tex);
float grass_min = min(grass_blending * slope_tex. z, 1.0);
col = mix(mix(text3 * road_blending,noise_mix , grass_min ), mix(text * slope_tex.z, mix(text2, snow_color.rgb * snow_intensity, mix(noise_tex, slope_tex, snow_intensity)), minT),clamp(minT, 0.1, 5.0));
ALBEDO = col.rgb;
}"
[resource]
shader = SubResource( 1 )
shader_param/grass_color = Color( 0.964706, 0.921569, 0.454902, 1 )
shader_param/snow_color = Color( 1, 1, 1, 1 )
shader_param/height_range = 1.596
shader_param/snow_intensity = 0.439
shader_param/grass_blending = 7.439
shader_param/road_blending = 1.422
shader_param/scale_grass = 42.083
shader_param/scale_cliff = 60.0
shader_param/slope = ExtResource( 7 )
shader_param/noise = ExtResource( 1 )
shader_param/grass_tex = ExtResource( 2 )
shader_param/grass_tint = ExtResource( 2 )
shader_param/cliff_tex = ExtResource( 3 )
shader_param/grass_normal = ExtResource( 5 )
shader_param/cliff_normal = ExtResource( 6 )
shader_param/sand_tex = ExtResource( 4 )