63 lines
1.7 KiB
Plaintext
63 lines
1.7 KiB
Plaintext
shader_type canvas_item;
|
|
render_mode skip_vertex_transform;
|
|
|
|
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;
|
|
|
|
void vertex() {
|
|
VERTEX = (WORLD_MATRIX * (EXTRA_MATRIX * vec4(VERTEX, 0.0, 1.0))).xy;
|
|
}
|
|
|
|
vec3 color_ramp(float h) {
|
|
if (h < 0.1f) {
|
|
return DeepWaterColor.rgb;
|
|
} else if (h < 0.12f) {
|
|
return WaterColor.rgb;
|
|
} else if (h < 0.45f) {
|
|
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;
|
|
} else if (h < 1.0){
|
|
return RockColor.rgb;
|
|
}
|
|
|
|
return SnowColor.rgb;
|
|
}
|
|
|
|
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 * texture(TextureMask, UV).r);
|
|
COLOR.a = 0.8;
|
|
// COLOR.rgb = vec3(1, 0, 0);
|
|
}
|
|
|