Added Noise based island generator.
parent
1ae17ed63b
commit
983bb792fa
|
@ -0,0 +1,59 @@
|
|||
[gd_resource type="ShaderMaterial" load_steps=2 format=2]
|
||||
|
||||
[sub_resource type="Shader" id=1]
|
||||
code = "shader_type canvas_item;
|
||||
render_mode skip_vertex_transform;
|
||||
|
||||
void vertex() {
|
||||
VERTEX = (WORLD_MATRIX * (EXTRA_MATRIX * vec4(VERTEX, 0.0, 1.0))).xy;
|
||||
}
|
||||
|
||||
vec3 color_ramp(float h) {
|
||||
if (h < 0.4f) {
|
||||
return vec3(0, 0, 0.6);
|
||||
} else if (h < 0.45f) {
|
||||
return vec3(0, 0, 0.7);
|
||||
} else if (h < 0.5f) {
|
||||
return vec3(0, 0, 1);
|
||||
} else if (h < 0.55){
|
||||
return vec3(0.8, 0.8, 0.1);
|
||||
} else if (h < 0.6){
|
||||
return vec3(0, 0.6, 0);
|
||||
} else if (h < 0.68){
|
||||
return vec3(0, 0.4, 0);
|
||||
} else if (h <= 0.78){
|
||||
return vec3(0.6, 0.6, 0.6);
|
||||
} else if (h < 1.0){
|
||||
return vec3(0.8, 0.8, 0.8);
|
||||
}
|
||||
|
||||
return vec3(1.0);
|
||||
}
|
||||
|
||||
vec3 rgbToGrayscale(vec3 color) {
|
||||
return vec3(dot(color.rgb, vec3(0.299, 0.587, 0.144)));
|
||||
}
|
||||
|
||||
float borderFalloff(vec2 uv) {
|
||||
return min(
|
||||
(0.5 - abs(-uv.x + 0.5)) * 2.0,
|
||||
(0.5 - abs(-uv.y + 0.5)) * 2.0);
|
||||
}
|
||||
|
||||
float borderFalloffCircle(vec2 uv) {
|
||||
return (0.5 - length(vec2(uv - vec2(0.5, 0.5)))) * 2.0;
|
||||
}
|
||||
|
||||
void fragment() {
|
||||
vec4 texture_color = texture(TEXTURE, UV);
|
||||
|
||||
|
||||
COLOR.rgb = vec3(abs(UV.x - 0.5) * 2.0);
|
||||
//COLOR.rgb = color_ramp(texture_color.r * borderFalloffCircle(UV) * 1.8);
|
||||
COLOR.rgb = color_ramp(texture_color.r * borderFalloff(UV) * 1.8);
|
||||
}
|
||||
|
||||
"
|
||||
|
||||
[resource]
|
||||
shader = SubResource( 1 )
|
|
@ -0,0 +1,88 @@
|
|||
[gd_scene load_steps=5 format=2]
|
||||
|
||||
[sub_resource type="Shader" id=1]
|
||||
code = "shader_type canvas_item;
|
||||
render_mode skip_vertex_transform;
|
||||
|
||||
void vertex() {
|
||||
VERTEX = (WORLD_MATRIX * (EXTRA_MATRIX * vec4(VERTEX, 0.0, 1.0))).xy;
|
||||
}
|
||||
|
||||
vec3 color_ramp(float h) {
|
||||
if (h < 0.4f) {
|
||||
return vec3(0, 0, 0.6);
|
||||
} else if (h < 0.45f) {
|
||||
return vec3(0, 0, 0.7);
|
||||
} else if (h < 0.5f) {
|
||||
return vec3(0, 0, 1);
|
||||
} else if (h < 0.55){
|
||||
return vec3(0.8, 0.8, 0.1);
|
||||
} else if (h < 0.6){
|
||||
return vec3(0, 0.6, 0);
|
||||
} else if (h < 0.68){
|
||||
return vec3(0, 0.4, 0);
|
||||
} else if (h <= 0.78){
|
||||
return vec3(0.6, 0.6, 0.6);
|
||||
} else if (h < 1.0){
|
||||
return vec3(0.8, 0.8, 0.8);
|
||||
}
|
||||
|
||||
return vec3(1.0);
|
||||
}
|
||||
|
||||
vec3 rgbToGrayscale(vec3 color) {
|
||||
return vec3(dot(color.rgb, vec3(0.299, 0.587, 0.144)));
|
||||
}
|
||||
|
||||
float borderFalloff(vec2 uv) {
|
||||
return min(
|
||||
(0.5 - abs(-uv.x + 0.5)) * 2.0,
|
||||
(0.5 - abs(-uv.y + 0.5)) * 2.0);
|
||||
}
|
||||
|
||||
float borderFalloffCircle(vec2 uv) {
|
||||
return (0.5 - length(vec2(uv - vec2(0.5, 0.5)))) * 2.0;
|
||||
}
|
||||
|
||||
void fragment() {
|
||||
vec4 texture_color = texture(TEXTURE, UV);
|
||||
|
||||
|
||||
COLOR.rgb = vec3(abs(UV.x - 0.5) * 2.0);
|
||||
//COLOR.rgb = color_ramp(texture_color.r * borderFalloffCircle(UV) * 1.8);
|
||||
COLOR.rgb = color_ramp(texture_color.r * borderFalloff(UV) * 1.8);
|
||||
}
|
||||
|
||||
"
|
||||
|
||||
[sub_resource type="ShaderMaterial" id=2]
|
||||
shader = SubResource( 1 )
|
||||
|
||||
[sub_resource type="OpenSimplexNoise" id=3]
|
||||
seed = 57
|
||||
octaves = 5
|
||||
period = 20.0
|
||||
persistence = 0.2
|
||||
lacunarity = 4.0
|
||||
|
||||
[sub_resource type="NoiseTexture" id=4]
|
||||
width = 128
|
||||
height = 128
|
||||
seamless = true
|
||||
noise = SubResource( 3 )
|
||||
noise_offset = Vector2( 2.632, 0 )
|
||||
|
||||
[node name="Node2D" type="Node2D"]
|
||||
|
||||
[node name="GridContainer" type="GridContainer" parent="."]
|
||||
margin_right = 861.0
|
||||
margin_bottom = 595.0
|
||||
|
||||
[node name="TextureRect" type="TextureRect" parent="GridContainer"]
|
||||
material = SubResource( 2 )
|
||||
margin_right = 861.0
|
||||
margin_bottom = 595.0
|
||||
size_flags_horizontal = 3
|
||||
size_flags_vertical = 3
|
||||
texture = SubResource( 4 )
|
||||
expand = true
|
|
@ -0,0 +1,28 @@
|
|||
[gd_scene load_steps=4 format=2]
|
||||
|
||||
[ext_resource path="res://scenes/TileWorld.cs" type="Script" id=1]
|
||||
[ext_resource path="res://icon.png" type="Texture" id=2]
|
||||
[ext_resource path="res://materials/IslandColorRampShader.tres" type="Material" id=3]
|
||||
|
||||
[node name="TileWorld" type="Spatial"]
|
||||
script = ExtResource( 1 )
|
||||
|
||||
[node name="DirectionalLight" type="DirectionalLight" parent="."]
|
||||
transform = Transform( 0.328059, -0.878387, 0.347583, 0, 0.367946, 0.929847, -0.944657, -0.305045, 0.120708, 0, 6.59293, 1.20265 )
|
||||
shadow_enabled = true
|
||||
directional_shadow_mode = 0
|
||||
|
||||
[node name="OffscreenViewport" type="Viewport" parent="."]
|
||||
size = Vector2( 100, 100 )
|
||||
own_world = true
|
||||
handle_input_locally = false
|
||||
hdr = false
|
||||
usage = 0
|
||||
render_target_v_flip = true
|
||||
render_target_update_mode = 3
|
||||
|
||||
[node name="TextureRect" type="TextureRect" parent="OffscreenViewport"]
|
||||
material = ExtResource( 3 )
|
||||
margin_right = 40.0
|
||||
margin_bottom = 40.0
|
||||
texture = ExtResource( 2 )
|
Loading…
Reference in New Issue