You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
36 lines
1.4 KiB
36 lines
1.4 KiB
shader_type canvas_item;
|
|
|
|
uniform float color_steps:hint_range(1.0, 255.0, 1.0);
|
|
uniform float color_min:hint_range(0.0, 1.0, 0.01) = 0;
|
|
uniform float color_max:hint_range(0.0, 1.0, 0.01) = 1;
|
|
uniform sampler2D color_curve;
|
|
|
|
void vertex() {
|
|
// Called for every vertex the material is visible on.
|
|
}
|
|
|
|
void fragment() {
|
|
vec2 texSize = vec2(textureSize(TEXTURE,0)); // For performance reasons, this function should be avoided as it always performs a full texture read. When possible, you should pass the texture size as a uniform instead.
|
|
texSize = texSize / 4.;
|
|
ivec2 intUv = ivec2(texSize * UV);
|
|
vec2 flooredUv = vec2(intUv) / texSize;
|
|
vec3 fullColor = texture(TEXTURE,flooredUv).rgb;
|
|
//vec3 strechedColor = (fullColor - color_min) / color_max;
|
|
vec3 strechedColor = vec3(
|
|
texture(color_curve,vec2(fullColor.r,0)).r,
|
|
texture(color_curve,vec2(fullColor.g,0)).r,
|
|
texture(color_curve,vec2(fullColor.b,0)).r);
|
|
vec3 scaledColor = strechedColor * color_steps;
|
|
vec3 roundColor = round(scaledColor);
|
|
vec3 backScaledColor = roundColor / color_steps;
|
|
COLOR = vec4(backScaledColor,1);
|
|
//COLOR = vec4(flooredUv,0,1);
|
|
//COLOR = vec4(vec3(float(textureQueryLevels(TEXTURE)/1)),1);
|
|
//COLOR = vec4(1,0,0,1);
|
|
}
|
|
|
|
//void light() {
|
|
// // Called for every pixel for every light affecting the CanvasItem.
|
|
// // Uncomment to replace the default light processing function with this one.
|
|
//}
|