From 76dc3f0af36775d2fdaab61134dd0f875ee48292 Mon Sep 17 00:00:00 2001 From: David Thompson Date: Sat, 30 Dec 2023 19:32:19 -0500 Subject: WIP graphics engine rewrite. --- data/shaders/path-fill-frag.glsl | 14 ++++++++++++++ data/shaders/path-fill-vert.glsl | 13 +++++++++++++ data/shaders/path-stroke-frag.glsl | 18 ++++++++++++++++-- data/shaders/path-stroke-vert.glsl | 14 ++++++++++++++ 4 files changed, 57 insertions(+), 2 deletions(-) (limited to 'data/shaders') diff --git a/data/shaders/path-fill-frag.glsl b/data/shaders/path-fill-frag.glsl index e839318..3e10bf0 100644 --- a/data/shaders/path-fill-frag.glsl +++ b/data/shaders/path-fill-frag.glsl @@ -12,11 +12,25 @@ varying vec2 fragPosition; in vec2 fragPosition; #endif +#ifdef GLSL120 uniform int mode; uniform vec4 color; uniform vec4 endColor; +uniform mat3 gradientMatrix; uniform vec2 gradientRange; uniform float radialGradientRatio; +#else +layout (std140) uniform Fill +{ + mat4 mvp; + vec4 color; + int mode; + vec4 endColor; + mat3 gradientMatrix; + vec2 gradientRange; + float radialGradientRatio; +}; +#endif vec4 gradientMix(float x) { float start = gradientRange.x; diff --git a/data/shaders/path-fill-vert.glsl b/data/shaders/path-fill-vert.glsl index d66bb14..f8bcace 100644 --- a/data/shaders/path-fill-vert.glsl +++ b/data/shaders/path-fill-vert.glsl @@ -14,9 +14,22 @@ varying vec2 fragPosition; out vec2 fragPosition; #endif +#ifdef GLSL120 uniform mat4 mvp; uniform vec4 color; uniform mat3 gradientMatrix; +#else +layout (std140) uniform Fill +{ + mat4 mvp; + vec4 color; + int mode; + vec4 endColor; + mat3 gradientMatrix; + vec2 gradientRange; + float radialGradientRatio; +}; +#endif void main(void) { // Short-circuit because the fragments will just be discarded diff --git a/data/shaders/path-stroke-frag.glsl b/data/shaders/path-stroke-frag.glsl index 9682c8f..324e3cf 100644 --- a/data/shaders/path-stroke-frag.glsl +++ b/data/shaders/path-stroke-frag.glsl @@ -14,6 +14,7 @@ in vec2 fragTex; in float fragStrokeLength; #endif +#ifdef GLSL120 uniform vec4 color; uniform float feather; uniform int strokeClosed; @@ -21,6 +22,19 @@ uniform float strokeWidth; uniform int strokeCap; uniform int strokeMiterStyle; uniform float strokeMiterLimit; +#else +layout (std140) uniform Stroke +{ + mat4 mvp; + vec4 color; + float feather; + float strokeWidth; + float strokeMiterLimit; + int strokeClosed; + int strokeCap; + int strokeMiterStyle; +}; +#endif float infinity = 1.0 / 0.0; @@ -47,7 +61,7 @@ void main(void) { if (strokeCap == 0) { // none d = infinity; - } else if (strokeCap == 1) { // butt + } else if (strokeCap == 1) { // butt (huh huh) d = max(dx + hw - 2 * feather, dy); } else if (strokeCap == 2) { // square d = max(dx, dy); @@ -58,7 +72,7 @@ void main(void) { } else if (strokeCap == 5) { // triangle in d = max(dy, hw - feather + dx - dy); } - // Stroke inner/join + // Stroke inner/join } else { d = abs(v); } diff --git a/data/shaders/path-stroke-vert.glsl b/data/shaders/path-stroke-vert.glsl index 5915010..f1c7e3a 100644 --- a/data/shaders/path-stroke-vert.glsl +++ b/data/shaders/path-stroke-vert.glsl @@ -22,10 +22,24 @@ out vec2 fragTex; out float fragStrokeLength; #endif +#ifdef GLSL120 uniform mat4 mvp; uniform vec4 color; uniform int mode; uniform int strokeClosed; +#else +layout (std140) uniform Stroke +{ + mat4 mvp; + vec4 color; + float feather; + float strokeWidth; + float strokeMiterLimit; + int strokeClosed; + int strokeCap; + int strokeMiterStyle; +}; +#endif void main(void) { // Short-circuit because the fragments will just be discarded anyway. -- cgit v1.2.3