packages feed

gelatin 0.0.0.2 → 0.0.0.3

raw patch · 7 files changed

+138/−2 lines, 7 filesPVP ok

version bump matches the API change (PVP)

API changes (from Hackage documentation)

Files

gelatin.cabal view
@@ -10,7 +10,7 @@ -- PVP summary:      +-+------- breaking API changes --                   | | +----- non-breaking API additions --                   | | | +--- code changes with no API change-version:             0.0.0.2+version:             0.0.0.3  -- A short (one-line) description of the package. synopsis:            An experimental real time renderer.@@ -41,7 +41,12 @@  -- Extra files to be distributed with the package, such as examples or a -- README.--- extra-source-files:+extra-source-files:    shaders/2d.frag,+                       shaders/2d.vert,+                       shaders/bezier.frag,+                       shaders/bezier.vert,+                       shaders/mask.frag,+                       shaders/mask.vert  -- Constraint on the version of Cabal needed to build this package. cabal-version:       >=1.10
+ shaders/2d.frag view
@@ -0,0 +1,16 @@+#version 330 core+in vec4 fcolor;+in vec2 fuv;+out vec4 fragColor;++uniform bool hasUV;+uniform sampler2D sampler;+++void main() {+    if (hasUV) {+        fragColor = texture(sampler, fuv.st);+    } else {+        fragColor = fcolor;+    }+}
+ shaders/2d.vert view
@@ -0,0 +1,18 @@+#version 330 core+layout(location = 0) in vec2 position;+layout(location = 1) in vec4 color;+layout(location = 2) in vec2 uv;++uniform mat4 projection;+uniform mat4 modelview;+uniform bool hasUV;+uniform sampler2D sampler;++out vec4 fcolor;+out vec2 fuv;++void main() {+    fcolor = color;+    fuv = uv;+    gl_Position = projection * modelview * vec4(position.xy, 0.0, 1.0);+}
+ shaders/bezier.frag view
@@ -0,0 +1,47 @@+// Loop-Blinn curve rendering++#version 330 core+in vec3 fbez;+in vec4 fcolor;+in vec2 fuv;+out vec4 fragColor;++uniform bool hasUV;+uniform sampler2D sampler;++void main() {+    vec2 p = fbez.xy;+    // When cw is true, winding is clockwise and we're drawing outside the+    // curve.+    bool cw = bool(fbez.z);+    // Gradients+    vec2 px = dFdx(p);+    vec2 py = dFdy(p);+    // Chain rule+    float fx = (2*p.x)*px.x - px.y;+    float fy = (2*p.x)*py.x - py.y;+    // Signed distance+    float sd = (p.x*p.x - p.y) / sqrt(fx*fx + fy*fy);+    //Linear alpha+    float alpha = 0.5 - sd;+    alpha = cw ? 1 - alpha : alpha;+    // Find the resulting fragment color+    float a = 0;++    if (alpha > 1) {+        a = 1;+    } else if (alpha < 0) {+        discard;+    } else {+        // We are right on the boundary, interpolate the color intensity.+        a = alpha;+    }++    vec4 color = vec4(0);+    if (hasUV) {+        color = texture(sampler, fuv.st);+    } else {+        color = fcolor;+    }+    fragColor = vec4(color.rgb, color.a * a);+}
+ shaders/bezier.vert view
@@ -0,0 +1,22 @@+// Loop-Blinn curve rendering++#version 330 core++layout(location = 0) in vec2 position;+layout(location = 1) in vec4 color;+layout(location = 2) in vec2 uv;+layout(location = 3) in vec3 bez;++uniform mat4 projection;+uniform mat4 modelview;++out vec3 fbez;+out vec4 fcolor;+out vec2 fuv;++void main() {+    fbez = bez;+    fuv = uv;+    fcolor = color;+    gl_Position = projection * modelview * vec4(position.xy, 0.0, 1.0);+}
+ shaders/mask.frag view
@@ -0,0 +1,13 @@+#version 330 core+uniform sampler2D mainTex;+uniform sampler2D maskTex;++in vec2 fuv;++out vec4 fragColor;++void main() {+    vec4 color = texture(mainTex, fuv.st);+    vec4 mask  = texture(maskTex, fuv.st);+    fragColor = vec4(color.rgb, color.a * mask.a);+}
+ shaders/mask.vert view
@@ -0,0 +1,15 @@+#version 330 core+layout(location = 0) in vec2 position;+layout(location = 2) in vec2 uv;++uniform mat4 projection;+uniform mat4 modelview;+uniform sampler2D mainTex;+uniform sampler2D maskTex;++out vec2 fuv;++void main() {+    fuv = uv;+    gl_Position = projection * modelview * vec4(position.xy, 0.0, 1.0);+}