2023-05-21 17:24:37 +02:00
|
|
|
shader_type canvas_item;
|
|
|
|
render_mode skip_vertex_transform;
|
|
|
|
|
2023-10-30 22:20:32 +01:00
|
|
|
uniform vec4 DeepWaterColor : hint_color = vec4(0, 0, 0.6, 1);
|
|
|
|
uniform vec4 WaterColor : hint_color = vec4(0, 0, 0.7, 1);
|
|
|
|
uniform vec4 LightWaterColor : hint_color = vec4(0, 0, 1, 1);
|
|
|
|
uniform vec4 SandColor : hint_color = vec4(0.8, 0.8, 0.1, 1);
|
|
|
|
uniform vec4 GrassColor : hint_color = vec4(0, 0.6, 0, 1);
|
|
|
|
uniform vec4 ForestColor : hint_color = vec4(0, 0.4, 0, 1);
|
|
|
|
uniform vec4 RockColor : hint_color = vec4(0.5, 0.5, 0.4, 1);
|
|
|
|
uniform vec4 SnowColor : hint_color = vec4(1);
|
|
|
|
uniform sampler2D TextureMask : hint_albedo;
|
|
|
|
|
2023-05-21 17:24:37 +02:00
|
|
|
void vertex() {
|
|
|
|
VERTEX = (WORLD_MATRIX * (EXTRA_MATRIX * vec4(VERTEX, 0.0, 1.0))).xy;
|
|
|
|
}
|
|
|
|
|
|
|
|
vec3 color_ramp(float h) {
|
2023-10-30 22:20:32 +01:00
|
|
|
if (h < 0.1f) {
|
|
|
|
return DeepWaterColor.rgb;
|
|
|
|
} else if (h < 0.12f) {
|
|
|
|
return WaterColor.rgb;
|
2023-05-21 17:24:37 +02:00
|
|
|
} else if (h < 0.45f) {
|
2023-10-30 22:20:32 +01:00
|
|
|
return LightWaterColor.rgb;
|
|
|
|
// } else if (h < 0.25){
|
|
|
|
// return SandColor.rgb;
|
|
|
|
} else if (h < 0.75){
|
|
|
|
return GrassColor.rgb;
|
|
|
|
// } else if (h < 0.78){
|
|
|
|
// return ForestColor.rgb;
|
2023-05-21 17:24:37 +02:00
|
|
|
} else if (h < 1.0){
|
2023-10-30 22:20:32 +01:00
|
|
|
return RockColor.rgb;
|
2023-05-21 17:24:37 +02:00
|
|
|
}
|
|
|
|
|
2023-10-30 22:20:32 +01:00
|
|
|
return SnowColor.rgb;
|
2023-05-21 17:24:37 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
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);
|
2023-10-30 22:20:32 +01:00
|
|
|
|
|
|
|
// COLOR.rgb = color_ramp(texture_color.r * borderFalloffCircle(UV) * 1.8);
|
|
|
|
COLOR.rgb = color_ramp(texture_color.r * texture(TextureMask, UV).r);
|
|
|
|
COLOR.a = 0.8;
|
|
|
|
// COLOR.rgb = vec3(1, 0, 0);
|
2023-05-21 17:24:37 +02:00
|
|
|
}
|
|
|
|
|