gpu: add ambient lighting based on fog color
This commit is contained in:
@@ -237,9 +237,11 @@ public class GpuPlugin extends Plugin implements DrawCallbacks
|
||||
private int uniBlockLarge;
|
||||
private int uniBlockMain;
|
||||
private int uniSmoothBanding;
|
||||
private int uniAmbientLighting;
|
||||
|
||||
private int drawDistance;
|
||||
private boolean smoothBanding;
|
||||
private boolean ambientLighting;
|
||||
private AntiAliasingMode antiAliasingMode;
|
||||
private AnisotropicFilteringMode anisotropicFilteringMode;
|
||||
private int fogDepth;
|
||||
@@ -266,6 +268,7 @@ public class GpuPlugin extends Plugin implements DrawCallbacks
|
||||
this.fogCircularity = config.fogCircularity();
|
||||
this.fogDensity = config.fogDensity();
|
||||
this.uiScalingMode = config.uiScalingMode();
|
||||
this.ambientLighting = config.ambientLighting();
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -548,6 +551,7 @@ public class GpuPlugin extends Plugin implements DrawCallbacks
|
||||
uniFogCornerRadius = gl.glGetUniformLocation(glProgram, "fogCornerRadius");
|
||||
uniFogDensity = gl.glGetUniformLocation(glProgram, "fogDensity");
|
||||
uniDrawDistance = gl.glGetUniformLocation(glProgram, "drawDistance");
|
||||
uniAmbientLighting = gl.glGetUniformLocation(glProgram, "ambientLighting");
|
||||
|
||||
uniTex = gl.glGetUniformLocation(glUiProgram, "tex");
|
||||
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
|
||||
gl.glUniform1f(uniBrightness, (float) textureProvider.getBrightness());
|
||||
|
||||
gl.glUniform1f(uniSmoothBanding, this.smoothBanding ? 0f : 1f);
|
||||
gl.glUniform1f(uniAmbientLighting, !this.ambientLighting ? 0f : 1f);
|
||||
|
||||
for (int id = 0; id < textures.length; ++id)
|
||||
{
|
||||
|
||||
@@ -191,4 +191,26 @@ public interface GpuPluginConfig extends Config
|
||||
{
|
||||
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 true;
|
||||
}
|
||||
}
|
||||
@@ -29,6 +29,8 @@ uniform vec2 textureOffsets[64];
|
||||
uniform float brightness;
|
||||
uniform float smoothBanding;
|
||||
uniform vec4 fogColor;
|
||||
uniform bool ambientLighting;
|
||||
vec3 mixedColor;
|
||||
|
||||
in vec4 Color;
|
||||
centroid in float fHsl;
|
||||
@@ -58,7 +60,12 @@ void main() {
|
||||
|
||||
smoothColor = textureColorBrightness * smoothColor;
|
||||
}
|
||||
|
||||
vec3 mixedColor = mix(smoothColor.rgb, fogColor.rgb, fogAmount);
|
||||
if(ambientLighting == true) {
|
||||
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);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user