From d7b67bda857b5ce29e3517637a650328fed16d77 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jaakko=20Kera=CC=88nen?= Date: Sun, 23 Apr 2017 14:16:24 +0300 Subject: [PATCH] Renderer|Client: Updated existing GLSL shaders to version 3.3 Also added a new shader for old DGL drawing routines. --- .../renderer.pack/lensflares.pack/shaders.dei | 10 +- .../lensflares.pack/shaders/lensflares.vsh | 42 +-- .../renderer.pack/shaders.dei | 1 + .../renderer.pack/shaders/debug.dei | 20 +- .../renderer.pack/shaders/dgl/dgl.dei | 5 + .../renderer.pack/shaders/dgl/dgl_draw.fsh | 50 ++++ .../renderer.pack/shaders/dgl/dgl_draw.vsh | 46 +++ .../renderer.pack/shaders/fx/bloom.dei | 94 +++---- .../renderer.pack/shaders/fx/blur.dei | 74 ++--- .../renderer.pack/shaders/fx/post.dei | 44 +-- .../renderer.pack/shaders/generic.dei | 88 +++--- .../renderer.pack/shaders/include/fog.glsl | 19 +- .../renderer.pack/shaders/include/hsv.glsl | 69 ++--- .../shaders/include/lighting.glsl | 57 ++-- .../shaders/include/reflection.glsl | 28 +- .../shaders/include/skeletal.glsl | 8 +- .../shaders/include/tangentspace.glsl | 26 +- .../shaders/include/texture.glsl | 6 +- .../renderer.pack/shaders/model.dei | 264 +++++++++--------- .../renderer.pack/shaders/ui.dei | 42 +-- 20 files changed, 542 insertions(+), 451 deletions(-) create mode 100644 doomsday/apps/client/net.dengine.client.pack/renderer.pack/shaders/dgl/dgl.dei create mode 100644 doomsday/apps/client/net.dengine.client.pack/renderer.pack/shaders/dgl/dgl_draw.fsh create mode 100644 doomsday/apps/client/net.dengine.client.pack/renderer.pack/shaders/dgl/dgl_draw.vsh diff --git a/doomsday/apps/client/net.dengine.client.pack/renderer.pack/lensflares.pack/shaders.dei b/doomsday/apps/client/net.dengine.client.pack/renderer.pack/lensflares.pack/shaders.dei index 5da3e3f1b1..3830a6179b 100644 --- a/doomsday/apps/client/net.dengine.client.pack/renderer.pack/lensflares.pack/shaders.dei +++ b/doomsday/apps/client/net.dengine.client.pack/renderer.pack/lensflares.pack/shaders.dei @@ -8,15 +8,15 @@ shader fx.lensflares { uniform sampler2D uTex; uniform sampler2D uDepthBuf; - varying highp vec4 vColor; - varying highp vec2 vUV; + in vec4 vColor; + in vec2 vUV; void main(void) { - highp vec4 tex = texture2D(uTex, vUV); - gl_FragColor = tex * vColor; + vec4 tex = texture(uTex, vUV); + out_FragColor = tex * vColor; // Discard fragments without alpha. - if(gl_FragColor.a <= 0.0) { + if (out_FragColor.a <= 0.0) { discard; } }" diff --git a/doomsday/apps/client/net.dengine.client.pack/renderer.pack/lensflares.pack/shaders/lensflares.vsh b/doomsday/apps/client/net.dengine.client.pack/renderer.pack/lensflares.pack/shaders/lensflares.vsh index 73ca2ec81b..c490457388 100644 --- a/doomsday/apps/client/net.dengine.client.pack/renderer.pack/lensflares.pack/shaders/lensflares.vsh +++ b/doomsday/apps/client/net.dengine.client.pack/renderer.pack/lensflares.pack/shaders/lensflares.vsh @@ -1,35 +1,35 @@ -uniform highp mat4 uMvpMatrix; -uniform highp vec4 uActiveRect; // (x-scale, y-scale, x-offset, y-offset) -uniform highp vec2 uViewUnit; -uniform highp vec2 uPixelAsUv; +uniform mat4 uMvpMatrix; +uniform vec4 uActiveRect; // (x-scale, y-scale, x-offset, y-offset) +uniform vec2 uViewUnit; +uniform vec2 uPixelAsUv; uniform sampler2D uDepthBuf; -attribute highp vec4 aVertex; -attribute highp vec4 aColor; -attribute highp vec2 aUV; -attribute highp vec2 aUV2; -attribute highp vec2 aUV3; +in vec4 aVertex; +in vec4 aColor; +in vec2 aUV; +in vec2 aUV2; +in vec2 aUV3; -varying highp vec4 vColor; -varying highp vec2 vUV; +out vec4 vColor; +out vec2 vUV; -bool isOccluded(highp vec2 uv) { +bool isOccluded(vec2 uv) { // Apply a possible viewport transformation. uv = uv * uActiveRect.xy + uActiveRect.zw; - float depth = texture2D(uDepthBuf, uv).r; + float depth = texture(uDepthBuf, uv).r; return (depth < (gl_Position.z/gl_Position.w + 1.0) / 2.0); } float occlusionLevel() { - highp vec2 depthUv = gl_Position.xy / gl_Position.w / 2.0 + vec2(0.5, 0.5); + vec2 depthUv = gl_Position.xy / gl_Position.w / 2.0 + vec2(0.5, 0.5); float occ = 0.0; - if(!isOccluded(depthUv)) occ += 0.2; - if(!isOccluded(depthUv + vec2(uPixelAsUv.x * 4.0, uPixelAsUv.y))) occ += 0.2; - if(!isOccluded(depthUv - vec2(uPixelAsUv.x * 4.0, uPixelAsUv.y))) occ += 0.2; - if(!isOccluded(depthUv + vec2(uPixelAsUv.x, uPixelAsUv.y * 4.0))) occ += 0.2; - if(!isOccluded(depthUv - vec2(uPixelAsUv.x, uPixelAsUv.y * 4.0))) occ += 0.2; + if (!isOccluded(depthUv)) occ += 0.2; + if (!isOccluded(depthUv + vec2(uPixelAsUv.x * 4.0, uPixelAsUv.y))) occ += 0.2; + if (!isOccluded(depthUv - vec2(uPixelAsUv.x * 4.0, uPixelAsUv.y))) occ += 0.2; + if (!isOccluded(depthUv + vec2(uPixelAsUv.x, uPixelAsUv.y * 4.0))) occ += 0.2; + if (!isOccluded(depthUv - vec2(uPixelAsUv.x, uPixelAsUv.y * 4.0))) occ += 0.2; return occ; } @@ -41,7 +41,7 @@ void main(void) { // Is the origin occluded in the depth buffer? float ocl = occlusionLevel(); - if(ocl <= 0.0) { + if (ocl <= 0.0) { // Occluded! Make it invisibile and leave the quad zero-sized. vUV = aUV; vColor = vec4(0.0, 0.0, 0.0, 0.0); @@ -52,7 +52,7 @@ void main(void) { } // Position on the axis that passes through the center of the view. - highp float axisPos = aUV3.s; + float axisPos = aUV3.s; gl_Position.xy *= axisPos; // Position the quad corners. diff --git a/doomsday/apps/client/net.dengine.client.pack/renderer.pack/shaders.dei b/doomsday/apps/client/net.dengine.client.pack/renderer.pack/shaders.dei index 206be0de8a..d9baf518b1 100644 --- a/doomsday/apps/client/net.dengine.client.pack/renderer.pack/shaders.dei +++ b/doomsday/apps/client/net.dengine.client.pack/renderer.pack/shaders.dei @@ -8,6 +8,7 @@ # - vertex: source of the vertex shader # - fragment: source of the fragment shader +@include @include @include @include diff --git a/doomsday/apps/client/net.dengine.client.pack/renderer.pack/shaders/debug.dei b/doomsday/apps/client/net.dengine.client.pack/renderer.pack/shaders/debug.dei index 29d9f0bb2b..9b15a26f8e 100644 --- a/doomsday/apps/client/net.dengine.client.pack/renderer.pack/shaders/debug.dei +++ b/doomsday/apps/client/net.dengine.client.pack/renderer.pack/shaders/debug.dei @@ -3,12 +3,12 @@ debug { # Visualize alpha information. shader alpha { vertex = " - uniform highp mat4 uMvpMatrix; - attribute highp vec4 aVertex; - attribute highp vec2 aUV; - attribute highp vec4 aColor; - varying highp vec2 vUV; - varying highp vec4 vColor; + uniform mat4 uMvpMatrix; + in vec4 aVertex; + in vec2 aUV; + in vec4 aColor; + out vec2 vUV; + out vec4 vColor; void main(void) { gl_Position = uMvpMatrix * aVertex; @@ -17,12 +17,12 @@ debug { }" fragment = " uniform sampler2D uTex; - varying highp vec2 vUV; - varying highp vec4 vColor; + in vec2 vUV; + in vec4 vColor; void main(void) { - highp vec4 col = vColor * texture2D(uTex, vUV); - gl_FragColor = vec4(col.a, col.a, col.a, 1.0); + vec4 col = vColor * texture(uTex, vUV); + out_FragColor = vec4(col.a, col.a, col.a, 1.0); }" } } diff --git a/doomsday/apps/client/net.dengine.client.pack/renderer.pack/shaders/dgl/dgl.dei b/doomsday/apps/client/net.dengine.client.pack/renderer.pack/shaders/dgl/dgl.dei new file mode 100644 index 0000000000..a6bc55c1c0 --- /dev/null +++ b/doomsday/apps/client/net.dengine.client.pack/renderer.pack/shaders/dgl/dgl.dei @@ -0,0 +1,5 @@ +# Shader for the DGL drawing routines that emulate OpenGL 1.x behavior. +shader dgl.draw { + vertex.path = "dgl_draw.vsh" + fragment.path = "dgl_draw.fsh" +} diff --git a/doomsday/apps/client/net.dengine.client.pack/renderer.pack/shaders/dgl/dgl_draw.fsh b/doomsday/apps/client/net.dengine.client.pack/renderer.pack/shaders/dgl/dgl_draw.fsh new file mode 100644 index 0000000000..1bb58d52b1 --- /dev/null +++ b/doomsday/apps/client/net.dengine.client.pack/renderer.pack/shaders/dgl/dgl_draw.fsh @@ -0,0 +1,50 @@ +/* + * The Doomsday Engine Project + * Common OpenGL Shaders: Legacy DGL Drawing + * + * Copyright (c) 2017 Jaakko Keränen + * + * @par License + * LGPL: http://www.gnu.org/licenses/lgpl.html + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation; either version 3 of the License, or (at your + * option) any later version. This program is distributed in the hope that it + * will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty + * of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser + * General Public License for more details. You should have received a copy of + * the GNU Lesser General Public License along with this program; if not, see: + * http://www.gnu.org/licenses + */ + +#version 330 + +uniform int uEnabledTextures; +uniform sampler2D uTex0; +uniform sampler2D uTex1; +uniform sampler2D uTex2; + +in vec4 vColor; +in vec2 vTexCoord[3]; + +void main() +{ + out_FragColor = vColor; + + // Colors from textures. + vec4 texColor[3] = vec4[3] (vec4(0.0), vec4(0.0), vec4(0.0)); + if ((uEnabledTextures & 0x1) != 0) { + texColor[0] = texture(uTex0, vTexCoord[0]); + out_FragColor *= texColor[0]; + } + if ((uEnabledTextures & 0x2) != 0) { + texColor[1] = texture(uTex1, vTexCoord[1]); + } + if ((uEnabledTextures & 0x4) != 0) { + texColor[2] = texture(uTex2, vTexCoord[2]); + } + + // TODO: Modulate the texture colors in the requested manner + +} diff --git a/doomsday/apps/client/net.dengine.client.pack/renderer.pack/shaders/dgl/dgl_draw.vsh b/doomsday/apps/client/net.dengine.client.pack/renderer.pack/shaders/dgl/dgl_draw.vsh new file mode 100644 index 0000000000..b1d6789014 --- /dev/null +++ b/doomsday/apps/client/net.dengine.client.pack/renderer.pack/shaders/dgl/dgl_draw.vsh @@ -0,0 +1,46 @@ +/* + * The Doomsday Engine Project + * Common OpenGL Shaders: Legacy DGL Drawing + * + * Copyright (c) 2017 Jaakko Keränen + * + * @par License + * LGPL: http://www.gnu.org/licenses/lgpl.html + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation; either version 3 of the License, or (at your + * option) any later version. This program is distributed in the hope that it + * will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty + * of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser + * General Public License for more details. You should have received a copy of + * the GNU Lesser General Public License along with this program; if not, see: + * http://www.gnu.org/licenses + */ + +#version 330 + +layout(location = 0) in vec3 aVertex; +layout(location = 1) in vec4 aColor; +layout(location = 2) in vec2 aTexCoord[3]; + +uniform mat4 uMvpMatrix; +uniform mat4 uTextureMatrix; + +out vec4 vColor; +out vec2 vTexCoord[3]; + +vec2 transformTexCoord(vec2 tc) +{ + vec4 coord = vec4(tc.s, tc.t, 0.0, 1.0); + return (uTextureMatrix * coord).xy; +} + +void main() +{ + gl_Position = uMvpMatrix * aVertex; + vColor = aColor; + for (int i = 0; i < 3; ++i) { + vTexCoord[i] = transformTexCoord(aTexCoord[i]); + } +} diff --git a/doomsday/apps/client/net.dengine.client.pack/renderer.pack/shaders/fx/bloom.dei b/doomsday/apps/client/net.dengine.client.pack/renderer.pack/shaders/fx/bloom.dei index cccc72e883..a23b10eb82 100644 --- a/doomsday/apps/client/net.dengine.client.pack/renderer.pack/shaders/fx/bloom.dei +++ b/doomsday/apps/client/net.dengine.client.pack/renderer.pack/shaders/fx/bloom.dei @@ -2,14 +2,14 @@ # (given a configurable threshold for brightness). fx.bloom { common = " - uniform highp mat4 uMvpMatrix; - uniform highp vec4 uColor; - uniform highp vec4 uWindow; + uniform mat4 uMvpMatrix; + uniform vec4 uColor; + uniform vec4 uWindow; - attribute highp vec4 aVertex; - attribute highp vec2 aUV; + in vec4 aVertex; + in vec2 aUV; - varying highp vec2 vUV; + out vec2 vUV; void main(void) { gl_Position = uMvpMatrix * aVertex; @@ -20,37 +20,37 @@ fx.bloom { vertex $= fx.bloom.common fragment = " uniform sampler2D uTex; - uniform highp float uIntensity; - uniform highp float uThreshold; - uniform highp vec2 uBlurStep; + uniform float uIntensity; + uniform float uThreshold; + uniform vec2 uBlurStep; - varying highp vec2 vUV; + in vec2 vUV; void main(void) { - highp vec4 sum = vec4(0.0); + vec4 sum = vec4(0.0); - sum += texture2D(uTex, vec2(vUV.s - 7.0 * uBlurStep.s, vUV.t)) * 0.0249; - sum += texture2D(uTex, vec2(vUV.s - 6.0 * uBlurStep.s, vUV.t)) * 0.0367; - sum += texture2D(uTex, vec2(vUV.s - 5.0 * uBlurStep.s, vUV.t)) * 0.0498; - sum += texture2D(uTex, vec2(vUV.s - 4.0 * uBlurStep.s, vUV.t)) * 0.0660; - sum += texture2D(uTex, vec2(vUV.s - 3.0 * uBlurStep.s, vUV.t)) * 0.0803; - sum += texture2D(uTex, vec2(vUV.s - 2.0 * uBlurStep.s, vUV.t)) * 0.0915; - sum += texture2D(uTex, vec2(vUV.s - uBlurStep.s, vUV.t)) * 0.0996; - sum += texture2D(uTex, vUV) * 0.1027; - sum += texture2D(uTex, vec2(vUV.s + uBlurStep.s, vUV.t)) * 0.0996; - sum += texture2D(uTex, vec2(vUV.s + 2.0 * uBlurStep.s, vUV.t)) * 0.0915; - sum += texture2D(uTex, vec2(vUV.s + 3.0 * uBlurStep.s, vUV.t)) * 0.0803; - sum += texture2D(uTex, vec2(vUV.s + 4.0 * uBlurStep.s, vUV.t)) * 0.0660; - sum += texture2D(uTex, vec2(vUV.s + 5.0 * uBlurStep.s, vUV.t)) * 0.0498; - sum += texture2D(uTex, vec2(vUV.s + 6.0 * uBlurStep.s, vUV.t)) * 0.0367; - sum += texture2D(uTex, vec2(vUV.s + 7.0 * uBlurStep.s, vUV.t)) * 0.0249; + sum += texture(uTex, vec2(vUV.s - 7.0 * uBlurStep.s, vUV.t)) * 0.0249; + sum += texture(uTex, vec2(vUV.s - 6.0 * uBlurStep.s, vUV.t)) * 0.0367; + sum += texture(uTex, vec2(vUV.s - 5.0 * uBlurStep.s, vUV.t)) * 0.0498; + sum += texture(uTex, vec2(vUV.s - 4.0 * uBlurStep.s, vUV.t)) * 0.0660; + sum += texture(uTex, vec2(vUV.s - 3.0 * uBlurStep.s, vUV.t)) * 0.0803; + sum += texture(uTex, vec2(vUV.s - 2.0 * uBlurStep.s, vUV.t)) * 0.0915; + sum += texture(uTex, vec2(vUV.s - uBlurStep.s, vUV.t)) * 0.0996; + sum += texture(uTex, vUV) * 0.1027; + sum += texture(uTex, vec2(vUV.s + uBlurStep.s, vUV.t)) * 0.0996; + sum += texture(uTex, vec2(vUV.s + 2.0 * uBlurStep.s, vUV.t)) * 0.0915; + sum += texture(uTex, vec2(vUV.s + 3.0 * uBlurStep.s, vUV.t)) * 0.0803; + sum += texture(uTex, vec2(vUV.s + 4.0 * uBlurStep.s, vUV.t)) * 0.0660; + sum += texture(uTex, vec2(vUV.s + 5.0 * uBlurStep.s, vUV.t)) * 0.0498; + sum += texture(uTex, vec2(vUV.s + 6.0 * uBlurStep.s, vUV.t)) * 0.0367; + sum += texture(uTex, vec2(vUV.s + 7.0 * uBlurStep.s, vUV.t)) * 0.0249; // Apply a threshold that gets rid of dark, non-luminous pixels. - highp float intens = max(sum.r, max(sum.g, sum.b)); + float intens = max(sum.r, max(sum.g, sum.b)); intens = (intens - uThreshold) * uIntensity; - gl_FragColor = vec4(vec3(intens) * normalize(sum.rgb + 0.2), 1.0); + out_FragColor = vec4(vec3(intens) * normalize(sum.rgb + 0.2), 1.0); }" } @@ -58,30 +58,30 @@ fx.bloom { vertex $= fx.bloom.common fragment = " uniform sampler2D uTex; - uniform highp vec2 uBlurStep; + uniform vec2 uBlurStep; - varying highp vec2 vUV; + in vec2 vUV; void main(void) { - highp vec4 sum = vec4(0.0); + vec4 sum = vec4(0.0); - sum += texture2D(uTex, vec2(vUV.s, vUV.t - 7.0 * uBlurStep.t)) * 0.0249; - sum += texture2D(uTex, vec2(vUV.s, vUV.t - 6.0 * uBlurStep.t)) * 0.0367; - sum += texture2D(uTex, vec2(vUV.s, vUV.t - 5.0 * uBlurStep.t)) * 0.0498; - sum += texture2D(uTex, vec2(vUV.s, vUV.t - 4.0 * uBlurStep.t)) * 0.0660; - sum += texture2D(uTex, vec2(vUV.s, vUV.t - 3.0 * uBlurStep.t)) * 0.0803; - sum += texture2D(uTex, vec2(vUV.s, vUV.t - 2.0 * uBlurStep.t)) * 0.0915; - sum += texture2D(uTex, vec2(vUV.s, vUV.t - uBlurStep.t )) * 0.0996; - sum += texture2D(uTex, vUV) * 0.1027; - sum += texture2D(uTex, vec2(vUV.s, vUV.t + uBlurStep.t )) * 0.0996; - sum += texture2D(uTex, vec2(vUV.s, vUV.t + 2.0 * uBlurStep.t)) * 0.0915; - sum += texture2D(uTex, vec2(vUV.s, vUV.t + 3.0 * uBlurStep.t)) * 0.0803; - sum += texture2D(uTex, vec2(vUV.s, vUV.t + 4.0 * uBlurStep.t)) * 0.0660; - sum += texture2D(uTex, vec2(vUV.s, vUV.t + 5.0 * uBlurStep.t)) * 0.0498; - sum += texture2D(uTex, vec2(vUV.s, vUV.t + 6.0 * uBlurStep.t)) * 0.0367; - sum += texture2D(uTex, vec2(vUV.s, vUV.t + 7.0 * uBlurStep.t)) * 0.0249; + sum += texture(uTex, vec2(vUV.s, vUV.t - 7.0 * uBlurStep.t)) * 0.0249; + sum += texture(uTex, vec2(vUV.s, vUV.t - 6.0 * uBlurStep.t)) * 0.0367; + sum += texture(uTex, vec2(vUV.s, vUV.t - 5.0 * uBlurStep.t)) * 0.0498; + sum += texture(uTex, vec2(vUV.s, vUV.t - 4.0 * uBlurStep.t)) * 0.0660; + sum += texture(uTex, vec2(vUV.s, vUV.t - 3.0 * uBlurStep.t)) * 0.0803; + sum += texture(uTex, vec2(vUV.s, vUV.t - 2.0 * uBlurStep.t)) * 0.0915; + sum += texture(uTex, vec2(vUV.s, vUV.t - uBlurStep.t )) * 0.0996; + sum += texture(uTex, vUV) * 0.1027; + sum += texture(uTex, vec2(vUV.s, vUV.t + uBlurStep.t )) * 0.0996; + sum += texture(uTex, vec2(vUV.s, vUV.t + 2.0 * uBlurStep.t)) * 0.0915; + sum += texture(uTex, vec2(vUV.s, vUV.t + 3.0 * uBlurStep.t)) * 0.0803; + sum += texture(uTex, vec2(vUV.s, vUV.t + 4.0 * uBlurStep.t)) * 0.0660; + sum += texture(uTex, vec2(vUV.s, vUV.t + 5.0 * uBlurStep.t)) * 0.0498; + sum += texture(uTex, vec2(vUV.s, vUV.t + 6.0 * uBlurStep.t)) * 0.0367; + sum += texture(uTex, vec2(vUV.s, vUV.t + 7.0 * uBlurStep.t)) * 0.0249; - gl_FragColor = sum; + out_FragColor = sum; }" } } diff --git a/doomsday/apps/client/net.dengine.client.pack/renderer.pack/shaders/fx/blur.dei b/doomsday/apps/client/net.dengine.client.pack/renderer.pack/shaders/fx/blur.dei index b8c6cedde6..9758655037 100644 --- a/doomsday/apps/client/net.dengine.client.pack/renderer.pack/shaders/fx/blur.dei +++ b/doomsday/apps/client/net.dengine.client.pack/renderer.pack/shaders/fx/blur.dei @@ -4,16 +4,16 @@ fx { blur { # Both passes use the same vertex shader. common = " - uniform highp mat4 uMvpMatrix; - uniform highp vec4 uColor; - uniform highp vec4 uWindow; + uniform mat4 uMvpMatrix; + uniform vec4 uColor; + uniform vec4 uWindow; - attribute highp vec4 aVertex; - attribute highp vec2 aUV; - attribute highp vec4 aColor; + in vec4 aVertex; + in vec2 aUV; + in vec4 aColor; - varying highp vec2 vUV; - varying highp vec4 vColor; + out vec2 vUV; + out vec4 vColor; void main(void) { gl_Position = uMvpMatrix * aVertex; @@ -25,24 +25,24 @@ fx { vertex $= fx.blur.common fragment = " uniform sampler2D uTex; - uniform highp vec2 uBlurStep; + uniform vec2 uBlurStep; - varying highp vec2 vUV; - varying highp vec4 vColor; + in vec2 vUV; + in vec4 vColor; void main(void) { - highp vec4 sum = vec4(0.0); - sum += texture2D(uTex, vec2(vUV.s - 4.0 * uBlurStep.s, vUV.t)) * 0.05; - sum += texture2D(uTex, vec2(vUV.s - 3.0 * uBlurStep.s, vUV.t)) * 0.09; - sum += texture2D(uTex, vec2(vUV.s - 2.0 * uBlurStep.s, vUV.t)) * 0.123; - sum += texture2D(uTex, vec2(vUV.s - uBlurStep.s, vUV.t)) * 0.154; - sum += texture2D(uTex, vUV) * 0.165; - sum += texture2D(uTex, vec2(vUV.s + uBlurStep.s, vUV.t)) * 0.154; - sum += texture2D(uTex, vec2(vUV.s + 2.0 * uBlurStep.s, vUV.t)) * 0.123; - sum += texture2D(uTex, vec2(vUV.s + 3.0 * uBlurStep.s, vUV.t)) * 0.09; - sum += texture2D(uTex, vec2(vUV.s + 4.0 * uBlurStep.s, vUV.t)) * 0.05; - gl_FragColor = sum; - gl_FragColor.a = 1.0; + vec4 sum = vec4(0.0); + sum += texture(uTex, vec2(vUV.s - 4.0 * uBlurStep.s, vUV.t)) * 0.05; + sum += texture(uTex, vec2(vUV.s - 3.0 * uBlurStep.s, vUV.t)) * 0.09; + sum += texture(uTex, vec2(vUV.s - 2.0 * uBlurStep.s, vUV.t)) * 0.123; + sum += texture(uTex, vec2(vUV.s - uBlurStep.s, vUV.t)) * 0.154; + sum += texture(uTex, vUV) * 0.165; + sum += texture(uTex, vec2(vUV.s + uBlurStep.s, vUV.t)) * 0.154; + sum += texture(uTex, vec2(vUV.s + 2.0 * uBlurStep.s, vUV.t)) * 0.123; + sum += texture(uTex, vec2(vUV.s + 3.0 * uBlurStep.s, vUV.t)) * 0.09; + sum += texture(uTex, vec2(vUV.s + 4.0 * uBlurStep.s, vUV.t)) * 0.05; + out_FragColor = sum; + out_FragColor.a = 1.0; }" } @@ -50,23 +50,23 @@ fx { vertex $= fx.blur.common fragment = " uniform sampler2D uTex; - uniform highp vec2 uBlurStep; + uniform vec2 uBlurStep; - varying highp vec2 vUV; - varying highp vec4 vColor; + in vec2 vUV; + in vec4 vColor; void main(void) { - highp vec4 sum = vec4(0.0); - sum += texture2D(uTex, vec2(vUV.s, vUV.t - 4.0 * uBlurStep.t)) * 0.05; - sum += texture2D(uTex, vec2(vUV.s, vUV.t - 3.0 * uBlurStep.t)) * 0.09; - sum += texture2D(uTex, vec2(vUV.s, vUV.t - 2.0 * uBlurStep.t)) * 0.123; - sum += texture2D(uTex, vec2(vUV.s, vUV.t - uBlurStep.t )) * 0.154; - sum += texture2D(uTex, vUV) * 0.165; - sum += texture2D(uTex, vec2(vUV.s, vUV.t + uBlurStep.t )) * 0.154; - sum += texture2D(uTex, vec2(vUV.s, vUV.t + 2.0 * uBlurStep.t)) * 0.123; - sum += texture2D(uTex, vec2(vUV.s, vUV.t + 3.0 * uBlurStep.t)) * 0.09; - sum += texture2D(uTex, vec2(vUV.s, vUV.t + 4.0 * uBlurStep.t)) * 0.05; - gl_FragColor = sum * vColor; + vec4 sum = vec4(0.0); + sum += texture(uTex, vec2(vUV.s, vUV.t - 4.0 * uBlurStep.t)) * 0.05; + sum += texture(uTex, vec2(vUV.s, vUV.t - 3.0 * uBlurStep.t)) * 0.09; + sum += texture(uTex, vec2(vUV.s, vUV.t - 2.0 * uBlurStep.t)) * 0.123; + sum += texture(uTex, vec2(vUV.s, vUV.t - uBlurStep.t )) * 0.154; + sum += texture(uTex, vUV) * 0.165; + sum += texture(uTex, vec2(vUV.s, vUV.t + uBlurStep.t )) * 0.154; + sum += texture(uTex, vec2(vUV.s, vUV.t + 2.0 * uBlurStep.t)) * 0.123; + sum += texture(uTex, vec2(vUV.s, vUV.t + 3.0 * uBlurStep.t)) * 0.09; + sum += texture(uTex, vec2(vUV.s, vUV.t + 4.0 * uBlurStep.t)) * 0.05; + out_FragColor = sum * vColor; }" } } diff --git a/doomsday/apps/client/net.dengine.client.pack/renderer.pack/shaders/fx/post.dei b/doomsday/apps/client/net.dengine.client.pack/renderer.pack/shaders/fx/post.dei index cd3f248b94..788b3b8735 100644 --- a/doomsday/apps/client/net.dengine.client.pack/renderer.pack/shaders/fx/post.dei +++ b/doomsday/apps/client/net.dengine.client.pack/renderer.pack/shaders/fx/post.dei @@ -4,10 +4,10 @@ fx { post { shader monochrome { vertex = " - uniform highp mat4 uMvpMatrix; - attribute highp vec4 aVertex; - attribute highp vec2 aUV; - varying highp vec2 vUV; + uniform mat4 uMvpMatrix; + in vec4 aVertex; + in vec2 aUV; + out vec2 vUV; void main(void) { gl_Position = uMvpMatrix * aVertex; @@ -15,28 +15,28 @@ fx { }" fragment = " uniform sampler2D uTex; - uniform highp float uFadeInOut; - varying highp vec2 vUV; + uniform float uFadeInOut; + in vec2 vUV; void main(void) { - highp vec4 original = texture2D(uTex, vUV); - highp float intens = + vec4 original = texture(uTex, vUV); + float intens = (0.2125 * original.r) + (0.7154 * original.g) + (0.0721 * original.b); - gl_FragColor = vec4(vec3(intens), 1.0); - if(uFadeInOut < 1.0) { - gl_FragColor = mix(original, gl_FragColor, uFadeInOut); + out_FragColor = vec4(vec3(intens), 1.0); + if (uFadeInOut < 1.0) { + out_FragColor = mix(original, out_FragColor, uFadeInOut); } }" } shader monochrome.inverted { vertex = " - uniform highp mat4 uMvpMatrix; - attribute highp vec4 aVertex; - attribute highp vec2 aUV; - varying highp vec2 vUV; + uniform mat4 uMvpMatrix; + in vec4 aVertex; + in vec2 aUV; + out vec2 vUV; void main(void) { gl_Position = uMvpMatrix * aVertex; @@ -44,19 +44,19 @@ fx { }" fragment = " uniform sampler2D uTex; - uniform highp float uFadeInOut; - varying highp vec2 vUV; + uniform float uFadeInOut; + in vec2 vUV; void main(void) { - highp vec4 original = texture2D(uTex, vUV); - highp float intens = + vec4 original = texture(uTex, vUV); + float intens = (0.2125 * original.r) + (0.7154 * original.g) + (0.0721 * original.b); - gl_FragColor = vec4(vec3(1.0 - intens), 1.0); - if(uFadeInOut < 1.0) { - gl_FragColor = mix(original, gl_FragColor, uFadeInOut); + out_FragColor = vec4(vec3(1.0 - intens), 1.0); + if (uFadeInOut < 1.0) { + out_FragColor = mix(original, out_FragColor, uFadeInOut); } }" } diff --git a/doomsday/apps/client/net.dengine.client.pack/renderer.pack/shaders/generic.dei b/doomsday/apps/client/net.dengine.client.pack/renderer.pack/shaders/generic.dei index ef1f7bdbcf..8977ac2af9 100644 --- a/doomsday/apps/client/net.dengine.client.pack/renderer.pack/shaders/generic.dei +++ b/doomsday/apps/client/net.dengine.client.pack/renderer.pack/shaders/generic.dei @@ -4,30 +4,30 @@ generic { # matrix. shader color_ucolor { vertex = " - uniform highp mat4 uMvpMatrix; - uniform highp vec4 uColor; - attribute highp vec4 aVertex; - attribute highp vec4 aColor; - varying highp vec4 vColor; + uniform mat4 uMvpMatrix; + uniform vec4 uColor; + in vec4 aVertex; + in vec4 aColor; + out vec4 vColor; void main(void) { gl_Position = uMvpMatrix * aVertex; vColor = uColor * aColor; }" fragment = " - varying highp vec4 vColor; + in vec4 vColor; void main(void) { - gl_FragColor = vColor; + out_FragColor = vColor; }" } shader texture { vertex = " - uniform highp mat4 uMvpMatrix; - attribute highp vec4 aVertex; - attribute highp vec2 aUV; - varying highp vec2 vUV; + uniform mat4 uMvpMatrix; + in vec4 aVertex; + in vec2 aUV; + out vec2 vUV; void main(void) { gl_Position = uMvpMatrix * aVertex; @@ -35,10 +35,10 @@ generic { }" fragment = " uniform sampler2D uTex; - varying highp vec2 vUV; + in vec2 vUV; void main(void) { - gl_FragColor = texture2D(uTex, vUV); + out_FragColor = texture(uTex, vUV); }" } @@ -47,12 +47,12 @@ generic { # combined model-view-projection matrix. shader color { vertex = " - uniform highp mat4 uMvpMatrix; - attribute highp vec4 aVertex; - attribute highp vec2 aUV; - attribute highp vec4 aColor; - varying highp vec2 vUV; - varying highp vec4 vColor; + uniform mat4 uMvpMatrix; + in vec4 aVertex; + in vec2 aUV; + in vec4 aColor; + out vec2 vUV; + out vec4 vColor; void main(void) { gl_Position = uMvpMatrix * aVertex; @@ -61,11 +61,11 @@ generic { }" fragment = " uniform sampler2D uTex; - varying highp vec2 vUV; - varying highp vec4 vColor; + in vec2 vUV; + in vec4 vColor; void main(void) { - gl_FragColor = vColor * texture2D(uTex, vUV); + out_FragColor = vColor * texture(uTex, vUV); }" } @@ -74,13 +74,13 @@ generic { # combined model-view-projection matrix. shader color_ucolor { vertex = " - uniform highp mat4 uMvpMatrix; - uniform highp vec4 uColor; - attribute highp vec4 aVertex; - attribute highp vec2 aUV; - attribute highp vec4 aColor; - varying highp vec2 vUV; - varying highp vec4 vColor; + uniform mat4 uMvpMatrix; + uniform vec4 uColor; + in vec4 aVertex; + in vec2 aUV; + in vec4 aColor; + out vec2 vUV; + out vec4 vColor; void main(void) { gl_Position = uMvpMatrix * aVertex; @@ -89,23 +89,23 @@ generic { }" fragment = " uniform sampler2D uTex; - varying highp vec2 vUV; - varying highp vec4 vColor; + in vec2 vUV; + in vec4 vColor; void main(void) { - gl_FragColor = vColor * texture2D(uTex, vUV); + out_FragColor = vColor * texture(uTex, vUV); }" } shader hsv.color_ucolor inherits generic.textured.color_ucolor { vertex = " - uniform highp mat4 uMvpMatrix; - uniform highp vec4 uColor; - attribute highp vec4 aVertex; - attribute highp vec2 aUV; - attribute highp vec4 aColor; - varying highp vec2 vUV; - varying highp vec4 vColor; + uniform mat4 uMvpMatrix; + uniform vec4 uColor; + in vec4 aVertex; + in vec2 aUV; + in vec4 aColor; + out vec2 vUV; + out vec4 vColor; void main(void) { gl_Position = uMvpMatrix * aVertex; @@ -115,14 +115,14 @@ generic { include.fragment fragment = " uniform sampler2D uTex; - uniform highp float uSaturation; - varying highp vec2 vUV; - varying highp vec4 vColor; + uniform float uSaturation; + in vec2 vUV; + in vec4 vColor; void main(void) { - highp vec4 hsv = rgbToHsv(texture2D(uTex, vUV)); + vec4 hsv = rgbToHsv(texture(uTex, vUV)); hsv.y *= uSaturation; - gl_FragColor = vColor * hsvToRgb(hsv); + out_FragColor = vColor * hsvToRgb(hsv); }" } } diff --git a/doomsday/apps/client/net.dengine.client.pack/renderer.pack/shaders/include/fog.glsl b/doomsday/apps/client/net.dengine.client.pack/renderer.pack/shaders/include/fog.glsl index 36b4d1377b..ee2a6ed689 100644 --- a/doomsday/apps/client/net.dengine.client.pack/renderer.pack/shaders/include/fog.glsl +++ b/doomsday/apps/client/net.dengine.client.pack/renderer.pack/shaders/include/fog.glsl @@ -18,21 +18,20 @@ * http://www.gnu.org/licenses */ -uniform highp vec4 uFogRange; // startDepth, fogDepth, nearclip, farclip -uniform highp vec4 uFogColor; // set alpha to zero to disable fog +uniform vec4 uFogRange; // startDepth, fogDepth, nearclip, farclip +uniform vec4 uFogColor; // set alpha to zero to disable fog void applyFog() { - if(uFogColor.a > 0.0) - { - highp float near = uFogRange.z; - highp float far = uFogRange.w; + if (uFogColor.a > 0.0) { + float near = uFogRange.z; + float far = uFogRange.w; // First convert the fragment Z back to view space. - highp float zNorm = gl_FragCoord.z * 2.0 - 1.0; - highp float zEye = -2.0 * far * near / (zNorm * (far - near) - (far + near)); + float zNorm = gl_FragCoord.z * 2.0 - 1.0; + float zEye = -2.0 * far * near / (zNorm * (far - near) - (far + near)); - highp float fogAmount = clamp((zEye - uFogRange.x) / uFogRange.y, 0.0, 1.0); - gl_FragColor.rgb = mix(gl_FragColor.rgb, uFogColor.rgb, fogAmount); + float fogAmount = clamp((zEye - uFogRange.x) / uFogRange.y, 0.0, 1.0); + out_FragColor.rgb = mix(out_FragColor.rgb, uFogColor.rgb, fogAmount); } } diff --git a/doomsday/apps/client/net.dengine.client.pack/renderer.pack/shaders/include/hsv.glsl b/doomsday/apps/client/net.dengine.client.pack/renderer.pack/shaders/include/hsv.glsl index 6c2aaadd4c..0d79a35a78 100644 --- a/doomsday/apps/client/net.dengine.client.pack/renderer.pack/shaders/include/hsv.glsl +++ b/doomsday/apps/client/net.dengine.client.pack/renderer.pack/shaders/include/hsv.glsl @@ -21,101 +21,86 @@ /** * Converts an RGBA value to HSVA. Hue uses degrees as the unit. */ -highp vec4 rgbToHsv(highp vec4 rgb) +vec4 rgbToHsv(vec4 rgb) { - highp vec4 hsv; + vec4 hsv; hsv.a = rgb.a; - highp float rgbMin = min(min(rgb.r, rgb.g), rgb.b); - highp float rgbMax = max(max(rgb.r, rgb.g), rgb.b); - highp float delta = rgbMax - rgbMin; + float rgbMin = min(min(rgb.r, rgb.g), rgb.b); + float rgbMax = max(max(rgb.r, rgb.g), rgb.b); + float delta = rgbMax - rgbMin; hsv.z = rgbMax; - if (delta < 0.00001) - { + if (delta < 0.00001) { hsv.xy = vec2(0.0); return hsv; } - if (rgbMax > 0.0) - { + if (rgbMax > 0.0) { hsv.y = delta / rgbMax; } - else - { + else { hsv.xy = vec2(0.0); return hsv; } - if (rgb.r >= rgbMax) - { + if (rgb.r >= rgbMax) { hsv.x = (rgb.g - rgb.b) / delta; } - else - { - if (rgb.g >= rgbMax) - { + else { + if (rgb.g >= rgbMax) { hsv.x = 2.0 + (rgb.b - rgb.r) / delta; } - else - { + else { hsv.x = 4.0 + (rgb.r - rgb.g) / delta; } } hsv.x *= 60.0; - if (hsv.x < 0.0) - { + if (hsv.x < 0.0) { hsv.x += 360.0; } return hsv; } -highp vec4 hsvToRgb(highp vec4 hsv) +vec4 hsvToRgb(vec4 hsv) { - highp vec4 rgb; + vec4 rgb; rgb.a = hsv.a; - if (hsv.y <= 0.0) - { + if (hsv.y <= 0.0) { rgb.rgb = vec3(hsv.z); return rgb; } - highp float hh = hsv.x; + float hh = hsv.x; if (hh >= 360.0) hh = 0.0; hh /= 60.0; - highp float ff = fract(hh); - highp float p = hsv.z * (1.0 - hsv.y); - highp float q = hsv.z * (1.0 - (hsv.y * ff)); - highp float t = hsv.z * (1.0 - (hsv.y * (1.0 - ff))); + float ff = fract(hh); + float p = hsv.z * (1.0 - hsv.y); + float q = hsv.z * (1.0 - (hsv.y * ff)); + float t = hsv.z * (1.0 - (hsv.y * (1.0 - ff))); int i = int(hh); - if (i == 0) - { + if (i == 0) { rgb.rgb = vec3(hsv.z, t, p); } - else if (i == 1) - { + else if (i == 1) { rgb.rgb = vec3(q, hsv.z, p); } - else if (i == 2) - { + else if (i == 2) { rgb.rgb = vec3(p, hsv.z, t); } - else if (i == 3) - { + else if (i == 3) { rgb.rgb = vec3(p, q, hsv.z); } - else if (i == 4) - { + else if (i == 4) { rgb.rgb = vec3(t, p, hsv.z); } - else - { + else { rgb.rgb = vec3(hsv.z, p, q); } diff --git a/doomsday/apps/client/net.dengine.client.pack/renderer.pack/shaders/include/lighting.glsl b/doomsday/apps/client/net.dengine.client.pack/renderer.pack/shaders/include/lighting.glsl index 6502428dc0..ddc29e8d51 100644 --- a/doomsday/apps/client/net.dengine.client.pack/renderer.pack/shaders/include/lighting.glsl +++ b/doomsday/apps/client/net.dengine.client.pack/renderer.pack/shaders/include/lighting.glsl @@ -18,37 +18,40 @@ * http://www.gnu.org/licenses */ -uniform highp float uSpecular; // factor for specular lights -uniform highp float uEmission; // factor for emissive light -uniform highp float uGlossiness; +uniform float uSpecular; // factor for specular lights +uniform float uEmission; // factor for emissive light +uniform float uGlossiness; -uniform highp vec4 uAmbientLight; -uniform highp vec4 uLightIntensities[4]; // colored -uniform highp vec3 uLightDirs[4]; // model space -uniform highp vec3 uEyePos; // model space +uniform vec4 uAmbientLight; +uniform vec4 uLightIntensities[4]; // colored +uniform vec3 uLightDirs[4]; // model space +uniform vec3 uEyePos; // model space -varying highp vec3 vEyeDir; // from vertex, in model space +#ifdef DENG_VERTEX_SHADER +out vec3 vEyeDir; // from vertex, in model space +#else +in vec3 vEyeDir; +#endif #ifdef DENG_VERTEX_SHADER -void calculateEyeDirection(highp vec4 vertex) +void calculateEyeDirection(vec4 vertex) { vEyeDir = uEyePos - vertex.xyz/vertex.w; } #endif // DENG_VERTEX_SHADER -highp vec3 diffuseLightContrib(int index, highp vec3 msNormal) +vec3 diffuseLightContrib(int index, vec3 msNormal) { - if(uLightIntensities[index].a <= 0.001) - { + if (uLightIntensities[index].a <= 0.001) { return vec3(0.0); // too dim } - highp float d = dot(msNormal, uLightDirs[index]); + float d = dot(msNormal, uLightDirs[index]); return max(d, 0.0) * uLightIntensities[index].rgb; } -highp vec3 diffuseLight(highp vec3 msNormal) +vec3 diffuseLight(vec3 msNormal) { return (uAmbientLight.rgb + diffuseLightContrib(0, msNormal) + @@ -59,29 +62,27 @@ highp vec3 diffuseLight(highp vec3 msNormal) #ifdef DENG_HAVE_UTEX -highp vec3 specularLightContrib(highp vec4 specGloss, int index, highp vec3 msNormal) +vec3 specularLightContrib(vec4 specGloss, int index, vec3 msNormal) { - if(uLightIntensities[index].a <= 0.001) // a == max of rgb - { + if (uLightIntensities[index].a <= 0.001) { // a == max of rgb return vec3(0.0); // Too dim. } - highp vec3 reflectedDir = reflect(-uLightDirs[index], msNormal); - highp float refDot = dot(normalize(vEyeDir), reflectedDir); - if(refDot <= 0.0) - { + vec3 reflectedDir = reflect(-uLightDirs[index], msNormal); + float refDot = dot(normalize(vEyeDir), reflectedDir); + if (refDot <= 0.0) { return vec3(0.0); // Wrong way. } - highp float gloss = max(1.0, uGlossiness * specGloss.a); - highp float specPower = min(pow(refDot, gloss), 1.0); + float gloss = max(1.0, uGlossiness * specGloss.a); + float specPower = min(pow(refDot, gloss), 1.0); return uSpecular * uLightIntensities[index].rgb * specPower * specGloss.rgb; } -highp vec4 specularGloss(highp vec2 specularUV) +vec4 specularGloss(vec2 specularUV) { - return texture2D(uTex, specularUV); + return texture(uTex, specularUV); } -highp vec3 specularLight(highp vec4 specGloss, highp vec3 msNormal) +vec3 specularLight(vec4 specGloss, vec3 msNormal) { return specularLightContrib(specGloss, 0, msNormal) + specularLightContrib(specGloss, 1, msNormal) + @@ -89,9 +90,9 @@ highp vec3 specularLight(highp vec4 specGloss, highp vec3 msNormal) specularLightContrib(specGloss, 3, msNormal); } -highp vec4 emittedLight(highp vec2 emissiveUV) +vec4 emittedLight(vec2 emissiveUV) { - highp vec4 emission = uEmission * texture2D(uTex, emissiveUV); + vec4 emission = uEmission * texture(uTex, emissiveUV); emission.a = 0.0; // Does not contribute to alpha. return emission; } diff --git a/doomsday/apps/client/net.dengine.client.pack/renderer.pack/shaders/include/reflection.glsl b/doomsday/apps/client/net.dengine.client.pack/renderer.pack/shaders/include/reflection.glsl index 30f34d8aa9..9696860aad 100644 --- a/doomsday/apps/client/net.dengine.client.pack/renderer.pack/shaders/include/reflection.glsl +++ b/doomsday/apps/client/net.dengine.client.pack/renderer.pack/shaders/include/reflection.glsl @@ -27,9 +27,9 @@ #define MAX_REFLECTION_BIAS 5.0 uniform samplerCube uReflectionTex; -uniform highp mat4 uReflectionMatrix; -uniform highp float uReflection; -uniform highp float uReflectionBlur; +uniform mat4 uReflectionMatrix; +uniform float uReflection; +uniform float uReflectionBlur; /* * Given the tangent space @a surfaceNormal, determines the reflection @@ -37,35 +37,35 @@ uniform highp float uReflectionBlur; * the fragment's tangent space matrix. @a bias is the mipmap bias for the * reflection. */ -highp vec3 reflectedColorBiased(highp vec3 msNormal, float bias) +vec3 reflectedColorBiased(vec3 msNormal, float bias) { // The reflection cube exists in local space, so we will use vectors // relative to the object's origin. - highp vec3 reflectedDir = reflect(normalize(vEyeDir), msNormal); + vec3 reflectedDir = reflect(normalize(vEyeDir), msNormal); reflectedDir = (uReflectionMatrix * vec4(reflectedDir, 0.0)).xyz; // Match world space directions. reflectedDir.z = -reflectedDir.z; reflectedDir.y = -reflectedDir.y; - return uReflection * textureCube(uReflectionTex, reflectedDir, - min(bias, MAX_REFLECTION_BIAS)).rgb; + return uReflection * texture(uReflectionTex, reflectedDir, + min(bias, MAX_REFLECTION_BIAS)).rgb; } -highp vec3 reflectedColor(highp vec3 msNormal) +vec3 reflectedColor(vec3 msNormal) { return reflectedColorBiased(msNormal, 0.0); } -highp vec4 diffuseAndReflectedLight(highp vec4 diffuseFactor, highp vec2 diffuseUV, - highp vec4 specGloss, highp vec3 msNormal) +vec4 diffuseAndReflectedLight(vec4 diffuseFactor, vec2 diffuseUV, + vec4 specGloss, vec3 msNormal) { // Reflection. - highp float mipBias = uReflectionBlur * (1.0 - specGloss.a); - highp vec3 reflection = specGloss.rgb * reflectedColorBiased(msNormal, mipBias); + float mipBias = uReflectionBlur * (1.0 - specGloss.a); + vec3 reflection = specGloss.rgb * reflectedColorBiased(msNormal, mipBias); // Diffuse. Surface opacity is also determined here. - highp vec4 color = diffuseFactor * vec4(diffuseLight(msNormal), 1.0) * - texture2D(uTex, diffuseUV); + vec4 color = diffuseFactor * vec4(diffuseLight(msNormal), 1.0) * + texture(uTex, diffuseUV); return color + vec4(reflection, 0.0); } diff --git a/doomsday/apps/client/net.dengine.client.pack/renderer.pack/shaders/include/skeletal.glsl b/doomsday/apps/client/net.dengine.client.pack/renderer.pack/shaders/include/skeletal.glsl index f8f202d072..dfd66a50d5 100644 --- a/doomsday/apps/client/net.dengine.client.pack/renderer.pack/shaders/include/skeletal.glsl +++ b/doomsday/apps/client/net.dengine.client.pack/renderer.pack/shaders/include/skeletal.glsl @@ -18,16 +18,16 @@ * http://www.gnu.org/licenses */ -uniform highp mat4 uBoneMatrices[64]; +uniform mat4 uBoneMatrices[64]; -attribute highp vec4 aBoneIDs; -attribute highp vec4 aBoneWeights; +in vec4 aBoneIDs; +in vec4 aBoneWeights; /* * Calculates the bone matrix for the current vertex. Bones and their weights * are determined by vertex attributes. */ -highp mat4 vertexBoneTransform() +mat4 vertexBoneTransform() { return uBoneMatrices[int(aBoneIDs.x + 0.5)] * aBoneWeights.x + uBoneMatrices[int(aBoneIDs.y + 0.5)] * aBoneWeights.y + diff --git a/doomsday/apps/client/net.dengine.client.pack/renderer.pack/shaders/include/tangentspace.glsl b/doomsday/apps/client/net.dengine.client.pack/renderer.pack/shaders/include/tangentspace.glsl index 8716d2f9cf..5faf2faf2d 100644 --- a/doomsday/apps/client/net.dengine.client.pack/renderer.pack/shaders/include/tangentspace.glsl +++ b/doomsday/apps/client/net.dengine.client.pack/renderer.pack/shaders/include/tangentspace.glsl @@ -18,22 +18,22 @@ * http://www.gnu.org/licenses */ -varying highp vec3 vTSNormal; -varying highp vec3 vTSTangent; -varying highp vec3 vTSBitangent; - #ifdef DENG_VERTEX_SHADER -attribute highp vec3 aNormal; -attribute highp vec3 aTangent; -attribute highp vec3 aBitangent; +in vec3 aNormal; +in vec3 aTangent; +in vec3 aBitangent; + +out vec3 vTSNormal; +out vec3 vTSTangent; +out vec3 vTSBitangent; -highp vec3 transformVector(highp vec3 dir, highp mat4 matrix) +vec3 transformVector(vec3 dir, mat4 matrix) { return (matrix * vec4(dir, 0.0)).xyz; } -void setTangentSpace(highp mat4 modelSpace) +void setTangentSpace(mat4 modelSpace) { vTSNormal = transformVector(aNormal, modelSpace); vTSTangent = transformVector(aTangent, modelSpace); @@ -44,12 +44,16 @@ void setTangentSpace(highp mat4 modelSpace) #ifdef DENG_FRAGMENT_SHADER -highp mat3 fragmentTangentSpace() +in vec3 vTSNormal; +in vec3 vTSTangent; +in vec3 vTSBitangent; + +mat3 fragmentTangentSpace() { return mat3(normalize(vTSTangent), normalize(vTSBitangent), normalize(vTSNormal)); } -highp vec3 modelSpaceNormalVector(highp vec2 uv) +vec3 modelSpaceNormalVector(vec2 uv) { return fragmentTangentSpace() * normalVector(uv); } diff --git a/doomsday/apps/client/net.dengine.client.pack/renderer.pack/shaders/include/texture.glsl b/doomsday/apps/client/net.dengine.client.pack/renderer.pack/shaders/include/texture.glsl index 58a93c1dc5..bab34e7351 100644 --- a/doomsday/apps/client/net.dengine.client.pack/renderer.pack/shaders/include/texture.glsl +++ b/doomsday/apps/client/net.dengine.client.pack/renderer.pack/shaders/include/texture.glsl @@ -25,12 +25,12 @@ uniform sampler2D uTex; // texture atlas /* * Maps the normalized @a uv to the rectangle defined by @a bounds. */ -highp vec2 mapToBounds(highp vec2 uv, highp vec4 bounds) +vec2 mapToBounds(vec2 uv, vec4 bounds) { return bounds.xy + uv * bounds.zw; } -highp vec3 normalVector(highp vec2 uv) +vec3 normalVector(vec2 uv) { - return normalize((texture2D(uTex, uv).xyz * 2.0) - 1.0); + return normalize((texture(uTex, uv).xyz * 2.0) - 1.0); } diff --git a/doomsday/apps/client/net.dengine.client.pack/renderer.pack/shaders/model.dei b/doomsday/apps/client/net.dengine.client.pack/renderer.pack/shaders/model.dei index a5d40ddb03..d8d1ba1429 100644 --- a/doomsday/apps/client/net.dengine.client.pack/renderer.pack/shaders/model.dei +++ b/doomsday/apps/client/net.dengine.client.pack/renderer.pack/shaders/model.dei @@ -22,27 +22,27 @@ model.skeletal { include/skeletal.glsl, include/lighting.glsl> vertex = " - uniform highp mat4 uMvpMatrix; + uniform mat4 uMvpMatrix; - attribute highp vec4 aVertex; - attribute highp vec4 aColor; - attribute highp vec2 aUV; - attribute highp vec4 aBounds; // diffuse map - attribute highp vec4 aBounds2; // normal map - attribute highp vec4 aBounds3; // specular map - attribute highp vec4 aBounds4; // emission map + in vec4 aVertex; + in vec4 aColor; + in vec2 aUV; + in vec4 aBounds; // diffuse map + in vec4 aBounds2; // normal map + in vec4 aBounds3; // specular map + in vec4 aBounds4; // emission map - varying highp vec4 vColor; - varying highp vec2 vUV; - varying highp vec4 vUVBounds[4]; + out vec4 vColor; + out vec2 vUV; + out vec4 vUVBounds[4]; void main(void) { - highp mat4 bone = vertexBoneTransform(); + mat4 bone = vertexBoneTransform(); setTangentSpace(bone); // Vertex position. - highp vec4 modelPos = bone * aVertex; + vec4 modelPos = bone * aVertex; calculateEyeDirection(modelPos); gl_Position = uMvpMatrix * modelPos; @@ -63,37 +63,37 @@ model.skeletal { include/reflection.glsl, include/fog.glsl> fragment = " - uniform highp vec3 uColor; // diffuse color multiplier - uniform highp float uAlpha; // diffuse alpha multiplier - uniform highp float uAlphaLimit; // alpha test to discard fragments - uniform highp vec2 uOffsetUV; - uniform highp float uMapTime; - - varying highp vec4 vColor; - varying highp vec2 vUV; - varying highp vec4 vUVBounds[4]; + uniform vec3 uColor; // diffuse color multiplier + uniform float uAlpha; // diffuse alpha multiplier + uniform float uAlphaLimit; // alpha test to discard fragments + uniform vec2 uOffsetUV; + uniform float uMapTime; + in vec4 vColor; + in vec2 vUV; + in vec4 vUVBounds[4]; + void main(void) { // Calculate UV at the fragment (wrapped inside the bounds). - highp vec2 wrappedUV = vUV + uOffsetUV; + vec2 wrappedUV = vUV + uOffsetUV; PREDEF_TRANSFORM_UV(wrappedUV); wrappedUV = fract(wrappedUV); - highp vec2 uv = mapToBounds(wrappedUV, vUVBounds[0]); - highp vec2 normalUV = mapToBounds(wrappedUV, vUVBounds[1]); - highp vec2 specularUV = mapToBounds(wrappedUV, vUVBounds[2]); - highp vec2 emissiveUV = mapToBounds(wrappedUV, vUVBounds[3]); + vec2 uv = mapToBounds(wrappedUV, vUVBounds[0]); + vec2 normalUV = mapToBounds(wrappedUV, vUVBounds[1]); + vec2 specularUV = mapToBounds(wrappedUV, vUVBounds[2]); + vec2 emissiveUV = mapToBounds(wrappedUV, vUVBounds[3]); - highp vec3 msNormal = modelSpaceNormalVector(normalUV); - highp vec4 specGloss = specularGloss(specularUV); + vec3 msNormal = modelSpaceNormalVector(normalUV); + vec4 specGloss = specularGloss(specularUV); - gl_FragColor = diffuseAndReflectedLight( + out_FragColor = diffuseAndReflectedLight( vColor * vec4(uColor, uAlpha), uv, specGloss, msNormal); - if(gl_FragColor.a < uAlphaLimit) discard; + if (out_FragColor.a < uAlphaLimit) discard; - gl_FragColor.rgb += specularLight(specGloss, msNormal); - gl_FragColor += emittedLight(emissiveUV); + out_FragColor.rgb += specularLight(specGloss, msNormal); + out_FragColor += emittedLight(emissiveUV); applyFog(); }" @@ -104,37 +104,37 @@ model.skeletal { shader opaque.generic inherits model.skeletal.generic { variable uAlphaLimit { value = 0.5 } fragment = " - uniform highp vec3 uColor; // diffuse color multiplier - uniform highp float uAlpha; - uniform highp float uAlphaLimit; // alpha test to discard fragments - uniform highp vec2 uOffsetUV; - uniform highp float uMapTime; + uniform vec3 uColor; // diffuse color multiplier + uniform float uAlpha; + uniform float uAlphaLimit; // alpha test to discard fragments + uniform vec2 uOffsetUV; + uniform float uMapTime; - varying highp vec4 vColor; - varying highp vec2 vUV; - varying highp vec4 vUVBounds[4]; + in vec4 vColor; + in vec2 vUV; + in vec4 vUVBounds[4]; void main(void) { // Calculate UV at the fragment (wrapped inside the bounds). - highp vec2 wrappedUV = vUV + uOffsetUV; + vec2 wrappedUV = vUV + uOffsetUV; PREDEF_TRANSFORM_UV(wrappedUV); wrappedUV = fract(wrappedUV); - highp vec2 uv = mapToBounds(wrappedUV, vUVBounds[0]); - highp vec2 normalUV = mapToBounds(wrappedUV, vUVBounds[1]); - highp vec2 specularUV = mapToBounds(wrappedUV, vUVBounds[2]); - highp vec2 emissiveUV = mapToBounds(wrappedUV, vUVBounds[3]); + vec2 uv = mapToBounds(wrappedUV, vUVBounds[0]); + vec2 normalUV = mapToBounds(wrappedUV, vUVBounds[1]); + vec2 specularUV = mapToBounds(wrappedUV, vUVBounds[2]); + vec2 emissiveUV = mapToBounds(wrappedUV, vUVBounds[3]); - highp vec3 msNormal = modelSpaceNormalVector(normalUV); - highp vec4 specGloss = specularGloss(specularUV); + vec3 msNormal = modelSpaceNormalVector(normalUV); + vec4 specGloss = specularGloss(specularUV); - gl_FragColor = diffuseAndReflectedLight( + out_FragColor = diffuseAndReflectedLight( vColor * vec4(uColor, uAlpha), uv, specGloss, msNormal); - if(gl_FragColor.a < uAlphaLimit) discard; + if (out_FragColor.a < uAlphaLimit) discard; - gl_FragColor.rgb += specularLight(specGloss, msNormal); - gl_FragColor += emittedLight(emissiveUV); + out_FragColor.rgb += specularLight(specGloss, msNormal); + out_FragColor += emittedLight(emissiveUV); applyFog(); }" @@ -163,26 +163,26 @@ model.skeletal { include/skeletal.glsl, include/lighting.glsl> vertex = " - uniform highp mat4 uMvpMatrix; + uniform mat4 uMvpMatrix; - attribute highp vec4 aVertex; - attribute highp vec4 aColor; - attribute highp vec2 aUV; - attribute highp vec4 aBounds; // diffuse map - attribute highp vec4 aBounds2; // normal map - attribute highp vec4 aBounds3; // specular map + in vec4 aVertex; + in vec4 aColor; + in vec2 aUV; + in vec4 aBounds; // diffuse map + in vec4 aBounds2; // normal map + in vec4 aBounds3; // specular map - varying highp vec4 vColor; - varying highp vec2 vUV; - varying highp vec4 vUVBounds[3]; + out vec4 vColor; + out vec2 vUV; + out vec4 vUVBounds[3]; void main(void) { - highp mat4 bone = vertexBoneTransform(); + mat4 bone = vertexBoneTransform(); setTangentSpace(bone); // Vertex position. - highp vec4 modelPos = bone * aVertex; + vec4 modelPos = bone * aVertex; calculateEyeDirection(modelPos); gl_Position = uMvpMatrix * modelPos; @@ -200,36 +200,36 @@ model.skeletal { include/reflection.glsl, include/fog.glsl> fragment = " - uniform highp float uAlphaLimit; - uniform highp float uAlpha; - uniform highp vec3 uColor; // diffuse color multiplier - uniform highp vec2 uOffsetUV; - uniform highp float uMapTime; + uniform float uAlphaLimit; + uniform float uAlpha; + uniform vec3 uColor; // diffuse color multiplier + uniform vec2 uOffsetUV; + uniform float uMapTime; - varying highp vec4 vColor; - varying highp vec2 vUV; - varying highp vec4 vUVBounds[3]; + in vec4 vColor; + in vec2 vUV; + in vec4 vUVBounds[3]; void main(void) { // Calculate UV at the fragment (wrapped inside the bounds). - highp vec2 wrappedUV = vUV + uOffsetUV; + vec2 wrappedUV = vUV + uOffsetUV; PREDEF_TRANSFORM_UV(wrappedUV); wrappedUV = fract(wrappedUV); - highp vec2 uv = mapToBounds(wrappedUV, vUVBounds[0]); - highp vec2 normalUV = mapToBounds(wrappedUV, vUVBounds[1]); - highp vec2 specularUV = mapToBounds(wrappedUV, vUVBounds[2]); + vec2 uv = mapToBounds(wrappedUV, vUVBounds[0]); + vec2 normalUV = mapToBounds(wrappedUV, vUVBounds[1]); + vec2 specularUV = mapToBounds(wrappedUV, vUVBounds[2]); - highp vec3 msNormal = modelSpaceNormalVector(normalUV); - highp vec4 specGloss = specularGloss(specularUV); + vec3 msNormal = modelSpaceNormalVector(normalUV); + vec4 specGloss = specularGloss(specularUV); - gl_FragColor = diffuseAndReflectedLight( + out_FragColor = diffuseAndReflectedLight( vColor * vec4(uColor, uAlpha), uv, specGloss, msNormal); - if(gl_FragColor.a < uAlphaLimit) discard; + if (out_FragColor.a < uAlphaLimit) discard; - gl_FragColor.rgb += specularLight(specGloss, msNormal); + out_FragColor.rgb += specularLight(specGloss, msNormal); - gl_FragColor.a = uAlpha; + out_FragColor.a = uAlpha; applyFog(); }" @@ -252,25 +252,25 @@ model.skeletal { include/skeletal.glsl, include/lighting.glsl> vertex = " - uniform highp mat4 uMvpMatrix; + uniform mat4 uMvpMatrix; - attribute highp vec4 aVertex; - attribute highp vec4 aColor; - attribute highp vec2 aUV; - attribute highp vec4 aBounds; // diffuse map - attribute highp vec4 aBounds2; // normal map + in vec4 aVertex; + in vec4 aColor; + in vec2 aUV; + in vec4 aBounds; // diffuse map + in vec4 aBounds2; // normal map - varying highp vec4 vColor; - varying highp vec2 vUV; - varying highp vec4 vUVBounds[2]; + out vec4 vColor; + out vec2 vUV; + out vec4 vUVBounds[2]; void main(void) { - highp mat4 bone = vertexBoneTransform(); + mat4 bone = vertexBoneTransform(); setTangentSpace(bone); // Vertex position. - highp vec4 modelPos = bone * aVertex; + vec4 modelPos = bone * aVertex; calculateEyeDirection(modelPos); gl_Position = uMvpMatrix * modelPos; @@ -286,31 +286,31 @@ model.skeletal { include/lighting.glsl, include/fog.glsl> fragment = " - uniform highp float uAlphaLimit; - uniform highp float uAlpha; - uniform highp vec3 uColor; // diffuse color multiplier - uniform highp vec2 uOffsetUV; - uniform highp float uMapTime; + uniform float uAlphaLimit; + uniform float uAlpha; + uniform vec3 uColor; // diffuse color multiplier + uniform vec2 uOffsetUV; + uniform float uMapTime; - varying highp vec4 vColor; - varying highp vec2 vUV; - varying highp vec4 vUVBounds[2]; + in vec4 vColor; + in vec2 vUV; + in vec4 vUVBounds[2]; void main(void) { // Calculate UV at the fragment (wrapped inside the bounds). - highp vec2 wrappedUV = vUV + uOffsetUV; + vec2 wrappedUV = vUV + uOffsetUV; PREDEF_TRANSFORM_UV(wrappedUV); wrappedUV = fract(wrappedUV); - highp vec2 uv = mapToBounds(wrappedUV, vUVBounds[0]); - highp vec2 normalUV = mapToBounds(wrappedUV, vUVBounds[1]); + vec2 uv = mapToBounds(wrappedUV, vUVBounds[0]); + vec2 normalUV = mapToBounds(wrappedUV, vUVBounds[1]); - highp vec3 msNormal = modelSpaceNormalVector(normalUV); - gl_FragColor = vColor * vec4(uColor * diffuseLight(msNormal), 1.0) - * texture2D(uTex, uv); - if(gl_FragColor.a < uAlphaLimit) discard; + vec3 msNormal = modelSpaceNormalVector(normalUV); + out_FragColor = vColor * vec4(uColor * diffuseLight(msNormal), 1.0) + * texture(uTex, uv); + if (out_FragColor.a < uAlphaLimit) discard; - gl_FragColor.a = uAlpha; + out_FragColor.a = uAlpha; applyFog(); }" @@ -333,23 +333,23 @@ model.skeletal { include.vertex vertex = " - uniform highp mat4 uMvpMatrix; + uniform mat4 uMvpMatrix; - attribute highp vec4 aVertex; - attribute highp vec4 aColor; - attribute highp vec2 aUV; - attribute highp vec4 aBounds; // diffuse map + in vec4 aVertex; + in vec4 aColor; + in vec2 aUV; + in vec4 aBounds; // diffuse map - varying highp vec4 vColor; - varying highp vec2 vUV; - varying highp vec4 vUVBounds; + out vec4 vColor; + out vec2 vUV; + out vec4 vUVBounds; void main(void) { - highp mat4 bone = vertexBoneTransform(); + mat4 bone = vertexBoneTransform(); // Vertex position. - highp vec4 modelPos = bone * aVertex; + vec4 modelPos = bone * aVertex; gl_Position = uMvpMatrix * modelPos; vColor = aColor; @@ -359,28 +359,28 @@ model.skeletal { include.fragment fragment = " - uniform highp float uAlphaLimit; - uniform highp float uAlpha; - uniform highp vec3 uColor; // diffuse color multiplier - uniform highp vec2 uOffsetUV; - uniform highp float uMapTime; + uniform float uAlphaLimit; + uniform float uAlpha; + uniform vec3 uColor; // diffuse color multiplier + uniform vec2 uOffsetUV; + uniform float uMapTime; - varying highp vec4 vColor; - varying highp vec2 vUV; - varying highp vec4 vUVBounds; + in vec4 vColor; + in vec2 vUV; + in vec4 vUVBounds; void main(void) { // Calculate UV at the fragment (wrapped inside the bounds). - highp vec2 wrappedUV = vUV + uOffsetUV; + vec2 wrappedUV = vUV + uOffsetUV; PREDEF_TRANSFORM_UV(wrappedUV); wrappedUV = fract(wrappedUV); - highp vec2 uv = mapToBounds(wrappedUV, vUVBounds); + vec2 uv = mapToBounds(wrappedUV, vUVBounds); - highp vec4 diffuse = vColor * texture2D(uTex, uv); - if(diffuse.a < uAlphaLimit) discard; + vec4 diffuse = vColor * texture(uTex, uv); + if (diffuse.a < uAlphaLimit) discard; - gl_FragColor = diffuse * vec4(uColor, uAlpha); + out_FragColor = diffuse * vec4(uColor, uAlpha); }" } } diff --git a/doomsday/apps/client/net.dengine.client.pack/renderer.pack/shaders/ui.dei b/doomsday/apps/client/net.dengine.client.pack/renderer.pack/shaders/ui.dei index 0a93adc4e6..ab09abe97e 100644 --- a/doomsday/apps/client/net.dengine.client.pack/renderer.pack/shaders/ui.dei +++ b/doomsday/apps/client/net.dengine.client.pack/renderer.pack/shaders/ui.dei @@ -2,20 +2,20 @@ ui { # Shader for UI widgets. shader guiwidget.batch { vertex = " - uniform highp mat4 uMvpMatrix; - uniform highp vec4 uColor[DENG_MAX_BATCH_UNIFORMS]; - uniform highp float uSaturation[DENG_MAX_BATCH_UNIFORMS]; - uniform highp vec4 uScissorRect[DENG_MAX_BATCH_UNIFORMS]; + uniform mat4 uMvpMatrix; + uniform vec4 uColor[DENG_MAX_BATCH_UNIFORMS]; + uniform float uSaturation[DENG_MAX_BATCH_UNIFORMS]; + uniform vec4 uScissorRect[DENG_MAX_BATCH_UNIFORMS]; - attribute highp vec4 aVertex; - attribute highp vec2 aUV; - attribute highp vec4 aColor; - attribute highp float aIndex; // uColor + in vec4 aVertex; + in vec2 aUV; + in vec4 aColor; + in float aIndex; // uColor - varying highp vec2 vUV; - varying highp vec4 vColor; - varying highp vec4 vScissor; - varying highp float vSaturation; + out vec2 vUV; + out vec4 vColor; + out vec4 vScissor; + out float vSaturation; void main(void) { gl_Position = uMvpMatrix * aVertex; @@ -30,28 +30,28 @@ ui { fragment = " uniform sampler2D uTex; - varying highp vec2 vUV; - varying highp vec4 vColor; - varying highp vec4 vScissor; - varying highp float vSaturation; - + in vec2 vUV; + in vec4 vColor; + in vec4 vScissor; + in float vSaturation; + void main(void) { // Check the scissor first. if (gl_FragCoord.x < vScissor.x || gl_FragCoord.x > vScissor.z || gl_FragCoord.y < vScissor.y || gl_FragCoord.y > vScissor.w) { discard; } - gl_FragColor = texture2D(uTex, vUV); + out_FragColor = texture(uTex, vUV); // Optionally adjust color saturation. if (vSaturation < 1.0) { - highp vec4 hsv = rgbToHsv(gl_FragColor); + highp vec4 hsv = rgbToHsv(out_FragColor); hsv.y *= vSaturation; - gl_FragColor = hsvToRgb(hsv); + out_FragColor = hsvToRgb(hsv); } // Final vertex color. - gl_FragColor *= vColor; + out_FragColor *= vColor; }" } }