add max distance for biome effects. make border fog cylindrical. Fix compile error on optifine.

This commit is contained in:
Xonk 2024-02-12 00:49:20 -05:00
parent 69dae189b1
commit b91c1f796f
9 changed files with 119 additions and 67 deletions

View File

@ -75,6 +75,22 @@ float R2_dither(){
return fract(alpha.x * coord.x + alpha.y * coord.y ) ; return fract(alpha.x * coord.x + alpha.y * coord.y ) ;
} }
//3D noise from 2d texture
float densityAtPos(in vec3 pos){
pos /= 18.;
pos.xz *= 0.5;
vec3 p = floor(pos);
vec3 f = fract(pos);
vec2 uv = p.xz + f.xz + p.y * vec2(0.0,193.0);
vec2 coord = uv / 512.0;
//The y channel has an offset to avoid using two textures fetches
vec2 xy = texture2D(noisetex, coord).yx;
return mix(xy.r,xy.g, f.y);
}
uniform vec3 cameraPosition;
/* RENDERTARGETS:1,7,8 */ /* RENDERTARGETS:1,7,8 */
void main() { void main() {
// overdraw prevention // overdraw prevention
@ -90,7 +106,16 @@ void main() {
// alpha is material masks, set it to 0.65 to make a DH LODs mask. // alpha is material masks, set it to 0.65 to make a DH LODs mask.
vec4 Albedo = vec4(gcolor.rgb, 1.0); vec4 Albedo = vec4(gcolor.rgb, 1.0);
// vec3 worldPos = mat3(gbufferModelViewInverse)*pos.xyz + cameraPosition;
// worldPos = (worldPos*vec3(1.0,1./48.,1.0)/4) ;
// worldPos = floor(worldPos * 4.0 + 0.001) / 32.0;
// float noiseTexture = densityAtPos(worldPos* 5000 ) +0.5;
// float noiseFactor = max(1.0 - 0.3 * dot(Albedo.rgb, Albedo.rgb),0.0);
// Albedo.rgb *= pow(noiseTexture, 0.6 * noiseFactor);
// Albedo.rgb *= (noiseTexture*noiseTexture)*0.5 + 0.5;
#ifdef WhiteWorld #ifdef WhiteWorld
Albedo.rgb = vec3(0.5); Albedo.rgb = vec3(0.5);
#endif #endif

View File

@ -754,12 +754,18 @@ void main() {
#ifdef OVERWORLD_SHADER #ifdef OVERWORLD_SHADER
DirectLightColor = lightCol.rgb/80.0; DirectLightColor = lightCol.rgb/80.0;
AmbientLightColor = averageSkyCol_Clouds;
#ifdef PER_BIOME_ENVIRONMENT #ifdef PER_BIOME_ENVIRONMENT
BiomeSunlightColor(DirectLightColor); // BiomeSunlightColor(DirectLightColor);
vec3 biomeDirect = DirectLightColor;
vec3 biomeIndirect = AmbientLightColor;
float inBiome = BiomeVLFogColors(biomeDirect, biomeIndirect);
float maxDistance = inBiome * min(max(1.0 - length(feetPlayerPos)/(32*8),0.0)*2.0,1.0);
DirectLightColor = mix(DirectLightColor, biomeDirect, maxDistance);
#endif #endif
AmbientLightColor = averageSkyCol_Clouds;
vec3 filteredShadow = vec3(1.412,1.0,0.0); vec3 filteredShadow = vec3(1.412,1.0,0.0);
if (!hand) filteredShadow = texture2D(colortex3,texcoord).rgb; if (!hand) filteredShadow = texture2D(colortex3,texcoord).rgb;
@ -845,7 +851,7 @@ void main() {
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(!hand || !entities) GriAndEminShadowFix(shadowPlayerPos, viewToWorld(FlatNormals), vanilla_AO, lightmap.y, entities);
vec3 projectedShadowPosition = mat3(shadowModelView) * shadowPlayerPos + shadowModelView[3].xyz; vec3 projectedShadowPosition = mat3(shadowModelView) * shadowPlayerPos + shadowModelView[3].xyz;

View File

@ -248,6 +248,7 @@ void main() {
vec3 np3 = normVec(p3); vec3 np3 = normVec(p3);
float linearDistance = length(p3); float linearDistance = length(p3);
float linearDistance_cylinder = length(p3.xz);
float lightleakfix = clamp(pow(eyeBrightnessSmooth.y/240.,2) ,0.0,1.0); float lightleakfix = clamp(pow(eyeBrightnessSmooth.y/240.,2) ,0.0,1.0);
float lightleakfixfast = clamp(eyeBrightness.y/240.,0.0,1.0); float lightleakfixfast = clamp(eyeBrightness.y/240.,0.0,1.0);
@ -292,9 +293,9 @@ void main() {
#if defined BorderFog #if defined BorderFog
#ifdef DISTANT_HORIZONS #ifdef DISTANT_HORIZONS
float fog = 1.0 - pow(1.0-pow(1.0-min(max(1.0 - linearDistance / dhFarPlane,0.0)*3.0,1.0),2.0),2.0); float fog = 1.0 - pow(1.0-pow(1.0-min(max(1.0 - linearDistance_cylinder / dhFarPlane,0.0)*3.0,1.0),2.0),2.0);
#else #else
float fog = 1.0 - pow(1.0-pow(1.0-min(max(1.0 - linearDistance / far,0.0)*5.0,1.0),2.0),2.0); float fog = 1.0 - pow(1.0-pow(1.0-min(max(1.0 - linearDistance_cylinder / far,0.0)*5.0,1.0),2.0),2.0);
#endif #endif
fog *= exp(-10.0 * pow(clamp(np3.y,0.0,1.0)*4.0,2.0)); fog *= exp(-10.0 * pow(clamp(np3.y,0.0,1.0)*4.0,2.0));

View File

@ -229,6 +229,7 @@ vec3 closestToCamera5taps_DH(vec2 texcoord, sampler2D depth, sampler2D dhDepth,
uniform sampler2D dhDepthTex; uniform sampler2D dhDepthTex;
uniform float far;
uniform float dhFarPlane; uniform float dhFarPlane;
uniform float dhNearPlane; uniform float dhNearPlane;
@ -250,9 +251,12 @@ float invertlinearDepthFast(const in float depth, const in float near, const in
vec3 toClipSpace3Prev_DH( vec3 viewSpacePosition, bool depthCheck ) { vec3 toClipSpace3Prev_DH( vec3 viewSpacePosition, bool depthCheck ) {
mat4 projectionMatrix = depthCheck ? dhPreviousProjection : gbufferPreviousProjection; #ifdef DISTANT_HORIZONS
mat4 projectionMatrix = depthCheck ? dhPreviousProjection : gbufferPreviousProjection;
return projMAD(projectionMatrix, viewSpacePosition) / -viewSpacePosition.z * 0.5 + 0.5; return projMAD(projectionMatrix, viewSpacePosition) / -viewSpacePosition.z * 0.5 + 0.5;
#else
return projMAD(gbufferPreviousProjection, viewSpacePosition) / -viewSpacePosition.z * 0.5 + 0.5;
#endif
} }
vec3 toScreenSpace_DH_special(vec3 POS, bool depthCheck ) { vec3 toScreenSpace_DH_special(vec3 POS, bool depthCheck ) {
@ -309,7 +313,7 @@ vec4 TAA_hq(){
#ifdef DISTANT_HORIZONS #ifdef DISTANT_HORIZONS
vec3 closestToCamera = closestToCamera5taps_DH(adjTC, depthtex0, dhDepthTex, depthCheck); vec3 closestToCamera = closestToCamera5taps_DH(adjTC, depthtex0, dhDepthTex, depthCheck);
#else #else
vec3 closestToCamera = closestToCamera5taps(adjTC, depthtex0); vec3 closestToCamera = closestToCamera5taps(adjTC,depthtex0);
#endif #endif
#endif #endif

View File

@ -77,8 +77,8 @@ float blueNoise(){
} }
#define DHVLFOG #define DHVLFOG
#define diagonal3(m) vec3((m)[0].x, (m)[1].y, m[2].z) // #define diagonal3(m) vec3((m)[0].x, (m)[1].y, m[2].z)
#define projMAD(m, v) (diagonal3(m) * (v) + (m)[3].xyz) // #define projMAD(m, v) (diagonal3(m) * (v) + (m)[3].xyz)
vec3 toScreenSpace(vec3 p) { vec3 toScreenSpace(vec3 p) {
vec4 iProjDiag = vec4(gbufferProjectionInverse[0].x, gbufferProjectionInverse[1].y, gbufferProjectionInverse[2].zw); vec4 iProjDiag = vec4(gbufferProjectionInverse[0].x, gbufferProjectionInverse[1].y, gbufferProjectionInverse[2].zw);

View File

@ -43,6 +43,7 @@ vec3 toScreenSpace(vec3 p) {
vec4 fragposition = iProjDiag * p3.xyzz + gbufferProjectionInverse[3]; vec4 fragposition = iProjDiag * p3.xyzz + gbufferProjectionInverse[3];
return fragposition.xyz / fragposition.w; return fragposition.xyz / fragposition.w;
} }
float R2_dither(){ float R2_dither(){
vec2 coord = gl_FragCoord.xy + (frameCounter%40000) * 2.0; vec2 coord = gl_FragCoord.xy + (frameCounter%40000) * 2.0;
vec2 alpha = vec2(0.75487765, 0.56984026); vec2 alpha = vec2(0.75487765, 0.56984026);
@ -76,32 +77,6 @@ vec3 normVec (vec3 vec){
return vec*inversesqrt(dot(vec,vec)); return vec*inversesqrt(dot(vec,vec));
} }
#define diagonal3(m) vec3((m)[0].x, (m)[1].y, m[2].z)
#define projMAD(m, v) (diagonal3(m) * (v) + (m)[3].xyz)
uniform mat4 dhPreviousProjection;
uniform mat4 dhProjectionInverse;
uniform mat4 dhProjection;
vec3 DH_toScreenSpace(vec3 p) {
vec4 iProjDiag = vec4(dhProjectionInverse[0].x, dhProjectionInverse[1].y, dhProjectionInverse[2].zw);
vec3 feetPlayerPos = p * 2. - 1.;
vec4 viewPos = iProjDiag * feetPlayerPos.xyzz + dhProjectionInverse[3];
return viewPos.xyz / viewPos.w;
}
vec3 DH_toClipSpace3(vec3 viewSpacePosition) {
return projMAD(dhProjection, viewSpacePosition) / -viewSpacePosition.z * 0.5 + 0.5;
}
uniform float dhFarPlane;
uniform float dhNearPlane;
float DH_ld(float dist) {
return (2.0 * dhNearPlane) / (dhFarPlane + dhNearPlane - dist * (dhFarPlane - dhNearPlane));
}
float DH_inv_ld (float lindepth){
return -((2.0*dhNearPlane/lindepth)-dhFarPlane-dhNearPlane)/(dhFarPlane-dhNearPlane);
}
#include "/lib/lightning_stuff.glsl" #include "/lib/lightning_stuff.glsl"
#include "/lib/sky_gradient.glsl" #include "/lib/sky_gradient.glsl"

View File

@ -33,9 +33,13 @@ vec3 toScreenSpace_DH( vec2 texcoord, float depth, float DHdepth ) {
} }
vec3 toClipSpace3_DH( vec3 viewSpacePosition, bool depthCheck ) { vec3 toClipSpace3_DH( vec3 viewSpacePosition, bool depthCheck ) {
mat4 projectionMatrix = depthCheck ? dhProjection : gbufferProjection; #ifdef DISTANT_HORIZONS
mat4 projectionMatrix = depthCheck ? dhProjection : gbufferProjection;
return projMAD(projectionMatrix, viewSpacePosition) / -viewSpacePosition.z * 0.5 + 0.5;
#else
return projMAD(gbufferProjection, viewSpacePosition) / -viewSpacePosition.z * 0.5 + 0.5;
#endif
return projMAD(projectionMatrix, viewSpacePosition) / -viewSpacePosition.z * 0.5 + 0.5;
} }
mat4 DH_shadowProjectionTweak( in mat4 projection){ mat4 DH_shadowProjectionTweak( in mat4 projection){

View File

@ -175,25 +175,26 @@
FinalFogColor = mix(FinalFogColor, BiomeColors, Inbiome); FinalFogColor = mix(FinalFogColor, BiomeColors, Inbiome);
} }
void BiomeSunlightColor( // void BiomeSunlightColor(
inout vec3 FinalSunlightColor // inout vec3 FinalSunlightColor
){ // ){
// this is a little complicated? lmao // // this is a little complicated? lmao
vec3 BiomeColors = vec3(0.0); // vec3 BiomeColors = vec3(0.0);
BiomeColors.r = isSwamps*SWAMP_R + isJungles*JUNGLE_R + isDarkForests*DARKFOREST_R + sandStorm*1.0 + snowStorm*0.6; // BiomeColors.r = isSwamps*SWAMP_R + isJungles*JUNGLE_R + isDarkForests*DARKFOREST_R + sandStorm*1.0 + snowStorm*0.6;
BiomeColors.g = isSwamps*SWAMP_G + isJungles*JUNGLE_G + isDarkForests*DARKFOREST_G + sandStorm*0.5 + snowStorm*0.8; // BiomeColors.g = isSwamps*SWAMP_G + isJungles*JUNGLE_G + isDarkForests*DARKFOREST_G + sandStorm*0.5 + snowStorm*0.8;
BiomeColors.b = isSwamps*SWAMP_B + isJungles*JUNGLE_B + isDarkForests*DARKFOREST_B + sandStorm*0.3 + snowStorm*1.0; // BiomeColors.b = isSwamps*SWAMP_B + isJungles*JUNGLE_B + isDarkForests*DARKFOREST_B + sandStorm*0.3 + snowStorm*1.0;
// these range 0.0-1.0. they will never overlap. // // these range 0.0-1.0. they will never overlap.
float Inbiome = isJungles+isSwamps+isDarkForests+sandStorm+snowStorm; // float Inbiome = isJungles+isSwamps+isDarkForests+sandStorm+snowStorm;
// interpoloate between normal fog colors and biome colors. the transition speeds are conrolled by the biome uniforms. // // interpoloate between normal fog colors and biome colors. the transition speeds are conrolled by the biome uniforms.
FinalSunlightColor = mix(FinalSunlightColor, FinalSunlightColor * (BiomeColors*0.8+0.2), Inbiome); // FinalSunlightColor = mix(FinalSunlightColor, FinalSunlightColor * (BiomeColors*0.8+0.2), Inbiome);
} // }
void BiomeFogDensity( void BiomeFogDensity(
inout vec4 UniformDensity, inout vec4 UniformDensity,
inout vec4 CloudyDensity inout vec4 CloudyDensity,
float maxDistance
){ ){
// these range 0.0-1.0. they will never overlap. // these range 0.0-1.0. they will never overlap.
float Inbiome = isJungles+isSwamps+isDarkForests+sandStorm+snowStorm; float Inbiome = isJungles+isSwamps+isDarkForests+sandStorm+snowStorm;
@ -202,9 +203,29 @@
BiomeFogDensity.x = isSwamps*SWAMP_UNIFORM_DENSITY + isJungles*JUNGLE_UNIFORM_DENSITY + isDarkForests*DARKFOREST_UNIFORM_DENSITY + sandStorm*15 + snowStorm*150; BiomeFogDensity.x = isSwamps*SWAMP_UNIFORM_DENSITY + isJungles*JUNGLE_UNIFORM_DENSITY + isDarkForests*DARKFOREST_UNIFORM_DENSITY + sandStorm*15 + snowStorm*150;
BiomeFogDensity.y = isSwamps*SWAMP_CLOUDY_DENSITY + isJungles*JUNGLE_CLOUDY_DENSITY + isDarkForests*DARKFOREST_CLOUDY_DENSITY + sandStorm*255 + snowStorm*255; BiomeFogDensity.y = isSwamps*SWAMP_CLOUDY_DENSITY + isJungles*JUNGLE_CLOUDY_DENSITY + isDarkForests*DARKFOREST_CLOUDY_DENSITY + sandStorm*255 + snowStorm*255;
UniformDensity = mix(UniformDensity, vec4(BiomeFogDensity.x), Inbiome); UniformDensity = mix(UniformDensity, vec4(BiomeFogDensity.x), Inbiome*maxDistance);
CloudyDensity = mix(CloudyDensity, vec4(BiomeFogDensity.y), Inbiome); CloudyDensity = mix(CloudyDensity, vec4(BiomeFogDensity.y), Inbiome*maxDistance);
} }
float BiomeVLFogColors(inout vec3 DirectLightCol, inout vec3 IndirectLightCol){
// this is a little complicated? lmao
vec3 BiomeColors = vec3(0.0);
BiomeColors.r = isSwamps*SWAMP_R + isJungles*JUNGLE_R + isDarkForests*DARKFOREST_R + sandStorm*1.0 + snowStorm*0.6;
BiomeColors.g = isSwamps*SWAMP_G + isJungles*JUNGLE_G + isDarkForests*DARKFOREST_G + sandStorm*0.5 + snowStorm*0.8;
BiomeColors.b = isSwamps*SWAMP_B + isJungles*JUNGLE_B + isDarkForests*DARKFOREST_B + sandStorm*0.3 + snowStorm*1.0;
// insure the biome colors are locked to the fog shape and lighting, but not its orignal color.
DirectLightCol = BiomeColors * max(dot(DirectLightCol,vec3(0.33333)), MIN_LIGHT_AMOUNT*0.025 + nightVision*0.2);
IndirectLightCol = BiomeColors * max(dot(IndirectLightCol,vec3(0.33333)), MIN_LIGHT_AMOUNT*0.025 + nightVision*0.2);
// these range 0.0-1.0. they will never overlap.
float Inbiome = isJungles+isSwamps+isDarkForests+sandStorm+snowStorm;
return Inbiome;
}
#endif #endif
/////////////////////////////////////////////////////////////////////////////// ///////////////////////////////////////////////////////////////////////////////
@ -213,7 +234,9 @@
#ifdef TIMEOFDAYFOG #ifdef TIMEOFDAYFOG
// uniform int worldTime; // uniform int worldTime;
void TimeOfDayFog(inout float Uniform, inout float Cloudy) { void TimeOfDayFog(
inout float Uniform, inout float Cloudy, float maxDistance
) {
float Time = worldTime%24000; float Time = worldTime%24000;
@ -233,7 +256,7 @@
#endif #endif
#ifdef PER_BIOME_ENVIRONMENT #ifdef PER_BIOME_ENVIRONMENT
BiomeFogDensity(UniformDensity, CloudyDensity); // let biome fog hijack to control densities, and overrride any other density controller... BiomeFogDensity(UniformDensity, CloudyDensity, maxDistance); // let biome fog hijack to control densities, and overrride any other density controller...
#endif #endif
Uniform *= Morning*UniformDensity.r + Noon*UniformDensity.g + Evening*UniformDensity.b + Night*UniformDensity.a; Uniform *= Morning*UniformDensity.r + Noon*UniformDensity.g + Evening*UniformDensity.b + Night*UniformDensity.a;

View File

@ -14,7 +14,7 @@ float densityAtPosFog(in vec3 pos){
} }
float cloudVol(in vec3 pos){ float cloudVol(in vec3 pos, float maxDistance ){
vec3 samplePos = pos*vec3(1.0,1./24.,1.0); vec3 samplePos = pos*vec3(1.0,1./24.,1.0);
vec3 samplePos2 = pos*vec3(1.0,1./48.,1.0); vec3 samplePos2 = pos*vec3(1.0,1./48.,1.0);
@ -40,7 +40,7 @@ float cloudVol(in vec3 pos){
if(sandStorm > 0 || snowStorm > 0) CloudyFog = mix(CloudyFog, max(densityAtPosFog((samplePos2 - vec3(frameTimeCounter,0,frameTimeCounter)*10) * 100.0 ) - 0.2,0.0) * heightlimit, sandStorm+snowStorm); if(sandStorm > 0 || snowStorm > 0) CloudyFog = mix(CloudyFog, max(densityAtPosFog((samplePos2 - vec3(frameTimeCounter,0,frameTimeCounter)*10) * 100.0 ) - 0.2,0.0) * heightlimit, sandStorm+snowStorm);
#endif #endif
TimeOfDayFog(UniformFog, CloudyFog); TimeOfDayFog(UniformFog, CloudyFog, maxDistance);
float noise = densityAtPosFog(samplePos * 12.0); float noise = densityAtPosFog(samplePos * 12.0);
float erosion = 1.0-densityAtPosFog(samplePos2 * (125 - (1-pow(1-noise,5))*25)); float erosion = 1.0-densityAtPosFog(samplePos2 * (125 - (1-pow(1-noise,5))*25));
@ -51,9 +51,9 @@ float cloudVol(in vec3 pos){
// float testfogshapes = clumpyFog*30; // float testfogshapes = clumpyFog*30;
// return testfogshapes; // return testfogshapes;
// return max(exp( max(pos.y - 90,0.0) / -1), 0.0) * 100;
return CloudyFog + UniformFog + RainFog; return CloudyFog + UniformFog + RainFog;
// float groundFog = max(exp( max(pos.y - 90,0.0) / -1), 0.0) * 100;
} }
@ -139,8 +139,9 @@ vec4 GetVolumetricFog(
LightSourcePhased = vec3(0.0); LightSourcePhased = vec3(0.0);
#endif #endif
#ifdef PER_BIOME_ENVIRONMENT #ifdef PER_BIOME_ENVIRONMENT
BiomeFogColor(LightSourcePhased); vec3 biomeDirect = LightSourcePhased;
BiomeFogColor(skyLightPhased); vec3 biomeIndirect = skyLightPhased;
float inBiome = BiomeVLFogColors(biomeDirect, biomeIndirect);
#endif #endif
skyLightPhased = max(skyLightPhased + skyLightPhased*(normalize(wpos).y*0.9+0.1),0.0); skyLightPhased = max(skyLightPhased + skyLightPhased*(normalize(wpos).y*0.9+0.1),0.0);
@ -200,7 +201,13 @@ vec4 GetVolumetricFog(
sh *= GetCloudShadow_VLFOG(progressW, WsunVec); sh *= GetCloudShadow_VLFOG(progressW, WsunVec);
#endif #endif
float densityVol = cloudVol(progressW) * lightleakfix;
#ifdef PER_BIOME_ENVIRONMENT
float maxDistance = inBiome * min(max(1.0 - length(d*dVWorld.xz)/(32*8),0.0)*2.0,1.0);
float densityVol = cloudVol(progressW, maxDistance) * lightleakfix;
#else
float densityVol = cloudVol(progressW, 0.0) * lightleakfix;
#endif
//Water droplets(fog) //Water droplets(fog)
float density = densityVol*300.0; float density = densityVol*300.0;
@ -213,11 +220,18 @@ vec4 GetVolumetricFog(
vec3 rL = rC*airCoef.x; vec3 rL = rC*airCoef.x;
vec3 m = (airCoef.y+density) * mC; vec3 m = (airCoef.y+density) * mC;
vec3 Atmosphere = skyLightPhased * (rL*RLmult + m); // not pbr so just make the atmosphere also dense fog heh #ifdef PER_BIOME_ENVIRONMENT
vec3 DirectLight = LightSourcePhased * sh * ((rL*RLmult)*rayL + m); vec3 Atmosphere = mix(skyLightPhased, biomeDirect, maxDistance) * (rL*RLmult + m); // not pbr so just make the atmosphere also dense fog heh
vec3 DirectLight = mix(LightSourcePhased, biomeIndirect, maxDistance) * sh * ((rL*RLmult)*rayL + m);
#else
vec3 Atmosphere = skyLightPhased * (rL*RLmult + m); // not pbr so just make the atmosphere also dense fog heh
vec3 DirectLight = LightSourcePhased * sh * ((rL*RLmult)*rayL + m);
#endif
vec3 Lightning = Iris_Lightningflash_VLfog(progressW-cameraPosition, lightningBoltPosition.xyz) * (rL + m); vec3 Lightning = Iris_Lightningflash_VLfog(progressW-cameraPosition, lightningBoltPosition.xyz) * (rL + m);
vec3 foglighting = (Atmosphere + DirectLight + Lightning) * lightleakfix; vec3 foglighting = (Atmosphere + DirectLight + Lightning) * lightleakfix;
color += (foglighting - foglighting * exp(-(rL+m)*dd*dL)) / ((rL+m)+0.00000001)*absorbance; color += (foglighting - foglighting * exp(-(rL+m)*dd*dL)) / ((rL+m)+0.00000001)*absorbance;
absorbance *= clamp(exp(-(rL+m)*dd*dL),0.0,1.0); absorbance *= clamp(exp(-(rL+m)*dd*dL),0.0,1.0);