From 833046aed0d812f1675847a9dca352e8814e9999 Mon Sep 17 00:00:00 2001 From: Joshua Goins Date: Tue, 8 Feb 2022 09:33:18 -0500 Subject: [PATCH] Remove old shader files --- engine/CMakeLists.txt | 4 --- engine/shaders/font.glsl | 5 --- engine/shaders/text.frag.glsl | 15 --------- engine/shaders/text.vert.glsl | 61 ----------------------------------- engine/shaders/ui.frag.glsl | 22 ------------- engine/shaders/ui.vert.glsl | 38 ---------------------- 6 files changed, 145 deletions(-) delete mode 100644 engine/shaders/font.glsl delete mode 100644 engine/shaders/text.frag.glsl delete mode 100644 engine/shaders/text.vert.glsl delete mode 100644 engine/shaders/ui.frag.glsl delete mode 100644 engine/shaders/ui.vert.glsl diff --git a/engine/CMakeLists.txt b/engine/CMakeLists.txt index 69c42eb..2a159f4 100755 --- a/engine/CMakeLists.txt +++ b/engine/CMakeLists.txt @@ -22,10 +22,6 @@ add_shaders(TARGET Renderer shaders/mesh.vert.nocompile.glsl shaders/post.vert.glsl shaders/post.frag.glsl - shaders/text.vert.glsl - shaders/text.frag.glsl - shaders/ui.vert.glsl - shaders/ui.frag.glsl shaders/imgui.vert.glsl shaders/imgui.frag.glsl shaders/debug.vert.glsl diff --git a/engine/shaders/font.glsl b/engine/shaders/font.glsl deleted file mode 100644 index dbe02fa..0000000 --- a/engine/shaders/font.glsl +++ /dev/null @@ -1,5 +0,0 @@ -uint getLower(const uint val) { return val & uint(0xFFFF); } -uint getUpper(const uint val) { return val >> 16 & uint(0xFFFF); } -float fixed_to_float(const uint val) { return float(val)/32.0; } -vec2 fixed2_to_vec2(const uint val) { return vec2(fixed_to_float(getLower(val)), fixed_to_float(getUpper(val))); } -vec2 uint_to_vec2(const uint val) { return vec2(getLower(val), getUpper(val)); } diff --git a/engine/shaders/text.frag.glsl b/engine/shaders/text.frag.glsl deleted file mode 100644 index 27a632a..0000000 --- a/engine/shaders/text.frag.glsl +++ /dev/null @@ -1,15 +0,0 @@ -layout(location = 0) in vec2 inUV; - -layout (location = 0) out vec4 outColor; - -layout (binding = 3) uniform sampler2D fontSampler; - -vec4 toSRGB(vec4 v) { - return vec4(pow(v.rgb, vec3(2.2)), v.a); -} - -void main() { - outColor = vec4(vec3(texture(fontSampler, inUV).r), texture(fontSampler, inUV).r); - - outColor = toSRGB(outColor); -} diff --git a/engine/shaders/text.vert.glsl b/engine/shaders/text.vert.glsl deleted file mode 100644 index c10aac9..0000000 --- a/engine/shaders/text.vert.glsl +++ /dev/null @@ -1,61 +0,0 @@ -#extension GL_GOOGLE_include_directive : require -#include "font.glsl" - -layout(location = 0) out vec2 outUV; - -struct GlyphInstance { - uint position, index, instance; -}; - -struct StringInstance { - uint xy; -}; - -struct GlyphMetric { - uint x0_y0, x1_y1; - float xoff, yoff; - float xoff2, yoff2; -}; - -layout(std430, binding = 0) buffer readonly InstanceBuffer { - GlyphInstance instances[]; -}; - -layout(std430, binding = 1) buffer readonly MetricBuffer { - GlyphMetric metrics[]; -}; - -layout(std430, binding = 2) buffer readonly StringBuffer { - StringInstance strings[]; -}; - -layout(push_constant) uniform readonly PushConstant{ - vec2 screenSize; - mat4 mvp; -}; - -void main() { - const GlyphInstance instance = instances[gl_InstanceIndex]; - const GlyphMetric metric = metrics[getLower(instance.index)]; - - vec2 p = vec2(gl_VertexIndex % 2, gl_VertexIndex / 2); - - const vec2 p0 = uint_to_vec2(metric.x0_y0); - const vec2 p1 = uint_to_vec2(metric.x1_y1); - - outUV = (p0 + (p1 - p0) * p) / vec2(2048, 1132); - - p *= vec2(metric.xoff2 - metric.xoff, metric.yoff2 - metric.yoff); - p += vec2(metric.xoff, metric.yoff); - p += fixed2_to_vec2(instance.position); - p += vec2(0, 18.2316); - - const StringInstance string = strings[instance.instance]; - - p += fixed2_to_vec2(string.xy); - p *= vec2(1, -1); - p *= 2.0 / screenSize; - p += vec2(-1, 1); - - gl_Position = mvp * vec4(p, 0.0, 1.0); -} diff --git a/engine/shaders/ui.frag.glsl b/engine/shaders/ui.frag.glsl deleted file mode 100644 index bbef2cc..0000000 --- a/engine/shaders/ui.frag.glsl +++ /dev/null @@ -1,22 +0,0 @@ -layout (location = 0) in vec2 inUV; -layout (location = 1) in vec4 inColor; - -layout (location = 0) out vec4 outColor; - -layout (binding = 2) uniform sampler2D colorSampler; - -vec4 toSRGB(vec4 v) { - return vec4(pow(v.rgb, vec3(2.2)), v.a); -} - -void main() { - if(inColor.a == 0.0) - discard; - - if(textureSize(colorSampler, 0).x > 1) - outColor = texture(colorSampler, inUV); - else - outColor = inColor; - - outColor = toSRGB(outColor); -} diff --git a/engine/shaders/ui.vert.glsl b/engine/shaders/ui.vert.glsl deleted file mode 100644 index 5e8b3d2..0000000 --- a/engine/shaders/ui.vert.glsl +++ /dev/null @@ -1,38 +0,0 @@ -#extension GL_GOOGLE_include_directive : require -#include "font.glsl" - -layout (location = 0) out vec2 outUV; -layout (location = 1) out vec4 outColor; - -struct ElementInstance { - vec4 color; - uint position, size; - uint padding[2]; -}; - -layout(std430, binding = 0) buffer readonly ElementBuffer { - ElementInstance elements[]; -}; - -layout(push_constant) uniform readonly PushConstant{ - vec2 screenSize; - mat4 mvp; -}; - -void main() { - const ElementInstance instance = elements[gl_InstanceIndex]; - - vec2 p = vec2(gl_VertexIndex % 2, gl_VertexIndex / 2); - outUV = p; - - p *= fixed2_to_vec2(instance.size); - p += fixed2_to_vec2(instance.position); - p *= vec2(1, -1); - p *= 2.0 / screenSize; - p += vec2(-1, 1); - - outColor = instance.color; - - gl_Position = mvp * vec4(p, 0.0, 1.0); -} -