Compare commits

..

No commits in common. "62bff793396557f1fc5ded369e7d2dda9ad39f7c" and "77ce93fb154961fa6dc6fce8a2c461d3dd136e67" have entirely different histories.

4 changed files with 119 additions and 17 deletions

View file

@ -3,7 +3,7 @@
![screenshot](./screenshot.png) ![screenshot](./screenshot.png)
<p align=center>Use Godot's GLSL dialect for color grading and more.</p> <p align=center>Color grading with code.</p>
## Table of Contents ## Table of Contents
@ -31,7 +31,56 @@ If you want to learn GDShader, take a look at the [Godot docs](https://docs.godo
**To get started, use the project template (see the Releases section of this repo) and open it in Godot.** **To get started, use the project template (see the Releases section of this repo) and open it in Godot.**
The template includes examples that you can use as a starting-point to write your own stuff. The template includes many examples. You can use them as a starting-point to write your own stuff.
Besides the regular GDShader stuff, Pigment 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
```glsl
//!load <filepath>
```
The main image file will be read and available as the sampler2D `TEXTURE`.
#### Load additional images
```glsl
//!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:
```glsl
//!load ...
//!steps 5
uniform int STEP;
uniform int STEPS;
void fragment() {
if (STEP == 0) {
...
} else if (STEP == 1) {
...
} else if (STEP == STEPS-1) {
...
}
}
```
## Shaderlib ## Shaderlib
@ -46,6 +95,8 @@ shader_type canvas_item;
#include "./shaderlib/oklab.gdshaderinc" #include "./shaderlib/oklab.gdshaderinc"
//!load ./images/swamp.jpg
void fragment() { void fragment() {
vec4 oklab = rgb2oklab(COLOR); vec4 oklab = rgb2oklab(COLOR);
vec4 oklch = oklab2oklch(oklab); vec4 oklch = oklab2oklch(oklab);
@ -66,7 +117,7 @@ You can run Pigment from the commandline or scripts.
``` ```
~ Pigment CLI ~ ~ Pigment CLI ~
-=============- -================-
Usage: Usage:
@ -82,20 +133,20 @@ Commands:
| Applies a shader file. | Applies a shader file.
--shader PATH The path to the shader --shader PATH The path to the shader
--input PATH The path to the image --input PATH The path to the input image.
Passing a folder activates batch mode Passing a folder activates batch mode.
--output PATH Where to write the resulting image to --output PATH Where to write the resulting image to.
In batch mode, this must be a folder In batch mode, this must be a folder.
``` ```
### Batch Mode ### Batch Mode
You can pass a directory to `--input` and `--output`. This will process all images in the input directory and write the output to the output directory. Since version v8.0, you can pass a directory to `--input` and `--output`. This will process all images in the input directory and write the output to the output directory.
> Note: This is not very fast, so using it on maaany images may take some time. > Note: You *can* use this feature for video frames, but it will take a loooong time.
#### Examples #### Examples
@ -107,5 +158,5 @@ You can pass a directory to `--input` and `--output`. This will process all imag
## Known Issues ## Known Issues
- On some systems, screen scaling could lead to an either blurry UI, or no scaling at all - screen scaling is unsupported; Using screen scaling could lead to an either blurry UI, or no scaling at all -> see #45
- CLI: Godot's `--headless` option is not supported - commandline interface: `--headless` is not supported

View file

@ -0,0 +1,21 @@
MAINTAINER ChaoticByte
# Using Ubuntu 20.04
FROM docker.io/ubuntu:focal AS os-base
# https://docs.godotengine.org/en/stable/contributing/development/compiling/compiling_for_linuxbsd.html
RUN apt-get update
RUN DEBIAN_FRONTEND=noninteractive apt-get install -yq python3-pip git build-essential pkg-config libx11-dev libxcursor-dev libxinerama-dev libgl1-mesa-dev libglu1-mesa-dev libasound2-dev libpulse-dev libudev-dev libxi-dev libxrandr-dev libwayland-dev
RUN pip3 install --system scons
FROM os-base AS clone-src
RUN git clone https://github.com/godotengine/godot.git -b 4.5-stable /godot-src
FROM clone-src
WORKDIR /godot-src
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

30
build-template/build.sh Executable file
View file

@ -0,0 +1,30 @@
#!/usr/bin/env bash
set -e
function log {
echo -e "\033[1;36m***** $@\033[0m"
}
log
log "Pigment - Godot Build Template Builder"
log
cd $(dirname $0)
log Switched to $(pwd)
tmpsuffix=$(date +%s%N)
image_name=pigment-godot-template-builder
container_name=${image_name}-${tmpsuffix}
output_file=godot.linuxbsd.template_release.x86_64
log Building image ${image_name} ...
buildah build -t ${image_name}
log Building godot build template with container ${container_name} ...
podman run --name ${container_name} localhost/${image_name}:latest
log Copying ${output_file} from container to $(realpath ./${output_file})
podman cp ${container_name}:/godot-src/bin/${output_file} ./${output_file}
log Removing container ${container_name}
podman container rm ${container_name}
log Done :D

View file

@ -13,13 +13,13 @@ func show_help():
"Commands:\n\n", "Commands:\n\n",
" help\n\n", " help\n\n",
" | Shows this help text.\n\n", " | Shows this help text.\n\n",
" apply --shader PATH --input PATH --output PATH\n\n", " apply --shader PATH [--load-image PATH]\n\n",
" | Applies a shader file.\n\n", " | Applies a shader file.\n\n",
" --shader PATH The path to the shader\n", " --shader PATH The path to the shader\n",
" --input PATH The path to the image\n", " --input PATH The path to the image.\n",
" Passing a folder activates batch mode\n", " Passing a folder activates batch mode.\n",
" --output PATH Where to write the resulting image to\n", " --output PATH Where to write the resulting image to.\n",
" In batch mode, this must be a folder\n") " In batch mode, this must be a folder.\n")
func parse_custom_cmdline(args: PackedStringArray): func parse_custom_cmdline(args: PackedStringArray):
var kwargs: Dictionary = {"--shader": null, "--output": null, "--input": null} var kwargs: Dictionary = {"--shader": null, "--output": null, "--input": null}