gpu: add colorblind mode

Co-authored-by: Adam <Adam@sigterm.info>
This commit is contained in:
Ben Poulson
2020-11-04 06:23:10 +00:00
committed by Adam
parent 7f49b88b42
commit b031d4c60f
6 changed files with 137 additions and 0 deletions

View File

@@ -252,6 +252,8 @@ public class GpuPlugin extends Plugin implements DrawCallbacks
private int modelOrientation;
// Uniforms
private int uniColorBlindMode;
private int uniUiColorBlindMode;
private int uniUseFog;
private int uniFogColor;
private int uniFogDepth;
@@ -536,11 +538,13 @@ public class GpuPlugin extends Plugin implements DrawCallbacks
uniFogColor = gl.glGetUniformLocation(glProgram, "fogColor");
uniFogDepth = gl.glGetUniformLocation(glProgram, "fogDepth");
uniDrawDistance = gl.glGetUniformLocation(glProgram, "drawDistance");
uniColorBlindMode = gl.glGetUniformLocation(glProgram, "colorBlindMode");
uniTex = gl.glGetUniformLocation(glUiProgram, "tex");
uniTexSamplingMode = gl.glGetUniformLocation(glUiProgram, "samplingMode");
uniTexTargetDimensions = gl.glGetUniformLocation(glUiProgram, "targetDimensions");
uniTexSourceDimensions = gl.glGetUniformLocation(glUiProgram, "sourceDimensions");
uniUiColorBlindMode = gl.glGetUniformLocation(glUiProgram, "colorBlindMode");
uniTextures = gl.glGetUniformLocation(glProgram, "textures");
uniTextureOffsets = gl.glGetUniformLocation(glProgram, "textureOffsets");
@@ -1121,6 +1125,7 @@ public class GpuPlugin extends Plugin implements DrawCallbacks
// Brightness happens to also be stored in the texture provider, so we use that
gl.glUniform1f(uniBrightness, (float) textureProvider.getBrightness());
gl.glUniform1f(uniSmoothBanding, config.smoothBanding() ? 0f : 1f);
gl.glUniform1i(uniColorBlindMode, config.colorBlindMode().ordinal());
// Calculate projection matrix
Matrix4 projectionMatrix = new Matrix4();
@@ -1248,6 +1253,7 @@ public class GpuPlugin extends Plugin implements DrawCallbacks
gl.glUniform1i(uniTex, 0);
gl.glUniform1i(uniTexSamplingMode, uiScalingMode.getMode());
gl.glUniform2i(uniTexSourceDimensions, canvasWidth, canvasHeight);
gl.glUniform1i(uniUiColorBlindMode, config.colorBlindMode().ordinal());
if (client.isStretchedEnabled())
{

View File

@@ -31,6 +31,7 @@ import net.runelite.client.config.Range;
import static net.runelite.client.plugins.gpu.GpuPlugin.MAX_FOG_DEPTH;
import net.runelite.client.plugins.gpu.config.AntiAliasingMode;
import static net.runelite.client.plugins.gpu.GpuPlugin.MAX_DISTANCE;
import net.runelite.client.plugins.gpu.config.ColorBlindMode;
import net.runelite.client.plugins.gpu.config.UIScalingMode;
@ConfigGroup("gpu")
@@ -123,4 +124,15 @@ public interface GpuPluginConfig extends Config
{
return 0;
}
@ConfigItem(
keyName = "colorBlindMode",
name = "Colorblindness Correction",
description = "Adjusts colors to account for colorblindness",
position = 8
)
default ColorBlindMode colorBlindMode()
{
return ColorBlindMode.NONE;
}
}

View File

@@ -0,0 +1,33 @@
/*
* Copyright (c) 2020 Ben Poulson <https://github.com/benpoulson>
* 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;
public enum ColorBlindMode
{
NONE,
PROTANOPE,
DEUTERANOPE,
TRITANOPE;
}