Skip to content

Commit 8931188

Browse files
committed
💄 Apply GLSL formatting and configuration updates
Apply comprehensive GLSL code formatting and linting configuration - Format GLSL shaders with consistent 2-space indentation and 120 character width - Improve readability with better line breaks and alignment in complex expressions - Update .glslrc.json to use compact array format for defines - Add .prettierignore file to exclude build output, dependencies, and IDE files - Configure prettier overrides for GLSL files with specific formatting options - Update GLSL linting script with improved code formatting and structure - Apply consistent formatting to documentation examples in advanced.md, developer-guide.md, and examples.md - Format neural synapse fire effect with enhanced performance optimizations - Update all fragment shaders with improved formatting and consistent style - Maintain functionality while improving code maintainability
1 parent 28afad5 commit 8931188

File tree

18 files changed

+1208
-867
lines changed

18 files changed

+1208
-867
lines changed

.glslrc.json

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -11,13 +11,11 @@
1111
"GL_EXT_shader_explicit_arithmetic_types_float32",
1212
"GL_EXT_shader_explicit_arithmetic_types_float64"
1313
],
14-
"defines": [
15-
"WEBGL_VERSION=2"
16-
],
14+
"defines": ["WEBGL_VERSION=2"],
1715
"warnings": {
1816
"unused_variables": true,
1917
"unused_functions": true,
2018
"missing_precision": true,
2119
"deprecated_functions": true
2220
}
23-
}
21+
}

.prettierignore

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
# Build output
2+
dist/
3+
build/
4+
5+
# Dependencies
6+
node_modules/
7+
8+
# Test coverage
9+
coverage/
10+
11+
# IDE
12+
.vscode/
13+
.idea/
14+
15+
# If you want to exclude specific GLSL files from formatting:
16+
# src/effects/*/fragment.glsl
17+
# src/effects/*/vertex.glsl
18+
19+
# Or exclude all GLSL files (uncomment if you prefer manual formatting):
20+
# *.glsl

.prettierrc

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,13 @@
11
{
2-
"plugins": ["prettier-plugin-uppercase-doctype", "prettier-plugin-glsl"]
2+
"plugins": ["prettier-plugin-uppercase-doctype", "prettier-plugin-glsl"],
3+
"overrides": [
4+
{
5+
"files": "*.glsl",
6+
"options": {
7+
"printWidth": 120,
8+
"tabWidth": 2,
9+
"useTabs": false
10+
}
11+
}
12+
]
313
}

docs/advanced.md

Lines changed: 11 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -623,15 +623,17 @@ vec3 getNormal(vec3 p) {
623623
const float eps = 0.001;
624624
vec2 e = vec2(eps, 0.0);
625625
626-
return normalize(vec3(
627-
map(p + e.xyy) - map(p - e.xyy),
628-
map(p + e.yxy) - map(p - e.yxy),
629-
map(p + e.yyx) - map(p - e.yyx)
630-
));
626+
return normalize(
627+
vec3(
628+
map(p + e.xyy) - map(p - e.xyy),
629+
map(p + e.yxy) - map(p - e.yxy),
630+
map(p + e.yyx) - map(p - e.yyx)
631+
)
632+
);
631633
}
632634
633635
// Usage in mainImage
634-
void mainImage(out vec4 fragColor, in vec2 fragCoord) {
636+
void mainImage(out vec4 fragColor, vec2 fragCoord) {
635637
vec2 uv = (fragCoord - 0.5 * iResolution.xy) / iResolution.y;
636638
637639
// Camera setup
@@ -916,12 +918,12 @@ Create effects that adapt to different types of RGB devices.
916918
### Responsive Layouts
917919

918920
```glsl
919-
void mainImage(out vec4 fragColor, in vec2 fragCoord) {
921+
void mainImage(out vec4 fragColor, vec2 fragCoord) {
920922
vec2 uv = fragCoord / iResolution.xy;
921923
float aspectRatio = iResolution.x / iResolution.y;
922924
923925
// Adjust for different aspect ratios
924-
if (aspectRatio > 16.0/9.0) {
926+
if (aspectRatio > 16.0 / 9.0) {
925927
// Ultrawide monitor or LED strip
926928
// Create horizontal effect
927929
float horizontalGradient = fract(uv.x * 5.0 - iTime * 0.1);
@@ -1095,7 +1097,7 @@ Use color output to visualize values:
10951097
uniform bool iDebugMode;
10961098
uniform int iDebugView; // 0: normal, 1: uv, 2: distance, 3: normals...
10971099
1098-
void mainImage(out vec4 fragColor, in vec2 fragCoord) {
1100+
void mainImage(out vec4 fragColor, vec2 fragCoord) {
10991101
vec2 uv = fragCoord / iResolution.xy;
11001102
11011103
// Normal effect calculation

docs/developer-guide.md

Lines changed: 17 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -255,19 +255,22 @@ vec3 getColor(float pos, int mode) {
255255
// Rainbow colors
256256
if (mode == 0) {
257257
return hsv2rgb(vec3(pos, 0.8, 1.0));
258-
}
259-
// Ocean colors
260-
else if (mode == 1) {
261-
return mix(vec3(0.0, 0.3, 0.8), vec3(0.0, 0.8, 1.0),
262-
sin(pos * 6.28) * 0.5 + 0.5);
263-
}
264-
// Fire colors
265-
else if (mode == 2) {
266-
return mix(vec3(1.0, 0.5, 0.0), vec3(1.0, 0.2, 0.0),
267-
sin(pos * 6.28) * 0.5 + 0.5);
268-
}
269-
// Neon colors
270-
else if (mode == 3) {
258+
} else // Ocean colors
259+
if (mode == 1) {
260+
return mix(
261+
vec3(0.0, 0.3, 0.8),
262+
vec3(0.0, 0.8, 1.0),
263+
sin(pos * 6.28) * 0.5 + 0.5
264+
);
265+
} else // Fire colors
266+
if (mode == 2) {
267+
return mix(
268+
vec3(1.0, 0.5, 0.0),
269+
vec3(1.0, 0.2, 0.0),
270+
sin(pos * 6.28) * 0.5 + 0.5
271+
);
272+
} else // Neon colors
273+
if (mode == 3) {
271274
float segment = floor(pos * 4.0) / 4.0;
272275
float t = fract(pos * 4.0);
273276
@@ -286,7 +289,7 @@ vec3 getColor(float pos, int mode) {
286289
return hsv2rgb(vec3(pos, 0.8, 1.0));
287290
}
288291
289-
void mainImage(out vec4 fragColor, in vec2 fragCoord) {
292+
void mainImage(out vec4 fragColor, vec2 fragCoord) {
290293
// Normalized coordinates
291294
vec2 uv = fragCoord / iResolution.xy;
292295

docs/examples.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -74,7 +74,7 @@ vec3 getColor(float t, int mode) {
7474
}
7575
}
7676
77-
void mainImage(out vec4 fragColor, in vec2 fragCoord) {
77+
void mainImage(out vec4 fragColor, vec2 fragCoord) {
7878
// Normalized pixel coordinates
7979
vec2 uv = fragCoord / iResolution.xy;
8080
@@ -301,7 +301,7 @@ vec3 hsv2rgb(vec3 c) {
301301
return c.z * mix(K.xxx, clamp(p - K.xxx, 0.0, 1.0), c.y);
302302
}
303303
304-
void mainImage(out vec4 fragColor, in vec2 fragCoord) {
304+
void mainImage(out vec4 fragColor, vec2 fragCoord) {
305305
// Center coordinates
306306
vec2 uv = fragCoord / iResolution.xy;
307307
vec2 center = uv - 0.5;
@@ -315,7 +315,7 @@ void mainImage(out vec4 fragColor, in vec2 fragCoord) {
315315
316316
// Color based on angle and time
317317
float angle = atan(center.y, center.x);
318-
float hue = fract((angle / 6.28) + iTime * iColorShift);
318+
float hue = fract(angle / 6.28 + iTime * iColorShift);
319319
320320
// Final color
321321
vec3 color = hsv2rgb(vec3(hue, 0.8, brightness));

0 commit comments

Comments
 (0)