diff --git a/runelite-client/src/main/java/net/runelite/client/plugins/gpu/GpuPlugin.java b/runelite-client/src/main/java/net/runelite/client/plugins/gpu/GpuPlugin.java index b630577428..998cee57b8 100644 --- a/runelite-client/src/main/java/net/runelite/client/plugins/gpu/GpuPlugin.java +++ b/runelite-client/src/main/java/net/runelite/client/plugins/gpu/GpuPlugin.java @@ -151,10 +151,6 @@ public class GpuPlugin extends Plugin implements DrawCallbacks private int glUiVertexShader; private int glUiFragmentShader; - private int glUiPremulProgram; - private int glUiPremulVertexShader; - private int glUiPremulFragmentShader; - private int vaoUiHandle; private int vboUiHandle; @@ -162,9 +158,6 @@ public class GpuPlugin extends Plugin implements DrawCallbacks private int texSceneHandle; private int rboSceneHandle; - private int fboUiHandle; - private int texUiHandle; - // scene vertex buffer id private int bufferId; // scene uv buffer id @@ -225,7 +218,6 @@ public class GpuPlugin extends Plugin implements DrawCallbacks private int uniProjectionMatrix; private int uniBrightness; private int uniTex; - private int uniTexPremul; private int uniTextures; private int uniTextureOffsets; private int uniBlockSmall; @@ -389,7 +381,6 @@ public class GpuPlugin extends Plugin implements DrawCallbacks shutdownInterfaceTexture(); shutdownProgram(); shutdownVao(); - shutdownUiFBO(); shutdownSceneFbo(); } @@ -507,14 +498,6 @@ public class GpuPlugin extends Plugin implements DrawCallbacks null, inputStreamToString(getClass().getResourceAsStream("fragui.glsl"))); - glUiPremulProgram = gl.glCreateProgram(); - glUiPremulVertexShader = gl.glCreateShader(gl.GL_VERTEX_SHADER); - glUiPremulFragmentShader = gl.glCreateShader(gl.GL_FRAGMENT_SHADER); - GLUtil.loadShaders(gl, glUiPremulProgram, glUiPremulVertexShader, -1, glUiPremulFragmentShader, - inputStreamToString(getClass().getResourceAsStream("vertuipremul.glsl")), - null, - inputStreamToString(getClass().getResourceAsStream("fraguipremul.glsl"))); - initUniforms(); } @@ -525,7 +508,6 @@ public class GpuPlugin extends Plugin implements DrawCallbacks uniSmoothBanding = gl.glGetUniformLocation(glProgram, "smoothBanding"); uniTex = gl.glGetUniformLocation(glUiProgram, "tex"); - uniTexPremul = gl.glGetUniformLocation(glUiPremulProgram, "tex"); uniTextures = gl.glGetUniformLocation(glProgram, "textures"); uniTextureOffsets = gl.glGetUniformLocation(glProgram, "textureOffsets"); @@ -578,17 +560,6 @@ public class GpuPlugin extends Plugin implements DrawCallbacks gl.glDeleteProgram(glUiProgram); glUiProgram = -1; - - /// - - gl.glDeleteShader(glUiPremulVertexShader); - glUiPremulVertexShader = -1; - - gl.glDeleteShader(glUiPremulFragmentShader); - glUiPremulFragmentShader = -1; - - gl.glDeleteProgram(glUiPremulProgram); - glUiPremulProgram = -1; } private void initVao() @@ -721,48 +692,6 @@ public class GpuPlugin extends Plugin implements DrawCallbacks } } - private void initUiFBO(int width, int height) - { - // Create and bind the FBO - fboUiHandle = glGenFrameBuffer(gl); - gl.glBindFramebuffer(gl.GL_FRAMEBUFFER, fboUiHandle); - - // Create the texture to render to - texUiHandle = glGenTexture(gl); - gl.glBindTexture(gl.GL_TEXTURE_2D, texUiHandle); - gl.glTexImage2D(gl.GL_TEXTURE_2D, 0, gl.GL_RGBA, width, height, 0, gl.GL_RGBA, gl.GL_UNSIGNED_BYTE, null); - - // Since this is an intermediate the same size as the input, just use nearest neighbors - gl.glTexParameteri(gl.GL_TEXTURE_2D, gl.GL_TEXTURE_MAG_FILTER, gl.GL_NEAREST); - gl.glTexParameteri(gl.GL_TEXTURE_2D, gl.GL_TEXTURE_MIN_FILTER, gl.GL_NEAREST); - - // Attach the texture to the framebuffer - gl.glFramebufferTexture(gl.GL_FRAMEBUFFER, gl.GL_COLOR_ATTACHMENT0, texUiHandle, 0); - - // Specify that we're going to draw onto color attachment 0 - int drawLocations[] = { gl.GL_COLOR_ATTACHMENT0 }; - gl.glDrawBuffers(1, drawLocations, 0); - - // Reset - gl.glBindFramebuffer(gl.GL_FRAMEBUFFER, 0); - gl.glBindTexture(gl.GL_TEXTURE_2D, 0); - } - - private void shutdownUiFBO() - { - if (fboUiHandle != -1) - { - glDeleteFrameBuffer(gl, fboUiHandle); - fboUiHandle = -1; - } - - if (texUiHandle != -1) - { - glDeleteTexture(gl, texUiHandle); - texUiHandle = -1; - } - } - private void createProjectionMatrix(float left, float right, float bottom, float top, float near, float far) { // create a standard orthographic projection @@ -1181,16 +1110,7 @@ public class GpuPlugin extends Plugin implements DrawCallbacks final int width = bufferProvider.getWidth(); final int height = bufferProvider.getHeight(); - // Don't blend on the login screen because the fires overflow their alphas. - final GameState gameState = client.getGameState(); - if (gameState == GameState.LOGGED_IN) - { - gl.glEnable(gl.GL_BLEND); - } - else - { - gl.glDisable(gl.GL_BLEND); - } + gl.glEnable(gl.GL_BLEND); vertexBuffer.clear(); // reuse vertex buffer for interface vertexBuffer.ensureCapacity(pixels.length); @@ -1207,49 +1127,14 @@ public class GpuPlugin extends Plugin implements DrawCallbacks gl.glTexImage2D(gl.GL_TEXTURE_2D, 0, gl.GL_RGBA, width, height, 0, gl.GL_BGRA, gl.GL_UNSIGNED_INT_8_8_8_8_REV, interfaceBuffer); lastCanvasWidth = canvasWidth; lastCanvasHeight = canvasHeight; - - shutdownUiFBO(); - initUiFBO(width, height); } else { gl.glTexSubImage2D(gl.GL_TEXTURE_2D, 0, 0, 0, width, height, gl.GL_BGRA, gl.GL_UNSIGNED_INT_8_8_8_8_REV, interfaceBuffer); } - // First pass: pre-multiply alpha. But only do it if we're blending. - if (gameState == GameState.LOGGED_IN && client.isStretchedEnabled() && !client.isStretchedFast()) - { - // Setup - gl.glDisable(gl.GL_BLEND); - gl.glBindFramebuffer(gl.GL_FRAMEBUFFER, fboUiHandle); - gl.glViewport(0, 0, width, height); - gl.glClear(gl.GL_COLOR_BUFFER_BIT); + gl.glBindTexture(gl.GL_TEXTURE_2D, interfaceTexture); - // Set up uniforms - gl.glUseProgram(glUiPremulProgram); - gl.glUniform1i(uniTexPremul, 0); - - // Do render call - gl.glBindVertexArray(vaoUiHandle); - gl.glDrawArrays(gl.GL_TRIANGLE_FAN, 0, 4); - - // Cleanup - gl.glBindFramebuffer(gl.GL_FRAMEBUFFER, 0); - gl.glEnable(gl.GL_BLEND); - - // Bind the texture we just drew to for use in pass 2 - gl.glBindTexture(gl.GL_TEXTURE_2D, texUiHandle); - - // Change the blend function to use pre-multiplied alpha - gl.glBlendFunc(gl.GL_ONE, gl.GL_ONE_MINUS_SRC_ALPHA); - } - else - { - gl.glBindTexture(gl.GL_TEXTURE_2D, interfaceTexture); - } - - - // Second pass: render onto the screen if (client.isStretchedEnabled()) { Dimension dim = client.getStretchedDimensions(); diff --git a/runelite-client/src/main/resources/net/runelite/client/plugins/gpu/fraguipremul.glsl b/runelite-client/src/main/resources/net/runelite/client/plugins/gpu/fraguipremul.glsl deleted file mode 100644 index ce52226ba1..0000000000 --- a/runelite-client/src/main/resources/net/runelite/client/plugins/gpu/fraguipremul.glsl +++ /dev/null @@ -1,37 +0,0 @@ -/* - * Copyright (c) 2018, Adam - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are met: - * - * 1. Redistributions of source code must retain the above copyright notice, this - * list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright notice, - * this list of conditions and the following disclaimer in the documentation - * and/or other materials provided with the distribution. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED - * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE - * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR - * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES - * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; - * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND - * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT - * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS - * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - */ -#version 330 - -layout (location = 0) out vec4 color; - -uniform sampler2D tex; - -in vec2 TexCoord; - -void main() -{ - vec4 c = texture(tex, TexCoord); - color = vec4(c.rgb * c.a, c.a); -} diff --git a/runelite-client/src/main/resources/net/runelite/client/plugins/gpu/vertuipremul.glsl b/runelite-client/src/main/resources/net/runelite/client/plugins/gpu/vertuipremul.glsl deleted file mode 100644 index bbfd632b20..0000000000 --- a/runelite-client/src/main/resources/net/runelite/client/plugins/gpu/vertuipremul.glsl +++ /dev/null @@ -1,38 +0,0 @@ -/* - * Copyright (c) 2018, Adam - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are met: - * - * 1. Redistributions of source code must retain the above copyright notice, this - * list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright notice, - * this list of conditions and the following disclaimer in the documentation - * and/or other materials provided with the distribution. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED - * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE - * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR - * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES - * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; - * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND - * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT - * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS - * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - */ -#version 330 - -layout (location = 0) in vec3 aPos; -layout (location = 1) in vec2 aTexCoord; - -out vec2 TexCoord; - -void main() -{ - gl_Position = vec4(aPos, 1.0); - - // Flip the UV because it's pre-flipped in the ui texture buffer, but we don't need it to be flipped here. - TexCoord = vec2(aTexCoord.x, 1 - aTexCoord.y); -}