khanat-client/scenes/decors/terrains/test/test.tscn

70 lines
1.8 KiB
Text
Raw Normal View History

2020-03-21 09:10:26 +00:00
[gd_scene load_steps=5 format=2]
[ext_resource path="res://assets/decors/terrains/heightmaps/test_heightmap.png" type="Texture" id=1]
[sub_resource type="PlaneMesh" id=1]
size = Vector2( 10, 10 )
subdivide_width = 10
subdivide_depth = 10
[sub_resource type="Shader" id=2]
code = "shader_type spatial;
render_mode blend_mix,depth_draw_opaque,cull_back,diffuse_burley,specular_schlick_ggx;
uniform vec4 albedo : hint_color;
uniform sampler2D texture_albedo : hint_albedo;
uniform float specular;
uniform float metallic;
uniform float roughness : hint_range(0,1);
uniform float point_size : hint_range(0,128);
uniform vec3 uv1_scale;
uniform vec3 uv1_offset;
uniform vec3 uv2_scale;
uniform vec3 uv2_offset;
uniform float max_height = 10.0;
uniform float min_height = 0.0;
uniform sampler2D texture_heightmap;
void vertex() {
UV=UV*uv1_scale.xy+uv1_offset.xy;
vec4 heightmap_tex = texture(texture_heightmap, UV);
VERTEX.y = min_height + (heightmap_tex.r * max_height);
}
void fragment() {
vec2 base_uv = UV;
vec4 albedo_tex = texture(texture_albedo,base_uv);
ALBEDO = albedo.rgb * albedo_tex.rgb;
METALLIC = metallic;
ROUGHNESS = roughness;
SPECULAR = specular;
}
"
[sub_resource type="ShaderMaterial" id=3]
shader = SubResource( 2 )
shader_param/albedo = Color( 1, 1, 1, 1 )
shader_param/specular = 0.5
shader_param/metallic = 0.0
shader_param/roughness = 1.0
shader_param/point_size = 1.0
shader_param/uv1_scale = Vector3( 1, 1, 1 )
shader_param/uv1_offset = Vector3( 0, 0, 0 )
shader_param/uv2_scale = Vector3( 1, 1, 1 )
shader_param/uv2_offset = Vector3( 0, 0, 0 )
shader_param/max_height = 10.0
shader_param/min_height = 0.0
shader_param/texture_heightmap = ExtResource( 1 )
[node name="spatial" type="Spatial"]
[node name="mesh_instance" type="MeshInstance" parent="."]
mesh = SubResource( 1 )
material/0 = SubResource( 3 )