redo application for ambient lighting in all dimensions. fix RTAO/SSGI in end/nether

This commit is contained in:
Xonk 2023-10-18 17:43:29 -04:00
parent 6816f30e79
commit ca39a0a6dd
9 changed files with 153 additions and 180 deletions

View File

@ -149,29 +149,24 @@ void main() {
Direct_lighting *= phaseg(clamp(dot(feetPlayerPos_normalized, WsunVec),0.0,1.0), 0.65)*2 + 0.5;
#endif
Indirect_lighting = DoAmbientLighting(averageSkyCol_Clouds, Torch_Color, clamp(lightmap.xy,0,1), 3.0);
#endif
#ifdef END_SHADER
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;
vec3 AmbientLightColor = averageSkyCol_Clouds;
vec3 TorchLight = (Torch_Color * TorchLM * 0.75) * TORCH_AMOUNT;
Indirect_lighting = max(vec3(0.5,0.75,1.0) * 0.1, (MIN_LIGHT_AMOUNT*0.01 + nightVision*0.5) ) + TorchLight;
#endif
#ifdef NETHER_SHADER
vec3 AmbientLightColor = skyCloudsFromTexLOD2(vec3( 0, 1, 0), colortex4, 6).rgb / 10;
vec3 AmbientLightColor = skyCloudsFromTexLOD2(vec3( 0, 1, 0), colortex4, 6).rgb / 15;
#endif
vec3 nothing = vec3(0.0);
Indirect_lighting = DoAmbientLighting_Nether(AmbientLightColor, Torch_Color, lightmap.x, nothing, nothing, nothing);
#ifdef END_SHADER
vec3 AmbientLightColor = vec3(1.0);
#endif
#ifdef FALLBACK_SHADER
Indirect_lighting = DoAmbientLighting_Fallback(vec3(1.0), Torch_Color, lightmap.x, vec3(0.0), feetPlayerPos);
vec3 AmbientLightColor = vec3(1.0);
#endif
Indirect_lighting = DoAmbientLightColor(AmbientLightColor, vec3(TORCH_R,TORCH_G,TORCH_B), clamp(lightmap.xy,0,1));
#ifndef LINES
gl_FragData[0].rgb = (Indirect_lighting + Direct_lighting) * Albedo;
#else

View File

@ -397,7 +397,7 @@ void main() {
// #endif
#ifdef WhiteWorld
Albedo.rgb = vec3(1.0);
Albedo.rgb = vec3(0.5);
#endif

View File

@ -368,9 +368,11 @@ if (gl_FragCoord.x * texelSize.x < 1.0 && gl_FragCoord.y * texelSize.y < 1.0 )
////////////////////////////////
vec2 lightmap = lmtexcoord.zw;
#ifndef OVERWORLD_SHADER
lightmap.y = 1.0;
#endif
vec3 Indirect_lighting = vec3(0.0);
vec3 Direct_lighting = vec3(0.0);
@ -437,14 +439,15 @@ if (gl_FragCoord.x * texelSize.x < 1.0 && gl_FragCoord.y * texelSize.y < 1.0 )
Direct_lighting = (lightCol.rgb/80.0) * NdotL * Shadows;
vec3 AmbientLightColor = averageSkyCol_Clouds;
vec3 ambientcoefs = WS_normal / dot(abs(WS_normal), vec3(1));
float SkylightDir = ambientcoefs.y*1.5;
float skylight = max(pow(viewToWorld(flatnormal).y*0.5+0.5,0.1) + SkylightDir, 0.25);
// float skylight = max(pow(viewToWorld(flatnormal).y*0.5+0.5,0.1) + viewToWorld(normal).y, 0.25) * 1.35;
Indirect_lighting = DoAmbientLighting(averageSkyCol_Clouds, vec3(TORCH_R,TORCH_G,TORCH_B), lightmap.xy, skylight);
// Indirect_lighting = DoAmbientLighting(averageSkyCol_Clouds, vec3(TORCH_R,TORCH_G,TORCH_B), lightmap.xy, skylight);
#endif
#ifdef NETHER_SHADER
@ -459,19 +462,18 @@ if (gl_FragCoord.x * texelSize.x < 1.0 && gl_FragCoord.y * texelSize.y < 1.0 )
down *= pow( max(-WS_normal.y, 0), 2);
AmbientLightColor += up + down;
// do all ambient lighting stuff
Indirect_lighting = DoAmbientLighting_Nether(AmbientLightColor, vec3(TORCH_R,TORCH_G,TORCH_B), lightmap.x, vec3(0.0), vec3(0.0), vec3(0.0));
#endif
#ifdef END_SHADER
// do all ambient lighting stuff
Indirect_lighting = DoAmbientLighting_End(gl_Fog.color.rgb, vec3(TORCH_R,TORCH_G,TORCH_B), lightmap.x, normal, feetPlayerPos );
vec3 AmbientLightColor = vec3(1.0);
#endif
#ifdef FALLBACK_SHADER
Indirect_lighting = DoAmbientLighting_Fallback(vec3(1.0), vec3(TORCH_R,TORCH_G,TORCH_B), lightmap.x, WS_normal, feetPlayerPos);
vec3 AmbientLightColor = vec3(1.0);
#endif
Indirect_lighting = DoAmbientLightColor(AmbientLightColor, vec3(TORCH_R,TORCH_G,TORCH_B), lightmap.xy);
vec3 FinalColor = (Indirect_lighting + Direct_lighting) * Albedo;
#ifdef Glass_Tint

View File

@ -210,19 +210,16 @@ vec3 BilateralFiltering(sampler2D tex, sampler2D depth,vec2 coord,float frDepth,
}
float interleaved_gradientNoise(){
vec2 coord = gl_FragCoord.xy + (frameCounter%40000) * 2.0;
float noise = fract( 52.9829189 * fract( (coord.x * 0.06711056) + (coord.y * 0.00583715)) );
float noise = fract( 52.9829189 * fract( (coord.x * 0.06711056) + (coord.y * 0.00583715) ) );
return noise ;
}
float R2_dither(){
vec2 coord = gl_FragCoord.xy + (frameCounter%40000) * 2.0;
vec2 alpha = vec2(0.75487765, 0.56984026);
return fract(alpha.x * gl_FragCoord.x + alpha.y * gl_FragCoord.y + 1.0/1.6180339887 * frameCounter) ;
return fract(alpha.x * coord.x + alpha.y * coord.y ) ;
}
// vec2 R2_dither(){
// vec2 alpha = vec2(0.75487765, 0.56984026);
// return vec2(fract(alpha.x * gl_FragCoord.x + alpha.y * gl_FragCoord.y + 1.0/1.6180339887 * frameCounter), fract((1.0-alpha.x) * gl_FragCoord.x + (1.0-alpha.y) * gl_FragCoord.y + 1.0/1.6180339887 * frameCounter));
// }
float blueNoise(){
return fract(texelFetch2D(noisetex, ivec2(gl_FragCoord.xy)%512, 0).a + 1.0/1.6180339887 * (frameCounter*0.5+0.5) );
return fract(texelFetch2D(noisetex, ivec2(gl_FragCoord.xy)%512, 0).a + 1.0/1.6180339887 * frameCounter);
}
vec4 blueNoise(vec2 coord){
return texelFetch2D(colortex6, ivec2(coord)%512 , 0) ;
@ -943,48 +940,39 @@ void main() {
/////////////////////////////////////////////////////////////////////////////////
#ifdef OVERWORLD_SHADER
vec3 ambientcoefs = slopednormal / dot(abs(slopednormal), vec3(1));
float SkylightDir = ambientcoefs.y*1.5;
if(isGrass) SkylightDir = 1.25;
float skylight = max(pow(viewToWorld(FlatNormals).y*0.5+0.5,0.1) + SkylightDir, 0.25) ;
// #if indirect_effect == 2
// skylight = 1.0;
// #endif
#if indirect_effect != 3 || indirect_effect != 4
Indirect_lighting = DoAmbientLighting(AmbientLightColor, vec3(TORCH_R,TORCH_G,TORCH_B), lightmap.xy, skylight);
#endif
Indirect_lighting += LightningFlashLighting;
AmbientLightColor *= skylight;
#endif
#ifdef NETHER_SHADER
AmbientLightColor = skyCloudsFromTexLOD2(normal, colortex4, 6).rgb / 10;
AmbientLightColor = skyCloudsFromTexLOD2(normal, colortex4, 6).rgb;
vec3 up = skyCloudsFromTexLOD2(vec3( 0, 1, 0), colortex4, 6).rgb / 10;
vec3 down = skyCloudsFromTexLOD2(vec3( 0,-1, 0), colortex4, 6).rgb / 10;
vec3 up = skyCloudsFromTexLOD2(vec3( 0, 1, 0), colortex4, 6).rgb;
vec3 down = skyCloudsFromTexLOD2(vec3( 0,-1, 0), colortex4, 6).rgb;
up *= pow( max( slopednormal.y, 0), 2);
down *= pow( max(-slopednormal.y, 0), 2);
AmbientLightColor += up + down;
Indirect_lighting = DoAmbientLighting_Nether(AmbientLightColor, vec3(TORCH_R,TORCH_G,TORCH_B), lightmap.x, normal, feetPlayerPos_normalized, feetPlayerPos );
#endif
#ifdef END_SHADER
Indirect_lighting = DoAmbientLighting_End(gl_Fog.color.rgb, vec3(TORCH_R,TORCH_G,TORCH_B), lightmap.x, normal, feetPlayerPos_normalized);
vec3 AmbientLightColor = vec3(1.0);
#endif
#ifdef FALLBACK_SHADER
Indirect_lighting = DoAmbientLighting_Fallback(vec3(1.0), vec3(TORCH_R,TORCH_G,TORCH_B), lightmap.x, normal, feetPlayerPos);
// if(hand) Indirect_lighting = vec3(TORCH_R,TORCH_G,TORCH_B) * 0.3;
vec3 AmbientLightColor = vec3(1.0);
#endif
Indirect_lighting = DoAmbientLightColor(AmbientLightColor, vec3(TORCH_R,TORCH_G,TORCH_B), lightmap.xy);
// Indirect_lighting += LightningFlashLighting;
////////////////////////////////////////////////////////////////////////////////////////////
//////////////////////////////// UNDER WATER SHADING ////////////////////////////////
////////////////////////////////////////////////////////////////////////////////////////////
@ -1034,12 +1022,13 @@ void main() {
vec3 AO = vec3( exp( (vanilla_AO*vanilla_AO) * -3) );
vec2 SSAO_SSS = SSAO(viewPos, FlatNormals, hand, isLeaf, noise);
AO *= exp((1.0-SSAO_SSS.x) * -5.0);
// AO *= exp((1.0-SSAO_SSS.x) * -5.0);
AO *= SSAO_SSS.x*SSAO_SSS.x*SSAO_SSS.x;
SkySSS = SSAO_SSS.y;
Indirect_lighting *= AO;
#endif
// GTAO
#if indirect_effect == 2
vec3 AO = vec3( exp( (vanilla_AO*vanilla_AO) * -3) );
@ -1052,7 +1041,7 @@ void main() {
// RTAO and/or SSGI
#if indirect_effect == 3 || indirect_effect == 4
if (!hand) ApplySSRT(Indirect_lighting, normal, vec3(bnoise, noise_2), viewPos, lightmap.xy, AmbientLightColor, vec3(TORCH_R,TORCH_G,TORCH_B), isGrass);
if (!hand) ApplySSRT(Indirect_lighting, viewPos, normal, vec3(bnoise, noise_2), lightmap.xy, AmbientLightColor, vec3(TORCH_R,TORCH_G,TORCH_B), isGrass);
#endif
#ifdef SSS_view
@ -1100,18 +1089,14 @@ void main() {
#endif
#ifdef OVERWORLD_SHADER
Direct_lighting = DoDirectLighting(DirectLightColor, Shadows, NdotL, 0.0);
// do this here so it gets underwater absorbtion.
// Direct_lighting += Direct_SSS * DirectLightColor;
Direct_lighting = max(Direct_lighting, Direct_SSS * DirectLightColor);
// do these here so it gets underwater absorbtion.
Direct_lighting = max(DirectLightColor * (NdotL * Shadows), DirectLightColor * Direct_SSS);
#endif
gl_FragData[0].rgb = (Indirect_lighting + Direct_lighting) * albedo;
#ifdef Specular_Reflections
vec2 specularNoises = vec2(noise, interleaved_gradientNoise());
vec2 specularNoises = vec2(noise, R2_dither());
DoSpecularReflections(gl_FragData[0].rgb, viewPos, feetPlayerPos_normalized, WsunVec, specularNoises, normal, SpecularTex.r, SpecularTex.g, albedo, DirectLightColor*Shadows*NdotL, lightmap.y, hand);
#endif
@ -1150,29 +1135,9 @@ void main() {
waterVolumetrics_notoverworld(gl_FragData[0].rgb, viewPos0, viewPos, estimatedDepth , estimatedDepth, Vdiff, noise_2, totEpsilon, scatterCoef, ambientColVol);
}
#endif
// vec3 testPos = feetPlayerPos_normalized + vec3(lightningBoltPosition.x, clamp(feetPlayerPos.y, lightningBoltPosition.y, lightningBoltPosition.y+150.0),lightningBoltPosition.z);
// // vec3 testPos = feetPlayerPos_normalized + vec3(lightningBoltPosition.x, lightningBoltPosition.y + 60,lightningBoltPosition.z);
// gl_FragData[0].rgb = vec3(1) * CustomPhase(clamp(dot(feetPlayerPos_normalized, WsunVec),0.0,1.0));
// float phaseorigin = 1.0 - clamp(dot(feetPlayerPos_normalized, normalize(testPos) ),0.0,1.0);
// mat4 Custom_ViewMatrix = BuildShadowViewMatrix(LightDir);
// mat4 Custom_ProjectionMatrix = BuildShadowProjectionMatrix();
// // vec3 projectedShadowPosition = mat3(Custom_ViewMatrix) * feetPlayerPos + Custom_ViewMatrix[3].xyz;
// // projectedShadowPosition = mat3(Custom_ProjectionMatrix) * projectedShadowPosition + Custom_ProjectionMatrix[3].xyz;
// vec3 projectedShadowPosition = mat3(shadowModelView) * feetPlayerPos + shadowModelView[3].xyz;
// projectedShadowPosition = diagonal3(shadowProjection) * projectedShadowPosition + shadowProjection[3].xyz;
// //apply distortion
// float distortFactor = calcDistort(projectedShadowPosition.xy);
// projectedShadowPosition.xy *= distortFactor;
// projectedShadowPosition = projectedShadowPosition * vec3(0.5,0.5,0.5/6.0) + vec3(0.5);
// gl_FragData[0].rgb = vec3(1);
/* DRAWBUFFERS:3 */
}
}

View File

@ -10,6 +10,7 @@ uniform sampler2D depthtex0;
uniform sampler2D colortex2;
uniform sampler2D colortex3;
// uniform sampler2D colortex4;
uniform sampler2D colortex6;
flat varying vec3 WsunVec;
uniform vec3 sunVec;
@ -68,7 +69,11 @@ float interleaved_gradientNoise(){
float blueNoise(){
return fract(texelFetch2D(noisetex, ivec2(gl_FragCoord.xy)%512, 0).a+ 1.0/1.6180339887 * frameCounter );
}
float R2_dither(){
vec2 coord = gl_FragCoord.xy + (frameCounter%40000) * 2.0;
vec2 alpha = vec2(0.75487765, 0.56984026);
return fract(alpha.x * coord.x + alpha.y * coord.y ) ;
}
void waterVolumetrics_notoverworld(inout vec3 inColor, vec3 rayStart, vec3 rayEnd, float estEndDepth, float estSunDepth, float rayLength, float dither, vec3 waterCoefs, vec3 scatterCoef, vec3 ambient){
inColor *= exp(-rayLength * waterCoefs); //No need to take the integrated value
@ -223,7 +228,13 @@ void waterVolumetrics(inout vec3 inColor, vec3 rayStart, vec3 rayEnd, float estE
//////////////////////////////VOID MAIN//////////////////////////////
//////////////////////////////VOID MAIN//////////////////////////////
//////////////////////////////VOID MAIN//////////////////////////////
vec4 blueNoise(vec2 coord){
return texelFetch2D(colortex6, ivec2(coord)%512 , 0) ;
}
vec2 R2_samples(int n){
vec2 alpha = vec2(0.75487765, 0.56984026);
return fract(alpha * n);
}
void main() {
/* DRAWBUFFERS:0 */
@ -233,8 +244,8 @@ void main() {
float z = texture2D(depthtex0,tc).x;
vec3 viewPos = toScreenSpace(vec3(tc/RENDER_SCALE,z));
float noise_1 = blueNoise();
float noise_2 = interleaved_gradientNoise();
float noise_1 = R2_dither();
float noise_2 = blueNoise();
if (isEyeInWater == 0){

View File

@ -39,12 +39,9 @@ vec3 toScreenSpace(vec3 p) {
return fragposition.xyz / fragposition.w;
}
float R2_dither(){
vec2 coord = gl_FragCoord.xy + (frameCounter%40000) * 2.0;
vec2 alpha = vec2(0.75487765, 0.56984026);
return fract(alpha.x * gl_FragCoord.x + alpha.y * gl_FragCoord.y + 1.0/1.6180339887 * frameCounter);
}
float R2_dither2(){
vec2 alpha = vec2(0.75487765, 0.56984026);
return fract(alpha.x * (1.0-gl_FragCoord.x) + alpha.y * (1.0-gl_FragCoord.y) + 1.0/1.6180339887 * frameCounter);
return fract(alpha.x * coord.x + alpha.y * coord.y ) ;
}
float interleaved_gradientNoise(){
vec2 alpha = vec2(0.75487765, 0.56984026);

View File

@ -1,98 +1,83 @@
// in this here file im doing all the lighting for sunlight, ambient light, torches, for solids and translucents.
// uniform float nightVision;
void DoRTAmbientLighting (vec3 TorchColor, vec2 Lightmap, inout float SkyLM, inout vec3 TorchLight, inout vec3 SkyLight){
vec3 DoAmbientLightColor(
vec3 SkyColor,
vec3 TorchColor,
vec2 Lightmap
){
// do sky lighting.
float skyLM = (pow(Lightmap.y,15.0)*2.0 + pow(Lightmap.y,2.5))*0.5;
SkyColor = (SkyColor / 30.0) * ambient_brightness * skyLM;
vec3 MinimumLight = vec3(0.2,0.4,1.0) * (MIN_LIGHT_AMOUNT*0.01 + nightVision);
vec3 IndirectLight = max(SkyColor, MinimumLight);
// do torch lighting.
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;
vec3 TorchLight = TorchColor * TORCH_AMOUNT * TorchLM;
return IndirectLight + TorchLight;
}
vec4 RT_AmbientLight(
vec3 TorchColor,
vec2 Lightmap
){
float skyLM = (pow(Lightmap.y,15.0)*2.0 + pow(Lightmap.y,2.5))*0.5;
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;
TorchLight = (TorchColor * TorchLM * 0.75) * TORCH_AMOUNT;
vec3 TorchLight = TorchColor * TORCH_AMOUNT * TorchLM;
SkyLM = (pow(Lightmap.y,15.0)*2.0 + pow(Lightmap.y,2.5))*0.5;
SkyLight = (SkyLight * ambient_brightness) / 30.0;
SkyLight = max(SkyLight * SkyLM, vec3(0.2,0.4,1.0) * (MIN_LIGHT_AMOUNT*0.025 + nightVision));
return vec4(TorchLight, skyLM);
}
// #ifdef NETHER_SHADER
// vec3 DoAmbientLighting_Nether(vec3 FogColor, vec3 TorchColor, float Lightmap, vec3 Normal, vec3 np3, vec3 WorldPos){
#ifdef OVERWORLD_SHADER
// float TorchLM = 10.0 - ( 1.0 / (pow(exp(-0.5*inversesqrt(Lightmap)),5.0)+0.1));
// TorchLM = pow(TorchLM/4,10) + pow(Lightmap,1.5)*0.5; //pow(TorchLM/4.5,10)*2.5 + pow(Lightmap.x,1.5)*0.5;
// vec3 TorchLight = TorchColor * TorchLM * 0.75;
// TorchLight *= TORCH_AMOUNT;
vec3 DoAmbientLighting (vec3 SkyColor, vec3 TorchColor, vec2 Lightmap, float skyLightDir){
// Lightmap.x = 0.0;
// Lightmap.y = 1.0;
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; //pow(TorchLM/4.5,10)*2.5 + pow(Lightmap.x,1.5)*0.5;
vec3 TorchLight = TorchColor * TorchLM * 0.75;
TorchLight *= TORCH_AMOUNT;
SkyColor = (SkyColor * ambient_brightness) / 30.0;
float skyLM = (pow(Lightmap.y,15.0)*2.0 + pow(Lightmap.y,2.5))*0.5;
vec3 SkyLight = max(SkyColor * skyLM, vec3(0.2,0.4,1.0) * (MIN_LIGHT_AMOUNT*0.01 + nightVision) );
return SkyLight * skyLightDir + TorchLight;
}
vec3 DoDirectLighting(vec3 SunColor, float Shadow, float NdotL, float SubsurfaceScattering){
vec3 SunLight = NdotL * Shadow * SunColor;
return SunLight;
}
// FogColor = max(FogColor, vec3(0.05) * MIN_LIGHT_AMOUNT*0.01 + nightVision);
#endif
// return FogColor + TorchLight ;
// }
// #endif
#ifdef NETHER_SHADER
vec3 DoAmbientLighting_Nether(vec3 FogColor, vec3 TorchColor, float Lightmap, vec3 Normal, vec3 np3, vec3 WorldPos){
// #ifdef END_SHADER
// vec3 DoAmbientLighting_End(vec3 FogColor, vec3 TorchColor, float Lightmap, vec3 Normal, vec3 np3){
float TorchLM = 10.0 - ( 1.0 / (pow(exp(-0.5*inversesqrt(Lightmap)),5.0)+0.1));
TorchLM = pow(TorchLM/4,10) + pow(Lightmap,1.5)*0.5; //pow(TorchLM/4.5,10)*2.5 + pow(Lightmap.x,1.5)*0.5;
vec3 TorchLight = TorchColor * TorchLM * 0.75;
TorchLight *= TORCH_AMOUNT;
FogColor = max(FogColor, vec3(0.05) * MIN_LIGHT_AMOUNT*0.01 + nightVision);
return FogColor + TorchLight ;
}
#endif
#ifdef END_SHADER
vec3 DoAmbientLighting_End(vec3 FogColor, vec3 TorchColor, float Lightmap, vec3 Normal, vec3 np3){
float TorchLM = 10.0 - ( 1.0 / (pow(exp(-0.5*inversesqrt(Lightmap)),5.0)+0.1));
TorchLM = pow(TorchLM/4,10) + pow(Lightmap,1.5)*0.5;
vec3 TorchLight = TorchColor * TorchLM * 0.75;
TorchLight *= TORCH_AMOUNT;
// float TorchLM = 10.0 - ( 1.0 / (pow(exp(-0.5*inversesqrt(Lightmap)),5.0)+0.1));
// TorchLM = pow(TorchLM/4,10) + pow(Lightmap,1.5)*0.5;
// vec3 TorchLight = TorchColor * TorchLM * 0.75;
// TorchLight *= TORCH_AMOUNT;
FogColor = FogColor / max(dot(FogColor,vec3(0.3333)),0.05);
// FogColor = FogColor / max(dot(FogColor,vec3(0.3333)),0.05);
vec3 FogTint = FogColor*clamp(1.1 + dot(Normal,np3),0.0,1.0) * 0.1;
// vec3 FogTint = FogColor*clamp(1.1 + dot(Normal,np3),0.0,1.0) * 0.1;
vec3 AmbientLight = max(vec3(0.5,0.75,1.0)* 0.1, (MIN_LIGHT_AMOUNT*0.01 + nightVision*0.5) );
// vec3 AmbientLight = max(vec3(0.5,0.75,1.0)* 0.1, (MIN_LIGHT_AMOUNT*0.01 + nightVision*0.5) );
return TorchLight + AmbientLight;// + AmbientLight + FogTint;
}
// return TorchLight + AmbientLight;// + AmbientLight + FogTint;
// }
#endif
// #endif
#ifdef FALLBACK_SHADER
vec3 DoAmbientLighting_Fallback(vec3 Color, vec3 TorchColor, float Lightmap, vec3 Normal, vec3 p3){
// #ifdef FALLBACK_SHADER
// vec3 DoAmbientLighting_Fallback(vec3 Color, vec3 TorchColor, float Lightmap, vec3 Normal, vec3 p3){
float TorchLM = 10.0 - ( 1.0 / (pow(exp(-0.5*inversesqrt(Lightmap)),5.0)+0.1));
TorchLM = pow(TorchLM/4,10) + pow(Lightmap,1.5)*0.5;
vec3 TorchLight = TorchColor * TorchLM * 0.75;
TorchLight *= TORCH_AMOUNT;
// float TorchLM = 10.0 - ( 1.0 / (pow(exp(-0.5*inversesqrt(Lightmap)),5.0)+0.1));
// TorchLM = pow(TorchLM/4,10) + pow(Lightmap,1.5)*0.5;
// vec3 TorchLight = TorchColor * TorchLM * 0.75;
// TorchLight *= TORCH_AMOUNT;
float NdotL = clamp(-dot(Normal,normalize(p3)),0.0,1.0);
// float NdotL = clamp(-dot(Normal,normalize(p3)),0.0,1.0);
float PlayerLight = exp( (1.0-clamp(1.0 - length(p3) / 32.0,0.0,1.0)) *-10.0);
// vec3 AmbientLight = TorchColor * PlayerLight * NdotL;
vec3 AmbientLight = vec3(0.5,0.3,1.0)*0.2 * (Normal.y*0.5+0.6);
// float PlayerLight = exp( (1.0-clamp(1.0 - length(p3) / 32.0,0.0,1.0)) *-10.0);
// // vec3 AmbientLight = TorchColor * PlayerLight * NdotL;
// vec3 AmbientLight = vec3(0.5,0.3,1.0)*0.2 * (Normal.y*0.5+0.6);
return TorchLight + AmbientLight;// + AmbientLight + FogTint;
}
#endif
// return TorchLight + AmbientLight;// + AmbientLight + FogTint;
// }
// #endif

View File

@ -215,7 +215,18 @@ vec3 RT(vec3 dir, vec3 position, float noise, float stepsizes){
return vec3(1.1);
}
void ApplySSRT(inout vec3 lighting, vec3 normal, vec3 noise, vec3 viewPos, vec2 lightmaps, vec3 skylightcolor, vec3 torchcolor, bool isGrass){
void ApplySSRT(
inout vec3 lighting,
vec3 viewPos,
vec3 normal,
vec3 noise,
vec2 lightmaps,
vec3 skylightcolor,
vec3 torchcolor,
bool isGrass
){
int nrays = RAY_COUNT;
vec3 radiance = vec3(0.0);
@ -225,11 +236,10 @@ void ApplySSRT(inout vec3 lighting, vec3 normal, vec3 noise, vec3 viewPos, vec2
vec3 occlusion2 = vec3(0.0);
vec3 skycontribution2 = vec3(0.0);
float skyLM = 0.0;
vec3 torchlight = vec3(0.0);
DoRTAmbientLighting(torchcolor, lightmaps, skyLM, torchlight, skylightcolor);
// rgb = torch color * lightmap. a = sky lightmap.
vec4 Lighting = RT_AmbientLight(torchcolor, lightmaps);
skylightcolor = (skylightcolor/15.0) * Lighting.a;
for (int i = 0; i < nrays; i++){
int seed = (frameCounter%40000)*nrays+i;
@ -243,15 +253,23 @@ void ApplySSRT(inout vec3 lighting, vec3 normal, vec3 noise, vec3 viewPos, vec2
#endif
#ifdef SKY_CONTRIBUTION_IN_SSRT
if(isGrass) rayDir.y = clamp(rayDir.y + 0.5,-1,1);
skycontribution = (skyCloudsFromTex(rayDir, colortex4).rgb / 15.0) * skyLM + torchlight;
#ifdef OVERWORLD_SHADER
if(isGrass) rayDir.y = clamp(rayDir.y + 0.5,-1,1);
skycontribution = (skyCloudsFromTexLOD(rayDir, colortex4, 0).rgb / 10.0) * Lighting.a + Lighting.rgb;
#else
skycontribution = (skyCloudsFromTexLOD2(rayDir, colortex4, 6).rgb / 10.0) * Lighting.a + Lighting.rgb;
#endif
#else
if(isGrass) rayDir.y = clamp(rayDir.y + 0.25,-1,1);
skycontribution = skylightcolor * 2 * (max(rayDir.y,0.0)*0.9+0.1) + torchlight;
#ifdef OVERWORLD_SHADER
if(isGrass) rayDir.y = clamp(rayDir.y + 0.25,-1,1);
#endif
skycontribution = skylightcolor * (max(rayDir.y,0.0)*0.9+0.1) + Lighting.rgb;
#if indirect_effect == 4
skycontribution2 = skylightcolor + torchlight;
skycontribution2 = skylightcolor + Lighting.rgb;
#endif
#endif

View File

@ -226,10 +226,10 @@ void DoSpecularReflections(
// apply background reflections to the final color. make sure it does not exist based on the lightmap
#ifdef Sky_reflection
#ifndef OVERWORLD_SHADER
if(hasReflections) Background_Reflection = (skyCloudsFromTexLOD2(L, colortex4, sqrt(Roughness) * 6.0).rgb / 30.0) * Metals;
#else
#ifdef OVERWORLD_SHADER
if(hasReflections) Background_Reflection = (skyCloudsFromTexLOD(L, colortex4, sqrt(Roughness) * 9.0).rgb / 30.0) * Metals;
#else
if(hasReflections) Background_Reflection = (skyCloudsFromTexLOD2(L, colortex4, sqrt(Roughness) * 6.0).rgb / 30.0) * Metals;
#endif
// take fresnel and lightmap levels into account and write to the final color