mirror of
https://github.com/X0nk/Bliss-Shader.git
synced 2025-01-04 00:23:41 +08:00
improve indoor lighting, fix sunlight breaking hand indoors. fix handheld torch range slider not working. extended minimum brightness slider values.
This commit is contained in:
parent
f22aa95189
commit
46405f95f1
@ -144,7 +144,7 @@ void main() {
|
|||||||
vec3 Direct_lighting = vec3(0.0);
|
vec3 Direct_lighting = vec3(0.0);
|
||||||
vec3 Indirect_lighting = vec3(0.0);
|
vec3 Indirect_lighting = vec3(0.0);
|
||||||
|
|
||||||
vec3 MinimumLightColor = vec3(0.2,0.4,1.0);
|
vec3 MinimumLightColor = vec3(1.0);
|
||||||
if(isEyeInWater == 1) MinimumLightColor = vec3(10.0);
|
if(isEyeInWater == 1) MinimumLightColor = vec3(10.0);
|
||||||
|
|
||||||
vec3 Torch_Color = vec3(TORCH_R,TORCH_G,TORCH_B);
|
vec3 Torch_Color = vec3(TORCH_R,TORCH_G,TORCH_B);
|
||||||
|
@ -325,7 +325,7 @@ void main() {
|
|||||||
#ifdef Hand_Held_lights
|
#ifdef Hand_Held_lights
|
||||||
|
|
||||||
|
|
||||||
if(HELD_ITEM_BRIGHTNESS > 0.0) torchlightmap = max(torchlightmap, HELD_ITEM_BRIGHTNESS * clamp( pow(max(1.0-length(fragpos)/10,0.0),1.5),0.0,1.0));
|
if(HELD_ITEM_BRIGHTNESS > 0.0) torchlightmap = max(torchlightmap, HELD_ITEM_BRIGHTNESS * clamp( pow(max(1.0-length(fragpos)/HANDHELD_LIGHT_RANGE,0.0),1.5),0.0,1.0));
|
||||||
|
|
||||||
#ifdef HAND
|
#ifdef HAND
|
||||||
torchlightmap *= 0.9;
|
torchlightmap *= 0.9;
|
||||||
|
@ -62,6 +62,7 @@ uniform int isEyeInWater;
|
|||||||
uniform float rainStrength;
|
uniform float rainStrength;
|
||||||
uniform float skyIntensityNight;
|
uniform float skyIntensityNight;
|
||||||
uniform float skyIntensity;
|
uniform float skyIntensity;
|
||||||
|
uniform ivec2 eyeBrightnessSmooth;
|
||||||
|
|
||||||
uniform int frameCounter;
|
uniform int frameCounter;
|
||||||
uniform float frameTimeCounter;
|
uniform float frameTimeCounter;
|
||||||
@ -355,10 +356,8 @@ if (gl_FragCoord.x * texelSize.x < 1.0 && gl_FragCoord.y * texelSize.y < 1.0 )
|
|||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
vec4 COLORTEST = vec4(Albedo, UnchangedAlpha);
|
vec4 COLORTEST = vec4(Albedo, UnchangedAlpha);
|
||||||
|
|
||||||
|
|
||||||
#ifdef BIOME_TINT_WATER
|
#ifdef BIOME_TINT_WATER
|
||||||
if (iswater > 0.95) COLORTEST.rgb = color.rgb;
|
if (iswater > 0.95) COLORTEST.rgb = color.rgb;
|
||||||
#endif
|
#endif
|
||||||
@ -420,7 +419,7 @@ if (gl_FragCoord.x * texelSize.x < 1.0 && gl_FragCoord.y * texelSize.y < 1.0 )
|
|||||||
#endif
|
#endif
|
||||||
|
|
||||||
vec3 Indirect_lighting = vec3(0.0);
|
vec3 Indirect_lighting = vec3(0.0);
|
||||||
vec3 MinimumLightColor = vec3(0.2,0.4,1.0);
|
vec3 MinimumLightColor = vec3(1.0);
|
||||||
if(isEyeInWater == 1) MinimumLightColor = vec3(10.0);
|
if(isEyeInWater == 1) MinimumLightColor = vec3(10.0);
|
||||||
vec3 Direct_lighting = vec3(0.0);
|
vec3 Direct_lighting = vec3(0.0);
|
||||||
|
|
||||||
|
@ -566,29 +566,29 @@ void Emission(
|
|||||||
// uniform mat4 gbufferProjectionInverse;
|
// uniform mat4 gbufferProjectionInverse;
|
||||||
// uniform mat4 dhProjectionInverse;
|
// uniform mat4 dhProjectionInverse;
|
||||||
|
|
||||||
vec3 getViewPos() {
|
// vec3 getViewPos() {
|
||||||
ivec2 uv = ivec2(gl_FragCoord.xy);
|
// ivec2 uv = ivec2(gl_FragCoord.xy);
|
||||||
vec2 viewSize = vec2(viewWidth, viewHeight);
|
// vec2 viewSize = vec2(viewWidth, viewHeight);
|
||||||
vec2 texcoord = gl_FragCoord.xy / viewSize;
|
// vec2 texcoord = gl_FragCoord.xy / viewSize;
|
||||||
|
|
||||||
vec4 viewPos = vec4(0.0);
|
// vec4 viewPos = vec4(0.0);
|
||||||
|
|
||||||
float depth = texelFetch(depthtex0, uv, 0).r;
|
// float depth = texelFetch(depthtex0, uv, 0).r;
|
||||||
|
|
||||||
if (depth < 1.0) {
|
// if (depth < 1.0) {
|
||||||
vec4 ndcPos = vec4(texcoord, depth, 1.0) * 2.0 - 1.0;
|
// vec4 ndcPos = vec4(texcoord, depth, 1.0) * 2.0 - 1.0;
|
||||||
viewPos = gbufferProjectionInverse * ndcPos;
|
// viewPos = gbufferProjectionInverse * ndcPos;
|
||||||
viewPos.xyz /= viewPos.w;
|
// viewPos.xyz /= viewPos.w;
|
||||||
} else {
|
// } else {
|
||||||
depth = texelFetch(dhDepthTex, ivec2(gl_FragCoord.xy), 0).r;
|
// depth = texelFetch(dhDepthTex, ivec2(gl_FragCoord.xy), 0).r;
|
||||||
|
|
||||||
vec4 ndcPos = vec4(texcoord, depth, 1.0) * 2.0 - 1.0;
|
// vec4 ndcPos = vec4(texcoord, depth, 1.0) * 2.0 - 1.0;
|
||||||
viewPos = dhProjectionInverse * ndcPos;
|
// viewPos = dhProjectionInverse * ndcPos;
|
||||||
viewPos.xyz /= viewPos.w;
|
// viewPos.xyz /= viewPos.w;
|
||||||
}
|
// }
|
||||||
|
|
||||||
return viewPos.xyz;
|
// return viewPos.xyz;
|
||||||
}
|
// }
|
||||||
|
|
||||||
vec4 BilateralUpscale(sampler2D tex, sampler2D depth, vec2 coord, float referenceDepth){
|
vec4 BilateralUpscale(sampler2D tex, sampler2D depth, vec2 coord, float referenceDepth){
|
||||||
|
|
||||||
@ -780,11 +780,7 @@ void main() {
|
|||||||
vec3 viewPos = toScreenSpace(vec3(texcoord/RENDER_SCALE - TAA_Offset*texelSize*0.5,z));
|
vec3 viewPos = toScreenSpace(vec3(texcoord/RENDER_SCALE - TAA_Offset*texelSize*0.5,z));
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
vec3 feetPlayerPos = mat3(gbufferModelViewInverse) * viewPos;
|
|
||||||
vec3 feetPlayerPos_normalized = normVec(feetPlayerPos);
|
|
||||||
|
|
||||||
|
|
||||||
vec3 playerPos = mat3(gbufferModelViewInverse) * getViewPos();
|
|
||||||
////// --------------- UNPACK OPAQUE GBUFFERS --------------- //////
|
////// --------------- UNPACK OPAQUE GBUFFERS --------------- //////
|
||||||
|
|
||||||
vec4 data = texture2D(colortex1,texcoord);
|
vec4 data = texture2D(colortex1,texcoord);
|
||||||
@ -841,6 +837,10 @@ void main() {
|
|||||||
// bool blocklights = abs(dataUnpacked1.w-0.8) <0.01;
|
// bool blocklights = abs(dataUnpacked1.w-0.8) <0.01;
|
||||||
|
|
||||||
|
|
||||||
|
if(hand) viewPos *= 5.0;
|
||||||
|
|
||||||
|
vec3 feetPlayerPos = mat3(gbufferModelViewInverse) * viewPos;
|
||||||
|
vec3 feetPlayerPos_normalized = normVec(feetPlayerPos);
|
||||||
////// --------------- COLORS --------------- //////
|
////// --------------- COLORS --------------- //////
|
||||||
|
|
||||||
float dirtAmount = Dirt_Amount + 0.01;
|
float dirtAmount = Dirt_Amount + 0.01;
|
||||||
@ -859,7 +859,7 @@ void main() {
|
|||||||
#endif
|
#endif
|
||||||
vec3 Absorbtion = vec3(1.0);
|
vec3 Absorbtion = vec3(1.0);
|
||||||
vec3 AmbientLightColor = vec3(0.0);
|
vec3 AmbientLightColor = vec3(0.0);
|
||||||
vec3 MinimumLightColor = vec3(0.2,0.4,1.0);
|
vec3 MinimumLightColor = vec3(1.0);
|
||||||
vec3 Indirect_lighting = vec3(0.0);
|
vec3 Indirect_lighting = vec3(0.0);
|
||||||
vec3 Indirect_SSS = vec3(0.0);
|
vec3 Indirect_SSS = vec3(0.0);
|
||||||
|
|
||||||
@ -985,18 +985,10 @@ void main() {
|
|||||||
#ifdef OVERWORLD_SHADER
|
#ifdef OVERWORLD_SHADER
|
||||||
|
|
||||||
NdotL = clamp((-15 + dot(slopednormal, WsunVec)*255.0) / 240.0 ,0.0,1.0);
|
NdotL = clamp((-15 + dot(slopednormal, WsunVec)*255.0) / 240.0 ,0.0,1.0);
|
||||||
// float shadowNDOTL = NdotL;
|
|
||||||
// #ifndef Variable_Penumbra_Shadows
|
|
||||||
// shadowNDOTL += LabSSS;
|
|
||||||
// #endif
|
|
||||||
|
|
||||||
|
|
||||||
// if(shadowNDOTL > 0.001){
|
|
||||||
|
|
||||||
|
|
||||||
vec3 shadowPlayerPos = mat3(gbufferModelViewInverse) * viewPos + gbufferModelViewInverse[3].xyz;
|
vec3 shadowPlayerPos = mat3(gbufferModelViewInverse) * viewPos + gbufferModelViewInverse[3].xyz;
|
||||||
|
|
||||||
if(!hand || !entities) GriAndEminShadowFix(shadowPlayerPos, viewToWorld(FlatNormals), vanilla_AO, lightmap.y, entities);
|
if(!entities || !hand) GriAndEminShadowFix(shadowPlayerPos, viewToWorld(FlatNormals), vanilla_AO, lightmap.y);
|
||||||
|
|
||||||
vec3 projectedShadowPosition = mat3(shadowModelView) * shadowPlayerPos + shadowModelView[3].xyz;
|
vec3 projectedShadowPosition = mat3(shadowModelView) * shadowPlayerPos + shadowModelView[3].xyz;
|
||||||
projectedShadowPosition = diagonal3(shadowProjection) * projectedShadowPosition + shadowProjection[3].xyz;
|
projectedShadowPosition = diagonal3(shadowProjection) * projectedShadowPosition + shadowProjection[3].xyz;
|
||||||
@ -1018,7 +1010,6 @@ void main() {
|
|||||||
projectedShadowPosition = projectedShadowPosition * vec3(0.5,0.5,0.5/6.0) + vec3(0.5);
|
projectedShadowPosition = projectedShadowPosition * vec3(0.5,0.5,0.5/6.0) + vec3(0.5);
|
||||||
|
|
||||||
float biasOffset = 0.0;
|
float biasOffset = 0.0;
|
||||||
if(hand) biasOffset = -0.00035;
|
|
||||||
|
|
||||||
#ifdef BASIC_SHADOW_FILTER
|
#ifdef BASIC_SHADOW_FILTER
|
||||||
float rdMul = filteredShadow.x*distortFactor*d0*k/shadowMapResolution;
|
float rdMul = filteredShadow.x*distortFactor*d0*k/shadowMapResolution;
|
||||||
@ -1054,6 +1045,7 @@ void main() {
|
|||||||
shadowMap += opaqueShadow;
|
shadowMap += opaqueShadow;
|
||||||
|
|
||||||
vec4 translucentShadow = texture2D(shadowcolor0, projectedShadowPosition.xy);
|
vec4 translucentShadow = texture2D(shadowcolor0, projectedShadowPosition.xy);
|
||||||
|
translucentShadow.rgb = normalize(translucentShadow.rgb + 0.0001);
|
||||||
float shadowAlpha = clamp(1.0 - pow(translucentShadow.a,5.0),0.0,1.0);
|
float shadowAlpha = clamp(1.0 - pow(translucentShadow.a,5.0),0.0,1.0);
|
||||||
|
|
||||||
#if SSS_TYPE != 0
|
#if SSS_TYPE != 0
|
||||||
@ -1080,7 +1072,7 @@ void main() {
|
|||||||
#ifdef OLD_LIGHTLEAK_FIX
|
#ifdef OLD_LIGHTLEAK_FIX
|
||||||
if (isEyeInWater == 0) Shadows *= clamp(pow(eyeBrightnessSmooth.y/240. + lightmap.y,2.0) ,0.0,1.0); // light leak fix
|
if (isEyeInWater == 0) Shadows *= clamp(pow(eyeBrightnessSmooth.y/240. + lightmap.y,2.0) ,0.0,1.0); // light leak fix
|
||||||
#endif
|
#endif
|
||||||
// }
|
|
||||||
|
|
||||||
////////////////////////////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////////////////////////////
|
||||||
//////////////////////////////// UNDER WATER SHADING ////////////////////////////////
|
//////////////////////////////// UNDER WATER SHADING ////////////////////////////////
|
||||||
|
@ -5,8 +5,7 @@ void GriAndEminShadowFix(
|
|||||||
inout vec3 WorldPos,
|
inout vec3 WorldPos,
|
||||||
vec3 FlatNormal,
|
vec3 FlatNormal,
|
||||||
float VanillaAO,
|
float VanillaAO,
|
||||||
float SkyLightmap,
|
float SkyLightmap
|
||||||
bool Entities
|
|
||||||
){
|
){
|
||||||
|
|
||||||
// float DistanceOffset = clamp(0.17 + length(WorldPos) / (shadowMapResolution*0.20), 0.0,1.0) ;
|
// float DistanceOffset = clamp(0.17 + length(WorldPos) / (shadowMapResolution*0.20), 0.0,1.0) ;
|
||||||
@ -15,10 +14,10 @@ void GriAndEminShadowFix(
|
|||||||
|
|
||||||
vec3 finalBias = Bias;
|
vec3 finalBias = Bias;
|
||||||
|
|
||||||
// stop lightleaking
|
// stop lightleaking by zooming up, centered on blocks
|
||||||
vec2 scale = vec2(0.5); scale.y *= 0.5;
|
vec2 scale = vec2(0.5); scale.y *= 0.5;
|
||||||
vec3 zoomShadow = scale.y - scale.x * fract(WorldPos + cameraPosition + Bias*scale.y);
|
vec3 zoomShadow = scale.y - scale.x * fract(WorldPos + cameraPosition + Bias*scale.y);
|
||||||
if(SkyLightmap < 0.1 && !Entities) finalBias = mix(Bias, zoomShadow, clamp(VanillaAO*5,0,1));
|
if(SkyLightmap < 0.1) finalBias = mix(Bias, zoomShadow, clamp(VanillaAO*5,0,1));
|
||||||
|
|
||||||
WorldPos += finalBias;
|
WorldPos += finalBias;
|
||||||
}
|
}
|
@ -4,18 +4,18 @@ vec3 DoAmbientLightColor(
|
|||||||
vec3 TorchColor,
|
vec3 TorchColor,
|
||||||
vec2 Lightmap
|
vec2 Lightmap
|
||||||
){
|
){
|
||||||
|
float LightLevelZero = clamp(pow(eyeBrightnessSmooth.y/240. + Lightmap.y,2.0) ,0.0,1.0);
|
||||||
|
|
||||||
// do sky lighting.
|
// do sky lighting.
|
||||||
float skyLM = (pow(Lightmap.y,15.0)*2.0 + pow(Lightmap.y,2.5))*0.5;
|
float skyLM = (pow(Lightmap.y,15.0)*2.0 + pow(Lightmap.y,2.5))*0.5;
|
||||||
SkyColor = SkyColor * ambient_brightness * skyLM;
|
|
||||||
vec3 MinimumLight = MinimumColor * (MIN_LIGHT_AMOUNT*0.01 + nightVision);
|
vec3 MinimumLight = MinimumColor * (MIN_LIGHT_AMOUNT*0.01 + nightVision);
|
||||||
vec3 IndirectLight = max(SkyColor, MinimumLight);
|
vec3 IndirectLight = max(SkyColor * ambient_brightness * skyLM, MinimumLight);
|
||||||
// vec3(0.2,0.4,1.0)
|
|
||||||
// do torch lighting.
|
// do torch lighting.
|
||||||
float TorchLM = 10.0 - ( 1.0 / (pow(exp(-0.5*inversesqrt(Lightmap.x)),5.0)+0.1));
|
float TorchLM = 10.0 - ( 1.0 / (pow(exp(-0.5*inversesqrt(Lightmap.x)),5.0)+0.1));
|
||||||
TorchLM = pow(TorchLM/4,10) + pow(Lightmap.x,1.5)*0.5;
|
TorchLM = pow(TorchLM/4,10) + pow(Lightmap.x,1.5)*0.5;
|
||||||
|
|
||||||
vec3 TorchLight = TorchColor * TORCH_AMOUNT * TorchLM;
|
vec3 TorchLight = TorchColor * TORCH_AMOUNT * TorchLM * (1.0 + LightLevelZero*dot(SkyColor * ambient_brightness,vec3(0.3333)));
|
||||||
return IndirectLight + TorchLight;
|
return IndirectLight + TorchLight;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -79,7 +79,7 @@
|
|||||||
// ----- INDIRECT LIGHT RELATED SETTINGS ----- //
|
// ----- INDIRECT LIGHT RELATED SETTINGS ----- //
|
||||||
/////////////////////////////////////////////////
|
/////////////////////////////////////////////////
|
||||||
|
|
||||||
#define MIN_LIGHT_AMOUNT 1.0 // [0.0 0.1 0.2 0.3 0.4 0.5 0.6 0.7 0.8 0.9 1.0 1.1 1.2 1.3 1.4 1.5 1.6 1.7 1.8 1.9 2.0 2.1 2.2 2.3 2.4 2.5 2.6 2.7 2.8 2.9 3.0 4.0 5.0 6.0 7.0 8.0 9.0 10.0]
|
#define MIN_LIGHT_AMOUNT 1.0 // [0.0 0.1 0.2 0.3 0.4 0.5 0.6 0.7 0.8 0.9 1.0 1.1 1.2 1.3 1.4 1.5 1.6 1.7 1.8 1.9 2.0 2.1 2.2 2.3 2.4 2.5 2.6 2.7 2.8 2.9 3.0 4.0 5.0 6.0 7.0 8.0 9.0 10.0 15.0 20.0 25.0 30.0 35.0 40.0 45.0 50.0 100.0 ]
|
||||||
#define ambient_brightness 1.0 // [0.0 0.1 0.2 0.3 0.4 0.5 0.6 0.7 0.8 0.9 1.0 1.1 1.2 1.3 1.4 1.5 1.6 1.7 1.8 1.9 2.0 2.1 2.2 2.3 2.4 2.5 2.6 2.7 2.8 2.9 3.0 ]
|
#define ambient_brightness 1.0 // [0.0 0.1 0.2 0.3 0.4 0.5 0.6 0.7 0.8 0.9 1.0 1.1 1.2 1.3 1.4 1.5 1.6 1.7 1.8 1.9 2.0 2.1 2.2 2.3 2.4 2.5 2.6 2.7 2.8 2.9 3.0 ]
|
||||||
|
|
||||||
#define AmbientLight_R 1.0 // [0.0 0.1 0.2 0.3 0.4 0.5 0.6 0.7 0.8 0.9 1.0 1.1 1.2 1.3 1.4 1.5 1.6 1.7 1.8 1.9 2.0]
|
#define AmbientLight_R 1.0 // [0.0 0.1 0.2 0.3 0.4 0.5 0.6 0.7 0.8 0.9 1.0 1.1 1.2 1.3 1.4 1.5 1.6 1.7 1.8 1.9 2.0]
|
||||||
|
@ -86,8 +86,10 @@ vec3 rayTraceSpeculars(vec3 dir, vec3 position, float dither, float quality, boo
|
|||||||
float dist = 1.0 + clamp(position.z*position.z/50.0,0.0,2.0); // shrink sample size as distance increases
|
float dist = 1.0 + clamp(position.z*position.z/50.0,0.0,2.0); // shrink sample size as distance increases
|
||||||
for (int i = 0; i <= int(quality); i++) {
|
for (int i = 0; i <= int(quality); i++) {
|
||||||
|
|
||||||
vec2 testthing = hand ? spos.xy*texelSize : spos.xy/texelSize/4.0; // fix for ssr on hand
|
vec2 scaleUV = hand ? spos.xy*texelSize : spos.xy/texelSize/4.0; // fix for ssr on hand
|
||||||
float sp = sqrt((texelFetch2D(colortex4,ivec2(testthing),0).a+0.1)/65000.0);
|
float sp = sqrt(texelFetch2D(colortex4,ivec2(scaleUV),0).a/65000.0);
|
||||||
|
|
||||||
|
|
||||||
sp = invLinZ(sp);
|
sp = invLinZ(sp);
|
||||||
|
|
||||||
if(sp <= max(maxZ,minZ) && sp >= min(maxZ,minZ) ) return vec3(spos.xy/RENDER_SCALE,sp);
|
if(sp <= max(maxZ,minZ) && sp >= min(maxZ,minZ) ) return vec3(spos.xy/RENDER_SCALE,sp);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user