Skip to content

Commit c29bc66

Browse files
kRHYME7rubiin
andcommitted
refactor: Porting our shaders to be #version 300 compatible (#894)
* Refactor: Ports Shaders to use #version directive and use version 3.00 as default. This avoids warning on hyprland-git * fix: add the implementation script --------- Co-authored-by: Rubin Bhandari <[email protected]>
1 parent 617dcbf commit c29bc66

File tree

13 files changed

+111
-144
lines changed

13 files changed

+111
-144
lines changed
Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,18 @@
1+
#version 300 es
2+
13
/*
24
┌─────────────────────────────────────────────────────────────────────────┐
35
│ This is a blank shader to disable hyprland shaders. │
46
└─────────────────────────────────────────────────────────────────────────┘
57
*/
68

79
precision mediump float;
8-
varying vec2 v_texcoord;
10+
11+
in vec2 v_texcoord;
12+
out vec4 fragColor;
13+
914
uniform sampler2D tex;
1015

1116
void main() {
12-
gl_FragColor = texture2D(tex, v_texcoord);
17+
fragColor = texture(tex, v_texcoord);
1318
}

Configs/.config/hypr/shaders/blue-light-filter.frag

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ We only need to match the file name and use 'inc' to incdicate that
1919
2020
2121
*/
22-
22+
#version 300 es
2323

2424
#ifndef BLUE_LIGHT_FILTER_TEMPERATURE
2525
#define BLUE_LIGHT_FILTER_TEMPERATURE 3000.0 // Default fallback value
@@ -30,7 +30,8 @@ We only need to match the file name and use 'inc' to incdicate that
3030

3131

3232
precision highp float;
33-
varying vec2 v_texcoord;
33+
in vec2 v_texcoord;
34+
out vec4 fragColor;
3435
uniform sampler2D tex;
3536

3637

@@ -55,7 +56,7 @@ vec3 colorTemperatureToRGB(const in float TEMPERATURE) {
5556
}
5657

5758
void main() {
58-
vec4 pixColor = texture2D(tex, v_texcoord);
59+
vec4 pixColor = texture(tex, v_texcoord);
5960

6061
// RGB
6162
vec3 color = vec3(pixColor[0], pixColor[1], pixColor[2]);
@@ -69,5 +70,5 @@ void main() {
6970

7071
vec4 outCol = vec4(color, pixColor[3]);
7172

72-
gl_FragColor = outCol;
73+
fragColor = outCol;
7374
}

Configs/.config/hypr/shaders/color-vision.frag

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -12,8 +12,9 @@
1212

1313
/*
1414
To override this parameters create a file named './color-vision.inc'
15-
We only need to match the file name and use 'inc' to incdicate that
15+
We only need to match the file name and use 'inc' to indicate that
1616
this is an "include" file
17+
NOTE: You also need to restate the #version on top example: #version 300 es
1718
Example:
1819
┌────────────────────────────────────────────────────────────────────────────┐
1920
│ //file: ./color-vision.inc │
@@ -25,6 +26,7 @@ We only need to match the file name and use 'inc' to incdicate that
2526
└────────────────────────────────────────────────────────────────────────────┘
2627
*/
2728

29+
#version 300 es
2830

2931
#ifndef COLOR_VISION_MODE
3032
#define COLOR_VISION_MODE 0 // Default fallback value
@@ -40,7 +42,8 @@ We only need to match the file name and use 'inc' to incdicate that
4042
*/
4143

4244
precision highp float;
43-
varying vec2 v_texcoord;
45+
in vec2 v_texcoord;
46+
out vec4 fragColor;
4447
uniform sampler2D tex;
4548

4649

@@ -135,12 +138,12 @@ vec3 daltonize(vec3 color, vec3 simulation) {
135138

136139
void main() {
137140
// Sample the texture at the current fragment's texture coordinates
138-
vec4 pixColor = texture2D(tex, v_texcoord);
141+
vec4 pixColor = texture(tex, v_texcoord);
139142
vec3 color = pixColor.rgb;
140143

141144
// No effect needed for normal vision with no intensity
142145
if (MODE == 0 && INTENSITY == 0.0) {
143-
gl_FragColor = pixColor;
146+
fragColor = pixColor;
144147
return;
145148
}
146149

@@ -177,5 +180,5 @@ void main() {
177180
}
178181

179182
// Output the final color with the original alpha value
180-
gl_FragColor = vec4(result, pixColor.a);
183+
fragColor = vec4(result, pixColor.a);
181184
}

Configs/.config/hypr/shaders/custom.frag

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -120,8 +120,10 @@ Example:
120120
#define COLOR_VISION_INTENSITY 0.0// Intensity of color vision effect (0.0-1.0)
121121
#endif
122122

123+
#version 300 es
123124
precision highp float;
124-
varying vec2 v_texcoord;
125+
in vec2 v_texcoord;
126+
out vec4 fragColor;
125127
uniform sampler2D tex;
126128

127129
// ======== Blue Light Filter Functions ========
@@ -345,7 +347,7 @@ return mix(color,colorTransformed,CV_INTENSITY);
345347

346348
void main(){
347349
// Get original pixel color
348-
vec4 pixColor=texture2D(tex,v_texcoord);
350+
vec4 pixColor=texture(tex,v_texcoord);
349351
vec3 color=pixColor.rgb;
350352

351353
// Apply effects in sequence based on enable flags
@@ -370,5 +372,5 @@ color=applyColorVision(color);
370372
#endif
371373

372374
// Output final color
373-
gl_FragColor=vec4(color,pixColor.a);
375+
fragColor=vec4(color,pixColor.a);
374376
}

Configs/.config/hypr/shaders/disable.frag

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,10 +4,14 @@
44
└─────────────────────────────────────────────────────────────────────────┘
55
*/
66

7+
#version 300 es
78
precision mediump float;
8-
varying vec2 v_texcoord;
9+
10+
in vec2 v_texcoord;
11+
out vec4 fragColor;
12+
913
uniform sampler2D tex;
1014

1115
void main() {
12-
gl_FragColor = texture2D(tex, v_texcoord);
13-
}
16+
fragColor = texture(tex, v_texcoord);
17+
}

Configs/.config/hypr/shaders/grayscale.frag

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -46,8 +46,10 @@ We only need to match the file name and use 'inc' to incdicate that
4646
#define GRAYSCALE_LUMINOSITY 0 // Default fallback value
4747
#endif
4848

49+
#version 300 es
4950
precision highp float;
50-
varying vec2 v_texcoord;
51+
in vec2 v_texcoord;
52+
out vec4 fragColor;
5153
uniform sampler2D tex;
5254

5355
// Enum for type of grayscale conversion
@@ -72,7 +74,7 @@ const int HDR = GRAYSCALE_LUMINOSITY_HDR; // Default to HDR standard
7274
const int LuminosityType = HDTV; // Default to HDTV standard
7375

7476
void main() {
75-
vec4 pixColor = texture2D(tex, v_texcoord);
77+
vec4 pixColor = texture(tex, v_texcoord);
7678

7779
float gray;
7880
if (Type == LUMINOSITY) {
@@ -93,5 +95,5 @@ void main() {
9395
}
9496
vec3 grayscale = vec3(gray);
9597

96-
gl_FragColor = vec4(grayscale, pixColor.a);
98+
fragColor = vec4(grayscale, pixColor.a);
9799
}

Configs/.config/hypr/shaders/invert-colors.frag

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -21,17 +21,19 @@ Example:
2121
#define INVERT_COLORS_INTENSITY 1.0// Default fallback value
2222
#endif
2323

24+
#version 300 es
2425
precision highp float;
25-
varying vec2 v_texcoord;
26+
in vec2 v_texcoord;
27+
out vec4 fragColor;
2628
uniform sampler2D tex;
2729

2830
// Intensity of color inversion (1.0 = full inversion, 0.0 = no inversion)
2931
const float INTENSITY=INVERT_COLORS_INTENSITY;
3032

3133
void main(){
32-
vec4 pixColor=texture2D(tex,v_texcoord);
34+
vec4 pixColor=texture(tex,v_texcoord);
3335

3436
// Apply inversion with intensity factor
3537
vec3 invertedColor=mix(pixColor.rgb,1.-pixColor.rgb,INTENSITY);
36-
gl_FragColor=vec4(invertedColor,pixColor.a);
38+
fragColor=vec4(invertedColor,pixColor.a);
3739
}

Configs/.config/hypr/shaders/oled-saver.frag

Lines changed: 11 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -35,8 +35,11 @@ this is an "include" file.
3535
└────────────────────────────────────────────────────────────────────────────┘
3636
*/
3737

38+
#version 300 es
39+
#define HYPRLAND_HOOK debug:damage_tracking false
40+
3841
#ifndef OLED_MONITOR
39-
#define OLED_MONITOR-1
42+
#define OLED_MONITOR -1
4043
#endif
4144

4245
#ifndef OLED_FILL_COLOR
@@ -52,17 +55,18 @@ this is an "include" file.
5255
#endif
5356

5457
precision highp float;
55-
varying vec2 v_texcoord;
58+
in vec2 v_texcoord;
59+
out vec4 fragColor;
5660
uniform sampler2D tex;
5761
uniform int wl_output;
5862
uniform float time;
5963

6064
void main(){
61-
vec4 originalColor=texture2D(tex,v_texcoord);
65+
vec4 originalColor=texture(tex,v_texcoord);
6266

6367
// If OLED_MONITOR is -1, always enable effect. Otherwise, only for matching monitor.
6468
if(OLED_MONITOR!=-1&&wl_output!=OLED_MONITOR){
65-
gl_FragColor=originalColor;
69+
fragColor=originalColor;
6670
return;
6771
}
6872

@@ -87,11 +91,11 @@ void main(){
8791
bool inArea=fragCoord.x>=area.x&&fragCoord.x<=(area.x+area.z)&&
8892
fragCoord.y>=area.y&&fragCoord.y<=(area.y+area.w);
8993
#ifdef OLED_INVERT_AREA
90-
gl_FragColor=inArea?originalColor:color;
94+
fragColor=inArea?originalColor:color;
9195
#else
92-
gl_FragColor=inArea?color:originalColor;
96+
fragColor=inArea?color:originalColor;
9397
#endif
9498
#else
95-
gl_FragColor=color;
99+
fragColor=color;
96100
#endif
97101
}

Configs/.config/hypr/shaders/oled.frag

Lines changed: 0 additions & 97 deletions
This file was deleted.

Configs/.config/hypr/shaders/paper.frag

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -42,8 +42,10 @@ Use 'inc' to indicate that this is an "include" file for custom defines.
4242
#define PAPER_GRAIN 0.7
4343
#endif
4444

45+
#version 300 es
4546
precision highp float;
46-
varying vec2 v_texcoord;
47+
in vec2 v_texcoord;
48+
out vec4 fragColor;
4749
uniform sampler2D tex;
4850

4951
// Paper grain texture (simple random noise)
@@ -61,7 +63,7 @@ vec3 to_sepia(vec3 color){
6163
}
6264

6365
void main(){
64-
vec4 pixColor=texture2D(tex,v_texcoord);
66+
vec4 pixColor=texture(tex,v_texcoord);
6567
float gray=dot(pixColor.rgb,vec3(.299,.587,.114));
6668
vec3 colorResult;
6769
if(PAPER_GRAYSCALE<0.){
@@ -84,5 +86,5 @@ void main(){
8486
colorResult=clamp(colorResult+grain*PAPER_GRAIN,0.,1.);
8587
// Minimal highlight compression: just cap the max gray value to avoid pure white
8688
colorResult=min(colorResult,vec3(.88));
87-
gl_FragColor=vec4(colorResult,pixColor.a);
89+
fragColor=vec4(colorResult,pixColor.a);
8890
}

0 commit comments

Comments
 (0)