Create and apply image filters using Godot's GLSL dialect.
Find a file
2025-03-31 15:41:31 +02:00
build-template Update to Godot 4.4 2025-03-13 20:57:31 +01:00
examples Add sobel filter (edge detection) 2025-03-31 15:41:31 +02:00
shaderlib Add sobel filter (edge detection) 2025-03-31 15:41:31 +02:00
src Fix: Show and align image viewport before first step 2025-03-31 15:39:36 +02:00
tools Update to Godot 4.4 2025-03-13 20:57:31 +01:00
.gitattributes Add project files 2024-06-04 18:31:04 +02:00
.gitignore Delete .gitkeep in dist folder, create it on demand 2025-02-05 17:50:41 +01:00
dist.sh Delete .gitkeep in dist folder, create it on demand 2025-02-05 17:50:41 +01:00
export_presets.cfg Update example project and export_presets.cfg for Godot 4.4 2025-03-15 18:16:02 +01:00
LICENSE Update LICENSE (fix name) 2025-01-17 15:37:57 +01:00
project.godot Disable low_processor_mode in the settings to improve multistep performance 2025-03-31 15:37:55 +02:00
README.md Declare shaderlib as stable, bump version to v10.0 2025-03-15 20:45:30 +01:00
screenshot.png Update screenshot 2025-03-13 21:55:27 +01:00

Fragmented

screenshot

An image editing/compositing software for graphics programmers.

Table of Contents

Supported Platforms

  • Linux

You can find the latest releases here.

Usage

With Fragemented, you are processing images with GDShaders. This brings almost endless opportunities to create unique art.
If you want to learn GDShader, take a look at the Godot docs.

The builtin editor got removed from Fragmented with version v9.0. I advise you to write your shaders directly in the Godot Editor.

To get started, use the project template (see the Releases section of this repo) and open it in Godot.

The template includes many examples. You can use them as a starting-point to write your own stuff.

Besides the regular GDShader stuff, Fragmented has so-called directives. Those allow to further control the behaviour of the application. The most important directive is //!load to load an image.

Load TEXTURE using the //!load directive

//!load <filepath>

The main image file will be read and available as the sampler2D TEXTURE.

Load additional images

//!load+ <name> <filepath>

uniform sampler2D <name>;

Have a look at the place_texture.gdshader example.

Have multiple steps with //!steps n

You can apply your shaderfile multiple times. At every additional step, TEXTURE is the result of the previous step. This can be used to chain effects that cannot be easily chained otherwise.

To query the current step index, a STEP uniform is automatically injected. If steps is set to 0, your shader won't be applied at all.

Example:

//!load ...
//!steps 5

uniform int STEP; // this is mandatory!

void fragment() {
  if (STEP == 0) {
	...
  } else if (STEP == 1) {
	...
  }
  // ... and so on
}

Shaderlib

This repo comes with a (still small) shader library including pre-written functions and more.
Have a look at the shaderlib folder.

Here is an example:

shader_type canvas_item;

#include "./shaderlib/oklab.gdshaderinc"

//!load ./images/swamp.jpg

void fragment() {
	vec4 oklab = rgb2oklab(COLOR);
	vec4 oklch = oklab2oklch(oklab);
	oklch.z -= 2.0;
	COLOR = oklab2rgb(oklch2oklab(oklch));
}

Commandline interface

You can run Fragmented from the commandline or scripts.

Note: Headless mode is not supported. Using the commandline interface still opens a window.

Usage

~ Fragmented CLI ~
-================-

Usage:

./Fragmented <command> <args...>

Commands:

 help

  | Shows this help text.

 apply --shader PATH [--load-image PATH]

  | Applies a shader file.

    --shader PATH      The path to the shader
    --output PATH      Where to write the resulting image to.
                       In batch mode, this must be a folder.
    --load-image PATH  The path to the image. This will overwrite the
                       load directive of the shader file.
                       Passing a folder activates batch mode.
                       (optional)

Batch Mode

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.

Note: You can use this feature for video frames, but it will take a loooong time.

Examples

./Fragmented apply --shader ./examples/oklab.gdshader --output ./output.png
./Fragmented apply --shader ./examples/oklab.gdshader --load-image ~/Pictures/test.png --output ./output.png

Known Issues

  • screen scaling is unsupported; Using screen scaling could lead to an either blurry UI, or no scaling at all -> see #45
  • commandline interface: --headless is not supported