mirror of
https://github.com/Orama-Interactive/Pixelorama.git
synced 2025-02-26 15:33:13 +00:00
* Basic logic for layer effects * Add an FX button and the ability to add effects, no way to remove or change properties of effects yet * Basic and ugly UI for adding and removing effects, no property changing yet * Swap effects * Fix preload shader paths * Change parameters for layer effects * Change gradient parameter in layer effect shaders, and other fixes * Use CollapsibleContainers for the shader properties * Set the correct gradient interpolation mode and color space in the UI * Make effects of group layers apply to children * Change `apply_fx` to `apply_effects`, formatting, some extra doc comments * Apply effects to other canvases, when merging layers and when exporting * Display humanized names of the shader unifrms * Some UI improvements to the LayerEffectsSettings * Add an Enabled button in the layer effects window, and change checkboxes to checkbuttons * Change BaseLayer.apply_effects() to take a cel as a parameter instead * Make layer effect buttons be affected by the modulate icon color * Add option in the View menu whether layer effects are displayed in the canvas or not * Rename `apply_effects()` to `display_effects()` * Add translation strings * Add nearest filter to the gradient map * Don't change Main.tscn * Fix more translations * Change the default cursor shape of the generated UI elements of the layer effects * Add undo/redo and effect application (apply effect destructively) There are some errors due to the usage of anonymous lambda methods in undo/redo, but it seems to be working well regardless. * Make layer effect application work on all cels
62 lines
1.6 KiB
Text
62 lines
1.6 KiB
Text
shader_type canvas_item;
|
|
render_mode unshaded;
|
|
|
|
uniform float hue : hint_range(-1, 1);
|
|
uniform float saturation : hint_range(-1, 1);
|
|
uniform float value : hint_range(-1, 1);
|
|
uniform sampler2D selection;
|
|
|
|
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),
|
|
vec4(c.gb, K.xy),
|
|
step(c.b, c.g));
|
|
vec4 q = mix(vec4(p.xyw, c.r),
|
|
vec4(c.r, p.yzx),
|
|
step(p.x, c.r));
|
|
float d = q.x - min(q.w, q.y);
|
|
float e = 1.0e-10;
|
|
return vec3(abs(q.z + (q.w - q.y) / (6.0 * d + e)),
|
|
d / (q.x + e),
|
|
q.x);
|
|
}
|
|
|
|
vec3 hsb2rgb(vec3 c){
|
|
vec3 rgb = clamp(abs(mod(c.x*6.0+vec3(0.0,4.0,2.0),
|
|
6.0)-3.0)-1.0,
|
|
0.0,
|
|
1.0 );
|
|
rgb = rgb*rgb*(3.0-2.0*rgb);
|
|
return c.z * mix(vec3(1.0), rgb, c.y);
|
|
}
|
|
|
|
void fragment() {
|
|
// Get color from the sprite texture at the current pixel we are rendering
|
|
vec4 original_color = texture(TEXTURE, UV);
|
|
vec4 selection_color = texture(selection, UV);
|
|
|
|
vec3 col = original_color.rgb;
|
|
vec3 hsb = rgb2hsb(col);
|
|
// If not greyscale
|
|
if(col[0] != col[1] || 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);
|
|
}
|
|
if(saturation > 0.0) {
|
|
hsb.y = mix(hsb.y, 1 , saturation);
|
|
}
|
|
else if (saturation < 0.0) {
|
|
hsb.y = mix(0, hsb.y , 1.0 - abs(saturation));
|
|
}
|
|
|
|
if(value > 0.0) {
|
|
hsb.z = mix(hsb.z, 1 , value);
|
|
}
|
|
else if (value < 0.0) {
|
|
hsb.z = mix(0, hsb.z , 1.0 - abs(value));
|
|
}
|
|
|
|
col = hsb2rgb(hsb);
|
|
vec3 output = mix(original_color.rgb, col, selection_color.a);
|
|
COLOR = vec4(output.rgb, original_color.a);
|
|
}
|