57 lines
1.5 KiB
Plaintext
57 lines
1.5 KiB
Plaintext
shader_type canvas_item;
|
|
|
|
#define pow2(x) (x * x)
|
|
#define iResolution 1.0/SCREEN_PIXEL_SIZE
|
|
|
|
uniform sampler2D data_texture;
|
|
uniform vec2 data_texture_size;
|
|
uniform sampler2D texture_low : filter_nearest, repeat_enable;
|
|
uniform float texture_low_threshold : hint_range(0, 1) = 0.3;
|
|
uniform sampler2D texture_medium : filter_nearest, repeat_enable;
|
|
uniform sampler2D texture_high : filter_nearest, repeat_enable;
|
|
uniform float texture_high_threshold : hint_range(0, 1) = 0.7;
|
|
|
|
uniform int dimension;
|
|
uniform vec2 texture_size = vec2(100,100);
|
|
|
|
uniform float smooth_change_range = 0.15;
|
|
|
|
varying vec2 vert;
|
|
|
|
void vertex() {
|
|
vert = VERTEX;
|
|
}
|
|
|
|
void fragment() {
|
|
vec4 pixel_color = texture(data_texture, vert/data_texture_size);
|
|
float value = pixel_color.x;
|
|
if (dimension == 1) value = pixel_color.y;
|
|
if (dimension == 2) value = pixel_color.z;
|
|
|
|
vec4 color = texture(texture_medium, vert/texture_size);
|
|
|
|
if (value < texture_low_threshold)
|
|
color =
|
|
min(
|
|
(texture_low_threshold - value) / smooth_change_range,
|
|
1.0
|
|
) * texture(texture_low, vert/texture_size)
|
|
+ (1.0 - min(
|
|
(texture_low_threshold - value) / smooth_change_range,
|
|
1.0
|
|
)
|
|
) * texture(texture_medium, vert/texture_size);
|
|
if (value > texture_high_threshold)
|
|
color =
|
|
min(
|
|
(value - texture_high_threshold) / smooth_change_range,
|
|
1.0
|
|
) * texture(texture_high, vert/texture_size)
|
|
+ (1.0 - min(
|
|
(value - texture_high_threshold) / smooth_change_range,
|
|
1.0
|
|
)
|
|
) * texture(texture_medium, vert/texture_size);
|
|
|
|
COLOR = color;
|
|
} |