Merge remote-tracking branch 'logarrhythmic/ui-bicubic-sampling'
This commit is contained in:
@@ -80,6 +80,7 @@ import net.runelite.client.plugins.PluginType;
|
||||
import static net.runelite.client.plugins.gpu.GLUtil.*;
|
||||
import net.runelite.client.plugins.gpu.config.AnisotropicFilteringMode;
|
||||
import net.runelite.client.plugins.gpu.config.AntiAliasingMode;
|
||||
import net.runelite.client.plugins.gpu.config.UIScalingMode;
|
||||
import net.runelite.client.plugins.gpu.template.Template;
|
||||
import net.runelite.client.ui.DrawManager;
|
||||
import net.runelite.client.util.OSType;
|
||||
@@ -227,6 +228,9 @@ public class GpuPlugin extends Plugin implements DrawCallbacks
|
||||
private int uniProjectionMatrix;
|
||||
private int uniBrightness;
|
||||
private int uniTex;
|
||||
private int uniTexSamplingMode;
|
||||
private int uniTexSourceDimensions;
|
||||
private int uniTexTargetDimensions;
|
||||
private int uniTextures;
|
||||
private int uniTextureOffsets;
|
||||
private int uniBlockSmall;
|
||||
@@ -241,6 +245,7 @@ public class GpuPlugin extends Plugin implements DrawCallbacks
|
||||
private int fogDepth;
|
||||
private int fogCircularity;
|
||||
private int fogDensity;
|
||||
private UIScalingMode uiScalingMode;
|
||||
|
||||
@Subscribe
|
||||
private void onConfigChanged(ConfigChanged event)
|
||||
@@ -260,6 +265,7 @@ public class GpuPlugin extends Plugin implements DrawCallbacks
|
||||
this.fogDepth = config.fogDepth();
|
||||
this.fogCircularity = config.fogCircularity();
|
||||
this.fogDensity = config.fogDensity();
|
||||
this.uiScalingMode = config.uiScalingMode();
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -519,10 +525,14 @@ public class GpuPlugin extends Plugin implements DrawCallbacks
|
||||
glUiProgram = gl.glCreateProgram();
|
||||
glUiVertexShader = gl.glCreateShader(gl.GL_VERTEX_SHADER);
|
||||
glUiFragmentShader = gl.glCreateShader(gl.GL_FRAGMENT_SHADER);
|
||||
template = new Template(resourceLoader);
|
||||
vertSource = template.process(resourceLoader.apply("vertui.glsl"));
|
||||
template = new Template(resourceLoader);
|
||||
fragSource = template.process(resourceLoader.apply("fragui.glsl"));
|
||||
GLUtil.loadShaders(gl, glUiProgram, glUiVertexShader, -1, glUiFragmentShader,
|
||||
inputStreamToString(getClass().getResourceAsStream("vertui.glsl")),
|
||||
vertSource,
|
||||
null,
|
||||
inputStreamToString(getClass().getResourceAsStream("fragui.glsl")));
|
||||
fragSource);
|
||||
|
||||
initUniforms();
|
||||
}
|
||||
@@ -540,6 +550,9 @@ public class GpuPlugin extends Plugin implements DrawCallbacks
|
||||
uniDrawDistance = gl.glGetUniformLocation(glProgram, "drawDistance");
|
||||
|
||||
uniTex = gl.glGetUniformLocation(glUiProgram, "tex");
|
||||
uniTexSamplingMode = gl.glGetUniformLocation(glUiProgram, "samplingMode");
|
||||
uniTexTargetDimensions = gl.glGetUniformLocation(glUiProgram, "targetDimensions");
|
||||
uniTexSourceDimensions = gl.glGetUniformLocation(glUiProgram, "sourceDimensions");
|
||||
uniTextures = gl.glGetUniformLocation(glProgram, "textures");
|
||||
uniTextureOffsets = gl.glGetUniformLocation(glProgram, "textureOffsets");
|
||||
|
||||
@@ -1222,26 +1235,31 @@ public class GpuPlugin extends Plugin implements DrawCallbacks
|
||||
gl.glTexSubImage2D(gl.GL_TEXTURE_2D, 0, 0, 0, width, height, gl.GL_BGRA, gl.GL_UNSIGNED_INT_8_8_8_8_REV, interfaceBuffer);
|
||||
}
|
||||
|
||||
// Use the texture bound in the first pass
|
||||
gl.glUseProgram(glUiProgram);
|
||||
gl.glUniform1i(uniTex, 0);
|
||||
gl.glUniform1i(uniTexSamplingMode, this.uiScalingMode.getMode());
|
||||
gl.glUniform2i(uniTexSourceDimensions, canvasWidth, canvasHeight);
|
||||
|
||||
if (client.isStretchedEnabled())
|
||||
{
|
||||
Dimension dim = client.getStretchedDimensions();
|
||||
glDpiAwareViewport(0, 0, dim.width, dim.height);
|
||||
gl.glUniform2i(uniTexTargetDimensions, dim.width, dim.height);
|
||||
}
|
||||
else
|
||||
{
|
||||
glDpiAwareViewport(0, 0, canvasWidth, canvasHeight);
|
||||
gl.glUniform2i(uniTexTargetDimensions, canvasWidth, canvasHeight);
|
||||
}
|
||||
|
||||
// Use the texture bound in the first pass
|
||||
gl.glUseProgram(glUiProgram);
|
||||
gl.glUniform1i(uniTex, 0);
|
||||
|
||||
// Set the sampling function used when stretching the UI.
|
||||
// This is probably better done with sampler objects instead of texture parameters, but this is easier and likely more portable.
|
||||
// See https://www.khronos.org/opengl/wiki/Sampler_Object for details.
|
||||
if (client.isStretchedEnabled())
|
||||
{
|
||||
final int function = client.isStretchedFast() ? gl.GL_NEAREST : gl.GL_LINEAR;
|
||||
final int function = this.uiScalingMode == UIScalingMode.LINEAR ? gl.GL_LINEAR : gl.GL_NEAREST;
|
||||
gl.glTexParameteri(gl.GL_TEXTURE_2D, gl.GL_TEXTURE_MIN_FILTER, function);
|
||||
gl.glTexParameteri(gl.GL_TEXTURE_2D, gl.GL_TEXTURE_MAG_FILTER, function);
|
||||
}
|
||||
|
||||
@@ -34,6 +34,7 @@ import static net.runelite.client.plugins.gpu.GpuPlugin.MAX_DISTANCE;
|
||||
import static net.runelite.client.plugins.gpu.GpuPlugin.MAX_FOG_DEPTH;
|
||||
import net.runelite.client.plugins.gpu.config.AnisotropicFilteringMode;
|
||||
import net.runelite.client.plugins.gpu.config.AntiAliasingMode;
|
||||
import net.runelite.client.plugins.gpu.config.UIScalingMode;
|
||||
|
||||
@ConfigGroup("gpu")
|
||||
public interface GpuPluginConfig extends Config
|
||||
@@ -77,11 +78,34 @@ public interface GpuPluginConfig extends Config
|
||||
return false;
|
||||
}
|
||||
|
||||
@ConfigTitleSection(
|
||||
keyName = "scalingTitle",
|
||||
name = "Scaling",
|
||||
description = "",
|
||||
position = 4
|
||||
)
|
||||
default Title scalingTitle()
|
||||
{
|
||||
return new Title();
|
||||
}
|
||||
|
||||
@ConfigItem(
|
||||
keyName = "uiScalingMode",
|
||||
name = "UI scaling mode",
|
||||
description = "Sampling function to use for the UI in stretched mode",
|
||||
titleSection = "scalingTitle",
|
||||
position = 5
|
||||
)
|
||||
default UIScalingMode uiScalingMode()
|
||||
{
|
||||
return UIScalingMode.CATMULL_ROM;
|
||||
}
|
||||
|
||||
@ConfigTitleSection(
|
||||
keyName = "ppTitle",
|
||||
name = "Post processing",
|
||||
description = "",
|
||||
position = 4
|
||||
position = 6
|
||||
)
|
||||
default Title ppTitle()
|
||||
{
|
||||
@@ -92,7 +116,7 @@ public interface GpuPluginConfig extends Config
|
||||
keyName = "antiAliasingMode",
|
||||
name = "Anti Aliasing",
|
||||
description = "Configures the anti-aliasing mode",
|
||||
position = 5,
|
||||
position = 7,
|
||||
titleSection = "ppTitle"
|
||||
)
|
||||
default AntiAliasingMode antiAliasingMode()
|
||||
@@ -104,7 +128,7 @@ public interface GpuPluginConfig extends Config
|
||||
keyName = "anisotropicFilteringMode",
|
||||
name = "Anisotropic Filtering",
|
||||
description = "Configures the anisotropic filtering mode",
|
||||
position = 6,
|
||||
position = 8,
|
||||
titleSection = "ppTitle"
|
||||
)
|
||||
default AnisotropicFilteringMode anisotropicFilteringMode()
|
||||
@@ -116,7 +140,7 @@ public interface GpuPluginConfig extends Config
|
||||
keyName = "fogTitle",
|
||||
name = "Fog",
|
||||
description = "",
|
||||
position = 7
|
||||
position = 9
|
||||
)
|
||||
default Title fogTitle()
|
||||
{
|
||||
@@ -130,7 +154,7 @@ public interface GpuPluginConfig extends Config
|
||||
keyName = "fogDepth",
|
||||
name = "Depth",
|
||||
description = "Distance from the scene edge the fog starts",
|
||||
position = 8,
|
||||
position = 10,
|
||||
titleSection = "fogTitle"
|
||||
)
|
||||
default int fogDepth()
|
||||
@@ -145,7 +169,7 @@ public interface GpuPluginConfig extends Config
|
||||
keyName = "fogCircularity",
|
||||
name = "Roundness",
|
||||
description = "Fog circularity in %",
|
||||
position = 9,
|
||||
position = 11,
|
||||
titleSection = "fogTitle"
|
||||
)
|
||||
default int fogCircularity()
|
||||
@@ -160,7 +184,7 @@ public interface GpuPluginConfig extends Config
|
||||
keyName = "fogDensity",
|
||||
name = "Density",
|
||||
description = "Relative fog thickness",
|
||||
position = 10,
|
||||
position = 12,
|
||||
titleSection = "fogTitle"
|
||||
)
|
||||
default int fogDensity()
|
||||
|
||||
@@ -0,0 +1,48 @@
|
||||
/*
|
||||
* Copyright (c) 2019 logarrhytmic <https://github.com/logarrhythmic>
|
||||
* 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.
|
||||
*/
|
||||
package net.runelite.client.plugins.gpu.config;
|
||||
|
||||
import lombok.Getter;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
|
||||
@Getter
|
||||
@RequiredArgsConstructor
|
||||
public enum UIScalingMode
|
||||
{
|
||||
NEAREST("Nearest Neighbor", 0),
|
||||
LINEAR("Bilinear", 0),
|
||||
MITCHELL("Bicubic (Mitchell)", 1),
|
||||
CATMULL_ROM("Bicubic (Catmull-Rom)", 2),
|
||||
XBR("xBR (best at 2x & above)", 3);
|
||||
|
||||
private final String name;
|
||||
private final int mode;
|
||||
|
||||
@Override
|
||||
public String toString()
|
||||
{
|
||||
return name;
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user