summaryrefslogtreecommitdiff
path: root/themes/src
diff options
context:
space:
mode:
authorMatthew Kosarek <matthew@matthewkosarek.xyz>2023-09-24 16:23:43 -0400
committerMatthew Kosarek <matthew@matthewkosarek.xyz>2023-09-24 16:23:43 -0400
commitff3b7a7fa3f2ce994fb4aaaa9699c1c91fa07904 (patch)
treed62df3ff940c7976923d70e116e502c381f96b97 /themes/src
parent61cd8d99e6a3475eaf2bd28bc24892cf1aae0398 (diff)
Working shaders again
Diffstat (limited to 'themes/src')
-rw-r--r--themes/src/_shaders/sun.frag45
-rw-r--r--themes/src/shaders/sun_frag.cpp45
-rw-r--r--themes/src/spring/SpringTheme.cpp4
-rw-r--r--themes/src/tools/shader.js4
4 files changed, 8 insertions, 90 deletions
diff --git a/themes/src/_shaders/sun.frag b/themes/src/_shaders/sun.frag
index dabd7ea..8463e06 100644
--- a/themes/src/_shaders/sun.frag
+++ b/themes/src/_shaders/sun.frag
@@ -1,48 +1,5 @@
varying lowp vec4 VertexColor;
-#ifdef GL_ES
-precision mediump float;
-#endif
-
-uniform vec2 u_resolution;
-
-vec2 skew (vec2 st) {
- vec2 r = vec2(0.0);
- r.x = 1.1547*st.x;
- r.y = st.y+0.5*r.x;
- return r;
-}
-
-vec3 simplexGrid (vec2 st) {
- vec3 xyz = vec3(0.0);
-
- vec2 p = fract(skew(st));
- if (p.x > p.y) {
- xyz.xy = 1.0-vec2(p.x,p.y-p.x);
- xyz.z = p.y;
- } else {
- xyz.yz = 1.0-vec2(p.x-p.y,p.y);
- xyz.x = p.x;
- }
-
- return fract(xyz);
-}
-
void main() {
- vec2 st = gl_FragCoord.xy/u_resolution.xy;
- vec3 color = VertexColor.xyz
-
- // Scale the space to see the grid
- st *= 10.;
-
- // Show the 2D grid
- color.rg = fract(st);
-
- // Skew the 2D grid
- // color.rg = fract(skew(st));
-
- // Subdivide the grid into to equilateral triangles
- // color = simplexGrid(st);
-
- gl_FragColor = vec4(color,1.0);
+ gl_FragColor = VertexColor;
}
diff --git a/themes/src/shaders/sun_frag.cpp b/themes/src/shaders/sun_frag.cpp
index d5af4be..d1ea160 100644
--- a/themes/src/shaders/sun_frag.cpp
+++ b/themes/src/shaders/sun_frag.cpp
@@ -2,50 +2,7 @@
const char* shader_sun_frag = "varying lowp vec4 VertexColor; \n"
" \n"
-"#ifdef GL_ES \n"
-"precision mediump float; \n"
-"#endif \n"
-" \n"
-"uniform vec2 u_resolution; \n"
-" \n"
-"vec2 skew (vec2 st) { \n"
-" vec2 r = vec2(0.0); \n"
-" r.x = 1.1547*st.x; \n"
-" r.y = st.y+0.5*r.x; \n"
-" return r; \n"
-"} \n"
-" \n"
-"vec3 simplexGrid (vec2 st) { \n"
-" vec3 xyz = vec3(0.0); \n"
-" \n"
-" vec2 p = fract(skew(st)); \n"
-" if (p.x > p.y) { \n"
-" xyz.xy = 1.0-vec2(p.x,p.y-p.x); \n"
-" xyz.z = p.y; \n"
-" } else { \n"
-" xyz.yz = 1.0-vec2(p.x-p.y,p.y); \n"
-" xyz.x = p.x; \n"
-" } \n"
-" \n"
-" return fract(xyz); \n"
-"} \n"
-" \n"
"void main() { \n"
-" vec2 st = gl_FragCoord.xy/u_resolution.xy; \n"
-" vec3 color = VertexColor.xyz \n"
-" \n"
-" // Scale the space to see the grid \n"
-" st *= 10.; \n"
-" \n"
-" // Show the 2D grid \n"
-" color.rg = fract(st); \n"
-" \n"
-" // Skew the 2D grid \n"
-" // color.rg = fract(skew(st)); \n"
-" \n"
-" // Subdivide the grid into to equilateral triangles \n"
-" // color = simplexGrid(st); \n"
-" \n"
-" gl_FragColor = vec4(color,1.0); \n"
+" gl_FragColor = VertexColor; \n"
"} \n"
" \n";
diff --git a/themes/src/spring/SpringTheme.cpp b/themes/src/spring/SpringTheme.cpp
index abe8c6e..39b6bad 100644
--- a/themes/src/spring/SpringTheme.cpp
+++ b/themes/src/spring/SpringTheme.cpp
@@ -44,8 +44,8 @@ void SpringTheme::load(WebglContext* context) {
fetch_shader(
{
- "themes/src/shaders/renderer3d.vert",
- "themes/src/shaders/renderer3d.frag"
+ "themes/src/_shaders/renderer3d.vert",
+ "themes/src/_shaders/renderer3d.frag"
},
on_shaders_loader,
this
diff --git a/themes/src/tools/shader.js b/themes/src/tools/shader.js
index 54ba6e0..10889db 100644
--- a/themes/src/tools/shader.js
+++ b/themes/src/tools/shader.js
@@ -8,6 +8,10 @@ const fs = require('fs');
const directory = path.join(__dirname, "..", "_shaders");
const out_directory = path.join(__dirname, "..", "shaders");
+if (!fs.existsSync(out_directory)){
+ fs.mkdirSync(out_directory);
+}
+
const files = fs.readdirSync(directory);
files.forEach(file => {
const filePath = path.join(directory, file);