diff options
author | clyne <clyne@bitgloo.com> | 2019-09-25 14:35:10 -0400 |
---|---|---|
committer | GitHub <noreply@github.com> | 2019-09-25 14:35:10 -0400 |
commit | 5de39474dd9c17cc7f09015f291769fbe3fd5931 (patch) | |
tree | 73de6ae8aad4418cd19d55d5b468a20b404446ec /Shaders | |
parent | ec0ab456cf869f2daa6dea41158c54da745626d8 (diff) | |
parent | 1703f84121f18277c2a9bd671e204730c131c102 (diff) |
Merge pull request #2 from tcsullivan/font-support
Font support
Diffstat (limited to 'Shaders')
-rw-r--r-- | Shaders/ui.frag | 16 | ||||
-rw-r--r-- | Shaders/ui.vert | 21 | ||||
-rw-r--r-- | Shaders/world.frag | 2 | ||||
-rw-r--r-- | Shaders/world.vert | 3 |
4 files changed, 31 insertions, 11 deletions
diff --git a/Shaders/ui.frag b/Shaders/ui.frag index 737344e..63e7eb0 100644 --- a/Shaders/ui.frag +++ b/Shaders/ui.frag @@ -1,12 +1,22 @@ +#version 130 + +#ifdef GL_FRAGMENT_PRECISION_HIGH +precision highp float; +#else +precision mediump float; +#endif + uniform sampler2D sampler; -varying vec2 texCoord; -varying vec4 color; +in vec2 texCoord; +in vec4 color; + +out vec4 FragColor; void main(){ vec4 pixelColor = texture2D(sampler, vec2(texCoord.x, texCoord.y)); //TODO allow antialiasing //if (pixelColor.w != 1.0f) // discard; - gl_FragColor = pixelColor * color; + FragColor = pixelColor.r * color; } diff --git a/Shaders/ui.vert b/Shaders/ui.vert index b2fcba4..d2e3902 100644 --- a/Shaders/ui.vert +++ b/Shaders/ui.vert @@ -1,14 +1,19 @@ -attribute vec3 coord2d; -attribute vec2 tex_coord; +#version 130 -uniform mat4 ortho; -uniform vec4 tex_color; +in vec3 coord2d; +in vec2 tex_coord; -varying vec2 texCoord; -varying vec4 color; +uniform mat4 projection; +uniform mat4 view; +uniform mat4 model; + +out vec2 texCoord; +out vec4 color; void main(){ texCoord = tex_coord; - color = tex_color; - gl_Position = ortho * vec4(coord2d.xyz, 1.0); + color = vec4(0.0f, 0.0f, 0.0f, 1.0f); + //color = tex_color; + //gl_Position = ortho * vec4(coord2d.xyz, 1.0f); + gl_Position = projection * view * model * vec4(coord2d.xyz, 1.0f); } diff --git a/Shaders/world.frag b/Shaders/world.frag index 18945a8..79d87aa 100644 --- a/Shaders/world.frag +++ b/Shaders/world.frag @@ -9,6 +9,7 @@ precision mediump float; uniform sampler2D textu; uniform sampler2D normu; +in float fragTrans; in vec2 texCoord; in vec4 fragCoord; out vec4 FragColor; @@ -25,6 +26,7 @@ void main() vec3 Falloff = vec3(0.4, 0.1, 0.002); vec4 DiffuseColor = texture2D(textu, texCoord); + DiffuseColor *= fragTrans; if (DiffuseColor.a < 0.1f) discard; diff --git a/Shaders/world.vert b/Shaders/world.vert index aa183a2..28fd307 100644 --- a/Shaders/world.vert +++ b/Shaders/world.vert @@ -3,16 +3,19 @@ //layout(location = 0)in vec3 vertex; in vec3 vertex; in vec2 texc; +in float trans; uniform mat4 projection; uniform mat4 view; uniform mat4 model; +out float fragTrans; out vec2 texCoord; out vec4 fragCoord; void main() { + fragTrans = trans; texCoord = texc; fragCoord = vec4(vertex, 1.0f); gl_Position = projection * view * model * fragCoord; |