DOUBLE CLOUD LAYER TEST VERSION. make ambient sss brightness slider work.

This commit is contained in:
Xonk
2023-11-22 02:01:06 -05:00
parent eabc47d999
commit d90a15e694
7 changed files with 229 additions and 232 deletions

View File

@ -491,7 +491,7 @@ vec3 SubsurfaceScattering_sky(vec3 albedo, float Scattering, float Density){
// vec3 scatter = sqrt(exp(-(absorbed * Scattering * 15))) * (1.0 - Scattering);
// vec3 scatter = exp(-5 * Scattering)*vec3(1);
vec3 scatter = exp((Scattering*Scattering) * absorbed * -5) * sqrt(1.0 - Scattering);
vec3 scatter = exp((Scattering*Scattering) * absorbed * -5.0) * sqrt(1.0 - Scattering);
// scatter *= pow(Density,LabSSS_Curve);
scatter *= clamp(1 - exp(Density * -10),0,1);
@ -640,7 +640,7 @@ void main() {
Background += Sky;
#ifdef VOLUMETRIC_CLOUDS
vec4 Clouds = texture2D_bicubic(colortex0, texcoord*CLOUDS_QUALITY);
vec4 Clouds = texture2D_bicubic_offset(colortex0, texcoord*CLOUDS_QUALITY, noise);
Background = Background * Clouds.a + Clouds.rgb;
#endif
@ -839,6 +839,7 @@ void main() {
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 + (1.0-lightmap.y) * 0.75) ;
AmbientLightColor *= skylight;
@ -949,7 +950,7 @@ void main() {
SkySSS = ScreenSpace_SSS(viewPos, FlatNormals, hand, isLeaf, noise);
#endif
vec3 ambientColor = (averageSkyCol_Clouds / 10.0);
vec3 ambientColor = averageSkyCol_Clouds / 12.0; // divide by 12 to match the brightest part of ambient light facing up
float skylightmap = pow(lightmap.y,3);
Indirect_SSS = SubsurfaceScattering_sky(albedo, SkySSS, LabSSS);
@ -961,7 +962,7 @@ void main() {
SSS_forSky *= skylightmap;
//light up dark parts so its more visible
Indirect_lighting = max(Indirect_lighting, SSS_forSky);
Indirect_lighting = max(Indirect_lighting, SSS_forSky * ambientsss_brightness);
// apply to ambient light.
Indirect_lighting = max(Indirect_lighting, Indirect_SSS * ambientsss_brightness);

View File

@ -174,6 +174,20 @@ vec3 viewToWorld(vec3 viewPosition) {
void applyContrast(inout vec3 color, float contrast){
color = ((color - 0.5) * max(contrast, 0.0)) + 0.5;
}
void ApplyDistortion(inout vec2 Texcoord, vec2 TangentNormals, vec2 depths){
vec2 UnalteredTexcoord = Texcoord;
// Texcoord = min(Texcoord, 1.0-abs(Texcoord));
Texcoord = abs(Texcoord + (TangentNormals * clamp((ld(depths.x) - ld(depths.y)) * 0.5,0.0,0.15)) * RENDER_SCALE );
float DistortedAlpha = decodeVec2(texture2D(colortex11,Texcoord).b).g;
if(DistortedAlpha <= 0.001) Texcoord = UnalteredTexcoord; // remove distortion on non-translucents
}
void main() {
/* DRAWBUFFERS:73 */
@ -234,12 +248,18 @@ void main() {
/// --- REFRACTION --- ///
#ifdef Refraction
refractedCoord += (tangentNormals * clamp((ld(z2) - ld(z)) * 0.5,0.0,0.15)) * RENDER_SCALE;
// refractedCoord += tangentNormals * 0.1 * RENDER_SCALE;
// refractedCoord = clamp(refractedCoord + (tangentNormals * clamp((ld(z2) - ld(z)) * 0.5,0.0,0.15)) * RENDER_SCALE ,-1.0,1.0);
float refractedalpha = decodeVec2(texture2D(colortex11,refractedCoord).b).g;
float refractedalpha2 = texture2D(colortex7,refractedCoord).a;
if( refractedalpha <= 0.001 || z < 0.56) refractedCoord = texcoord; // remove refracted coords on solids
// // refractedCoord = clamp(refractedCoord - tangentNormals, refractedCoord-0.5,refractedCoord);
// // if(tangentNormals.xy <= vec2(0.0, 0.0) ) refractedCoord = abs(refractedCoord - tangentNormals);
// // refractedCoord += tangentNormals * 0.1 * RENDER_SCALE;
// float refractedalpha = decodeVec2(texture2D(colortex11,refractedCoord).b).g;
// // float refractedalpha2 = texture2D(colortex7,refractedCoord).a;
// if( refractedalpha <= 0.001) refractedCoord = texcoord; // remove refracted coords on solids
ApplyDistortion(refractedCoord, tangentNormals, vec2(z2,z));
#endif
/// --- MAIN COLOR BUFFER --- ///