Skip to content

Commit

Permalink
docs(shaders): more comments
Browse files Browse the repository at this point in the history
  • Loading branch information
loqusion committed May 6, 2024
1 parent d7779ec commit 341b707
Show file tree
Hide file tree
Showing 3 changed files with 59 additions and 6 deletions.
21 changes: 20 additions & 1 deletion shaders/blue-light-filter.glsl.mustache
Original file line number Diff line number Diff line change
@@ -1,10 +1,29 @@
// from https://github.com/hyprwm/Hyprland/issues/1140#issuecomment-1335128437
/*
* Blue Light Filter
*
* Use warmer colors to make the display easier on your eyes.
*
* Source: https://github.com/hyprwm/Hyprland/issues/1140#issuecomment-1335128437
*/

precision highp float;
varying vec2 v_texcoord;
uniform sampler2D tex;

/**
* Color temperature in Kelvin.
*
* @min 1000.0
* @max 40000.0
*/
const float temperature = float({{#nc}}{{temperature}} ? 2600.0{{/nc}});

/**
* Strength of filter.
*
* @min 0.0
* @max 1.0
*/
const float temperatureStrength = float({{#nc}}{{strength}} ? 1.0{{/nc}});

#define WithQuickAndDirtyLuminancePreservation
Expand Down
21 changes: 17 additions & 4 deletions shaders/color-filter.glsl.mustache
Original file line number Diff line number Diff line change
@@ -1,11 +1,22 @@
// Color blind shader for hyprland.
// From: https://godotshaders.com/shader/colorblindness-correction-shader/
/*
* Color Filter
*
* Adjust colors for color vision deficiencies.
* Supports protanopia (red-green), deuteranopia (green-red), and tritanopia (blue-yellow).
*
* Source: https://godotshaders.com/shader/colorblindness-correction-shader/
*/

precision highp float;
varying vec2 v_texcoord;
uniform sampler2D tex;

// Intensity of filter (1.0 - 0.0)
/**
* Strength of filter.
*
* @min 0.0
* @max 1.0
*/
const float intensity = float({{#nc}}{{strength}} ? 0.2{{/nc}});

// Enum for color correction type
Expand All @@ -19,7 +30,9 @@ const int TRITANOPIA = 2;
const int TRITAN = TRITANOPIA;
const int BLUEYELLOW = TRITANOPIA;

// Color correction type
/**
* Type of color correction.
*/
const int type = {{#nc}}{{type}} ? PROTANOPIA{{/nc}};

void main() {
Expand Down
23 changes: 22 additions & 1 deletion shaders/vibrance.glsl.mustache
Original file line number Diff line number Diff line change
@@ -1,15 +1,36 @@
// from https://github.com/hyprwm/Hyprland/issues/1140#issuecomment-1614863627
/*
* Vibrance
*
* Enhance color saturation.
* Also supports per-channel multipliers.
*
* Source: https://github.com/hyprwm/Hyprland/issues/1140#issuecomment-1614863627
*/

precision highp float;
varying vec2 v_texcoord;
uniform sampler2D tex;

// see https://github.com/CeeJayDK/SweetFX/blob/a792aee788c6203385a858ebdea82a77f81c67f0/Shaders/Vibrance.fx#L20-L30

/**
* Per-channel multiplier to vibrance strength.
*
* @min 0.0
* @max 10.0
*/
const vec3 VIB_RGB_BALANCE = vec3(
float({{#nc}}{{balance.red}} ? 1.0{{/nc}}),
float({{#nc}}{{balance.green}} ? 1.0{{/nc}}),
float({{#nc}}{{balance.blue}} ? 1.0{{/nc}})
);

/**
* Strength of filter.
*
* @min -1.0
* @max 1.0
*/
const float VIB_VIBRANCE = float({{#nc}}{{strength}} ? 0.15{{/nc}});

const vec3 VIB_coeffVibrance = VIB_RGB_BALANCE * -VIB_VIBRANCE;
Expand Down

0 comments on commit 341b707

Please sign in to comment.