Merge pull request #2280 from open-osrs/ambient-lighting
gpu: add ambient lighting
This commit is contained in:
@@ -237,9 +237,11 @@ public class GpuPlugin extends Plugin implements DrawCallbacks
|
|||||||
private int uniBlockLarge;
|
private int uniBlockLarge;
|
||||||
private int uniBlockMain;
|
private int uniBlockMain;
|
||||||
private int uniSmoothBanding;
|
private int uniSmoothBanding;
|
||||||
|
private int uniAmbientLighting;
|
||||||
|
|
||||||
private int drawDistance;
|
private int drawDistance;
|
||||||
private boolean smoothBanding;
|
private boolean smoothBanding;
|
||||||
|
private boolean ambientLighting;
|
||||||
private AntiAliasingMode antiAliasingMode;
|
private AntiAliasingMode antiAliasingMode;
|
||||||
private AnisotropicFilteringMode anisotropicFilteringMode;
|
private AnisotropicFilteringMode anisotropicFilteringMode;
|
||||||
private int fogDepth;
|
private int fogDepth;
|
||||||
@@ -266,6 +268,7 @@ public class GpuPlugin extends Plugin implements DrawCallbacks
|
|||||||
this.fogCircularity = config.fogCircularity();
|
this.fogCircularity = config.fogCircularity();
|
||||||
this.fogDensity = config.fogDensity();
|
this.fogDensity = config.fogDensity();
|
||||||
this.uiScalingMode = config.uiScalingMode();
|
this.uiScalingMode = config.uiScalingMode();
|
||||||
|
this.ambientLighting = config.ambientLighting();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@@ -548,6 +551,7 @@ public class GpuPlugin extends Plugin implements DrawCallbacks
|
|||||||
uniFogCornerRadius = gl.glGetUniformLocation(glProgram, "fogCornerRadius");
|
uniFogCornerRadius = gl.glGetUniformLocation(glProgram, "fogCornerRadius");
|
||||||
uniFogDensity = gl.glGetUniformLocation(glProgram, "fogDensity");
|
uniFogDensity = gl.glGetUniformLocation(glProgram, "fogDensity");
|
||||||
uniDrawDistance = gl.glGetUniformLocation(glProgram, "drawDistance");
|
uniDrawDistance = gl.glGetUniformLocation(glProgram, "drawDistance");
|
||||||
|
uniAmbientLighting = gl.glGetUniformLocation(glProgram, "ambientLighting");
|
||||||
|
|
||||||
uniTex = gl.glGetUniformLocation(glUiProgram, "tex");
|
uniTex = gl.glGetUniformLocation(glUiProgram, "tex");
|
||||||
uniTexSamplingMode = gl.glGetUniformLocation(glUiProgram, "samplingMode");
|
uniTexSamplingMode = gl.glGetUniformLocation(glUiProgram, "samplingMode");
|
||||||
@@ -1111,7 +1115,9 @@ public class GpuPlugin extends Plugin implements DrawCallbacks
|
|||||||
|
|
||||||
// Brightness happens to also be stored in the texture provider, so we use that
|
// Brightness happens to also be stored in the texture provider, so we use that
|
||||||
gl.glUniform1f(uniBrightness, (float) textureProvider.getBrightness());
|
gl.glUniform1f(uniBrightness, (float) textureProvider.getBrightness());
|
||||||
|
|
||||||
gl.glUniform1f(uniSmoothBanding, this.smoothBanding ? 0f : 1f);
|
gl.glUniform1f(uniSmoothBanding, this.smoothBanding ? 0f : 1f);
|
||||||
|
gl.glUniform1f(uniAmbientLighting, !this.ambientLighting ? 0f : 1f);
|
||||||
|
|
||||||
for (int id = 0; id < textures.length; ++id)
|
for (int id = 0; id < textures.length; ++id)
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -191,4 +191,26 @@ public interface GpuPluginConfig extends Config
|
|||||||
{
|
{
|
||||||
return 10;
|
return 10;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ConfigTitleSection(
|
||||||
|
keyName = "effectsTitle",
|
||||||
|
name = "Effects",
|
||||||
|
description = "",
|
||||||
|
position = 13
|
||||||
|
)
|
||||||
|
default Title effectsTitle()
|
||||||
|
{
|
||||||
|
return new Title();
|
||||||
|
}
|
||||||
|
|
||||||
|
@ConfigItem(
|
||||||
|
keyName = "ambientLighting",
|
||||||
|
name = "Ambient Lighting",
|
||||||
|
description = "Produces global lighting based on current fog color",
|
||||||
|
position = 14
|
||||||
|
)
|
||||||
|
default boolean ambientLighting()
|
||||||
|
{
|
||||||
|
return false;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
@@ -29,6 +29,8 @@ uniform vec2 textureOffsets[64];
|
|||||||
uniform float brightness;
|
uniform float brightness;
|
||||||
uniform float smoothBanding;
|
uniform float smoothBanding;
|
||||||
uniform vec4 fogColor;
|
uniform vec4 fogColor;
|
||||||
|
uniform bool ambientLighting;
|
||||||
|
vec3 mixedColor;
|
||||||
|
|
||||||
in vec4 Color;
|
in vec4 Color;
|
||||||
centroid in float fHsl;
|
centroid in float fHsl;
|
||||||
@@ -58,7 +60,12 @@ void main() {
|
|||||||
|
|
||||||
smoothColor = textureColorBrightness * smoothColor;
|
smoothColor = textureColorBrightness * smoothColor;
|
||||||
}
|
}
|
||||||
|
if(ambientLighting == true) {
|
||||||
vec3 mixedColor = mix(smoothColor.rgb, fogColor.rgb, fogAmount);
|
mixedColor = mix(smoothColor.rgb, vec3((fogColor.r-fogColor.r/10),(fogColor.g-fogColor.g/10),(fogColor.b-fogColor.b/10)), fogAmount);
|
||||||
|
mixedColor = mixedColor+vec3(fogColor.r/10, fogColor.g/10, fogColor.b/10);
|
||||||
|
}
|
||||||
|
if(ambientLighting == false) {
|
||||||
|
mixedColor = mix(smoothColor.rgb, fogColor.rgb, fogAmount);
|
||||||
|
}
|
||||||
FragColor = vec4(mixedColor, smoothColor.a);
|
FragColor = vec4(mixedColor, smoothColor.a);
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user