2024-06-09 16:25:55 +02:00
|
|
|
|
2024-12-19 16:48:32 +01:00
|
|
|
<h1 align=center>Fragmented</h1>
|
2024-06-09 16:25:55 +02:00
|
|
|
|
|
|
|

|
|
|
|
|
|
|
|
<p align=center>Create image filters by writing shaders.</p>
|
2024-06-09 16:44:28 +02:00
|
|
|
|
|
|
|
## Supported Platforms
|
|
|
|
|
2024-06-21 10:33:34 +02:00
|
|
|
- Linux
|
2024-06-09 16:44:28 +02:00
|
|
|
|
2024-12-19 16:48:32 +01:00
|
|
|
You can find the latest releases [here](https://github.com/ChaoticByte/Fragmented/releases/latest).
|
2024-06-09 16:44:28 +02:00
|
|
|
|
|
|
|
## Usage
|
|
|
|
|
2024-12-19 18:52:47 +01:00
|
|
|
The repo includes examples. You can use them as a starting-point to write your own filters.
|
|
|
|
Just load an image using `//!load`, edit the shader code and hit `F5` to see the changes.
|
2024-06-09 16:44:28 +02:00
|
|
|
|
2024-12-19 18:52:47 +01:00
|
|
|
### Load TEXTURE using the `//!load` directive
|
|
|
|
|
|
|
|
```glsl
|
|
|
|
//!load <filepath>
|
|
|
|
```
|
|
|
|
|
|
|
|
The image file will be read and available as the `TEXTURE` variable.
|
|
|
|
|
|
|
|
#### Load additional images
|
2024-06-09 16:44:28 +02:00
|
|
|
|
|
|
|
```glsl
|
2024-12-21 18:27:21 +01:00
|
|
|
//!load+ <name> <filepath>
|
2024-06-09 16:44:28 +02:00
|
|
|
uniform sampler2D <name>;
|
|
|
|
```
|
|
|
|
|
2024-12-28 00:00:46 +01:00
|
|
|
Have a look at the `place_texture.gdshader` example:
|
2024-06-09 16:44:28 +02:00
|
|
|
|
|
|
|
```glsl
|
|
|
|
shader_type canvas_item;
|
|
|
|
|
2024-12-28 00:00:46 +01:00
|
|
|
#include "res://shaderlib/transform.gdshaderinc"
|
|
|
|
|
2024-12-19 19:03:00 +01:00
|
|
|
//!load ./swamp.jpg
|
2024-12-28 00:00:46 +01:00
|
|
|
//!load+ img2 ./grass.png
|
2024-12-19 18:52:47 +01:00
|
|
|
|
2024-12-28 00:00:46 +01:00
|
|
|
uniform sampler2D img2: repeat_disable, filter_nearest;
|
2024-06-09 16:44:28 +02:00
|
|
|
|
|
|
|
void fragment() {
|
2024-12-28 00:00:46 +01:00
|
|
|
vec4 grass = place_texture(img2, UV, TEXTURE_PIXEL_SIZE, vec2(0, .47), vec2(1));
|
|
|
|
grass.rgb += (vec3(0.03, 0.07, 0.11) - ((UV.y - .8) * 0.15)); // color correction
|
|
|
|
COLOR.rgb = mix(COLOR.rgb, grass.rgb, grass.a);
|
2024-06-09 16:44:28 +02:00
|
|
|
}
|
|
|
|
```
|
2024-12-22 23:04:35 +01:00
|
|
|
|
|
|
|
## 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 on how to use it (the `hsv.gdshader` example):
|
|
|
|
|
|
|
|
```glsl
|
|
|
|
shader_type canvas_item;
|
|
|
|
|
|
|
|
#include "res://shaderlib/hsv.gdshaderinc"
|
|
|
|
|
|
|
|
//!load ./swamp.jpg
|
|
|
|
|
|
|
|
void fragment() {
|
|
|
|
COLOR = hsv_offset(COLOR, 0.32, 0.2, 0.0);
|
|
|
|
}
|
|
|
|
```
|