mirror of
https://github.com/X0nk/Bliss-Shader.git
synced 2025-06-26 18:22:33 +08:00
allow volumetric fog to intersect volumetric clouds
This commit is contained in:
@ -395,11 +395,11 @@ vec3 alterCoords(in vec3 coords, bool lighting){
|
|||||||
|
|
||||||
float theDistance = length(coords + (lighting ? vec3(0.0) : cameraPosition));
|
float theDistance = length(coords + (lighting ? vec3(0.0) : cameraPosition));
|
||||||
|
|
||||||
coords.x = max(coords.x,0.0);
|
coords.x = coords.x*3;
|
||||||
|
|
||||||
coords.y = coords.y;
|
coords.y = coords.y;
|
||||||
|
|
||||||
coords.z = coords.z/3;
|
coords.z = coords.z*3;
|
||||||
|
|
||||||
return coords;
|
return coords;
|
||||||
}
|
}
|
||||||
@ -442,7 +442,8 @@ vec4 raymarchTest(
|
|||||||
// float cloudRange = mix(max(cameraPosition.y - maxHeight,0.0), max(minHeight - cameraPosition.y,0.0), clamp(rayDirection.y,0.0,1.0));
|
// float cloudRange = mix(max(cameraPosition.y - maxHeight,0.0), max(minHeight - cameraPosition.y,0.0), clamp(rayDirection.y,0.0,1.0));
|
||||||
|
|
||||||
|
|
||||||
vec3 rayProgress = rayDirection*dither.x + cameraPosition + (rayDirection / length(alterCoords(rayDirection, false))) * 200;
|
|
||||||
|
vec3 rayProgress = rayDirection + cameraPosition + (rayDirection / length(alterCoords(rayDirection, false))) * 200.0;
|
||||||
|
|
||||||
float dL = length(rayDirection);
|
float dL = length(rayDirection);
|
||||||
|
|
||||||
@ -530,11 +531,12 @@ void main() {
|
|||||||
vec3 directLightColor = lightCol.rgb / 2400.0;
|
vec3 directLightColor = lightCol.rgb / 2400.0;
|
||||||
vec3 indirectLightColor = averageSkyCol / 1200.0;
|
vec3 indirectLightColor = averageSkyCol / 1200.0;
|
||||||
vec3 indirectLightColor_dynamic = averageSkyCol_Clouds / 1200.0;
|
vec3 indirectLightColor_dynamic = averageSkyCol_Clouds / 1200.0;
|
||||||
|
float cloudPlaneDistance = 0.0;
|
||||||
|
|
||||||
#if defined OVERWORLD_SHADER
|
#if defined OVERWORLD_SHADER
|
||||||
// z0 = texture2D(depthtex0, tc + jitter/VL_RENDER_RESOLUTION).x;
|
// z0 = texture2D(depthtex0, tc + jitter/VL_RENDER_RESOLUTION).x;
|
||||||
// viewPos0 = toScreenSpace_DH(tc/RENDER_SCALE, z0, DH_z0);
|
// viewPos0 = toScreenSpace_DH(tc/RENDER_SCALE, z0, DH_z0);
|
||||||
vec4 VolumetricClouds = GetVolumetricClouds(viewPos0, BN, WsunVec, directLightColor, indirectLightColor);
|
vec4 VolumetricClouds = GetVolumetricClouds(viewPos0, BN, WsunVec, directLightColor, indirectLightColor, cloudPlaneDistance);
|
||||||
|
|
||||||
#ifdef CAVE_FOG
|
#ifdef CAVE_FOG
|
||||||
|
|
||||||
@ -548,7 +550,7 @@ void main() {
|
|||||||
float atmosphereAlpha = 1.0;
|
float atmosphereAlpha = 1.0;
|
||||||
|
|
||||||
vec3 sceneColor = texelFetch2D(colortex3,ivec2(tc/texelSize),0).rgb * VolumetricClouds.a + VolumetricClouds.rgb;
|
vec3 sceneColor = texelFetch2D(colortex3,ivec2(tc/texelSize),0).rgb * VolumetricClouds.a + VolumetricClouds.rgb;
|
||||||
vec4 VolumetricFog = GetVolumetricFog(viewPos0, WsunVec, BN, directLightColor, indirectLightColor, indirectLightColor_dynamic, atmosphereAlpha, VolumetricClouds.rgb);
|
vec4 VolumetricFog = GetVolumetricFog(viewPos0, WsunVec, BN, directLightColor, indirectLightColor, indirectLightColor_dynamic, atmosphereAlpha, VolumetricClouds.rgb, cloudPlaneDistance);
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
@ -558,7 +560,6 @@ void main() {
|
|||||||
|
|
||||||
#if defined OVERWORLD_SHADER
|
#if defined OVERWORLD_SHADER
|
||||||
VolumetricFog = vec4(VolumetricClouds.rgb * VolumetricFog.a + VolumetricFog.rgb, VolumetricFog.a*VolumetricClouds.a);
|
VolumetricFog = vec4(VolumetricClouds.rgb * VolumetricFog.a + VolumetricFog.rgb, VolumetricFog.a*VolumetricClouds.a);
|
||||||
// VolumetricFog = vec4(VolumetricClouds.rgb * VolumetricFog.a + VolumetricFog.rgb, VolumetricFog.a*VolumetricClouds.a);
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
if (isEyeInWater == 1){
|
if (isEyeInWater == 1){
|
||||||
@ -574,8 +575,10 @@ void main() {
|
|||||||
|
|
||||||
// VolumetricFog = raymarchTest(viewPos0, BN);
|
// VolumetricFog = raymarchTest(viewPos0, BN);
|
||||||
|
|
||||||
gl_FragData[0] = clamp(VolumetricFog, 0.0, 65000.0);
|
|
||||||
|
|
||||||
|
gl_FragData[0] = clamp(VolumetricFog, 0.0, 65000.0);
|
||||||
|
// gl_FragData[0] = clamp(vec4(vec3(cloudPlaneDistance/1000.0),0), 0.0, 65000.0);
|
||||||
|
//
|
||||||
|
|
||||||
// vec4 currentFrame = VolumetricFog;
|
// vec4 currentFrame = VolumetricFog;
|
||||||
// vec4 previousFrame = texture2D(colortex10, gl_FragCoord.xy * texelSize);
|
// vec4 previousFrame = texture2D(colortex10, gl_FragCoord.xy * texelSize);
|
||||||
|
@ -332,6 +332,7 @@ vec4 VLTemporalFiltering(vec3 viewPos, bool depthCheck, out float DEBUG){
|
|||||||
previousPosition.xy = texcoord + velocity;
|
previousPosition.xy = texcoord + velocity;
|
||||||
|
|
||||||
vec4 currentFrame = texture2D(colortex0, VLtexCoord);
|
vec4 currentFrame = texture2D(colortex0, VLtexCoord);
|
||||||
|
// return currentFrame;
|
||||||
|
|
||||||
if (previousPosition.x < 0.0 || previousPosition.y < 0.0 || previousPosition.x > 1.0 || previousPosition.y > 1.0) return currentFrame;
|
if (previousPosition.x < 0.0 || previousPosition.y < 0.0 || previousPosition.x > 1.0 || previousPosition.y > 1.0) return currentFrame;
|
||||||
|
|
||||||
|
@ -343,10 +343,11 @@ if (gl_FragCoord.x > 18.+257. && gl_FragCoord.y > 1. && gl_FragCoord.x < 18+257+
|
|||||||
suncol = vec3(0.0);
|
suncol = vec3(0.0);
|
||||||
#endif
|
#endif
|
||||||
float rejection = 1.0;
|
float rejection = 1.0;
|
||||||
vec4 volumetricClouds = GetVolumetricClouds(viewPos, vec2(noise, 1.0-noise), WsunVec, suncol*2.5, skyGroundCol/30.0);
|
float cloudPlaneDistance = 0.0;
|
||||||
|
vec4 volumetricClouds = GetVolumetricClouds(viewPos, vec2(noise, 1.0-noise), WsunVec, suncol*2.5, skyGroundCol/30.0, cloudPlaneDistance);
|
||||||
|
|
||||||
float atmosphereAlpha = 1.0;
|
float atmosphereAlpha = 1.0;
|
||||||
vec4 volumetricFog = GetVolumetricFog(viewPos, WsunVec, vec2(noise, 1.0-noise), suncol*2.5, skyGroundCol/30.0, averageSkyCol_Clouds*5.0, atmosphereAlpha, volumetricClouds.rgb);
|
vec4 volumetricFog = GetVolumetricFog(viewPos, WsunVec, vec2(noise, 1.0-noise), suncol*2.5, skyGroundCol/30.0, averageSkyCol_Clouds*5.0, atmosphereAlpha, volumetricClouds.rgb, cloudPlaneDistance);
|
||||||
|
|
||||||
sky = sky * volumetricClouds.a + volumetricClouds.rgb / 5.0;
|
sky = sky * volumetricClouds.a + volumetricClouds.rgb / 5.0;
|
||||||
sky = sky * volumetricFog.a + volumetricFog.rgb / 5.0;
|
sky = sky * volumetricFog.a + volumetricFog.rgb / 5.0;
|
||||||
|
@ -353,13 +353,14 @@ void main() {
|
|||||||
indirectLightColor_dynamic += vec3(TORCH_R,TORCH_G,TORCH_B) * pow(1.0-sqrt(1.0-clamp(lightmap.x,0.0,1.0)),2.0) * TORCH_AMOUNT;
|
indirectLightColor_dynamic += vec3(TORCH_R,TORCH_G,TORCH_B) * pow(1.0-sqrt(1.0-clamp(lightmap.x,0.0,1.0)),2.0) * TORCH_AMOUNT;
|
||||||
|
|
||||||
vec4 finalVolumetrics = vec4(0.0,0.0,0.0,1.0);
|
vec4 finalVolumetrics = vec4(0.0,0.0,0.0,1.0);
|
||||||
|
float cloudPlaneDistance = 0.0;
|
||||||
|
|
||||||
if(!iswater){
|
if(!iswater){
|
||||||
#ifdef OVERWORLD_SHADER
|
#ifdef OVERWORLD_SHADER
|
||||||
vec4 VolumetricClouds = GetVolumetricClouds(viewPos1, vec2(noise_1, noise_2), WsunVec, directLightColor, indirectLightColor);
|
vec4 VolumetricClouds = GetVolumetricClouds(viewPos1, vec2(noise_1, noise_2), WsunVec, directLightColor, indirectLightColor,cloudPlaneDistance);
|
||||||
|
|
||||||
float atmosphereAlpha = 1.0;
|
float atmosphereAlpha = 1.0;
|
||||||
vec4 VolumetricFog = GetVolumetricFog(viewPos1, WsunVec, vec2(noise_1, noise_2), directLightColor, indirectLightColor, indirectLightColor_dynamic, atmosphereAlpha, VolumetricClouds.rgb);
|
vec4 VolumetricFog = GetVolumetricFog(viewPos1, WsunVec, vec2(noise_1, noise_2), directLightColor, indirectLightColor, indirectLightColor_dynamic, atmosphereAlpha, VolumetricClouds.rgb,cloudPlaneDistance);
|
||||||
|
|
||||||
finalVolumetrics.rgb += VolumetricClouds.rgb;
|
finalVolumetrics.rgb += VolumetricClouds.rgb;
|
||||||
#endif
|
#endif
|
||||||
|
@ -76,7 +76,8 @@ vec4 GetVolumetricFog(
|
|||||||
in vec3 AmbientColor,
|
in vec3 AmbientColor,
|
||||||
in vec3 AveragedAmbientColor,
|
in vec3 AveragedAmbientColor,
|
||||||
inout float atmosphereAlpha,
|
inout float atmosphereAlpha,
|
||||||
inout vec3 sceneColor
|
inout vec3 sceneColor,
|
||||||
|
in float cloudPlaneDistance
|
||||||
){
|
){
|
||||||
#ifndef TOGGLE_VL_FOG
|
#ifndef TOGGLE_VL_FOG
|
||||||
return vec4(0.0,0.0,0.0,1.0);
|
return vec4(0.0,0.0,0.0,1.0);
|
||||||
@ -165,14 +166,17 @@ vec4 GetVolumetricFog(
|
|||||||
// SkyLightColor *= lightLevelZero*0.9 + 0.1;
|
// SkyLightColor *= lightLevelZero*0.9 + 0.1;
|
||||||
vec3 finalsceneColor = vec3(0.0);
|
vec3 finalsceneColor = vec3(0.0);
|
||||||
|
|
||||||
|
|
||||||
for (int i = 0; i < SAMPLECOUNT; i++) {
|
for (int i = 0; i < SAMPLECOUNT; i++) {
|
||||||
float d = (pow(expFactor, float(i+dither.x)/float(SAMPLECOUNT))/expFactor - 1.0/expFactor)/(1-1.0/expFactor);
|
float d = (pow(expFactor, float(i+dither.x)/float(SAMPLECOUNT))/expFactor - 1.0/expFactor)/(1-1.0/expFactor);
|
||||||
float dd = pow(expFactor, float(i+dither.y)/float(SAMPLECOUNT)) * log(expFactor) / float(SAMPLECOUNT)/(expFactor-1.0);
|
float dd = pow(expFactor, float(i+dither.y)/float(SAMPLECOUNT)) * log(expFactor) / float(SAMPLECOUNT)/(expFactor-1.0);
|
||||||
|
|
||||||
|
// check if the fog intersects clouds
|
||||||
|
if(length(d*dVWorld) > cloudPlaneDistance) break;
|
||||||
|
|
||||||
progress = start.xyz + d*dV;
|
progress = start.xyz + d*dV;
|
||||||
progressW = gbufferModelViewInverse[3].xyz + cameraPosition + d*dVWorld;
|
progressW = gbufferModelViewInverse[3].xyz + cameraPosition + d*dVWorld;
|
||||||
|
|
||||||
// if(length(progressW-cameraPosition) > cloudDepth) break;
|
|
||||||
//------------------------------------
|
//------------------------------------
|
||||||
//------ SAMPLE SHADOWS FOR FOG EFFECTS
|
//------ SAMPLE SHADOWS FOR FOG EFFECTS
|
||||||
//------------------------------------
|
//------------------------------------
|
||||||
@ -270,16 +274,12 @@ vec4 GetVolumetricFog(
|
|||||||
//------------------------------------
|
//------------------------------------
|
||||||
//------ ATMOSPHERE HAZE EFFECT
|
//------ ATMOSPHERE HAZE EFFECT
|
||||||
//------------------------------------
|
//------------------------------------
|
||||||
#if defined CloudLayer0 && defined VOLUMETRIC_CLOUDS
|
|
||||||
float cloudPlaneCutoff = clamp((CloudLayer0_height + max(eyeAltitude-(CloudLayer0_height-100),0)) - progressW.y,0.0,1.0);
|
|
||||||
#else
|
|
||||||
float cloudPlaneCutoff = 1.0;
|
|
||||||
#endif
|
|
||||||
// maximum range for atmosphere haze, basically.
|
// maximum range for atmosphere haze, basically.
|
||||||
float planetVolume = 1.0 - exp(clamp(1.0 - length(progressW-cameraPosition) / (16*150), 0.0,1.0) * -10);
|
float planetVolume = 1.0 - exp(clamp(1.0 - length(progressW-cameraPosition) / (16*150), 0.0,1.0) * -10);
|
||||||
|
|
||||||
// just air
|
// just air
|
||||||
vec2 airCoef = (exp2(-max(progressW.y-SEA_LEVEL,0.0)/vec2(8.0e3, 1.2e3)*vec2(6.,7.0)) * 192.0 * Haze_amount) * cloudPlaneCutoff * planetVolume;
|
vec2 airCoef = (exp2(-max(progressW.y-SEA_LEVEL,0.0)/vec2(8.0e3, 1.2e3)*vec2(6.,7.0)) * 192.0 * Haze_amount) * planetVolume;
|
||||||
|
|
||||||
// Pbr for air, yolo mix between mie and rayleigh for water droplets
|
// Pbr for air, yolo mix between mie and rayleigh for water droplets
|
||||||
vec3 rL = rC*airCoef.x;
|
vec3 rL = rC*airCoef.x;
|
||||||
@ -291,10 +291,10 @@ vec4 GetVolumetricFog(
|
|||||||
vec3 Atmosphere = (LightSourcePhased * sh * (rayL*rL + sunPhase*m) + AveragedAmbientColor * (rL+m) * (lightLevelZero*0.99 + 0.01)) * inACave;
|
vec3 Atmosphere = (LightSourcePhased * sh * (rayL*rL + sunPhase*m) + AveragedAmbientColor * (rL+m) * (lightLevelZero*0.99 + 0.01)) * inACave;
|
||||||
color += (Atmosphere - Atmosphere * atmosphereVolumeCoeff) / (rL+m+1e-6) * atmosphereAbsorbance;
|
color += (Atmosphere - Atmosphere * atmosphereVolumeCoeff) / (rL+m+1e-6) * atmosphereAbsorbance;
|
||||||
|
|
||||||
// finalsceneColor = sceneColor * totalAbsorbance;
|
|
||||||
|
|
||||||
atmosphereAbsorbance *= atmosphereVolumeCoeff*fogVolumeCoeff;
|
atmosphereAbsorbance *= atmosphereVolumeCoeff*fogVolumeCoeff;
|
||||||
|
|
||||||
|
// totalAbsorbance *= dot(atmosphereVolumeCoeff,vec3(0.33333));
|
||||||
|
|
||||||
//------------------------------------
|
//------------------------------------
|
||||||
//------ LPV FOG EFFECT
|
//------ LPV FOG EFFECT
|
||||||
//------------------------------------
|
//------------------------------------
|
||||||
|
@ -237,11 +237,13 @@ vec4 raymarchCloud(
|
|||||||
float distanceFade,
|
float distanceFade,
|
||||||
|
|
||||||
float referenceDistance,
|
float referenceDistance,
|
||||||
vec3 sampledSkyCol
|
vec3 sampledSkyCol,
|
||||||
|
|
||||||
|
inout vec2 cloudPlaneDistance
|
||||||
){
|
){
|
||||||
vec3 color = vec3(0.0);
|
vec3 color = vec3(0.0);
|
||||||
float totalAbsorbance = 1.0;
|
float totalAbsorbance = 1.0;
|
||||||
|
float GetPos = 0.0;
|
||||||
|
|
||||||
float planetShadow = getPlanetShadow(rayPosition, sunVector);
|
float planetShadow = getPlanetShadow(rayPosition, sunVector);
|
||||||
sunScattering *= planetShadow;
|
sunScattering *= planetShadow;
|
||||||
@ -249,6 +251,7 @@ vec4 raymarchCloud(
|
|||||||
|
|
||||||
float distanceFactor = length(rayDirection);
|
float distanceFactor = length(rayDirection);
|
||||||
|
|
||||||
|
|
||||||
if(LayerIndex == ALTOSTRATUS_LAYER){
|
if(LayerIndex == ALTOSTRATUS_LAYER){
|
||||||
float density = dailyWeatherParams1.z;
|
float density = dailyWeatherParams1.z;
|
||||||
|
|
||||||
@ -267,6 +270,9 @@ vec4 raymarchCloud(
|
|||||||
|
|
||||||
// check if the pixel has visible clouds before doing work.
|
// check if the pixel has visible clouds before doing work.
|
||||||
if(shapeWithDensity > 1e-5){
|
if(shapeWithDensity > 1e-5){
|
||||||
|
|
||||||
|
cloudPlaneDistance.x = length(rayPosition - cameraPosition); cloudPlaneDistance.y = 0.0;
|
||||||
|
|
||||||
// can add the initial cloud shape sample for a free shadow starting step :D
|
// can add the initial cloud shape sample for a free shadow starting step :D
|
||||||
float sunShadowMask = (shapeWithDensity + getCloudScattering(LayerIndex, rayPosition, sunVector, dither, minHeight, maxHeight, density)) * (1.0-abs(WsunVec.y));
|
float sunShadowMask = (shapeWithDensity + getCloudScattering(LayerIndex, rayPosition, sunVector, dither, minHeight, maxHeight, density)) * (1.0-abs(WsunVec.y));
|
||||||
float indirectShadowMask = 0.5;
|
float indirectShadowMask = 0.5;
|
||||||
@ -290,6 +296,8 @@ vec4 raymarchCloud(
|
|||||||
}
|
}
|
||||||
|
|
||||||
if(LayerIndex < ALTOSTRATUS_LAYER){
|
if(LayerIndex < ALTOSTRATUS_LAYER){
|
||||||
|
|
||||||
|
|
||||||
float density = dailyWeatherParams1.x;
|
float density = dailyWeatherParams1.x;
|
||||||
|
|
||||||
if(LayerIndex == LARGECUMULUS_LAYER) density = dailyWeatherParams1.y;
|
if(LayerIndex == LARGECUMULUS_LAYER) density = dailyWeatherParams1.y;
|
||||||
@ -304,8 +312,10 @@ vec4 raymarchCloud(
|
|||||||
skylightOcclusion = mix(1.0, skylightOcclusion, distanceFade);
|
skylightOcclusion = mix(1.0, skylightOcclusion, distanceFade);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
|
||||||
for(int i = 0; i < int(samples); i++) {
|
for(int i = 0; i < int(samples); i++) {
|
||||||
|
|
||||||
|
|
||||||
// check if the ray staring position is going farther than the reference distance, if yes, dont begin marching. this is to check for intersections with the world.
|
// check if the ray staring position is going farther than the reference distance, if yes, dont begin marching. this is to check for intersections with the world.
|
||||||
#ifndef VL_CLOUDS_DEFERRED
|
#ifndef VL_CLOUDS_DEFERRED
|
||||||
if(length(rayPosition - cameraPosition) > referenceDistance) break;
|
if(length(rayPosition - cameraPosition) > referenceDistance) break;
|
||||||
@ -318,8 +328,12 @@ vec4 raymarchCloud(
|
|||||||
float shapeWithDensity = shape*density;
|
float shapeWithDensity = shape*density;
|
||||||
float shapeWithDensityFaded = shape*density * pow(clamp((rayPosition.y - minHeight)/(max(maxHeight-minHeight,1.0)*0.25),0.0,1.0),2.0);
|
float shapeWithDensityFaded = shape*density * pow(clamp((rayPosition.y - minHeight)/(max(maxHeight-minHeight,1.0)*0.25),0.0,1.0),2.0);
|
||||||
|
|
||||||
|
|
||||||
// check if the pixel has visible clouds before doing work.
|
// check if the pixel has visible clouds before doing work.
|
||||||
if(shapeWithDensityFaded > 1e-5){
|
if(shapeWithDensityFaded > 1e-5){
|
||||||
|
|
||||||
|
cloudPlaneDistance.x = length(rayPosition - cameraPosition); cloudPlaneDistance.y = 0.0;
|
||||||
|
|
||||||
// can add the initial cloud shape sample for a free shadow starting step :D
|
// can add the initial cloud shape sample for a free shadow starting step :D
|
||||||
float indirectShadowMask = 1.0 - min(max(rayPosition.y - minHeight,0.0) / max(maxHeight-minHeight,1.0), 1.0);
|
float indirectShadowMask = 1.0 - min(max(rayPosition.y - minHeight,0.0) / max(maxHeight-minHeight,1.0), 1.0);
|
||||||
float sunShadowMask = shapeWithDensity + getCloudScattering(LayerIndex, rayPosition, sunVector, dither, minHeight, maxHeight, density);
|
float sunShadowMask = shapeWithDensity + getCloudScattering(LayerIndex, rayPosition, sunVector, dither, minHeight, maxHeight, density);
|
||||||
@ -348,18 +362,21 @@ vec4 raymarchCloud(
|
|||||||
vec3 atmosphereHaze = (sampledSkyCol - sampledSkyCol * distancefog);
|
vec3 atmosphereHaze = (sampledSkyCol - sampledSkyCol * distancefog);
|
||||||
lighting = lighting * distancefog + atmosphereHaze;
|
lighting = lighting * distancefog + atmosphereHaze;
|
||||||
|
|
||||||
|
|
||||||
float densityCoeff = exp(-distanceFactor*shapeWithDensityFaded);
|
float densityCoeff = exp(-distanceFactor*shapeWithDensityFaded);
|
||||||
color += (lighting - lighting * densityCoeff) * totalAbsorbance;
|
color += (lighting - lighting * densityCoeff) * totalAbsorbance;
|
||||||
totalAbsorbance *= densityCoeff;
|
totalAbsorbance *= densityCoeff;
|
||||||
|
|
||||||
// check if you can see through the cloud on the pixel before doing the next iteration
|
// check if you can see through the cloud on the pixel before doing the next iteration
|
||||||
if (totalAbsorbance < 1e-5) break;
|
if (totalAbsorbance < 1e-5) break;
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
rayPosition += rayDirection;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
rayPosition += rayDirection;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
return vec4(color, totalAbsorbance);
|
return vec4(color, totalAbsorbance);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -391,7 +408,9 @@ vec4 GetVolumetricClouds(
|
|||||||
vec2 dither,
|
vec2 dither,
|
||||||
vec3 sunVector,
|
vec3 sunVector,
|
||||||
vec3 directLightCol,
|
vec3 directLightCol,
|
||||||
vec3 indirectLightCol
|
vec3 indirectLightCol,
|
||||||
|
|
||||||
|
inout float cloudPlaneDistance
|
||||||
){
|
){
|
||||||
#ifndef VOLUMETRIC_CLOUDS
|
#ifndef VOLUMETRIC_CLOUDS
|
||||||
return vec4(0.0,0.0,0.0,1.0);
|
return vec4(0.0,0.0,0.0,1.0);
|
||||||
@ -438,6 +457,20 @@ vec4 GetVolumetricClouds(
|
|||||||
vec3 rayDirection = NormPlayerPos.xyz * (cloudheight/length(NormPlayerPos.xyz/cloudDist)/samples);
|
vec3 rayDirection = NormPlayerPos.xyz * (cloudheight/length(NormPlayerPos.xyz/cloudDist)/samples);
|
||||||
vec3 rayPosition = getRayOrigin(rayDirection, cameraPosition, dither.y, minHeight, maxHeight);
|
vec3 rayPosition = getRayOrigin(rayDirection, cameraPosition, dither.y, minHeight, maxHeight);
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
// setup for getting distance
|
||||||
|
vec3 playerPos = mat3(gbufferModelViewInverse) * viewPos;
|
||||||
|
#ifdef DISTANT_HORIZONS
|
||||||
|
float maxLength = min(length(playerPos), max(far, dhRenderDistance))/length(playerPos);
|
||||||
|
#else
|
||||||
|
float maxLength = min(length(playerPos), far)/length(playerPos);
|
||||||
|
#endif
|
||||||
|
playerPos *= maxLength;
|
||||||
|
|
||||||
|
float startDistance = length(playerPos);
|
||||||
|
|
||||||
|
|
||||||
///------- do color stuff outside of the raymarcher loop
|
///------- do color stuff outside of the raymarcher loop
|
||||||
vec3 sunScattering = directLightCol * (phaseCloud(SdotV, 0.85) + phaseCloud(SdotV, 0.75)) * 3.14;
|
vec3 sunScattering = directLightCol * (phaseCloud(SdotV, 0.85) + phaseCloud(SdotV, 0.75)) * 3.14;
|
||||||
vec3 sunMultiScattering = directLightCol * 0.8;// * (phaseCloud(SdotV, 0.35) + phaseCloud(-SdotV, 0.35) * 0.5) * 6.28;
|
vec3 sunMultiScattering = directLightCol * 0.8;// * (phaseCloud(SdotV, 0.35) + phaseCloud(-SdotV, 0.35) * 0.5) * 6.28;
|
||||||
@ -468,8 +501,9 @@ vec4 GetVolumetricClouds(
|
|||||||
////------- RENDER SMALL CUMULUS CLOUDS
|
////------- RENDER SMALL CUMULUS CLOUDS
|
||||||
vec4 smallCumulusClouds = cloudColor;
|
vec4 smallCumulusClouds = cloudColor;
|
||||||
|
|
||||||
|
vec2 cloudLayer0_Distance = vec2(startDistance, 1.0);
|
||||||
#ifdef CloudLayer0
|
#ifdef CloudLayer0
|
||||||
smallCumulusClouds = raymarchCloud(SMALLCUMULUS_LAYER, samples, rayPosition, rayDirection, dither.x, minHeight, maxHeight, unignedSunVec, sunScattering, sunMultiScattering, skyScattering, distanceFade, lViewPosM, sampledSkyCol);
|
smallCumulusClouds = raymarchCloud(SMALLCUMULUS_LAYER, samples, rayPosition, rayDirection, dither.x, minHeight, maxHeight, unignedSunVec, sunScattering, sunMultiScattering, skyScattering, distanceFade, lViewPosM, sampledSkyCol, cloudLayer0_Distance);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
////------- RENDER LARGE CUMULUS CLOUDS
|
////------- RENDER LARGE CUMULUS CLOUDS
|
||||||
@ -484,7 +518,8 @@ vec4 GetVolumetricClouds(
|
|||||||
rayDirection = NormPlayerPos.xyz * (cloudheight/length(NormPlayerPos.xyz/cloudDist)/samples);
|
rayDirection = NormPlayerPos.xyz * (cloudheight/length(NormPlayerPos.xyz/cloudDist)/samples);
|
||||||
rayPosition = getRayOrigin(rayDirection, cameraPosition, dither.y, minHeight, maxHeight);
|
rayPosition = getRayOrigin(rayDirection, cameraPosition, dither.y, minHeight, maxHeight);
|
||||||
|
|
||||||
if(smallCumulusClouds.a > 1e-5) largeCumulusClouds = raymarchCloud(LARGECUMULUS_LAYER, samples, rayPosition, rayDirection, dither.x, minHeight, maxHeight, unignedSunVec, sunScattering, sunMultiScattering, skyScattering, distanceFade, lViewPosM, sampledSkyCol);
|
vec2 cloudLayer1_Distance = vec2(startDistance, 1.0);
|
||||||
|
if(smallCumulusClouds.a > 1e-5) largeCumulusClouds = raymarchCloud(LARGECUMULUS_LAYER, samples, rayPosition, rayDirection, dither.x, minHeight, maxHeight, unignedSunVec, sunScattering, sunMultiScattering, skyScattering, distanceFade, lViewPosM, sampledSkyCol, cloudLayer1_Distance);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
////------- RENDER ALTOSTRATUS CLOUDS
|
////------- RENDER ALTOSTRATUS CLOUDS
|
||||||
@ -499,11 +534,25 @@ vec4 GetVolumetricClouds(
|
|||||||
rayDirection = NormPlayerPos.xyz * (cloudheight/length(NormPlayerPos.xyz/cloudDist));
|
rayDirection = NormPlayerPos.xyz * (cloudheight/length(NormPlayerPos.xyz/cloudDist));
|
||||||
rayPosition = getRayOrigin(rayDirection, cameraPosition, dither.y, minHeight, maxHeight);
|
rayPosition = getRayOrigin(rayDirection, cameraPosition, dither.y, minHeight, maxHeight);
|
||||||
|
|
||||||
if(smallCumulusClouds.a > 1e-5 || largeCumulusClouds.a > 1e-5) altoStratusClouds = raymarchCloud(ALTOSTRATUS_LAYER, samples, rayPosition, rayDirection, dither.x, minHeight, maxHeight, unignedSunVec, sunScattering, sunMultiScattering, skyScattering, distanceFade, lViewPosM, sampledSkyCol);
|
vec2 cloudLayer2_Distance = vec2(startDistance, 1.0);
|
||||||
|
if(smallCumulusClouds.a > 1e-5 || largeCumulusClouds.a > 1e-5) altoStratusClouds = raymarchCloud(ALTOSTRATUS_LAYER, samples, rayPosition, rayDirection, dither.x, minHeight, maxHeight, unignedSunVec, sunScattering, sunMultiScattering, skyScattering, distanceFade, lViewPosM, sampledSkyCol, cloudLayer2_Distance);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
////------- BLEND LAYERS
|
////------- BLEND LAYERS
|
||||||
|
|
||||||
|
#if defined CloudLayer0 && !defined CloudLayer1 && !defined CloudLayer2
|
||||||
|
cloudPlaneDistance = cloudLayer1_Distance.x;
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#if defined CloudLayer0 && defined CloudLayer1 && !defined CloudLayer2
|
||||||
|
cloudPlaneDistance = mix(cloudLayer0_Distance.x, cloudLayer1_Distance.x, cloudLayer0_Distance.y);
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#if defined CloudLayer0 && defined CloudLayer1 && defined CloudLayer2
|
||||||
|
cloudPlaneDistance = mix(cloudLayer2_Distance.x, cloudLayer1_Distance.x, cloudLayer2_Distance.y);
|
||||||
|
cloudPlaneDistance = mix(cloudLayer0_Distance.x, cloudPlaneDistance, cloudLayer0_Distance.y);
|
||||||
|
#endif
|
||||||
|
|
||||||
#ifdef CloudLayer2
|
#ifdef CloudLayer2
|
||||||
cloudColor = altoStratusClouds;
|
cloudColor = altoStratusClouds;
|
||||||
#endif
|
#endif
|
||||||
@ -511,6 +560,8 @@ vec4 GetVolumetricClouds(
|
|||||||
cloudColor.rgb *= largeCumulusClouds.a;
|
cloudColor.rgb *= largeCumulusClouds.a;
|
||||||
cloudColor.rgb += largeCumulusClouds.rgb;
|
cloudColor.rgb += largeCumulusClouds.rgb;
|
||||||
cloudColor.a *= largeCumulusClouds.a;
|
cloudColor.a *= largeCumulusClouds.a;
|
||||||
|
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
#ifdef CloudLayer0
|
#ifdef CloudLayer0
|
||||||
cloudColor.rgb *= smallCumulusClouds.a;
|
cloudColor.rgb *= smallCumulusClouds.a;
|
||||||
|
Reference in New Issue
Block a user