mirror of
https://github.com/Orama-Interactive/Pixelorama.git
synced 2025-01-18 17:19:50 +00:00
Fix warnings in some shaders
This commit is contained in:
parent
f15e8fb8f2
commit
4d26a6dd55
|
@ -6,6 +6,10 @@ uniform float saturation : hint_range(-1, 1);
|
|||
uniform float value : hint_range(-1, 1);
|
||||
uniform sampler2D selection : filter_nearest;
|
||||
|
||||
bool is_equal_approx(float a, float b) {
|
||||
return abs(a - b) <= 0.0001;
|
||||
}
|
||||
|
||||
vec3 rgb2hsb(vec3 c){
|
||||
vec4 K = vec4(0.0, -1.0 / 3.0, 2.0 / 3.0, -1.0);
|
||||
vec4 p = mix(vec4(c.bg, K.wz),
|
||||
|
@ -38,7 +42,7 @@ void fragment() {
|
|||
vec3 col = original_color.rgb;
|
||||
vec3 hsb = rgb2hsb(col);
|
||||
// If not greyscale
|
||||
if(col[0] != col[1] || col[1] != col[2]) {
|
||||
if(!is_equal_approx(col[0], col[1]) || !is_equal_approx(col[1], col[2])) {
|
||||
// Shift the color by shift_amount, but rolling over the value goes over 1
|
||||
hsb.x = mod(hsb.x + hue, 1.0);
|
||||
}
|
||||
|
|
|
@ -8,6 +8,9 @@ uniform int pattern : hint_range(0, 2) = 0; // diamond, circle, square
|
|||
uniform bool inside = false;
|
||||
uniform sampler2D selection : filter_nearest;
|
||||
|
||||
bool is_zero_approx(float num) {
|
||||
return num < 0.0001;
|
||||
}
|
||||
|
||||
bool has_contrary_neighbour(vec2 uv, vec2 texture_pixel_size, sampler2D tex) {
|
||||
for (float i = -ceil(width); i <= ceil(width); i++) {
|
||||
|
@ -24,7 +27,7 @@ bool has_contrary_neighbour(vec2 uv, vec2 texture_pixel_size, sampler2D tex) {
|
|||
for (float j = -ceil(offset); j <= ceil(offset); j++) {
|
||||
vec2 xy = uv + texture_pixel_size * vec2(i, j);
|
||||
|
||||
if ((xy != clamp(xy, vec2(0.0), vec2(1.0)) || texture(tex, xy).a == 0.0) == inside) {
|
||||
if ((xy != clamp(xy, vec2(0.0), vec2(1.0)) || is_zero_approx(texture(tex, xy).a)) == inside) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -31,4 +31,3 @@ void fragment() {
|
|||
vec4 color = swap_color(original_color);
|
||||
COLOR = mix(original_color.rgba, color, selection_color.a);
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue