tweak sky color sampling a little to avoid blowing out on a single little cloud. mac OS test as well

This commit is contained in:
Xonk 2023-07-06 17:05:01 -04:00
parent 7119baabb3
commit 7cceac5169
4 changed files with 21 additions and 16 deletions

View File

@ -616,9 +616,6 @@ vec3 SubsurfaceScattering_sky(vec3 albedo, float Scattering, float Density){
// vec3 scatter = exp(-sqrt(max(Scattering+0.05,0.0) * absorbed * 25)) * exp(Scattering * -5); // vec3 scatter = exp(-sqrt(max(Scattering+0.05,0.0) * absorbed * 25)) * exp(Scattering * -5);
vec3 scatter = exp(-sqrt(Scattering * absorbed * 5)) * pow((-Scattering+1.0)*1.25,2.0); vec3 scatter = exp(-sqrt(Scattering * absorbed * 5)) * pow((-Scattering+1.0)*1.25,2.0);
scatter *= pow(Density,LabSSS_Curve); scatter *= pow(Density,LabSSS_Curve);
// temporary
scatter *= ambientsss_brightness;
return scatter; return scatter;
} }
@ -845,7 +842,9 @@ void main() {
vec3 DirectLightColor = (lightCol.rgb/80.0); vec3 DirectLightColor = (lightCol.rgb/80.0);
DirectLightColor *= clamp(abs(WsunVec.y)*2,0.,1.); DirectLightColor *= clamp(abs(WsunVec.y)*2,0.,1.);
#ifdef ambientLight_only
DirectLightColor = vec3(0.0);
#endif
vec3 AmbientLightColor = averageSkyCol_Clouds; vec3 AmbientLightColor = averageSkyCol_Clouds;
@ -1043,17 +1042,24 @@ void main() {
Indirect_lighting *= AO; Indirect_lighting *= AO;
vec3 SSS_forSky = vec3(0.0);
#ifdef Ambient_SSS #ifdef Ambient_SSS
if (!hand){ if (!hand){
vec3 SSS_forSky = vec3(0.0);
#if indirect_effect != 1 #if indirect_effect != 1
ScreenSpace_SSS(SkySSS, fragpos, blueNoise(gl_FragCoord.xy).rg, FlatNormals, isLeaf); ScreenSpace_SSS(SkySSS, fragpos, blueNoise(gl_FragCoord.xy).rg, FlatNormals, isLeaf);
#endif #endif
SSS_forSky = SubsurfaceScattering_sky(albedo, SkySSS, LabSSS) * ((AmbientLightColor* 2.0 * ambient_brightness)* 8./150.) * pow(newLightmap.y,3) * pow(1.0-clamp(abs(ambientCoefs.y+0.5),0.0,1.0),0.1) ; SSS_forSky = SubsurfaceScattering_sky(albedo, SkySSS, LabSSS);
SSS_forSky *= (AmbientLightColor* 2.0 * ambient_brightness) * 8./150.;
SSS_forSky *= pow(newLightmap.y,3);
// SSS_forSky *= pow(1.0-clamp(abs(ambientCoefs.y+0.5),0.0,1.0),0.1);
SSS += SSS_forSky;// Indirect_lighting += SubsurfaceScattering_sky(albedo, SkySSS, LabSSS) * ((AmbientLightColor* 2.0 * ambient_brightness)* 8./150.) * pow(newLightmap.y,3); SSS += SSS_forSky * pow(1.0-clamp(abs(ambientCoefs.y+0.5),0.0,1.0),0.1); // Indirect_lighting += SubsurfaceScattering_sky(albedo, SkySSS, LabSSS) * ((AmbientLightColor* 2.0 * ambient_brightness)* 8./150.) * pow(newLightmap.y,3);
} }
#endif #endif
// Indirect_lighting = max(Indirect_lighting, SSS_forSky);
@ -1123,9 +1129,6 @@ void main() {
#endif #endif
#endif #endif
#ifdef ambientLight_only
DirectLightColor = vec3(0.0);
#endif
Direct_lighting = DoDirectLighting(DirectLightColor, Shadows, NdotL, 0.0); Direct_lighting = DoDirectLighting(DirectLightColor, Shadows, NdotL, 0.0);

View File

@ -76,9 +76,9 @@ void main() {
vec2 sample3x3[9] = vec2[]( vec2 sample3x3[9] = vec2[](
vec2(-1.0, 0.0), vec2(-1.0, -0.3),
vec2( 0.0, 0.0), vec2( 0.0, 0.0),
vec2( 1.0, 0.0), vec2( 1.0, -0.3),
vec2(-1.0, -0.5), vec2(-1.0, -0.5),
vec2( 0.0, -0.5), vec2( 0.0, -0.5),

View File

@ -1,5 +1,5 @@
#extension GL_EXT_gpu_shader4 : enable // #extension GL_EXT_gpu_shader4 : enable
#extension GL_ARB_shader_texture_lod : enable // #extension GL_ARB_shader_texture_lod : enable
#include "/lib/settings.glsl" #include "/lib/settings.glsl"

View File

@ -141,6 +141,7 @@ vec3 rayTraceSpeculars(vec3 dir,vec3 position,float dither, float quality, bool
maxZ += stepv.z; maxZ += stepv.z;
reflectLength += 1.0 / quality; // for shit reflectLength += 1.0 / quality; // for shit
} }
@ -270,7 +271,7 @@ void MaterialReflections(
vec3 F = mix_vec3(f0, vec3(1.0), fresnel); vec3 F = mix_vec3(f0, vec3(1.0), fresnel);
vec3 rayContrib = F; vec3 rayContrib = F;
float rayContribLuma = luma(rayContrib); float rayContribLuma = dot(rayContrib,vec3(0.333333));
float VisibilityFactor = rayContribLuma * pow(1.0-roughness,3.0); float VisibilityFactor = rayContribLuma * pow(1.0-roughness,3.0);
bool hasReflections = Roughness_Threshold == 1.0 ? true : (f0.y * (1.0 - roughness * Roughness_Threshold)) > 0.01; bool hasReflections = Roughness_Threshold == 1.0 ? true : (f0.y * (1.0 - roughness * Roughness_Threshold)) > 0.01;
@ -297,8 +298,9 @@ void MaterialReflections(
float LOD = clamp(reflectLength * 6.0, 0.0,6.0); float LOD = clamp(reflectLength * 6.0, 0.0,6.0);
if(hand || isEntities) LOD = VisibilityFactor*6; if(hand || isEntities) LOD = VisibilityFactor*6;
// LOD = 0.0;
if (rtPos.z < 1.) { // Reproject on previous frame if (rtPos.z < 1.0) { // Reproject on previous frame
vec3 previousPosition = mat3(gbufferModelViewInverse) * toScreenSpace(rtPos) + gbufferModelViewInverse[3].xyz + cameraPosition-previousCameraPosition; vec3 previousPosition = mat3(gbufferModelViewInverse) * toScreenSpace(rtPos) + gbufferModelViewInverse[3].xyz + cameraPosition-previousCameraPosition;
previousPosition = mat3(gbufferPreviousModelView) * previousPosition + gbufferPreviousModelView[3].xyz; previousPosition = mat3(gbufferPreviousModelView) * previousPosition + gbufferPreviousModelView[3].xyz;
previousPosition.xy = projMAD(gbufferPreviousProjection, previousPosition).xy / -previousPosition.z * 0.5 + 0.5; previousPosition.xy = projMAD(gbufferPreviousProjection, previousPosition).xy / -previousPosition.z * 0.5 + 0.5;