mirror of
https://github.com/X0nk/Bliss-Shader.git
synced 2025-06-22 00:37:35 +08:00
add max distance for biome effects. make border fog cylindrical. Fix compile error on optifine.
This commit is contained in:
@ -33,9 +33,13 @@ vec3 toScreenSpace_DH( vec2 texcoord, float depth, float DHdepth ) {
|
||||
}
|
||||
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){
|
||||
|
@ -175,25 +175,26 @@
|
||||
FinalFogColor = mix(FinalFogColor, BiomeColors, Inbiome);
|
||||
}
|
||||
|
||||
void BiomeSunlightColor(
|
||||
inout vec3 FinalSunlightColor
|
||||
){
|
||||
// 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;
|
||||
// void BiomeSunlightColor(
|
||||
// inout vec3 FinalSunlightColor
|
||||
// ){
|
||||
// // 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;
|
||||
|
||||
// these range 0.0-1.0. they will never overlap.
|
||||
float Inbiome = isJungles+isSwamps+isDarkForests+sandStorm+snowStorm;
|
||||
// // these range 0.0-1.0. they will never overlap.
|
||||
// float Inbiome = isJungles+isSwamps+isDarkForests+sandStorm+snowStorm;
|
||||
|
||||
// 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);
|
||||
}
|
||||
// // 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);
|
||||
// }
|
||||
|
||||
void BiomeFogDensity(
|
||||
inout vec4 UniformDensity,
|
||||
inout vec4 CloudyDensity
|
||||
inout vec4 CloudyDensity,
|
||||
float maxDistance
|
||||
){
|
||||
// these range 0.0-1.0. they will never overlap.
|
||||
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.y = isSwamps*SWAMP_CLOUDY_DENSITY + isJungles*JUNGLE_CLOUDY_DENSITY + isDarkForests*DARKFOREST_CLOUDY_DENSITY + sandStorm*255 + snowStorm*255;
|
||||
|
||||
UniformDensity = mix(UniformDensity, vec4(BiomeFogDensity.x), Inbiome);
|
||||
CloudyDensity = mix(CloudyDensity, vec4(BiomeFogDensity.y), Inbiome);
|
||||
UniformDensity = mix(UniformDensity, vec4(BiomeFogDensity.x), Inbiome*maxDistance);
|
||||
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
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
@ -213,7 +234,9 @@
|
||||
|
||||
#ifdef TIMEOFDAYFOG
|
||||
// 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;
|
||||
|
||||
@ -233,7 +256,7 @@
|
||||
#endif
|
||||
|
||||
#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
|
||||
|
||||
Uniform *= Morning*UniformDensity.r + Noon*UniformDensity.g + Evening*UniformDensity.b + Night*UniformDensity.a;
|
||||
|
@ -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 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);
|
||||
#endif
|
||||
|
||||
TimeOfDayFog(UniformFog, CloudyFog);
|
||||
TimeOfDayFog(UniformFog, CloudyFog, maxDistance);
|
||||
|
||||
float noise = densityAtPosFog(samplePos * 12.0);
|
||||
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;
|
||||
// return testfogshapes;
|
||||
|
||||
// return max(exp( max(pos.y - 90,0.0) / -1), 0.0) * 100;
|
||||
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);
|
||||
#endif
|
||||
#ifdef PER_BIOME_ENVIRONMENT
|
||||
BiomeFogColor(LightSourcePhased);
|
||||
BiomeFogColor(skyLightPhased);
|
||||
vec3 biomeDirect = LightSourcePhased;
|
||||
vec3 biomeIndirect = skyLightPhased;
|
||||
float inBiome = BiomeVLFogColors(biomeDirect, biomeIndirect);
|
||||
#endif
|
||||
|
||||
skyLightPhased = max(skyLightPhased + skyLightPhased*(normalize(wpos).y*0.9+0.1),0.0);
|
||||
@ -200,7 +201,13 @@ vec4 GetVolumetricFog(
|
||||
sh *= GetCloudShadow_VLFOG(progressW, WsunVec);
|
||||
#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)
|
||||
float density = densityVol*300.0;
|
||||
|
||||
@ -213,11 +220,18 @@ vec4 GetVolumetricFog(
|
||||
vec3 rL = rC*airCoef.x;
|
||||
vec3 m = (airCoef.y+density) * mC;
|
||||
|
||||
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);
|
||||
#ifdef PER_BIOME_ENVIRONMENT
|
||||
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 foglighting = (Atmosphere + DirectLight + Lightning) * lightleakfix;
|
||||
|
||||
|
||||
|
||||
color += (foglighting - foglighting * exp(-(rL+m)*dd*dL)) / ((rL+m)+0.00000001)*absorbance;
|
||||
absorbance *= clamp(exp(-(rL+m)*dd*dL),0.0,1.0);
|
||||
|
Reference in New Issue
Block a user