Skip to content

Commit b3044f6

Browse files
authored
Merge pull request #46 from ChaoticByte/release/v8.0
Release/v8.0
2 parents dc325d3 + c0d9e00 commit b3044f6

13 files changed

+156
-76
lines changed

README.md

Lines changed: 38 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,15 @@
33

44
![screenshot](./screenshot.png)
55

6-
<p align=center>Create image filters by writing shaders.</p>
6+
<p align=center>An image editing/compositing software for graphics programmers.</p>
7+
8+
## Table of Contents
9+
10+
- [Supported Platforms](#supported-platforms)
11+
- [Usage](#usage)
12+
- [Shaderlib](#shaderlib)
13+
- [Commandline interface](#commandline-interface)
14+
- [Known Issues](#known-issues)
715

816
## Supported Platforms
917

@@ -13,8 +21,12 @@ You can find the latest releases [here](https://github.com/ChaoticByte/Fragmente
1321

1422
## Usage
1523

16-
The repo includes examples. You can use them as a starting-point to write your own filters.
17-
Just load an image using `//!load`, edit the shader code and hit `F5` to see the changes.
24+
With Fragemented, you are editing images by writing GDShaders. This brings almost endless opportunities to create unique art.
25+
If you want to learn GDShader, take a look at the [Godot docs](https://docs.godotengine.org/en/stable/tutorials/shaders/).
26+
27+
The repo also includes examples. You can use them as a starting-point to write your own filters.
28+
29+
Besides the regular GDShader stuff, Fragmented also has so-called directives. Those allow to further control the behaviour of the application. The most important directive is `//!load` to load an image.
1830

1931
### Load TEXTURE using the `//!load` directive
2032

@@ -68,12 +80,15 @@ Here is an example:
6880
```glsl
6981
shader_type canvas_item;
7082
71-
#include "res://shaderlib/hsv.gdshaderinc"
83+
#include "res://shaderlib/oklab.gdshaderinc"
7284
73-
//!load ./examples/images/swamp.jpg
85+
//!load ./images/swamp.jpg
7486
7587
void fragment() {
76-
COLOR = hsv_offset(COLOR, 0.32, 0.2, 0.0);
88+
vec4 oklab = rgb2oklab(COLOR);
89+
vec4 oklch = oklab2oklch(oklab);
90+
oklch.z -= 2.0;
91+
COLOR = oklab2rgb(oklch2oklab(oklch));
7792
}
7893
```
7994

@@ -89,14 +104,23 @@ You can run Fragmented from the commandline or scripts.
89104
./Fragmented cmd --shader PATH [--load-image PATH]
90105
91106
--shader PATH The path to the shader
92-
--output PATH Where to write the resulting image to
107+
--output PATH Where to write the resulting image to.
108+
In batch mode, this must be a folder.
93109
--load-image PATH The path to the image. This will overwrite the
94-
load directive of the shader file (optional)
110+
load directive of the shader file.
111+
Passing a folder activates batch mode.
112+
(optional)
95113
96114
```
97115

98116
You can also run `./Fragmented cmd help` to show the help message.
99117

118+
### Batch Mode
119+
120+
Since version v8.0, you can pass a directory to `--load-image` and `--output`. This will process all images in the input directory and write the output to the output directory.
121+
122+
> Note: You *can* use this feature for video frames, but it will take a loooong time.
123+
100124
#### Examples
101125

102126
```
@@ -106,3 +130,9 @@ You can also run `./Fragmented cmd help` to show the help message.
106130
```
107131
./Fragmented cmd --shader ./examples/oklab.gdshader --load-image ~/Pictures/test.png --output ./output.png
108132
```
133+
134+
## Known Issues
135+
136+
- screen scaling is unsupported; Using screen scaling could lead to an either blurry UI, or no scaling at all -> see #45
137+
- the shaderlib API is still unstable, this will change with version 10
138+
- commandline interface: `--headless` is not supported

build-template/Containerfile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,4 +18,4 @@ RUN git clone https://github.com/godotengine/godot.git -b 4.3-stable /godot-src
1818
FROM clone-src
1919

2020
WORKDIR /godot-src
21-
ENTRYPOINT scons platform=linuxbsd target=template_release lto=full optimize=size disable_3d=yes module_text_server_adv_enabled=no module_text_server_fb_enabled=yes module_basis_universal_enabled=no module_csg_enabled=no module_dds_enabled=no module_enet_enabled=no module_gridmap_enabled=no module_hdr_enabled=no module_jsonrpc_enabled=no module_ktx_enabled=no module_mbedtls_enabled=no module_meshoptimizer_enabled=no module_minimp3_enabled=no module_mobile_vr_enabled=no module_msdfgen_enabled=no module_multiplayer_enabled=no module_navigation_enabled=no module_ogg_enabled=no module_openxr_enabled=no module_raycast_enabled=no module_squish_enabled=no module_svg_enabled=no module_tga_enabled=no module_theora_enabled=no module_tinyexr_enabled=no module_upnp_enabled=no module_vhacd_enabled=no module_vorbis_enabled=no module_webrtc_enabled=no module_websocket_enabled=no module_webxr_enabled=no module_zip_enabled=no arch=x86_64 && strip bin/godot.linuxbsd.template_release.x86_64
21+
ENTRYPOINT scons platform=linuxbsd target=template_release lto=full optimize=size disable_3d=yes module_text_server_adv_enabled=no module_text_server_fb_enabled=yes module_basis_universal_enabled=no module_csg_enabled=no module_enet_enabled=no module_gridmap_enabled=no module_jsonrpc_enabled=no module_mbedtls_enabled=no module_meshoptimizer_enabled=no module_minimp3_enabled=no module_mobile_vr_enabled=no module_msdfgen_enabled=no module_multiplayer_enabled=no module_navigation_enabled=no module_ogg_enabled=no module_openxr_enabled=no module_raycast_enabled=no module_squish_enabled=no module_theora_enabled=no module_upnp_enabled=no module_vhacd_enabled=no module_vorbis_enabled=no module_webrtc_enabled=no module_websocket_enabled=no module_webxr_enabled=no arch=x86_64 && strip bin/godot.linuxbsd.template_release.x86_64

examples/color_and_pixelate.gdshader

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
shader_type canvas_item;
22

3-
#include "res://shaderlib/colorspaces.gdshaderinc"
4-
#include "res://shaderlib/effects.gdshaderinc"
3+
#include "res://shaderlib/hsv.gdshaderinc"
4+
#include "res://shaderlib/pixelate.gdshaderinc"
55

66
//!load ./images/swamp.jpg
77

examples/oklab.gdshader

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
shader_type canvas_item;
22

3-
#include "res://shaderlib/colorspaces.gdshaderinc"
3+
#include "res://shaderlib/oklab.gdshaderinc"
44

55
//!load ./images/swamp.jpg
66

examples/place_texture.gdshader

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
shader_type canvas_item;
22

3-
#include "res://shaderlib/transform.gdshaderinc"
4-
#include "res://shaderlib/transparency.gdshaderinc"
3+
#include "res://shaderlib/place_texture.gdshaderinc"
4+
#include "res://shaderlib/common.gdshaderinc"
55

66
//!load ./images/swamp.jpg
77
//!load+ img2 ./images/grass.png

project.godot

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ config_version=5
1111
[application]
1212

1313
config/name="Fragmented"
14-
config/version="v7.0"
14+
config/version="v8.0"
1515
run/main_scene="res://scenes/main.tscn"
1616
config/features=PackedStringArray("4.3", "Mobile")
1717
run/low_processor_mode=true

shaderlib/common.gdshaderinc

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,3 +3,13 @@
33
float cbrt(float x) {
44
return pow(x, 1.0/3.0);
55
}
6+
7+
/*
8+
Alpha Blending a over b after Bruce A. Wallace
9+
source: https://en.wikipedia.org/wiki/Alpha_compositing
10+
*/
11+
vec4 alpha_blend(vec4 b, vec4 a) {
12+
float alpha = a.a + (b.a * (1.0 - a.a));
13+
vec3 col = ((a.rgb*a.a) + ((b.rgb*b.a) * (1.0 - a.a)) / alpha);
14+
return vec4(col.r, col.g, col.b, alpha);
15+
}

shaderlib/hsv.gdshaderinc

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
2+
/*
3+
rgb2hsv and hsv2rgb functions adapted
4+
from https://godotshaders.com/shader/hsv-adjustment/
5+
original code by https://godotshaders.com/author/al1-ce/
6+
7+
Color space conversion functions always work with vec4.
8+
The fourth value is always alpha.
9+
*/
10+
11+
// Convert RGB to HSV (hue, saturation, brightness)
12+
vec4 rgb2hsv(vec4 c) {
13+
vec4 K = vec4(0.0, -1.0 / 3.0, 2.0 / 3.0, -1.0);
14+
vec4 p = mix(vec4(c.bg, K.wz), vec4(c.gb, K.xy), step(c.b, c.g));
15+
vec4 q = mix(vec4(p.xyw, c.r), vec4(c.r, p.yzx), step(p.x, c.r));
16+
float d = q.x - min(q.w, q.y);
17+
float e = 1.0e-10;
18+
return vec4(abs(q.z + (q.w - q.y) / (6.0 * d + e)), d / (q.x + e), q.x, c.a);
19+
}
20+
21+
// Convert HSV back to RGB (red, green, blue)
22+
vec4 hsv2rgb(vec4 c) {
23+
vec4 K = vec4(1.0, 2.0 / 3.0, 1.0 / 3.0, 3.0);
24+
vec3 p = abs(fract(c.xxx + K.xyz) * 6.0 - K.www);
25+
vec3 rgb = c.z * mix(K.xxx, clamp(p - K.xxx, 0.0, 1.0), c.y);
26+
return vec4(rgb.r, rgb.g, rgb.b, c.a);
27+
}

shaderlib/colorspaces.gdshaderinc renamed to shaderlib/oklab.gdshaderinc

Lines changed: 5 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -1,42 +1,16 @@
11

2-
/*
3-
Color space conversion functions always work with vec4.
4-
The fourth value is always alpha.
5-
*/
6-
7-
#include "res://shaderlib/common.gdshaderinc"
8-
9-
/*
10-
rgb2hsv and hsv2rgb functions adapted
11-
from https://godotshaders.com/shader/hsv-adjustment/
12-
original code by https://godotshaders.com/author/al1-ce/
13-
*/
14-
15-
// Convert RGB to HSV (hue, saturation, brightness)
16-
vec4 rgb2hsv(vec4 c) {
17-
vec4 K = vec4(0.0, -1.0 / 3.0, 2.0 / 3.0, -1.0);
18-
vec4 p = mix(vec4(c.bg, K.wz), vec4(c.gb, K.xy), step(c.b, c.g));
19-
vec4 q = mix(vec4(p.xyw, c.r), vec4(c.r, p.yzx), step(p.x, c.r));
20-
float d = q.x - min(q.w, q.y);
21-
float e = 1.0e-10;
22-
return vec4(abs(q.z + (q.w - q.y) / (6.0 * d + e)), d / (q.x + e), q.x, c.a);
23-
}
24-
25-
// Convert HSV back to RGB (red, green, blue)
26-
vec4 hsv2rgb(vec4 c) {
27-
vec4 K = vec4(1.0, 2.0 / 3.0, 1.0 / 3.0, 3.0);
28-
vec3 p = abs(fract(c.xxx + K.xyz) * 6.0 - K.www);
29-
vec3 rgb = c.z * mix(K.xxx, clamp(p - K.xxx, 0.0, 1.0), c.y);
30-
return vec4(rgb.r, rgb.g, rgb.b, c.a);
31-
}
32-
332
/*
343
OkLab and OkLCh
354
For more details on oklab, see
365
- https://bottosson.github.io/posts/oklab/
376
- https://en.wikipedia.org/wiki/Oklab_color_space
7+
8+
Color space conversion functions always work with vec4.
9+
The fourth value is always alpha.
3810
*/
3911

12+
#include "res://shaderlib/common.gdshaderinc"
13+
4014
vec4 rgb2oklab(vec4 c) {
4115
float l = 0.4122214708f * c.r + 0.5363325363f * c.g + 0.0514459929f * c.b;
4216
float m = 0.2119034982f * c.r + 0.6806995451f * c.g + 0.1073969566f * c.b;
File renamed without changes.

0 commit comments

Comments
 (0)