mirror of
https://github.com/X0nk/Bliss-Shader.git
synced 2025-06-22 00:37:35 +08:00
Add the whole ass shader
it has begun
This commit is contained in:
182
shaders/lib/ROBOBO_sky.glsl
Normal file
182
shaders/lib/ROBOBO_sky.glsl
Normal file
@ -0,0 +1,182 @@
|
||||
// uniform float LowCoverage;
|
||||
|
||||
// uniform float isDeserts;
|
||||
const float sunAngularSize = 0.533333;
|
||||
const float moonAngularSize = 0.516667;
|
||||
|
||||
//Sky coefficients and heights
|
||||
|
||||
#define airNumberDensity 2.5035422e25
|
||||
#define ozoneConcentrationPeak 8e-6
|
||||
const float ozoneNumberDensity = airNumberDensity * ozoneConcentrationPeak;
|
||||
#define ozoneCrossSection vec3(4.51103766177301e-21, 3.2854797958699e-21, 1.96774621921165e-22)
|
||||
|
||||
#define sky_planetRadius 6731e3
|
||||
|
||||
#define sky_atmosphereHeight 110e3
|
||||
#define sky_scaleHeights vec2(8.0e3, 1.2e3)
|
||||
|
||||
#define sky_mieg 0.80 //[0.0 0.01 0.02 0.03 0.04 0.05 0.06 0.07 0.08 0.09 0.1 0.11 0.12 0.13 0.14 0.15 0.16 0.17 0.18 0.19 0.2 0.21 0.22 0.23 0.24 0.25 0.26 0.27 0.28 0.29 0.3 0.31 0.32 0.33 0.34 0.35 0.36 0.37 0.38 0.39 0.4 0.41 0.42 0.43 0.44 0.45 0.46 0.47 0.48 0.49 0.5 0.51 0.52 0.53 0.54 0.55 0.56 0.57 0.58 0.59 0.6 0.61 0.62 0.63 0.64 0.65 0.66 0.67 0.68 0.69 0.7 0.71 0.72 0.73 0.74 0.75 0.76 0.77 0.78 0.79 0.8 0.81 0.82 0.83 0.84 0.85 0.86 0.87 0.88 0.89 0.9 0.91 0.92 0.93 0.94 0.95 0.96 0.97 0.98 0.99 1.0 ]
|
||||
#define sky_coefficientRayleighR 5.8 //[0.0 0.1 0.2 0.3 0.4 0.5 0.6 0.7 0.8 0.9 1.0 1.1 1.2 1.3 1.4 1.5 1.6 1.7 1.8 1.9 2.0 2.1 2.2 2.3 2.4 2.5 2.6 2.7 2.8 2.9 3.0 3.1 3.2 3.3 3.4 3.5 3.6 3.7 3.8 3.9 4.0 4.1 4.2 4.3 4.4 4.5 4.6 4.7 4.8 4.9 5.0 5.1 5.2 5.3 5.4 5.5 5.6 5.7 5.8 5.9 6.0 6.1 6.2 6.3 6.4 6.5 6.6 6.7 6.8 6.9 7.0 7.1 7.2 7.3 7.4 7.5 7.6 7.7 7.8 7.9 8.0 8.1 8.2 8.3 8.4 8.5 8.6 8.7 8.8 8.9 9.0 9.1 9.2 9.3 9.4 9.5 9.6 9.7 9.8 9.9 10.0 ]
|
||||
#define sky_coefficientRayleighG 1.35 //[0.0 0.1 0.2 0.3 0.4 0.5 0.6 0.7 0.8 0.9 1.0 1.1 1.2 1.3 1.4 1.5 1.6 1.7 1.8 1.9 2.0 2.1 2.2 2.3 2.4 2.5 2.6 2.7 2.8 2.9 3.0 3.1 3.2 3.3 3.4 3.5 3.6 3.7 3.8 3.9 4.0 4.1 4.2 4.3 4.4 4.5 4.6 4.7 4.8 4.9 5.0 5.1 5.2 5.3 5.4 5.5 5.6 5.7 5.8 5.9 6.0 6.1 6.2 6.3 6.4 6.5 6.6 6.7 6.8 6.9 7.0 7.1 7.2 7.3 7.4 7.5 7.6 7.7 7.8 7.9 8.0 8.1 8.2 8.3 8.4 8.5 8.6 8.7 8.8 8.9 9.0 9.1 9.2 9.3 9.4 9.5 9.6 9.7 9.8 9.9 10.0 ]
|
||||
#define sky_coefficientRayleighB 3.31 //[0.0 0.1 0.2 0.3 0.4 0.5 0.6 0.7 0.8 0.9 1.0 1.1 1.2 1.3 1.4 1.5 1.6 1.7 1.8 1.9 2.0 2.1 2.2 2.3 2.4 2.5 2.6 2.7 2.8 2.9 3.0 3.1 3.2 3.3 3.4 3.5 3.6 3.7 3.8 3.9 4.0 4.1 4.2 4.3 4.4 4.5 4.6 4.7 4.8 4.9 5.0 5.1 5.2 5.3 5.4 5.5 5.6 5.7 5.8 5.9 6.0 6.1 6.2 6.3 6.4 6.5 6.6 6.7 6.8 6.9 7.0 7.1 7.2 7.3 7.4 7.5 7.6 7.7 7.8 7.9 8.0 8.1 8.2 8.3 8.4 8.5 8.6 8.7 8.8 8.9 9.0 9.1 9.2 9.3 9.4 9.5 9.6 9.7 9.8 9.9 10.0 ]
|
||||
|
||||
#define sky_coefficientRayleigh vec3(sky_coefficientRayleighR*1e-6, sky_coefficientRayleighG*1e-5, sky_coefficientRayleighB*1e-5)
|
||||
|
||||
|
||||
#define sky_coefficientMieR 3.0 //[0.0 0.1 0.2 0.3 0.4 0.5 0.6 0.7 0.8 0.9 1.0 1.1 1.2 1.3 1.4 1.5 1.6 1.7 1.8 1.9 2.0 2.1 2.2 2.3 2.4 2.5 2.6 2.7 2.8 2.9 3.0 3.1 3.2 3.3 3.4 3.5 3.6 3.7 3.8 3.9 4.0 4.1 4.2 4.3 4.4 4.5 4.6 4.7 4.8 4.9 5.0 5.1 5.2 5.3 5.4 5.5 5.6 5.7 5.8 5.9 6.0 6.1 6.2 6.3 6.4 6.5 6.6 6.7 6.8 6.9 7.0 7.1 7.2 7.3 7.4 7.5 7.6 7.7 7.8 7.9 8.0 8.1 8.2 8.3 8.4 8.5 8.6 8.7 8.8 8.9 9.0 9.1 9.2 9.3 9.4 9.5 9.6 9.7 9.8 9.9 10.0 ]
|
||||
#define sky_coefficientMieG 3.0 //[0.0 0.1 0.2 0.3 0.4 0.5 0.6 0.7 0.8 0.9 1.0 1.1 1.2 1.3 1.4 1.5 1.6 1.7 1.8 1.9 2.0 2.1 2.2 2.3 2.4 2.5 2.6 2.7 2.8 2.9 3.0 3.1 3.2 3.3 3.4 3.5 3.6 3.7 3.8 3.9 4.0 4.1 4.2 4.3 4.4 4.5 4.6 4.7 4.8 4.9 5.0 5.1 5.2 5.3 5.4 5.5 5.6 5.7 5.8 5.9 6.0 6.1 6.2 6.3 6.4 6.5 6.6 6.7 6.8 6.9 7.0 7.1 7.2 7.3 7.4 7.5 7.6 7.7 7.8 7.9 8.0 8.1 8.2 8.3 8.4 8.5 8.6 8.7 8.8 8.9 9.0 9.1 9.2 9.3 9.4 9.5 9.6 9.7 9.8 9.9 10.0 ]
|
||||
#define sky_coefficientMieB 3.0 //[0.0 0.1 0.2 0.3 0.4 0.5 0.6 0.7 0.8 0.9 1.0 1.1 1.2 1.3 1.4 1.5 1.6 1.7 1.8 1.9 2.0 2.1 2.2 2.3 2.4 2.5 2.6 2.7 2.8 2.9 3.0 3.1 3.2 3.3 3.4 3.5 3.6 3.7 3.8 3.9 4.0 4.1 4.2 4.3 4.4 4.5 4.6 4.7 4.8 4.9 5.0 5.1 5.2 5.3 5.4 5.5 5.6 5.7 5.8 5.9 6.0 6.1 6.2 6.3 6.4 6.5 6.6 6.7 6.8 6.9 7.0 7.1 7.2 7.3 7.4 7.5 7.6 7.7 7.8 7.9 8.0 8.1 8.2 8.3 8.4 8.5 8.6 8.7 8.8 8.9 9.0 9.1 9.2 9.3 9.4 9.5 9.6 9.7 9.8 9.9 10.0 ]
|
||||
|
||||
#define sky_coefficientMie vec3(sky_coefficientMieR*1e-6, sky_coefficientMieG*1e-6, sky_coefficientMieB*1e-6) // Should be >= 2e-6
|
||||
const vec3 sky_coefficientOzone = (ozoneCrossSection * (ozoneNumberDensity * 0.2e-6)); // ozone cross section * (ozone number density * (cm ^ 3))
|
||||
|
||||
const vec2 sky_inverseScaleHeights = 1.0 / sky_scaleHeights;
|
||||
const vec2 sky_scaledPlanetRadius = sky_planetRadius * sky_inverseScaleHeights;
|
||||
const float sky_atmosphereRadius = sky_planetRadius + sky_atmosphereHeight;
|
||||
const float sky_atmosphereRadiusSquared = sky_atmosphereRadius * sky_atmosphereRadius;
|
||||
|
||||
#define sky_coefficientsScattering mat2x3(sky_coefficientRayleigh, sky_coefficientMie)
|
||||
const mat3 sky_coefficientsAttenuation = mat3(sky_coefficientRayleigh , sky_coefficientMie, sky_coefficientOzone ); // commonly called the extinction coefficient
|
||||
|
||||
#define sun_illuminance 128000.0 //[10000.0 20000.0 30000.0 40000.0 50000.0 60000.0 70000.0 80000.0 90000.0 100000.0 110000.0 120000.0 130000.0 140000.0 160000.0]
|
||||
#define moon_illuminance 200.0 //[0.0 10.0 20.0 30.0 40.0 50.0 60.0 70.0 80.0 90.0 100.0 150.0 200.0 300.0 400.0 500.0 600.0 700.0 800.0 900.0 1000.0]
|
||||
|
||||
#define sunColorR 1.0 //[0.0 0.01 0.02 0.03 0.04 0.05 0.06 0.07 0.08 0.09 0.1 0.11 0.12 0.13 0.14 0.15 0.16 0.17 0.18 0.19 0.2 0.21 0.22 0.23 0.24 0.25 0.26 0.27 0.28 0.29 0.3 0.31 0.32 0.33 0.34 0.35 0.36 0.37 0.38 0.39 0.4 0.41 0.42 0.43 0.44 0.45 0.46 0.47 0.48 0.49 0.5 0.51 0.52 0.53 0.54 0.55 0.56 0.57 0.58 0.59 0.6 0.61 0.62 0.63 0.64 0.65 0.66 0.67 0.68 0.69 0.7 0.71 0.72 0.73 0.74 0.75 0.76 0.77 0.78 0.79 0.8 0.81 0.82 0.83 0.84 0.85 0.86 0.87 0.88 0.89 0.9 0.91 0.92 0.93 0.94 0.95 0.96 0.97 0.98 0.99 1.0 ]
|
||||
#define sunColorG 0.91 //[0.0 0.01 0.02 0.03 0.04 0.05 0.06 0.07 0.08 0.09 0.1 0.11 0.12 0.13 0.14 0.15 0.16 0.17 0.18 0.19 0.2 0.21 0.22 0.23 0.24 0.25 0.26 0.27 0.28 0.29 0.3 0.31 0.32 0.33 0.34 0.35 0.36 0.37 0.38 0.39 0.4 0.41 0.42 0.43 0.44 0.45 0.46 0.47 0.48 0.49 0.5 0.51 0.52 0.53 0.54 0.55 0.56 0.57 0.58 0.59 0.6 0.61 0.62 0.63 0.64 0.65 0.66 0.67 0.68 0.69 0.7 0.71 0.72 0.73 0.74 0.75 0.76 0.77 0.78 0.79 0.8 0.81 0.82 0.83 0.84 0.85 0.86 0.87 0.88 0.89 0.9 0.91 0.92 0.93 0.94 0.95 0.96 0.97 0.98 0.99 1.0 ]
|
||||
#define sunColorB 0.81 //[0.0 0.01 0.02 0.03 0.04 0.05 0.06 0.07 0.08 0.09 0.1 0.11 0.12 0.13 0.14 0.15 0.16 0.17 0.18 0.19 0.2 0.21 0.22 0.23 0.24 0.25 0.26 0.27 0.28 0.29 0.3 0.31 0.32 0.33 0.34 0.35 0.36 0.37 0.38 0.39 0.4 0.41 0.42 0.43 0.44 0.45 0.46 0.47 0.48 0.49 0.5 0.51 0.52 0.53 0.54 0.55 0.56 0.57 0.58 0.59 0.6 0.61 0.62 0.63 0.64 0.65 0.66 0.67 0.68 0.69 0.7 0.71 0.72 0.73 0.74 0.75 0.76 0.77 0.78 0.79 0.8 0.81 0.82 0.83 0.84 0.85 0.86 0.87 0.88 0.89 0.9 0.91 0.92 0.93 0.94 0.95 0.96 0.97 0.98 0.99 1.0 ]
|
||||
|
||||
#define colortype 2 // 1 = RGB sliders for sun/moon color. 2 = blackbody. [1 2]
|
||||
#define Sun_temp 7000 // [1000 2000 3000 4000 5000 6000 7000 8000 9000 10000]
|
||||
#define Moon_temp 15000 // [1000 2000 3000 4000 5000 6000 7000 8000 9000 10000]
|
||||
|
||||
// #define sunColorBase mix( vec3(sunColorR,sunColorG,sunColorB), blackbody(50000), LowCoverage) * sun_illuminance
|
||||
|
||||
|
||||
|
||||
|
||||
#define moonColorR 0.9080 //[0.0 0.01 0.02 0.03 0.04 0.05 0.06 0.07 0.08 0.09 0.1 0.11 0.12 0.13 0.14 0.15 0.16 0.17 0.18 0.19 0.2 0.21 0.22 0.23 0.24 0.25 0.26 0.27 0.28 0.29 0.3 0.31 0.32 0.33 0.34 0.35 0.36 0.37 0.38 0.39 0.4 0.41 0.42 0.43 0.44 0.45 0.46 0.47 0.48 0.49 0.5 0.51 0.52 0.53 0.54 0.55 0.56 0.57 0.58 0.59 0.6 0.61 0.62 0.63 0.64 0.65 0.66 0.67 0.68 0.69 0.7 0.71 0.72 0.73 0.74 0.75 0.76 0.77 0.78 0.79 0.8 0.81 0.82 0.83 0.84 0.85 0.86 0.87 0.88 0.89 0.9 0.91 0.92 0.93 0.94 0.95 0.96 0.97 0.98 0.99 1.0 ]
|
||||
#define moonColorG 0.9121 //[0.0 0.01 0.02 0.03 0.04 0.05 0.06 0.07 0.08 0.09 0.1 0.11 0.12 0.13 0.14 0.15 0.16 0.17 0.18 0.19 0.2 0.21 0.22 0.23 0.24 0.25 0.26 0.27 0.28 0.29 0.3 0.31 0.32 0.33 0.34 0.35 0.36 0.37 0.38 0.39 0.4 0.41 0.42 0.43 0.44 0.45 0.46 0.47 0.48 0.49 0.5 0.51 0.52 0.53 0.54 0.55 0.56 0.57 0.58 0.59 0.6 0.61 0.62 0.63 0.64 0.65 0.66 0.67 0.68 0.69 0.7 0.71 0.72 0.73 0.74 0.75 0.76 0.77 0.78 0.79 0.8 0.81 0.82 0.83 0.84 0.85 0.86 0.87 0.88 0.89 0.9 0.91 0.92 0.93 0.94 0.95 0.96 0.97 0.98 0.99 1.0 ]
|
||||
#define moonColorB 0.8948 //[0.0 0.01 0.02 0.03 0.04 0.05 0.06 0.07 0.08 0.09 0.1 0.11 0.12 0.13 0.14 0.15 0.16 0.17 0.18 0.19 0.2 0.21 0.22 0.23 0.24 0.25 0.26 0.27 0.28 0.29 0.3 0.31 0.32 0.33 0.34 0.35 0.36 0.37 0.38 0.39 0.4 0.41 0.42 0.43 0.44 0.45 0.46 0.47 0.48 0.49 0.5 0.51 0.52 0.53 0.54 0.55 0.56 0.57 0.58 0.59 0.6 0.61 0.62 0.63 0.64 0.65 0.66 0.67 0.68 0.69 0.7 0.71 0.72 0.73 0.74 0.75 0.76 0.77 0.78 0.79 0.8 0.81 0.82 0.83 0.84 0.85 0.86 0.87 0.88 0.89 0.9 0.91 0.92 0.93 0.94 0.95 0.96 0.97 0.98 0.99 1.0 ]
|
||||
|
||||
#if colortype == 1
|
||||
#define sunColorBase vec3(sunColorR,sunColorG,sunColorB) * sun_illuminance
|
||||
#define moonColorBase vec3(moonColorR,moonColorG,moonColorB) * moon_illuminance //Fake Purkinje effect
|
||||
#else
|
||||
#define sunColorBase blackbody(Sun_temp) * sun_illuminance
|
||||
#define moonColorBase blackbody(Moon_temp) * moon_illuminance //Fake Purkinje effect
|
||||
#endif
|
||||
|
||||
|
||||
float sky_rayleighPhase(float cosTheta) {
|
||||
const vec2 mul_add = vec2(0.1, 0.28) * rPI;
|
||||
return cosTheta * mul_add.x + mul_add.y; // optimized version from [Elek09], divided by 4 pi for energy conservation
|
||||
}
|
||||
|
||||
float sky_miePhase(float cosTheta, const float g) {
|
||||
float gg = g * g;
|
||||
return (gg * -0.25 + 0.25) * rPI * pow(-(2.0 * g) * cosTheta + (gg + 1.0), -1.5);
|
||||
}
|
||||
|
||||
vec2 sky_phase(float cosTheta, const float g) {
|
||||
return vec2(sky_rayleighPhase(cosTheta), sky_miePhase(cosTheta, g));
|
||||
}
|
||||
|
||||
vec3 sky_density(float centerDistance) {
|
||||
vec2 rayleighMie = exp(centerDistance * -sky_inverseScaleHeights + sky_scaledPlanetRadius);
|
||||
|
||||
// Ozone distribution curve by Sergeant Sarcasm - https://www.desmos.com/calculator/j0wozszdwa
|
||||
float ozone = exp(-max(0.0, (35000.0 - centerDistance) - sky_planetRadius) * (1.0 / 5000.0))
|
||||
* exp(-max(0.0, (centerDistance - 35000.0) - sky_planetRadius) * (1.0 / 15000.0));
|
||||
return vec3(rayleighMie, ozone);
|
||||
}
|
||||
|
||||
vec3 sky_airmass(vec3 position, vec3 direction, float rayLength, const float steps) {
|
||||
float stepSize = rayLength * (1.0 / steps);
|
||||
vec3 increment = direction * stepSize;
|
||||
position += increment * 0.5;
|
||||
|
||||
vec3 airmass = vec3(0.0);
|
||||
for (int i = 0; i < steps; ++i, position += increment) {
|
||||
airmass += sky_density(length(position));
|
||||
}
|
||||
|
||||
return airmass * stepSize;
|
||||
}
|
||||
vec3 sky_airmass(vec3 position, vec3 direction, const float steps) {
|
||||
float rayLength = dot(position, direction);
|
||||
rayLength = rayLength * rayLength + sky_atmosphereRadiusSquared - dot(position, position);
|
||||
if (rayLength < 0.0) return vec3(0.0);
|
||||
rayLength = sqrt(rayLength) - dot(position, direction);
|
||||
|
||||
return sky_airmass(position, direction, rayLength, steps);
|
||||
}
|
||||
|
||||
vec3 sky_opticalDepth(vec3 position, vec3 direction, float rayLength, const float steps) {
|
||||
return sky_coefficientsAttenuation * sky_airmass(position, direction, rayLength, steps);
|
||||
}
|
||||
vec3 sky_opticalDepth(vec3 position, vec3 direction, const float steps) {
|
||||
return sky_coefficientsAttenuation * sky_airmass(position, direction, steps);
|
||||
}
|
||||
|
||||
vec3 sky_transmittance(vec3 position, vec3 direction, const float steps) {
|
||||
return exp2(-sky_opticalDepth(position, direction, steps) * rLOG2);
|
||||
}
|
||||
|
||||
|
||||
|
||||
vec3 calculateAtmosphere(vec3 background, vec3 viewVector, vec3 upVector, vec3 sunVector, vec3 moonVector, out vec2 pid, out vec3 transmittance, const int iSteps, float noise) {
|
||||
const int jSteps = 4;
|
||||
|
||||
|
||||
vec3 viewPosition = (sky_planetRadius + eyeAltitude) * upVector;
|
||||
|
||||
vec2 aid = rsi(viewPosition, viewVector, sky_atmosphereRadius);
|
||||
if (aid.y < 0.0) {transmittance = vec3(1.0); return vec3(0.0);}
|
||||
|
||||
pid = rsi(viewPosition, viewVector, sky_planetRadius * 0.998);
|
||||
bool planetIntersected = pid.y >= 0.0;
|
||||
|
||||
vec2 sd = vec2((planetIntersected && pid.x < 0.0) ? pid.y : max(aid.x, 0.0), (planetIntersected && pid.x > 0.0) ? pid.x : aid.y);
|
||||
|
||||
float stepSize = (sd.y - sd.x) * (1.0 / iSteps);
|
||||
vec3 increment = viewVector * stepSize;
|
||||
vec3 position = viewVector * sd.x + viewPosition;
|
||||
position += increment * (0.34*noise);
|
||||
vec2 phaseSun = sky_phase(dot(viewVector, sunVector ), sky_mieg);
|
||||
vec2 phaseMoon = sky_phase(dot(viewVector, moonVector), sky_mieg);
|
||||
|
||||
vec3 scatteringSun = vec3(0.0);
|
||||
vec3 scatteringMoon = vec3(0.0);
|
||||
vec3 scatteringAmbient = vec3(0.0);
|
||||
|
||||
transmittance = vec3(1.0);
|
||||
|
||||
|
||||
// float low_sun = clamp(pow(1.0-sunVector.y,10.0) + 1.0,1.0, 2.0);
|
||||
|
||||
float high_sun = clamp(pow(sunVector.y+0.6,5),0.0,1.0) * 3.0; // make sunrise less blue, and allow sunset to be bluer
|
||||
float low_sun = clamp(((1.0-abs(sunVector.y))*3.) - high_sun,1.0,2.5) ;
|
||||
|
||||
for (int i = 0; i < iSteps; ++i, position += increment) {
|
||||
vec3 density = sky_density(length(position));
|
||||
if (density.y > 1e35) break;
|
||||
vec3 stepAirmass = density * stepSize;
|
||||
vec3 stepOpticalDepth = sky_coefficientsAttenuation * stepAirmass;
|
||||
|
||||
vec3 stepTransmittance = exp2(-stepOpticalDepth * rLOG2);
|
||||
vec3 stepTransmittedFraction = clamp01((stepTransmittance - 1.0) / -stepOpticalDepth);
|
||||
vec3 stepScatteringVisible = transmittance * stepTransmittedFraction;
|
||||
|
||||
scatteringSun += sky_coefficientsScattering * (stepAirmass.xy * phaseSun ) * stepScatteringVisible * sky_transmittance(position, sunVector*0.5+0.1, jSteps);
|
||||
scatteringMoon += sky_coefficientsScattering * (stepAirmass.xy * phaseMoon) * stepScatteringVisible * sky_transmittance(position, moonVector, jSteps);
|
||||
// Nice way to fake multiple scattering.
|
||||
scatteringAmbient += sky_coefficientsScattering * stepAirmass.xy * (stepScatteringVisible * low_sun);
|
||||
|
||||
transmittance *= stepTransmittance;
|
||||
}
|
||||
|
||||
vec3 scattering = scatteringSun * sunColorBase + (scatteringAmbient) * background + scatteringMoon*moonColorBase ;
|
||||
// scattering = vec3(0,high_sun*255.,0);
|
||||
return scattering;
|
||||
}
|
44
shaders/lib/Shadow_Params.glsl
Normal file
44
shaders/lib/Shadow_Params.glsl
Normal file
@ -0,0 +1,44 @@
|
||||
|
||||
|
||||
const float ambientOcclusionLevel = 0.15; //[0.0 0.01 0.02 0.03 0.04 0.05 0.06 0.07 0.08 0.09 0.1 0.11 0.12 0.13 0.14 0.15 0.16 0.17 0.18 0.19 0.2 0.21 0.22 0.23 0.24 0.25 0.26 0.27 0.28 0.29 0.3 0.31 0.32 0.33 0.34 0.35 0.36 0.37 0.38 0.39 0.4 0.41 0.42 0.43 0.44 0.45 0.46 0.47 0.48 0.49 0.5 0.51 0.52 0.53 0.54 0.55 0.56 0.57 0.58 0.59 0.6 0.61 0.62 0.63 0.64 0.65 0.66 0.67 0.68 0.69 0.7 0.71 0.72 0.73 0.74 0.75 0.76 0.77 0.78 0.79 0.8 0.81 0.82 0.83 0.84 0.85 0.86 0.87 0.88 0.89 0.9 0.91 0.92 0.93 0.94 0.95 0.96 0.97 0.98 0.99 1.0 ]
|
||||
|
||||
|
||||
|
||||
const float sunPathRotation = -35; //[-90 -89 -88 -87 -86 -85 -84 -83 -82 -81 -80 -79 -78 -77 -76 -75 -74 -73 -72 -71 -70 -69 -68 -67 -66 -65 -64 -63 -62 -61 -60 -59 -58 -57 -56 -55 -54 -53 -52 -51 -50 -49 -48 -47 -46 -45 -44 -43 -42 -41 -40 -39 -38 -37 -36 -35 -34 -33 -32 -31 -30 -29 -28 -27 -26 -25 -24 -23 -22 -21 -20 -19 -18 -17 -16 -15 -14 -13 -12 -11 -10 -9 -8 -7 -6 -5 -4 -3 -2 -1 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 ]
|
||||
|
||||
const int shadowMapResolution = 2048; //Will probably crash at 16 384 [512 768 1024 1536 2048 3172 4096 8192 16384]
|
||||
const float shadowDistance = 69.; //[32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 ] Not linear at all when shadowDistanceRenderMul is set to -1.0, 175.0 is enough for 40 render distance
|
||||
const float shadowDistanceRenderMul = -1.0; //[-1.0 1.0] Can help to increase shadow draw distance when set to -1.0, at the cost of performance
|
||||
|
||||
#define Variable_Penumbra_Shadows //Makes the shadows more blurry the more distant they are to objects (costs fps)
|
||||
#define VPS_Search_Samples 4 //The number of samples used to find occluders [4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32]
|
||||
#define Min_Shadow_Filter_Radius 5.0 //If Variable_Penumbra_Shadows are not used, will be used as shadow filter size. [0.0 1.0 2.0 3.0 4.0 5.0 6.0 7.0 8.0 9.0 10.0 11.0 12.0 13.0 14.0 15.0 16.0 17.0 18.0 19.0 20.0 21.0 22.0 23.0 24.0 25.0 26.0 27.0 28.0 29.0 30.0 31.0 32.0 33.0 34.0 35.0 36.0 37.0 38.0 39.0 40.0 41.0 42.0 43.0 44.0 45.0 46.0 47.0 48.0 49.0 50.0 51.0 52.0 53.0 54.0 55.0 56.0 57.0 58.0 59.0 60.0 61.0 62.0 63.0 64.0 65.0 66.0 67.0 68.0 69.0 70.0 71.0 72.0 73.0 74.0 75.0 76.0 77.0 78.0 79.0 80.0 81.0 82.0 83.0 84.0 85.0 86.0 87.0 88.0 89.0 90.0 91.0 92.0 93.0 94.0 95.0 96.0 97.0 98.0 99.0 100.0 101.0 102.0 103.0 104.0 105.0 106.0 107.0 108.0 109.0 110.0 111.0 112.0 113.0 114.0 115.0 116.0 117.0 118.0 119.0 ]
|
||||
#define Max_Shadow_Filter_Radius 30.0 //Not used if Variable_Penumbra_Shadows are not used. Will cause issues at too high values [0.0 1.0 2.0 3.0 4.0 5.0 6.0 7.0 8.0 9.0 10.0 11.0 12.0 13.0 14.0 15.0 16.0 17.0 18.0 19.0 20.0 21.0 22.0 23.0 24.0 25.0 26.0 27.0 28.0 29.0 30.0 31.0 32.0 33.0 34.0 35.0 36.0 37.0 38.0 39.0 40.0 41.0 42.0 43.0 44.0 45.0 46.0 47.0 48.0 49.0 50.0 51.0 52.0 53.0 54.0 55.0 56.0 57.0 58.0 59.0 60.0 61.0 62.0 63.0 64.0 65.0 66.0 67.0 68.0 69.0 70.0 71.0 72.0 73.0 74.0 75.0 76.0 77.0 78.0 79.0 80.0 81.0 82.0 83.0 84.0 85.0 86.0 87.0 88.0 89.0 90.0 91.0 92.0 93.0 94.0 95.0 96.0 97.0 98.0 99.0 100.0 101.0 102.0 103.0 104.0 105.0 106.0 107.0 108.0 109.0 110.0 111.0 112.0 113.0 114.0 115.0 116.0 117.0 118.0 119.0 ]
|
||||
#define Max_Filter_Depth 20.0 //Distance to the occluder at which the shadow filter size reaches its maximum. [0.0 1.0 2.0 3.0 4.0 5.0 6.0 7.0 8.0 9.0 10.0 11.0 12.0 13.0 14.0 15.0 16.0 17.0 18.0 19.0 20.0 21.0 22.0 23.0 24.0 25.0 26.0 27.0 28.0 29.0 30.0 31.0 32.0 33.0 34.0 35.0 36.0 37.0 38.0 39.0 40.0 41.0 42.0 43.0 44.0 45.0 46.0 47.0 48.0 49.0 50.0 51.0 52.0 53.0 54.0 55.0 56.0 57.0 58.0 59.0 60.0 61.0 62.0 63.0 64.0 65.0 66.0 67.0 68.0 69.0 70.0 71.0 72.0 73.0 74.0 75.0 76.0 77.0 78.0 79.0 80.0 81.0 82.0 83.0 84.0 85.0 86.0 87.0 88.0 89.0 90.0 91.0 92.0 93.0 94.0 95.0 96.0 97.0 98.0 99.0 100.0 101.0 102.0 103.0 104.0 105.0 106.0 107.0 108.0 109.0 110.0 111.0 112.0 113.0 114.0 115.0 116.0 117.0 118.0 119.0 ]
|
||||
#define SCREENSPACE_CONTACT_SHADOWS //Raymarch towards the sun in screen-space, in order to cast shadows outside of the shadow map or at the contact of objects. Can get really expensive at high resolutions.
|
||||
#define SHADOW_FILTER_SAMPLE_COUNT 13 // Number of samples used to filter the actual shadows [1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 ]
|
||||
|
||||
// #define SSGI
|
||||
#define RAY_COUNT 4 // [1 2 3 4 5 6 7 8 9 10 12 14 16 18 21 24 28 32 37 43 49 57 65 75 86 100]
|
||||
#define STEPS 8 // [ 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99]
|
||||
#define STEP_LENGTH 12. // [ 4. 5. 6. 7. 8. 9. 10. 11. 12. 13. 14. 15. 16. 17. 18. 19. 20. 21. 22. 23. 24. 25. 26. 27. 28. 29. 30.]
|
||||
#define SubSurfaceScattering
|
||||
|
||||
const float k = 1.8;
|
||||
const float d0 = 0.04;
|
||||
const float d1 = 0.61;
|
||||
float a = exp(d0);
|
||||
float b = (exp(d1)-a)*150./128.0;
|
||||
|
||||
vec4 BiasShadowProjection(in vec4 projectedShadowSpacePosition) {
|
||||
|
||||
float distortFactor = log(length(projectedShadowSpacePosition.xy)*b+a)*k;
|
||||
projectedShadowSpacePosition.xy /= distortFactor;
|
||||
return projectedShadowSpacePosition;
|
||||
}
|
||||
|
||||
|
||||
|
||||
float calcDistort(vec2 worldpos){
|
||||
return 1.0/(log(length(worldpos)*b+a)*k);
|
||||
}
|
100
shaders/lib/biome_specifics.glsl
Normal file
100
shaders/lib/biome_specifics.glsl
Normal file
@ -0,0 +1,100 @@
|
||||
// #define Biome_specific_environment // makes the fog density and color look unique in certain biomes. (swamps, jungles, lush caves, giant pines, dark forests)
|
||||
// #define Jungle_fog_strength 1.0 // how strong the fog gets there. set to zero to have normal fog [0.0 0.25 0.50 0.75 1.0]
|
||||
// #define Swamp_fog_strength 1.0 // how strong the fog gets there. set to zero to have normal fog [0.0 0.25 0.50 0.75 1.0]
|
||||
// #define Lush_fog_strength 1.0 // how strong the fog gets there. set to zero to have normal fog [0.0 0.25 0.50 0.75 1.0]
|
||||
|
||||
// #define Time_of_day_fog // fog starts closer to you at sunrise/sunset + night
|
||||
// #define Rain_fog // rain fog.
|
||||
// #define Lightmap_based_fog // fog that changes lighting based on the light from the sky. so if you're in a cave, it changes. if you go to the surface, its mostly normal
|
||||
|
||||
// #define Swamp_R 0.9 // the color of the fog. only effects this specific biome [0.01 0.02 0.03 0.04 0.05 0.06 0.07 0.08 0.09 0.1 0.11 0.12 0.13 0.14 0.15 0.16 0.17 0.18 0.19 0.2 0.21 0.22 0.23 0.24 0.25 0.26 0.27 0.28 0.29 0.3 0.31 0.32 0.33 0.34 0.35 0.36 0.37 0.38 0.39 0.4 0.41 0.42 0.43 0.44 0.45 0.46 0.47 0.48 0.49 0.5 0.51 0.52 0.53 0.54 0.55 0.56 0.57 0.58 0.59 0.6 0.61 0.62 0.63 0.64 0.65 0.66 0.67 0.68 0.69 0.7 0.71 0.72 0.73 0.74 0.75 0.76 0.77 0.78 0.79 0.8 0.81 0.82 0.83 0.84 0.85 0.86 0.87 0.88 0.89 0.9 0.91 0.92 0.93 0.94 0.95 0.96 0.97 0.98 0.99 1.0]
|
||||
// #define Swamp_G 1.0 // the color of the fog. only effects this specific biome [0.01 0.02 0.03 0.04 0.05 0.06 0.07 0.08 0.09 0.1 0.11 0.12 0.13 0.14 0.15 0.16 0.17 0.18 0.19 0.2 0.21 0.22 0.23 0.24 0.25 0.26 0.27 0.28 0.29 0.3 0.31 0.32 0.33 0.34 0.35 0.36 0.37 0.38 0.39 0.4 0.41 0.42 0.43 0.44 0.45 0.46 0.47 0.48 0.49 0.5 0.51 0.52 0.53 0.54 0.55 0.56 0.57 0.58 0.59 0.6 0.61 0.62 0.63 0.64 0.65 0.66 0.67 0.68 0.69 0.7 0.71 0.72 0.73 0.74 0.75 0.76 0.77 0.78 0.79 0.8 0.81 0.82 0.83 0.84 0.85 0.86 0.87 0.88 0.89 0.9 0.91 0.92 0.93 0.94 0.95 0.96 0.97 0.98 0.99 1.0]
|
||||
// #define Swamp_B 0.35 // the color of the fog. only effects this specific biome [0.01 0.02 0.03 0.04 0.05 0.06 0.07 0.08 0.09 0.1 0.11 0.12 0.13 0.14 0.15 0.16 0.17 0.18 0.19 0.2 0.21 0.22 0.23 0.24 0.25 0.26 0.27 0.28 0.29 0.3 0.31 0.32 0.33 0.34 0.35 0.36 0.37 0.38 0.39 0.4 0.41 0.42 0.43 0.44 0.45 0.46 0.47 0.48 0.49 0.5 0.51 0.52 0.53 0.54 0.55 0.56 0.57 0.58 0.59 0.6 0.61 0.62 0.63 0.64 0.65 0.66 0.67 0.68 0.69 0.7 0.71 0.72 0.73 0.74 0.75 0.76 0.77 0.78 0.79 0.8 0.81 0.82 0.83 0.84 0.85 0.86 0.87 0.88 0.89 0.9 0.91 0.92 0.93 0.94 0.95 0.96 0.97 0.98 0.99 1.0]
|
||||
|
||||
// #define Jungle_R 0.5 // the color of the fog. only effects this specific biome [0.01 0.02 0.03 0.04 0.05 0.06 0.07 0.08 0.09 0.1 0.11 0.12 0.13 0.14 0.15 0.16 0.17 0.18 0.19 0.2 0.21 0.22 0.23 0.24 0.25 0.26 0.27 0.28 0.29 0.3 0.31 0.32 0.33 0.34 0.35 0.36 0.37 0.38 0.39 0.4 0.41 0.42 0.43 0.44 0.45 0.46 0.47 0.48 0.49 0.5 0.51 0.52 0.53 0.54 0.55 0.56 0.57 0.58 0.59 0.6 0.61 0.62 0.63 0.64 0.65 0.66 0.67 0.68 0.69 0.7 0.71 0.72 0.73 0.74 0.75 0.76 0.77 0.78 0.79 0.8 0.81 0.82 0.83 0.84 0.85 0.86 0.87 0.88 0.89 0.9 0.91 0.92 0.93 0.94 0.95 0.96 0.97 0.98 0.99 1.0]
|
||||
// #define Jungle_G 1.0 // the color of the fog. only effects this specific biome [0.01 0.02 0.03 0.04 0.05 0.06 0.07 0.08 0.09 0.1 0.11 0.12 0.13 0.14 0.15 0.16 0.17 0.18 0.19 0.2 0.21 0.22 0.23 0.24 0.25 0.26 0.27 0.28 0.29 0.3 0.31 0.32 0.33 0.34 0.35 0.36 0.37 0.38 0.39 0.4 0.41 0.42 0.43 0.44 0.45 0.46 0.47 0.48 0.49 0.5 0.51 0.52 0.53 0.54 0.55 0.56 0.57 0.58 0.59 0.6 0.61 0.62 0.63 0.64 0.65 0.66 0.67 0.68 0.69 0.7 0.71 0.72 0.73 0.74 0.75 0.76 0.77 0.78 0.79 0.8 0.81 0.82 0.83 0.84 0.85 0.86 0.87 0.88 0.89 0.9 0.91 0.92 0.93 0.94 0.95 0.96 0.97 0.98 0.99 1.0]
|
||||
// #define Jungle_B 0.8 // the color of the fog. only effects this specific biome [0.01 0.02 0.03 0.04 0.05 0.06 0.07 0.08 0.09 0.1 0.11 0.12 0.13 0.14 0.15 0.16 0.17 0.18 0.19 0.2 0.21 0.22 0.23 0.24 0.25 0.26 0.27 0.28 0.29 0.3 0.31 0.32 0.33 0.34 0.35 0.36 0.37 0.38 0.39 0.4 0.41 0.42 0.43 0.44 0.45 0.46 0.47 0.48 0.49 0.5 0.51 0.52 0.53 0.54 0.55 0.56 0.57 0.58 0.59 0.6 0.61 0.62 0.63 0.64 0.65 0.66 0.67 0.68 0.69 0.7 0.71 0.72 0.73 0.74 0.75 0.76 0.77 0.78 0.79 0.8 0.81 0.82 0.83 0.84 0.85 0.86 0.87 0.88 0.89 0.9 0.91 0.92 0.93 0.94 0.95 0.96 0.97 0.98 0.99 1.0]
|
||||
|
||||
// #define override_R 0.5 // the color of the fog. only effects this specific biome [0.01 0.02 0.03 0.04 0.05 0.06 0.07 0.08 0.09 0.1 0.11 0.12 0.13 0.14 0.15 0.16 0.17 0.18 0.19 0.2 0.21 0.22 0.23 0.24 0.25 0.26 0.27 0.28 0.29 0.3 0.31 0.32 0.33 0.34 0.35 0.36 0.37 0.38 0.39 0.4 0.41 0.42 0.43 0.44 0.45 0.46 0.47 0.48 0.49 0.5 0.51 0.52 0.53 0.54 0.55 0.56 0.57 0.58 0.59 0.6 0.61 0.62 0.63 0.64 0.65 0.66 0.67 0.68 0.69 0.7 0.71 0.72 0.73 0.74 0.75 0.76 0.77 0.78 0.79 0.8 0.81 0.82 0.83 0.84 0.85 0.86 0.87 0.88 0.89 0.9 0.91 0.92 0.93 0.94 0.95 0.96 0.97 0.98 0.99 1.0]
|
||||
// #define override_G 1.0 // the color of the fog. only effects this specific biome [0.01 0.02 0.03 0.04 0.05 0.06 0.07 0.08 0.09 0.1 0.11 0.12 0.13 0.14 0.15 0.16 0.17 0.18 0.19 0.2 0.21 0.22 0.23 0.24 0.25 0.26 0.27 0.28 0.29 0.3 0.31 0.32 0.33 0.34 0.35 0.36 0.37 0.38 0.39 0.4 0.41 0.42 0.43 0.44 0.45 0.46 0.47 0.48 0.49 0.5 0.51 0.52 0.53 0.54 0.55 0.56 0.57 0.58 0.59 0.6 0.61 0.62 0.63 0.64 0.65 0.66 0.67 0.68 0.69 0.7 0.71 0.72 0.73 0.74 0.75 0.76 0.77 0.78 0.79 0.8 0.81 0.82 0.83 0.84 0.85 0.86 0.87 0.88 0.89 0.9 0.91 0.92 0.93 0.94 0.95 0.96 0.97 0.98 0.99 1.0]
|
||||
// #define override_B 0.8 // the color of the fog. only effects this specific biome [0.01 0.02 0.03 0.04 0.05 0.06 0.07 0.08 0.09 0.1 0.11 0.12 0.13 0.14 0.15 0.16 0.17 0.18 0.19 0.2 0.21 0.22 0.23 0.24 0.25 0.26 0.27 0.28 0.29 0.3 0.31 0.32 0.33 0.34 0.35 0.36 0.37 0.38 0.39 0.4 0.41 0.42 0.43 0.44 0.45 0.46 0.47 0.48 0.49 0.5 0.51 0.52 0.53 0.54 0.55 0.56 0.57 0.58 0.59 0.6 0.61 0.62 0.63 0.64 0.65 0.66 0.67 0.68 0.69 0.7 0.71 0.72 0.73 0.74 0.75 0.76 0.77 0.78 0.79 0.8 0.81 0.82 0.83 0.84 0.85 0.86 0.87 0.88 0.89 0.9 0.91 0.92 0.93 0.94 0.95 0.96 0.97 0.98 0.99 1.0]
|
||||
|
||||
// #define Swamp_cloudyfog_Density 25. // how dense or thick the cloudy fog is. only effects this specific biome [0. 5. 10. 15. 20. 25. 30. 35. 40. 45. 50. 55. 60. 65. 70. 75. 80. 85. 90. 95. 100.]
|
||||
// #define Jungle_Cloudy_Fog_Density 10. // how dense or thick the cloudy fog is. only effects this specific biome [0. 5. 10. 15. 20. 25. 30. 35. 40. 45. 50. 55. 60. 65. 70. 75. 80. 85. 90. 95. 100.]
|
||||
// #define override_Cloudy_Fog_Density 1. // how dense or thick the cloudy fog is. only effects this specific biome [0. 5. 10. 15. 20. 25. 30. 35. 40. 45. 50. 55. 60. 65. 70. 75. 80. 85. 90. 95. 100.]
|
||||
|
||||
// #define Swamp_UniformFog_Density 15. // how dense or thick the uniform fog is. only effects this specific biome [0. 5. 10. 15. 20. 25. 30. 35. 40. 45. 50. 55. 60. 65. 70. 75. 80. 85. 90. 95. 100.]
|
||||
// #define Jungle_Uniform_Fog_Density 10. //how dense or thick the uniform fog is. only effects this specific biome [0. 5. 10. 15. 20. 25. 30. 35. 40. 45. 50. 55. 60. 65. 70. 75. 80. 85. 90. 95. 100.]
|
||||
// #define override_Uniform_Fog_Density 1. //how dense or thick the uniform fog is. only effects this specific biome [0. 5. 10. 15. 20. 25. 30. 35. 40. 45. 50. 55. 60. 65. 70. 75. 80. 85. 90. 95. 100.]
|
||||
|
||||
// #define Swamp_Mie 0.75 // control the size of the peak of light around the sun in the fog. only effects this specific biome [0.1 0.2 0.3 0.4 0.5 0.6 0.7 0.75 0.8 0.85 0.9 0.95 1.0]
|
||||
// #define Jungle_Mie 0.75 // control the size of the peak of light around the sun in the fog. only effects this specific biome [0.1 0.2 0.3 0.4 0.5 0.6 0.7 0.75 0.8 0.85 0.9 0.95 1.0]
|
||||
// #define override_Mie 1.0 // control the size of the peak of light around the sun in the fog. only effects this specific biome [0.1 0.2 0.3 0.4 0.5 0.6 0.7 0.75 0.8 0.85 0.9 0.95 1.0]
|
||||
|
||||
// #define Swamp_Sun_Strength 1.0 // control how strong the sun shines through fog. only effects this specific biome [0.0 0.25 0.50 0.75 1.0 1.25 1.50 1.75 2.0 3.0 4.0 5.0 6.0 7.0 8.0 9.0 10.0]
|
||||
// #define Jungle_Sun_Strength 1.0 // control how strong the sun shines through fog. only effects this specific biome [0.0 0.25 0.50 0.75 1.0 1.25 1.50 1.75 2.0 3.0 4.0 5.0 6.0 7.0 8.0 9.0 10.0]
|
||||
// #define override_Sun_Strength 1.0 // control how strong the sun shines through fog. only effects this specific biome [0.0 0.25 0.50 0.75 1.0 1.25 1.50 1.75 2.0 3.0 4.0 5.0 6.0 7.0 8.0 9.0 10.0]
|
||||
|
||||
// #define Swamp_Bloomy_Fog 2.0 // control how bloomy the fog looks. only effects this specific biome [0.0 1.0 2.0 3.0 4.0 5.0 6.0 7.0 8.0 9.0 10.0]
|
||||
// #define Jungle_Bloomy_Fog 3.0 // control how bloomy the fog looks. only effects this specific biome [0.0 1.0 2.0 3.0 4.0 5.0 6.0 7.0 8.0 9.0 10.0]
|
||||
// #define override_Bloomy_Fog 1.0 // control how bloomy the fog looks. only effects this specific biome [0.0 1.0 2.0 3.0 4.0 5.0 6.0 7.0 8.0 9.0 10.0]
|
||||
|
||||
// #define Swamp_cloudyfog_height 30 // controll the fade away at the top of the fog [5 10 20 30 40 50 60 70 80 90 100]
|
||||
// #define Jungle_cloudyfog_fade 30 // controll the fade away at the top of the fog [5 10 20 30 40 50 60 70 80 90 100]
|
||||
// #define override_cloudyfog_fade 50 // controll the fade away at the top of the fog [5 10 20 30 40 50 60 70 80 90 100]
|
||||
|
||||
// #define Swamp_uniformfog_height 10 // controll the fade away at the top of the fog [5 10 20 30 40 50 60 70 80 90 100]
|
||||
// #define Jungle_uniformfog_fade 10 // controll the fade away at the top of the fog [5 10 20 30 40 50 60 70 80 90 100]
|
||||
// #define override_uniformfog_fade 50 // controll the fade away at the top of the fog [5 10 20 30 40 50 60 70 80 90 100]
|
||||
|
||||
|
||||
// #define override_fog 0 // override the fog that exists everywhere with your own [0 1]
|
||||
|
||||
// // uniform int isEyeInWater;
|
||||
// // uniform float blindness;
|
||||
// // uniform float rainStrength;
|
||||
// // uniform ivec2 eyeBrightnessSmooth;
|
||||
// // uniform float eyeAltitude;
|
||||
// // uniform int worldTime;
|
||||
|
||||
// uniform float isJungles;
|
||||
// uniform float isSwamps;
|
||||
// uniform float isLush;
|
||||
// uniform float isDeserts;
|
||||
|
||||
// // float timething = (worldTime%24000)*1.0;
|
||||
// // float TimeOfDayFog = clamp((1.0 - clamp( timething-11000,0.0,2000.0)/2000.) * (clamp(timething,0.0,2000.0)/2000.) ,0.0,1.0);
|
||||
|
||||
// // fuck you
|
||||
// #ifdef Biome_specific_environment
|
||||
// float SWAMPS = isSwamps;
|
||||
// float JUNGLES = isJungles;
|
||||
// float LUSHCAVE = isLush;
|
||||
// float DESERTS = isDeserts;
|
||||
// float OVERRIDE = max(override_fog - (SWAMPS + JUNGLES),0);
|
||||
// #else
|
||||
// float OVERRIDE = 0;
|
||||
// float SWAMPS = 0;
|
||||
// float JUNGLES = 0;
|
||||
// float LUSHCAVE = 0;
|
||||
// float DESERTS = 0;
|
||||
// #endif
|
||||
|
||||
// // all the fog settings that do various things.
|
||||
// float[8] Biome_Fog_Properties = float[8](
|
||||
// /*[0] biome check*/ SWAMPS*Swamp_fog_strength + JUNGLES*Jungle_fog_strength + OVERRIDE
|
||||
// /*[1] cloudy fog density*/ ,SWAMPS*Swamp_cloudyfog_Density + JUNGLES*Jungle_Cloudy_Fog_Density + OVERRIDE*override_cloudyfog_fade
|
||||
// /*[2] uniform fog density*/ ,SWAMPS*Swamp_UniformFog_Density + JUNGLES*Jungle_Uniform_Fog_Density + OVERRIDE*override_Uniform_Fog_Density
|
||||
// /*[3] sunlight strength*/ ,SWAMPS*Swamp_Sun_Strength + JUNGLES*Jungle_Sun_Strength + OVERRIDE*override_Sun_Strength
|
||||
// /*[4] bloomy fog strength*/ ,SWAMPS*Swamp_Bloomy_Fog + JUNGLES*Jungle_Bloomy_Fog + OVERRIDE*override_Bloomy_Fog
|
||||
// /*[5] fog mie size */ ,SWAMPS*Swamp_Mie + JUNGLES*Jungle_Mie + OVERRIDE*override_Mie
|
||||
// /*[6] cloudy fog fade */ ,SWAMPS*Swamp_cloudyfog_height + JUNGLES*Jungle_cloudyfog_fade + OVERRIDE*override_Cloudy_Fog_Density
|
||||
// /*[7] uniform fog fade */ ,SWAMPS*Swamp_uniformfog_height + JUNGLES*Jungle_uniformfog_fade + OVERRIDE*override_uniformfog_fade
|
||||
// );
|
||||
|
||||
// // ??? ive no clue what this one does ngl
|
||||
// vec3 Biome_FogColor = vec3(
|
||||
// SWAMPS*Swamp_R + JUNGLES*Jungle_R + OVERRIDE*override_R
|
||||
// ,SWAMPS*Swamp_G + JUNGLES*Jungle_G + OVERRIDE*override_G
|
||||
// ,SWAMPS*Swamp_B + JUNGLES*Jungle_B + OVERRIDE*override_B
|
||||
// );
|
273
shaders/lib/climate_settings.glsl
Normal file
273
shaders/lib/climate_settings.glsl
Normal file
@ -0,0 +1,273 @@
|
||||
// this file contains all things for seasons, weather, and biome specific settings.
|
||||
// i gotta start centralizing shit someday.
|
||||
|
||||
#define Seasons
|
||||
#define Season_Length 24 // how long each season lasts in minecraft days. 91 is roughly how long each season is in reality. 1 will make a year last 4 days [ 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91]
|
||||
// #define Snowy_Winter // snow in the winter, yes or no?
|
||||
|
||||
#define Summer_R 1.0 // the color of the plants during this season [0.0 0.1 0.2 0.3 0.4 0.5 0.6 0.7 0.8 0.9 1.0 1.1 1.2 1.3 1.4 1.5 1.6 1.7 1.8 1.9 2.0]
|
||||
#define Summer_G 1.0 // the color of the plants during this season [0.0 0.1 0.2 0.3 0.4 0.5 0.6 0.7 0.8 0.9 1.0 1.1 1.2 1.3 1.4 1.5 1.6 1.7 1.8 1.9 2.0]
|
||||
#define Summer_B 1.0 // the color of the plants during this season [0.0 0.1 0.2 0.3 0.4 0.5 0.6 0.7 0.8 0.9 1.0 1.1 1.2 1.3 1.4 1.5 1.6 1.7 1.8 1.9 2.0]
|
||||
#define Summer_Leaf_R 1.0 // the color of the plants during this season [0.0 0.1 0.2 0.3 0.4 0.5 0.6 0.7 0.8 0.9 1.0 1.1 1.2 1.3 1.4 1.5 1.6 1.7 1.8 1.9 2.0]
|
||||
#define Summer_Leaf_G 1.0 // the color of the plants during this season [0.0 0.1 0.2 0.3 0.4 0.5 0.6 0.7 0.8 0.9 1.0 1.1 1.2 1.3 1.4 1.5 1.6 1.7 1.8 1.9 2.0]
|
||||
#define Summer_Leaf_B 1.0 // the color of the plants during this season [0.0 0.1 0.2 0.3 0.4 0.5 0.6 0.7 0.8 0.9 1.0 1.1 1.2 1.3 1.4 1.5 1.6 1.7 1.8 1.9 2.0]
|
||||
|
||||
#define Fall_R 1.5 // the color of the plants during this season [0.0 0.1 0.2 0.3 0.4 0.5 0.6 0.7 0.8 0.9 1.0 1.1 1.2 1.3 1.4 1.5 1.6 1.7 1.8 1.9 2.0]
|
||||
#define Fall_G 1.0 // the color of the plants during this season [0.0 0.1 0.2 0.3 0.4 0.5 0.6 0.7 0.8 0.9 1.0 1.1 1.2 1.3 1.4 1.5 1.6 1.7 1.8 1.9 2.0]
|
||||
#define Fall_B 1.0 // the color of the plants during this season [0.0 0.1 0.2 0.3 0.4 0.5 0.6 0.7 0.8 0.9 1.0 1.1 1.2 1.3 1.4 1.5 1.6 1.7 1.8 1.9 2.0]
|
||||
#define Fall_Leaf_R 1.8 // the color of the plants during this season [0.0 0.1 0.2 0.3 0.4 0.5 0.6 0.7 0.8 0.9 1.0 1.1 1.2 1.3 1.4 1.5 1.6 1.7 1.8 1.9 2.0]
|
||||
#define Fall_Leaf_G 0.8 // the color of the plants during this season [0.0 0.1 0.2 0.3 0.4 0.5 0.6 0.7 0.8 0.9 1.0 1.1 1.2 1.3 1.4 1.5 1.6 1.7 1.8 1.9 2.0]
|
||||
#define Fall_Leaf_B 0.0 // the color of the plants during this season [0.0 0.1 0.2 0.3 0.4 0.5 0.6 0.7 0.8 0.9 1.0 1.1 1.2 1.3 1.4 1.5 1.6 1.7 1.8 1.9 2.0]
|
||||
|
||||
#define Winter_R 1.2 // the color of the plants during this season [0.0 0.1 0.2 0.3 0.4 0.5 0.6 0.7 0.8 0.9 1.0 1.1 1.2 1.3 1.4 1.5 1.6 1.7 1.8 1.9 2.0]
|
||||
#define Winter_G 0.8 // the color of the plants during this season [0.0 0.1 0.2 0.3 0.4 0.5 0.6 0.7 0.8 0.9 1.0 1.1 1.2 1.3 1.4 1.5 1.6 1.7 1.8 1.9 2.0]
|
||||
#define Winter_B 1.0 // the color of the plants during this season [0.0 0.1 0.2 0.3 0.4 0.5 0.6 0.7 0.8 0.9 1.0 1.1 1.2 1.3 1.4 1.5 1.6 1.7 1.8 1.9 2.0]
|
||||
#define Winter_Leaf_R 1.2 // the color of the plants during this season [0.0 0.1 0.2 0.3 0.4 0.5 0.6 0.7 0.8 0.9 1.0 1.1 1.2 1.3 1.4 1.5 1.6 1.7 1.8 1.9 2.0]
|
||||
#define Winter_Leaf_G 0.5 // the color of the plants during this season [0.0 0.1 0.2 0.3 0.4 0.5 0.6 0.7 0.8 0.9 1.0 1.1 1.2 1.3 1.4 1.5 1.6 1.7 1.8 1.9 2.0]
|
||||
#define Winter_Leaf_B 1.0 // the color of the plants during this season [0.0 0.1 0.2 0.3 0.4 0.5 0.6 0.7 0.8 0.9 1.0 1.1 1.2 1.3 1.4 1.5 1.6 1.7 1.8 1.9 2.0]
|
||||
|
||||
#define Spring_R 1.0 // the color of the plants during this season [0.0 0.1 0.2 0.3 0.4 0.5 0.6 0.7 0.8 0.9 1.0 1.1 1.2 1.3 1.4 1.5 1.6 1.7 1.8 1.9 2.0]
|
||||
#define Spring_G 0.9 // the color of the plants during this season [0.0 0.1 0.2 0.3 0.4 0.5 0.6 0.7 0.8 0.9 1.0 1.1 1.2 1.3 1.4 1.5 1.6 1.7 1.8 1.9 2.0]
|
||||
#define Spring_B 1.1 // the color of the plants during this season [0.0 0.1 0.2 0.3 0.4 0.5 0.6 0.7 0.8 0.9 1.0 1.1 1.2 1.3 1.4 1.5 1.6 1.7 1.8 1.9 2.0]
|
||||
#define Spring_Leaf_R 1.0 // the color of the plants during this season [0.0 0.1 0.2 0.3 0.4 0.5 0.6 0.7 0.8 0.9 1.0 1.1 1.2 1.3 1.4 1.5 1.6 1.7 1.8 1.9 2.0]
|
||||
#define Spring_Leaf_G 0.8 // the color of the plants during this season [0.0 0.1 0.2 0.3 0.4 0.5 0.6 0.7 0.8 0.9 1.0 1.1 1.2 1.3 1.4 1.5 1.6 1.7 1.8 1.9 2.0]
|
||||
#define Spring_Leaf_B 0.8 // the color of the plants during this season [0.0 0.1 0.2 0.3 0.4 0.5 0.6 0.7 0.8 0.9 1.0 1.1 1.2 1.3 1.4 1.5 1.6 1.7 1.8 1.9 2.0]
|
||||
|
||||
|
||||
#define Daily_Weather // different skies for different days, and fog.
|
||||
#define WeatherDay -1 // [-1 0 1 2 3 4 5 6 7]
|
||||
|
||||
#define cloudCoverage 0.4 // Cloud coverage [ 0.0 0.1 0.2 0.3 0.4 0.5 0.6 0.7 0.8 0.9 1.0]
|
||||
#define Rain_coverage 0.6 // how much the coverage of the clouds change during rain [ 0.0 0.1 0.2 0.3 0.4 0.5 0.6 0.7 0.8 0.9 1.0 1.2 1.3 1.4 1.5 1.6 1.7 1.8 1.9 2.0 3.0 4.0 5.0]
|
||||
|
||||
#define Biome_specific_environment // makes the fog density and color look unique in certain biomes. (swamps, jungles, lush caves, giant pines, dark forests)
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
///////////////////////////////// SEASONS /////////////////////////////////////
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
/////////////////////////////////////////////////////////////////////////////// VERTEX SHADER
|
||||
#ifdef Seasons
|
||||
#ifdef SEASONS_VSH
|
||||
varying vec4 seasonColor;
|
||||
void YearCycleColor (
|
||||
inout vec3 FinalColor,
|
||||
vec3 glcolor
|
||||
){
|
||||
// colors for things that arent leaves and using the tint index.
|
||||
vec3 SummerCol = vec3(Summer_R, Summer_G, Summer_B) * glcolor;
|
||||
vec3 AutumnCol = vec3(Fall_R, Fall_G, Fall_B) * glcolor;
|
||||
vec3 WinterCol = vec3(Winter_R, Winter_G, Winter_B) ;
|
||||
vec3 SpringCol = vec3(Spring_R, Spring_G, Spring_B) * glcolor;
|
||||
|
||||
// do leaf colors different because thats cool and i like it
|
||||
if(mc_Entity.x == 10003){
|
||||
SummerCol = vec3(Summer_Leaf_R, Summer_Leaf_G, Summer_Leaf_B) * glcolor;
|
||||
AutumnCol = vec3(Fall_Leaf_R, Fall_Leaf_G, Fall_Leaf_B) * glcolor;
|
||||
WinterCol = vec3(Winter_Leaf_R, Winter_Leaf_G, Winter_Leaf_B) ;
|
||||
SpringCol = vec3(Spring_Leaf_R, Spring_Leaf_G, Spring_Leaf_B)* glcolor;
|
||||
}
|
||||
|
||||
// length of each season in minecraft days
|
||||
int SeasonLength = Season_Length;
|
||||
|
||||
// loop the year. multiply the season length by the 4 seasons to create a years time.
|
||||
float YearLoop = mod(worldDay, SeasonLength * 4);
|
||||
|
||||
// the time schedule for each season
|
||||
float SummerTime = clamp(YearLoop ,0, SeasonLength) / SeasonLength;
|
||||
float AutumnTime = clamp(YearLoop - SeasonLength ,0, SeasonLength) / SeasonLength;
|
||||
float WinterTime = clamp(YearLoop - SeasonLength*2 ,0, SeasonLength) / SeasonLength;
|
||||
float SpringTime = clamp(YearLoop - SeasonLength*3 ,0, SeasonLength) / SeasonLength;
|
||||
|
||||
// lerp all season colors together
|
||||
vec3 SummerToFall = mix(SummerCol, AutumnCol, SummerTime);
|
||||
vec3 FallToWinter = mix(SummerToFall, WinterCol, AutumnTime);
|
||||
vec3 WinterToSpring = mix(FallToWinter, SpringCol, WinterTime);
|
||||
vec3 SpringToSummer = mix(WinterToSpring, SummerCol, SpringTime);
|
||||
|
||||
// make it so that you only have access to parts of the texture that use the tint index
|
||||
bool IsTintIndex = floor(dot(glcolor,vec3(0.5))) < 1.0;
|
||||
|
||||
// multiply final color by the final lerped color, because it contains all the other colors.
|
||||
if (IsTintIndex && mc_Entity.x != 200) FinalColor = SpringToSummer;
|
||||
}
|
||||
#endif
|
||||
#endif
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
////////////////////////////// DAILY WEATHER //////////////////////////////////
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
#ifdef WEATHERCLOUDS
|
||||
uniform float CumulusCoverage;
|
||||
uniform float CirrusCoverage;
|
||||
uniform float CirrusThickness;
|
||||
|
||||
float DailyWeather_LowAltitude(
|
||||
float Coverage
|
||||
){
|
||||
|
||||
#ifdef Daily_Weather
|
||||
int W_DAY = WeatherDay;
|
||||
|
||||
if(W_DAY > -1) {
|
||||
if(W_DAY == 0) Coverage += 0.1;
|
||||
if(W_DAY == 1) Coverage += 0.5;
|
||||
if(W_DAY == 2) Coverage += 0.2;
|
||||
if(W_DAY == 3) Coverage += 0.8;
|
||||
if(W_DAY == 4) Coverage += 0.1;
|
||||
if(W_DAY == 5) Coverage += 0.6;
|
||||
if(W_DAY == 6) Coverage += 0.0;
|
||||
if(W_DAY == 7) Coverage += 1.0;
|
||||
}else{
|
||||
Coverage += mix(CumulusCoverage, Rain_coverage, rainStrength);
|
||||
}
|
||||
#else
|
||||
Coverage += mix(cloudCoverage, Rain_coverage, rainStrength);
|
||||
#endif
|
||||
|
||||
return Coverage;
|
||||
}
|
||||
|
||||
void DailyWeather_HighAltitude(
|
||||
inout float Coverage,
|
||||
inout float Thickness
|
||||
){
|
||||
|
||||
#ifdef Daily_Weather
|
||||
float W_DAY = WeatherDay;
|
||||
|
||||
if(W_DAY > -1) {
|
||||
if(W_DAY == 0){ Coverage = 0.8; Thickness = 0.5; }
|
||||
if(W_DAY == 1){ Coverage = 0.8; Thickness = 0.5; }
|
||||
if(W_DAY == 2){ Coverage = 0.0; Thickness = 0.5; }
|
||||
if(W_DAY == 3){ Coverage = 0.0; Thickness = 0.5; }
|
||||
if(W_DAY == 4){ Coverage = 0.0; Thickness = 0.5; }
|
||||
if(W_DAY == 5){ Coverage = 0.0; Thickness = 0.5; }
|
||||
if(W_DAY == 6){ Coverage = 0.0; Thickness = 0.5; }
|
||||
if(W_DAY == 7){ Coverage = 0.0; Thickness = 0.5; }
|
||||
}else{
|
||||
Coverage = CirrusCoverage;
|
||||
Thickness = CirrusThickness;
|
||||
}
|
||||
#else
|
||||
Coverage = 0.5;
|
||||
Thickness = 0.05;
|
||||
#endif
|
||||
|
||||
Coverage = pow(1.0-Coverage,3) * 50;
|
||||
Thickness = Thickness * 10;
|
||||
}
|
||||
#endif
|
||||
|
||||
#ifdef Daily_Weather
|
||||
uniform float Day;
|
||||
|
||||
void DailyWeather_FogDensity(
|
||||
inout vec4 UniformDensity,
|
||||
inout vec4 CloudyDensity
|
||||
){
|
||||
// it's so symmetrical~
|
||||
float day0 = clamp(clamp(Day, 0.0,1.0)*clamp(2-Day, 0.0,1.0),0.0,1.0);
|
||||
float day1 = clamp(clamp(Day-1, 0.0,1.0)*clamp(3-Day, 0.0,1.0),0.0,1.0);
|
||||
float day2 = clamp(clamp(Day-2, 0.0,1.0)*clamp(4-Day, 0.0,1.0),0.0,1.0);
|
||||
float day3 = clamp(clamp(Day-3, 0.0,1.0)*clamp(5-Day, 0.0,1.0),0.0,1.0);
|
||||
float day4 = clamp(clamp(Day-4, 0.0,1.0)*clamp(6-Day, 0.0,1.0),0.0,1.0);
|
||||
float day5 = clamp(clamp(Day-5, 0.0,1.0)*clamp(7-Day, 0.0,1.0),0.0,1.0);
|
||||
float day6 = clamp(clamp(Day-6, 0.0,1.0)*clamp(8-Day, 0.0,1.0),0.0,1.0);
|
||||
float day7 = clamp(clamp(Day-7, 0.0,1.0)*clamp(9-Day, 0.0,1.0),0.0,1.0);
|
||||
|
||||
// set fog Profiles for each of the 8 days in the cycle.
|
||||
// U = uniform fog || C = cloudy fog
|
||||
vec4 MistyDay_U = vec4(5);
|
||||
|
||||
vec4 FoggyDay_U = vec4(5);
|
||||
vec4 FoggyDay_C = vec4(25);
|
||||
|
||||
|
||||
UniformDensity += FoggyDay_U*day1 + MistyDay_U*day4;
|
||||
CloudyDensity += FoggyDay_C*day1;
|
||||
}
|
||||
#endif
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
///////////////////////////// BIOME SPECIFICS /////////////////////////////////
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
#ifdef Biome_specific_environment
|
||||
uniform float isJungles;
|
||||
uniform float isSwamps;
|
||||
uniform float isLush;
|
||||
uniform float isDeserts;
|
||||
|
||||
void BiomeFogColor(
|
||||
inout vec3 FinalFogColor
|
||||
){
|
||||
// this is a little complicated? lmao
|
||||
vec3 BiomeColors;
|
||||
BiomeColors.r = isSwamps*0.7 + isJungles*0.5;
|
||||
BiomeColors.g = isSwamps*1.0 + isJungles*1.0;
|
||||
BiomeColors.b = isSwamps*0.35 + isJungles*0.8;
|
||||
|
||||
// insure the biome colors are locked to the fog shape and lighting, but not its orignal color.
|
||||
BiomeColors *= dot(FinalFogColor,vec3(0.5));
|
||||
|
||||
// these range 0.0-1.0. they will never overlap.
|
||||
float Inbiome = isJungles+isSwamps;
|
||||
|
||||
// interpoloate between normal fog colors and biome colors. the transition speeds are conrolled by the biome uniforms.
|
||||
FinalFogColor = mix(FinalFogColor, BiomeColors, Inbiome);
|
||||
}
|
||||
|
||||
void BiomeFogDensity(
|
||||
inout vec4 UniformDensity,
|
||||
inout vec4 CloudyDensity
|
||||
){
|
||||
// these range 0.0-1.0. they will never overlap.
|
||||
float Inbiome = isJungles+isSwamps;
|
||||
|
||||
vec2 BiomeFogDensity; // x = uniform || y = cloudy
|
||||
BiomeFogDensity.x = isSwamps*5 + isJungles*5;
|
||||
BiomeFogDensity.y = isSwamps*50 + isJungles*2;
|
||||
|
||||
UniformDensity = mix(UniformDensity, vec4(BiomeFogDensity.x), Inbiome);
|
||||
CloudyDensity = mix(CloudyDensity, vec4(BiomeFogDensity.y), Inbiome);
|
||||
}
|
||||
#endif
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
////////////////////////////// FOG CONTROLLER /////////////////////////////////
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
#ifdef TIMEOFDAYFOG
|
||||
uniform int worldTime;
|
||||
void TimeOfDayFog(inout float Uniform, inout float Cloudy) {
|
||||
|
||||
float Time = (worldTime%24000)*1.0;
|
||||
|
||||
// set schedules for fog to appear at specific ranges of time in the day.
|
||||
float Morning = clamp((Time-22000)/2000,0,1) + clamp((2000-Time)/2000,0,1);
|
||||
float Noon = clamp(Time/2000,0,1) * clamp((12000-Time)/2000,0,1);
|
||||
float Evening = clamp((Time-10000)/2000,0,1) * clamp((14000-Time)/2000,0,1) ;
|
||||
float Night = clamp((Time-13000)/2000,0,1) * clamp((23000-Time)/2000,0,1) ;
|
||||
|
||||
// set densities. morn, noon, even, night
|
||||
vec4 UniformDensity = vec4(1.0, 0.0, 1.0, 10.0);
|
||||
vec4 CloudyDensity = vec4(5.0, 0.0, 5.0, 25.0);
|
||||
|
||||
#ifdef Daily_Weather
|
||||
DailyWeather_FogDensity(UniformDensity, CloudyDensity); // let daily weather influence fog densities.
|
||||
#endif
|
||||
|
||||
#ifdef Biome_specific_environment
|
||||
BiomeFogDensity(UniformDensity, CloudyDensity); // 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;
|
||||
Cloudy *= Morning*CloudyDensity.r + Noon*CloudyDensity.g + Evening*CloudyDensity.b + Night*CloudyDensity.a;
|
||||
}
|
||||
#endif
|
16
shaders/lib/clouds.glsl
Normal file
16
shaders/lib/clouds.glsl
Normal file
@ -0,0 +1,16 @@
|
||||
vec3 cloud2D(vec3 fragpos,vec3 col){
|
||||
vec3 wpos = fragpos;
|
||||
float wind = frameTimeCounter/200.;
|
||||
vec2 intersection = ((2000.0-cameraPosition.y)*wpos.xz*inversesqrt(wpos.y+cameraPosition.y/512.-50./512.) + cameraPosition.xz+wind)/40000.;
|
||||
|
||||
|
||||
float phase = pow(clamp(dot(fragpos,sunVec),0.,1.),2.)*0.5+0.5;
|
||||
|
||||
float fbm = clamp((texture2D(noisetex,intersection*vec2(1.,1.5)).a + texture2D(noisetex,intersection*vec2(2.,7.)+wind*0.4).a/2.)-0.5*(1.0-rainStrength),0.,1.) ;
|
||||
|
||||
|
||||
|
||||
|
||||
return mix(col,6.*(vec3(0.9,1.2,1.5)*skyIntensityNight*0.02*(1.0-rainStrength*0.9)+17.*phase*nsunColor*skyIntensity*0.7*(1.0-rainStrength*0.9)),0.0*(fbm*fbm)*(fbm*fbm)*(fbm*clamp(wpos.y*0.9,0.,1.)));
|
||||
|
||||
}
|
46
shaders/lib/color_dither.glsl
Normal file
46
shaders/lib/color_dither.glsl
Normal file
@ -0,0 +1,46 @@
|
||||
//using white noise for color dithering : gives a somewhat more "filmic" look when noise is visible
|
||||
float nrand( vec2 n )
|
||||
{
|
||||
return fract(sin(dot(n.xy, vec2(12.9898, 78.233)))* 43758.5453);
|
||||
}
|
||||
|
||||
float triangWhiteNoise( vec2 n )
|
||||
{
|
||||
|
||||
float t = fract( frameTimeCounter );
|
||||
float rnd = nrand( n + 0.07*t );
|
||||
|
||||
float center = rnd*2.0-1.0;
|
||||
rnd = center*inversesqrt(abs(center));
|
||||
rnd = max(-1.0,rnd);
|
||||
return rnd-sign(center);
|
||||
}
|
||||
|
||||
vec3 fp10Dither(vec3 color,vec2 tc01){
|
||||
float dither = triangWhiteNoise(tc01);
|
||||
const vec3 mantissaBits = vec3(6.,6.,5.);
|
||||
vec3 exponent = floor(log2(color));
|
||||
return color + dither*exp2(-mantissaBits)*exp2(exponent);
|
||||
}
|
||||
|
||||
vec3 fp16Dither(vec3 color,vec2 tc01){
|
||||
float dither = triangWhiteNoise(tc01);
|
||||
const vec3 mantissaBits = vec3(10.);
|
||||
vec3 exponent = floor(log2(color));
|
||||
return color + dither*exp2(-mantissaBits)*exp2(exponent);
|
||||
}
|
||||
|
||||
vec3 int8Dither(vec3 color,vec2 tc01){
|
||||
float dither = triangWhiteNoise(tc01);
|
||||
return color + dither*exp2(-8.0);
|
||||
}
|
||||
|
||||
vec3 int10Dither(vec3 color,vec2 tc01){
|
||||
float dither = triangWhiteNoise(tc01);
|
||||
return color + dither*exp2(-10.0);
|
||||
}
|
||||
|
||||
vec3 int16Dither(vec3 color,vec2 tc01){
|
||||
float dither = triangWhiteNoise(tc01);
|
||||
return color + dither*exp2(-16.0);
|
||||
}
|
157
shaders/lib/color_transforms.glsl
Normal file
157
shaders/lib/color_transforms.glsl
Normal file
@ -0,0 +1,157 @@
|
||||
//faster and actually more precise than pow 2.2
|
||||
vec3 toLinear(vec3 sRGB){
|
||||
return sRGB * (sRGB * (sRGB * 0.305306011 + 0.682171111) + 0.012522878);
|
||||
}
|
||||
|
||||
float luma(vec3 color) {
|
||||
return dot(color,vec3(0.299, 0.587, 0.114));
|
||||
}
|
||||
|
||||
const mat3 ACESInputMat =
|
||||
mat3(0.59719, 0.35458, 0.04823,
|
||||
0.07600, 0.90834, 0.01566,
|
||||
0.02840, 0.13383, 0.83777
|
||||
);
|
||||
|
||||
// ODT_SAT => XYZ => D60_2_D65 => sRGB
|
||||
const mat3 ACESOutputMat =
|
||||
mat3( 1.60475, -0.53108, -0.07367,
|
||||
-0.10208, 1.10813, -0.00605,
|
||||
-0.00327, -0.07276, 1.07602
|
||||
);
|
||||
vec3 LinearTosRGB(in vec3 color)
|
||||
{
|
||||
vec3 x = color * 12.92f;
|
||||
vec3 y = 1.055f * pow(clamp(color,0.0,1.0), vec3(1.0f / 2.4f)) - 0.055f;
|
||||
|
||||
vec3 clr = color;
|
||||
clr.r = color.r < 0.0031308f ? x.r : y.r;
|
||||
clr.g = color.g < 0.0031308f ? x.g : y.g;
|
||||
clr.b = color.b < 0.0031308f ? x.b : y.b;
|
||||
|
||||
return clr;
|
||||
}
|
||||
vec3 ToneMap_Hejl2015(in vec3 hdr)
|
||||
{
|
||||
vec4 vh = vec4(hdr*0.85, 3.0); //0
|
||||
vec4 va = (1.75 * vh) + 0.05; //0.05
|
||||
vec4 vf = ((vh * va + 0.004f) / ((vh * (va + 0.55f) + 0.0491f))) - 0.0821f+0.000633604888; //((0+0.004)/((0*(0.05+0.55)+0.0491)))-0.0821
|
||||
return vf.xyz / vf.www;
|
||||
}
|
||||
vec3 HableTonemap(vec3 linearColor) {
|
||||
// A = shoulder strength
|
||||
const float A = 0.45;
|
||||
// B = linear strength
|
||||
const float B = 0.28;
|
||||
// C = linear angle
|
||||
const float C = 0.1;
|
||||
// D = toe strength
|
||||
const float D = 0.5;
|
||||
// E = toe numerator
|
||||
const float E = 0.01;
|
||||
// F = toe denominator
|
||||
const float F = 0.3;
|
||||
// Note: E / F = toe angle
|
||||
// linearWhite = linear white point value
|
||||
|
||||
vec3 x = linearColor*2.0;
|
||||
vec3 color = ((x * (A * x + C * B) + D * E) / (x * (A * x + B) + D * F)) - E / F;
|
||||
|
||||
const float W = 11.0;
|
||||
const float white = ((W * (A * W + C * B) + D * E) / (W * (A * W + B) + D * F)) - E / F;
|
||||
|
||||
return color / white;
|
||||
}
|
||||
|
||||
vec3 reinhard(vec3 x){
|
||||
x *= 1.66;
|
||||
return x/(1.0+x);
|
||||
}
|
||||
vec3 ACESFilm( vec3 x )
|
||||
{
|
||||
x*=0.9;
|
||||
float a = 2.51f;
|
||||
float b = 0.03f;
|
||||
float c = 2.43f;
|
||||
float d = 0.59f;
|
||||
float e = 0.14f;
|
||||
return (x*(a*x+b))/(x*(c*x+d)+e);
|
||||
}
|
||||
|
||||
// From https://www.shadertoy.com/view/WdjSW3
|
||||
vec3 Tonemap_Lottes(vec3 x) {
|
||||
// Lottes 2016, "Advanced Techniques and Optimization of HDR Color Pipelines"
|
||||
const float a = 1.6;
|
||||
const float d = 0.977;
|
||||
const float hdrMax = 8.0;
|
||||
const float midIn = 0.23;
|
||||
const float midOut = 0.267;
|
||||
|
||||
// Can be precomputed
|
||||
const float b =
|
||||
(-pow(midIn, a) + pow(hdrMax, a) * midOut) /
|
||||
((pow(hdrMax, a * d) - pow(midIn, a * d)) * midOut);
|
||||
const float c =
|
||||
(pow(hdrMax, a * d) * pow(midIn, a) - pow(hdrMax, a) * pow(midIn, a * d) * midOut) /
|
||||
((pow(hdrMax, a * d) - pow(midIn, a * d)) * midOut);
|
||||
|
||||
return pow(x,vec3(a)) / (pow(x, vec3(a * d)) * b + c);
|
||||
}
|
||||
vec3 curve(vec3 x){
|
||||
return 1.0 - x/(1.0+x);
|
||||
}
|
||||
vec3 Tonemap_Uchimura_Modified(vec3 x, float P, float a, float m, float l, float c, float b) {
|
||||
// Uchimura 2017, "HDR theory and practice"
|
||||
// Math: https://www.desmos.com/calculator/gslcdxvipg
|
||||
// Source: https://www.slideshare.net/nikuque/hdr-theory-and-practicce-jp
|
||||
float l0 = ((P - m) * l) / a;
|
||||
float L0 = m - m / a;
|
||||
float L1 = m + (1.0 - m) / a;
|
||||
float S0 = m + l0;
|
||||
float S1 = m + a * l0;
|
||||
float C2 = (a * P) / (P - S1);
|
||||
float CP = C2 / P;
|
||||
|
||||
vec3 w0 = 1.0 - smoothstep(x, vec3(0.0), vec3(m));
|
||||
vec3 w2 = step(m + l0, x);
|
||||
vec3 w1 = 1.0 - w0 - w2;
|
||||
|
||||
vec3 T = m * pow(x / m, vec3(c)) + b;
|
||||
vec3 S = P - (P - S1) * curve(CP * (x - S0));
|
||||
vec3 L = m + a * (x - m);
|
||||
|
||||
return clamp(T * w0 + L * w1 + S * w2,0.0,1.0);
|
||||
}
|
||||
// From https://www.shadertoy.com/view/WdjSW3
|
||||
vec3 Tonemap_Uchimura(vec3 x, float P, float a, float m, float l, float c, float b) {
|
||||
// Uchimura 2017, "HDR theory and practice"
|
||||
// Math: https://www.desmos.com/calculator/gslcdxvipg
|
||||
// Source: https://www.slideshare.net/nikuque/hdr-theory-and-practicce-jp
|
||||
float l0 = ((P - m) * l) / a;
|
||||
float L0 = m - m / a;
|
||||
float L1 = m + (1.0 - m) / a;
|
||||
float S0 = m + l0;
|
||||
float S1 = m + a * l0;
|
||||
float C2 = (a * P) / (P - S1);
|
||||
float CP = -C2 / P;
|
||||
|
||||
vec3 w0 = 1.0 - smoothstep(x, vec3(0.0), vec3(m));
|
||||
vec3 w2 = step(m + l0, x);
|
||||
vec3 w1 = 1.0 - w0 - w2;
|
||||
|
||||
vec3 T = m * pow(x / m, vec3(c)) + b;
|
||||
vec3 S = P - (P - S1) * exp(CP * (x - S0));
|
||||
vec3 L = m + a * (x - m);
|
||||
|
||||
return clamp(T * w0 + L * w1 + S * w2,0.0,1.0);
|
||||
}
|
||||
|
||||
vec3 Tonemap_Uchimura(vec3 x) {
|
||||
const float P = 1.0; // max display brightness 1.0
|
||||
const float a = 1.0; // contrast 1.0
|
||||
const float m = 0.12; // linear section start 0.22
|
||||
const float l = 0.22; // linear section length 0.4
|
||||
const float c = 1.5; // black 1.33
|
||||
const float b = 0.0; // pedestal 0.0
|
||||
return Tonemap_Uchimura_Modified(x, P, a, m, l, c, b);
|
||||
}
|
55
shaders/lib/projections.glsl
Normal file
55
shaders/lib/projections.glsl
Normal file
@ -0,0 +1,55 @@
|
||||
uniform mat4 gbufferProjection;
|
||||
uniform mat4 gbufferProjectionInverse;
|
||||
uniform mat4 gbufferPreviousProjection;
|
||||
uniform mat4 gbufferModelViewInverse;
|
||||
uniform mat4 gbufferModelView;
|
||||
uniform mat4 shadowModelView;
|
||||
uniform mat4 shadowProjection;
|
||||
|
||||
uniform vec3 cameraPosition;
|
||||
|
||||
|
||||
#define diagonal3(m) vec3((m)[0].x, (m)[1].y, m[2].z)
|
||||
#define projMAD(m, v) (diagonal3(m) * (v) + (m)[3].xyz)
|
||||
|
||||
vec3 toClipSpace3(vec3 viewSpacePosition) {
|
||||
return projMAD(gbufferProjection, viewSpacePosition) / -viewSpacePosition.z * 0.5 + 0.5;
|
||||
}
|
||||
|
||||
vec3 toScreenSpace(vec3 p) {
|
||||
vec4 iProjDiag = vec4(gbufferProjectionInverse[0].x, gbufferProjectionInverse[1].y, gbufferProjectionInverse[2].zw);
|
||||
vec3 p3 = p * 2. - 1.;
|
||||
vec4 fragposition = iProjDiag * p3.xyzz + gbufferProjectionInverse[3];
|
||||
return fragposition.xyz / fragposition.w;
|
||||
}
|
||||
|
||||
vec3 toScreenSpaceVector(vec3 p) {
|
||||
vec4 iProjDiag = vec4(gbufferProjectionInverse[0].x, gbufferProjectionInverse[1].y, gbufferProjectionInverse[2].zw);
|
||||
vec3 p3 = p * 2. - 1.;
|
||||
vec4 fragposition = iProjDiag * p3.xyzz + gbufferProjectionInverse[3];
|
||||
return normalize(fragposition.xyz);
|
||||
}
|
||||
|
||||
vec3 toWorldSpace(vec3 p3){
|
||||
p3 = mat3(gbufferModelViewInverse) * p3 + gbufferModelViewInverse[3].xyz;
|
||||
return p3;
|
||||
}
|
||||
|
||||
vec3 toWorldSpaceCamera(vec3 p3){
|
||||
p3 = mat3(gbufferModelViewInverse) * p3 + gbufferModelViewInverse[3].xyz;
|
||||
return p3 + cameraPosition;
|
||||
}
|
||||
|
||||
vec3 toShadowSpace(vec3 p3){
|
||||
p3 = mat3(gbufferModelViewInverse) * p3 + gbufferModelViewInverse[3].xyz;
|
||||
p3 = mat3(shadowModelView) * p3 + shadowModelView[3].xyz;
|
||||
return p3;
|
||||
}
|
||||
|
||||
vec3 toShadowSpaceProjected(vec3 p3){
|
||||
p3 = mat3(gbufferModelViewInverse) * p3 + gbufferModelViewInverse[3].xyz;
|
||||
p3 = mat3(shadowModelView) * p3 + shadowModelView[3].xyz;
|
||||
p3 = diagonal3(shadowProjection) * p3 + shadowProjection[3].xyz;
|
||||
|
||||
return p3;
|
||||
}
|
20
shaders/lib/res_params.glsl
Normal file
20
shaders/lib/res_params.glsl
Normal file
@ -0,0 +1,20 @@
|
||||
#define TAA
|
||||
// #define TAA_UPSCALING // Lowers render resolution and uses TAA to combine several lower resolution images (greatly improves performance). USE THIS INSTEAD OF SHADER RENDER QUALITY OPTION IF YOU WANT TO INCREASE FPS (Leave it to 1). IF YOU WANT TO INCREASE QUALITY DISABLE THIS AND INCREASE SHADER RENDER QUALITY
|
||||
#ifndef TAA
|
||||
#undef TAA_UPSCALING
|
||||
#endif
|
||||
|
||||
|
||||
|
||||
#ifdef TAA_UPSCALING
|
||||
#define RENDER_SCALE_X 0.7 // X axis render resolution multiplier [0.5 0.51 0.52 0.53 0.54 0.55 0.56 0.57 0.58 0.59 0.6 0.61 0.62 0.63 0.64 0.65 0.66 0.67 0.68 0.69 0.7 0.71 0.72 0.73 0.74 0.75 0.76 0.77 0.78 0.79 0.8 0.81 0.82 0.83 0.84 0.85 0.86 0.87 0.88 0.89 0.9 0.91 0.92 0.93 0.94 0.95 0.96 0.97 0.98 0.99 1. ]
|
||||
#define RENDER_SCALE_Y 0.7 // Y axis render resolution multiplier [0.5 0.51 0.52 0.53 0.54 0.55 0.56 0.57 0.58 0.59 0.6 0.61 0.62 0.63 0.64 0.65 0.66 0.67 0.68 0.69 0.7 0.71 0.72 0.73 0.74 0.75 0.76 0.77 0.78 0.79 0.8 0.81 0.82 0.83 0.84 0.85 0.86 0.87 0.88 0.89 0.9 0.91 0.92 0.93 0.94 0.95 0.96 0.97 0.98 0.99 1. ]
|
||||
#define RENDER_SCALE vec2(RENDER_SCALE_X, RENDER_SCALE_Y)
|
||||
#define UPSCALING_SHARPNENING 2.0 - RENDER_SCALE_X - RENDER_SCALE_Y
|
||||
#else
|
||||
#define RENDER_SCALE vec2(1.0, 1.0)
|
||||
#define UPSCALING_SHARPNENING 0.0
|
||||
#endif
|
||||
|
||||
#define BLOOM_QUALITY 0.5 // Reduces the resolution at which bloom is computed. (0.5 = half of default resolution) [0.5 0.51 0.52 0.53 0.54 0.55 0.56 0.57 0.58 0.59 0.6 0.61 0.62 0.63 0.64 0.65 0.66 0.67 0.68 0.69 0.7 0.71 0.72 0.73 0.74 0.75 0.76 0.77 0.78 0.79 0.8 0.81 0.82 0.83 0.84 0.85 0.86 0.87 0.88 0.89 0.9 0.91 0.92 0.93 0.94 0.95 0.96 0.97 0.98 0.99 1. ]
|
||||
#define VL_RENDER_RESOLUTION 0.5 // Reduces the resolution at which volumetric fog is computed. (0.5 = half of default resolution) [0.25 0.5 1.0]
|
45
shaders/lib/settings.glsl
Normal file
45
shaders/lib/settings.glsl
Normal file
@ -0,0 +1,45 @@
|
||||
#define Moon_temp 15000 // [1000 2000 3000 4000 5000 6000 7000 8000 9000 10000]
|
||||
|
||||
|
||||
|
||||
#define CAVE_LIGHT_LEAK_FIX // Hackish way to remove sunlight incorrectly leaking into the caves. Can inacurrately create shadows in some places
|
||||
#define CLOUDS_SHADOWS
|
||||
#define CLOUDS_QUALITY 0.5 //[0.1 0.125 0.15 0.2 0.25 0.3 0.35 0.4 0.45 0.5 0.55 0.6 0.65 0.7 0.75 0.8 0.9 1.0]
|
||||
#define TORCH_R 1.0 // [0.01 0.02 0.03 0.04 0.05 0.06 0.07 0.08 0.09 0.1 0.11 0.12 0.13 0.14 0.15 0.16 0.17 0.18 0.19 0.2 0.21 0.22 0.23 0.24 0.25 0.26 0.27 0.28 0.29 0.3 0.31 0.32 0.33 0.34 0.35 0.36 0.37 0.38 0.39 0.4 0.41 0.42 0.43 0.44 0.45 0.46 0.47 0.48 0.49 0.5 0.51 0.52 0.53 0.54 0.55 0.56 0.57 0.58 0.59 0.6 0.61 0.62 0.63 0.64 0.65 0.66 0.67 0.68 0.69 0.7 0.71 0.72 0.73 0.74 0.75 0.76 0.77 0.78 0.79 0.8 0.81 0.82 0.83 0.84 0.85 0.86 0.87 0.88 0.89 0.9 0.91 0.92 0.93 0.94 0.95 0.96 0.97 0.98 0.99 1.0]
|
||||
#define TORCH_G 0.75 // [0.01 0.02 0.03 0.04 0.05 0.06 0.07 0.08 0.09 0.1 0.11 0.12 0.13 0.14 0.15 0.16 0.17 0.18 0.19 0.2 0.21 0.22 0.23 0.24 0.25 0.26 0.27 0.28 0.29 0.3 0.31 0.32 0.33 0.34 0.35 0.36 0.37 0.38 0.39 0.4 0.41 0.42 0.43 0.44 0.45 0.46 0.47 0.48 0.49 0.5 0.51 0.52 0.53 0.54 0.55 0.56 0.57 0.58 0.59 0.6 0.61 0.62 0.63 0.64 0.65 0.66 0.67 0.68 0.69 0.7 0.71 0.72 0.73 0.74 0.75 0.76 0.77 0.78 0.79 0.8 0.81 0.82 0.83 0.84 0.85 0.86 0.87 0.88 0.89 0.9 0.91 0.92 0.93 0.94 0.95 0.96 0.97 0.98 0.99 1.0]
|
||||
#define TORCH_B 0.5 // [0.01 0.02 0.03 0.04 0.05 0.06 0.07 0.08 0.09 0.1 0.11 0.12 0.13 0.14 0.15 0.16 0.17 0.18 0.19 0.2 0.21 0.22 0.23 0.24 0.25 0.26 0.27 0.28 0.29 0.3 0.31 0.32 0.33 0.34 0.35 0.36 0.37 0.38 0.39 0.4 0.41 0.42 0.43 0.44 0.45 0.46 0.47 0.48 0.49 0.5 0.51 0.52 0.53 0.54 0.55 0.56 0.57 0.58 0.59 0.6 0.61 0.62 0.63 0.64 0.65 0.66 0.67 0.68 0.69 0.7 0.71 0.72 0.73 0.74 0.75 0.76 0.77 0.78 0.79 0.8 0.81 0.82 0.83 0.84 0.85 0.86 0.87 0.88 0.89 0.9 0.91 0.92 0.93 0.94 0.95 0.96 0.97 0.98 0.99 1.0]
|
||||
|
||||
#define ambient_colortype 0 // Toggle which method you want to change the color of ambient light with. [0 1]
|
||||
#define ambient_temp 9000 // [1000 2000 3000 4000 5000 6000 7000 8000 9000 10000 15000 50000]
|
||||
#define ambient_brightness 1.0 // [0.0 0.1 0.2 0.3 0.4 0.5 0.6 0.7 0.8 0.9 1.0 1.1 1.2 1.3 1.4 1.5 1.6 1.7 1.8 1.9 2.0 2.1 2.2 2.3 2.4 2.5 2.6 2.7 2.8 2.9 3.0 ]
|
||||
#define AmbientLight_R 0.91 // [0.01 0.02 0.03 0.04 0.05 0.06 0.07 0.08 0.09 0.1 0.11 0.12 0.13 0.14 0.15 0.16 0.17 0.18 0.19 0.2 0.21 0.22 0.23 0.24 0.25 0.26 0.27 0.28 0.29 0.3 0.31 0.32 0.33 0.34 0.35 0.36 0.37 0.38 0.39 0.4 0.41 0.42 0.43 0.44 0.45 0.46 0.47 0.48 0.49 0.5 0.51 0.52 0.53 0.54 0.55 0.56 0.57 0.58 0.59 0.6 0.61 0.62 0.63 0.64 0.65 0.66 0.67 0.68 0.69 0.7 0.71 0.72 0.73 0.74 0.75 0.76 0.77 0.78 0.79 0.8 0.81 0.82 0.83 0.84 0.85 0.86 0.87 0.88 0.89 0.9 0.91 0.92 0.93 0.94 0.95 0.96 0.97 0.98 0.99 1.0]
|
||||
#define AmbientLight_G 0.86 // [0.01 0.02 0.03 0.04 0.05 0.06 0.07 0.08 0.09 0.1 0.11 0.12 0.13 0.14 0.15 0.16 0.17 0.18 0.19 0.2 0.21 0.22 0.23 0.24 0.25 0.26 0.27 0.28 0.29 0.3 0.31 0.32 0.33 0.34 0.35 0.36 0.37 0.38 0.39 0.4 0.41 0.42 0.43 0.44 0.45 0.46 0.47 0.48 0.49 0.5 0.51 0.52 0.53 0.54 0.55 0.56 0.57 0.58 0.59 0.6 0.61 0.62 0.63 0.64 0.65 0.66 0.67 0.68 0.69 0.7 0.71 0.72 0.73 0.74 0.75 0.76 0.77 0.78 0.79 0.8 0.81 0.82 0.83 0.84 0.85 0.86 0.87 0.88 0.89 0.9 0.91 0.92 0.93 0.94 0.95 0.96 0.97 0.98 0.99 1.0]
|
||||
#define AmbientLight_B 1.0 // [0.01 0.02 0.03 0.04 0.05 0.06 0.07 0.08 0.09 0.1 0.11 0.12 0.13 0.14 0.15 0.16 0.17 0.18 0.19 0.2 0.21 0.22 0.23 0.24 0.25 0.26 0.27 0.28 0.29 0.3 0.31 0.32 0.33 0.34 0.35 0.36 0.37 0.38 0.39 0.4 0.41 0.42 0.43 0.44 0.45 0.46 0.47 0.48 0.49 0.5 0.51 0.52 0.53 0.54 0.55 0.56 0.57 0.58 0.59 0.6 0.61 0.62 0.63 0.64 0.65 0.66 0.67 0.68 0.69 0.7 0.71 0.72 0.73 0.74 0.75 0.76 0.77 0.78 0.79 0.8 0.81 0.82 0.83 0.84 0.85 0.86 0.87 0.88 0.89 0.9 0.91 0.92 0.93 0.94 0.95 0.96 0.97 0.98 0.99 1.0]
|
||||
|
||||
|
||||
#define Sub_surface_scattering // (place the flashlight on your hand example here)
|
||||
// #define LabPBR_subsurface_scattering
|
||||
#define LabSSS_Curve 1.0 // i just really like how it looks at 2.0, so i made it an option. [0.0 0.1 0.2 0.3 0.4 0.5 0.6 0.7 0.8 0.9 1.0 1.1 1.2 1.3 1.4 1.5 1.6 1.7 1.8 1.9 2.0 2.1 2.2 2.3 2.4 2.5 2.6 2.7 2.8 2.9 3.0 ]
|
||||
#define Strong_SSS_strength 45 // [ 0.0 0.1 0.2 0.3 0.4 0.5 0.6 0.7 0.8 0.9 1.0 2 3 4 5 6 7 8 9 10 15 20 30 35 40 45 50]
|
||||
#define Medium_SSS_strength 30 // [ 0.0 0.1 0.2 0.3 0.4 0.5 0.6 0.7 0.8 0.9 1.0 2 3 4 5 6 7 8 9 10 15 20 30 35 40 45 50]
|
||||
|
||||
#define indirect_effect 1 // Choose what effect is applied to indirect light. [0 1 2 3]
|
||||
#define AO_Strength 0.8 // strength of shadowed areas [0.0 0.1 0.2 0.3 0.4 0.5 0.6 0.7 0.8 0.9 1.0 1.1 1.2 1.3 1.4 1.5 1.6 1.7 1.8 1.9 2.0 2.1 2.2 2.3 2.4 2.5 2.6 2.7 2.8 2.9 3.0 ]
|
||||
#define GI_Strength 5.0 // strength of bounced light areas [ 1 2 3 4 5 6 7 8 9 10]
|
||||
// #define HQ_SSGI
|
||||
|
||||
|
||||
// #define LabPBR_Emissives
|
||||
#define Emissive_Brightness 10.0 // [1. 2. 3. 4. 5. 6. 7. 8. 9. 10. 15. 20. 25. 30. 35. 40. 45. 50. 100.]
|
||||
#define Emissive_Curve 2.0 // yes i blatantly copied kappa here. [1.0 1.1 1.2 1.3 1.4 1.5 1.6 1.7 1.8 1.9 2.0 2.1 2.2 2.3 2.4 2.5 2.6 2.7 2.8 2.9 3.0 ]
|
||||
|
||||
#define Puddle_Size 1.0 // [0.5 0.6 0.7 0.8 0.9 1.0 1.1 1.2 1.3 1.4 1.5]
|
||||
#define Puddles // yes
|
||||
// #define Porosity
|
||||
|
||||
|
||||
// #define Allow_Vanilla_sky // allow the vanilla sky to appear. may appear broken with some resourcepacks.
|
||||
|
||||
// #define WhiteWorld // THIS IS A DEBUG VIEW. uses to see AO easier. used to see fake GI better (green light)
|
||||
// #define ambientLight_only // THIS IS A DEBUG VIEW. turn the sunlight off. DOES NOT increase performance, the shadows are still working in the background
|
||||
#define MIN_LIGHT_AMOUNT 1.0 //[0.0 0.5 1.0 1.5 2.0 3.0 4.0 5.0]
|
84
shaders/lib/sky_gradient.glsl
Normal file
84
shaders/lib/sky_gradient.glsl
Normal file
@ -0,0 +1,84 @@
|
||||
#define DRAW_SUN //if not using custom sky
|
||||
#define SKY_BRIGHTNESS_DAY 1.0 //[0.0 0.5 0.75 1. 1.2 1.4 1.6 1.8 2.0]
|
||||
#define SKY_BRIGHTNESS_NIGHT 1.0 //[0.0 0.5 0.75 1. 1.2 1.4 1.6 1.8 2.0]
|
||||
#define ffstep(x,y) clamp((y - x) * 1e35,0.0,1.0)
|
||||
vec3 drawSun(float cosY, float sunInt,vec3 nsunlight,vec3 inColor){
|
||||
return inColor+nsunlight/0.0008821203*pow(smoothstep(cos(0.0093084168595*3.2),cos(0.0093084168595*1.8),cosY),3.)*0.62;
|
||||
}
|
||||
const float pi = 3.141592653589793238462643383279502884197169;
|
||||
vec2 sphereToCarte(vec3 dir) {
|
||||
float lonlat = atan(-dir.x, -dir.z);
|
||||
return vec2(lonlat * (0.5/pi) +0.5,0.5*dir.y+0.5);
|
||||
}
|
||||
vec3 skyFromTex(vec3 pos,sampler2D sampler){
|
||||
vec2 p = sphereToCarte(pos);
|
||||
return texture2D(sampler,p*texelSize*256.+vec2(18.5,1.5)*texelSize).rgb;
|
||||
}
|
||||
float w0(float a)
|
||||
{
|
||||
return (1.0/6.0)*(a*(a*(-a + 3.0) - 3.0) + 1.0);
|
||||
}
|
||||
|
||||
float w1(float a)
|
||||
{
|
||||
return (1.0/6.0)*(a*a*(3.0*a - 6.0) + 4.0);
|
||||
}
|
||||
|
||||
float w2(float a)
|
||||
{
|
||||
return (1.0/6.0)*(a*(a*(-3.0*a + 3.0) + 3.0) + 1.0);
|
||||
}
|
||||
|
||||
float w3(float a)
|
||||
{
|
||||
return (1.0/6.0)*(a*a*a);
|
||||
}
|
||||
|
||||
float g0(float a)
|
||||
{
|
||||
return w0(a) + w1(a);
|
||||
}
|
||||
|
||||
float g1(float a)
|
||||
{
|
||||
return w2(a) + w3(a);
|
||||
}
|
||||
|
||||
float h0(float a)
|
||||
{
|
||||
return -1.0 + w1(a) / (w0(a) + w1(a));
|
||||
}
|
||||
|
||||
float h1(float a)
|
||||
{
|
||||
return 1.0 + w3(a) / (w2(a) + w3(a));
|
||||
}
|
||||
|
||||
vec4 texture2D_bicubic(sampler2D tex, vec2 uv)
|
||||
{
|
||||
vec4 texelSize = vec4(texelSize,1.0/texelSize);
|
||||
uv = uv*texelSize.zw;
|
||||
vec2 iuv = floor( uv );
|
||||
vec2 fuv = fract( uv );
|
||||
|
||||
float g0x = g0(fuv.x);
|
||||
float g1x = g1(fuv.x);
|
||||
float h0x = h0(fuv.x);
|
||||
float h1x = h1(fuv.x);
|
||||
float h0y = h0(fuv.y);
|
||||
float h1y = h1(fuv.y);
|
||||
|
||||
vec2 p0 = (vec2(iuv.x + h0x, iuv.y + h0y) - 0.5) * texelSize.xy;
|
||||
vec2 p1 = (vec2(iuv.x + h1x, iuv.y + h0y) - 0.5) * texelSize.xy;
|
||||
vec2 p2 = (vec2(iuv.x + h0x, iuv.y + h1y) - 0.5) * texelSize.xy;
|
||||
vec2 p3 = (vec2(iuv.x + h1x, iuv.y + h1y) - 0.5) * texelSize.xy;
|
||||
|
||||
return g0(fuv.y) * (g0x * texture2D(tex, p0) +
|
||||
g1x * texture2D(tex, p1)) +
|
||||
g1(fuv.y) * (g0x * texture2D(tex, p2) +
|
||||
g1x * texture2D(tex, p3));
|
||||
}
|
||||
vec4 skyCloudsFromTex(vec3 pos,sampler2D sampler){
|
||||
vec2 p = sphereToCarte(pos);
|
||||
return texture2D(sampler,p*texelSize*256.+vec2(18.5+257.,1.5)*texelSize);
|
||||
}
|
349
shaders/lib/specular.glsl
Normal file
349
shaders/lib/specular.glsl
Normal file
@ -0,0 +1,349 @@
|
||||
//#define Specular_Reflections // reflections on blocks. REQUIRES A PBR RESOURCEPACK.
|
||||
#define Screen_Space_Reflections // toggle screenspace reflections. if you want normal performance but still want a bit of shiny, the sun reflection stays on when this is turned off.
|
||||
#define Sky_reflection // just in case you dont want it i guess
|
||||
// #define Rough_reflections // turns the roughness GGXVNDF ON. sizable performance impact, and introduces alot of noise.
|
||||
|
||||
#define Sun_specular_Strength 3 // increase for more sparkles [1 2 3 4 5 6 7 8 9 10]
|
||||
#define reflection_quality 30 // adjust the quality of the screenspace reflections. [6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 25 30 35 40 45 50 55 60 65 70 75 80 85 90 95 100 ]
|
||||
#define Roughness_Threshold 1.5 // using a curve on the roughness, make the reflections more or less visible on rough surfaces. good for hiding noise on rough materials [1.0 1.1 1.2 1.3 1.4 1.5 1.6 1.7 1.8 1.9 2.0 2.1 2.2 2.3 2.4 2.5 2.6 2.7 2.8 2.9 3.0 ]
|
||||
|
||||
// #define SCREENSHOT_MODE // go render mode and accumulate frames for as long as you want for max image quality.
|
||||
|
||||
|
||||
|
||||
uniform sampler2D gaux1;
|
||||
uniform int framemod8;
|
||||
|
||||
const vec2[8] offsets = vec2[8](vec2(1./8.,-3./8.),
|
||||
vec2(-1.,3.)/8.,
|
||||
vec2(5.0,1.)/8.,
|
||||
vec2(-3,-5.)/8.,
|
||||
vec2(-5.,5.)/8.,
|
||||
vec2(-7.,-1.)/8.,
|
||||
vec2(3,7.)/8.,
|
||||
vec2(7.,-7.)/8.);
|
||||
|
||||
|
||||
// sun specular stuff
|
||||
float square(float x){
|
||||
return x*x;
|
||||
}
|
||||
float g(float NdotL, float roughness){
|
||||
float alpha = square(max(roughness, 0.02));
|
||||
return 2.0 * NdotL / (NdotL + sqrt(square(alpha) + (1.0 - square(alpha)) * square(NdotL)));
|
||||
}
|
||||
float gSimple(float dp, float roughness){
|
||||
float k = roughness + 1;
|
||||
k *= k/8.0;
|
||||
return dp / (dp * (1.0-k) + k);
|
||||
}
|
||||
vec3 GGX2(vec3 n, vec3 v, vec3 l, float r, vec3 F0) {
|
||||
|
||||
float roughness = r; // when roughness is zero it fucks up
|
||||
float alpha = square(roughness) + 1e-5;
|
||||
|
||||
vec3 h = normalize(l + v) ;
|
||||
|
||||
float dotLH = clamp(dot(h,l),0.,1.);
|
||||
float dotNH = clamp(dot(h,n),0.,1.);
|
||||
float dotNL = clamp(dot(n,l),0.,1.);
|
||||
float dotNV = clamp(dot(n,v),0.,1.);
|
||||
float dotVH = clamp(dot(h,v),0.,1.);
|
||||
|
||||
|
||||
float D = alpha / (3.141592653589793*square(square(dotNH) * (alpha - 1.0) + 1.0));
|
||||
float G = gSimple(dotNV, roughness) * gSimple(dotNL, roughness);
|
||||
vec3 F = F0 + (1. - F0) * exp2((-5.55473*dotVH-6.98316)*dotVH);
|
||||
|
||||
return dotNL * F * (G * D / (4 * dotNV * dotNL + 1e-7));
|
||||
}
|
||||
|
||||
|
||||
// other shit
|
||||
float invLinZ (float lindepth){
|
||||
return -((2.0*near/lindepth)-far-near)/(far-near);
|
||||
}
|
||||
vec3 toClipSpace3(vec3 viewSpacePosition) {
|
||||
return projMAD(gbufferProjection, viewSpacePosition) / -viewSpacePosition.z * 0.5 + 0.5;
|
||||
}
|
||||
float linZ(float depth) {
|
||||
return (2.0 * near) / (far + near - depth * (far - near));
|
||||
// l = (2*n)/(f+n-d(f-n))
|
||||
// f+n-d(f-n) = 2n/l
|
||||
// -d(f-n) = ((2n/l)-f-n)
|
||||
// d = -((2n/l)-f-n)/(f-n)
|
||||
|
||||
}
|
||||
// vec3 rayTrace_GI(vec3 dir,vec3 position,float dither, float quality){
|
||||
|
||||
// vec3 clipPosition = toClipSpace3(position);
|
||||
// float rayLength = ((position.z + dir.z * far*sqrt(3.)) > -near) ?
|
||||
// (-near -position.z) / dir.z : far*sqrt(3.);
|
||||
// vec3 direction = normalize(toClipSpace3(position+dir*rayLength)-clipPosition); //convert to clip space
|
||||
// direction.xy = normalize(direction.xy);
|
||||
|
||||
// //get at which length the ray intersects with the edge of the screen
|
||||
// vec3 maxLengths = (step(0.,direction)-clipPosition) / direction;
|
||||
// float mult = min(min(maxLengths.x,maxLengths.y),maxLengths.z);
|
||||
|
||||
// vec3 stepv = direction * mult / quality*vec3(RENDER_SCALE,1.0);
|
||||
|
||||
// vec3 spos = clipPosition*vec3(RENDER_SCALE,1.0) ;
|
||||
|
||||
// float minZ = spos.z+stepv.z;
|
||||
// float maxZ = spos.z+stepv.z;
|
||||
|
||||
// spos.xy += TAA_Offset*texelSize*0.5/RENDER_SCALE;
|
||||
// spos += stepv*dither ;
|
||||
|
||||
// for(int i = 0; i < int(quality); i++){
|
||||
// float sp = sqrt(texelFetch2D(colortex4,ivec2(spos.xy/texelSize/4),0).w/65000.0);
|
||||
// float currZ = linZ(spos.z);
|
||||
// if( sp < currZ) {
|
||||
// float dist = abs(sp-currZ)/currZ;
|
||||
// if (dist <= 0.05) return vec3(spos.xy, invLinZ(sp))/vec3(RENDER_SCALE,1.0);
|
||||
// }
|
||||
// spos += stepv ;
|
||||
// }
|
||||
// return vec3(1.1);
|
||||
// }
|
||||
vec3 rayTrace_GI(vec3 dir,vec3 position,float dither, float quality){
|
||||
|
||||
vec3 clipPosition = toClipSpace3(position);
|
||||
float rayLength = ((position.z + dir.z * far*sqrt(3.)) > -near) ?
|
||||
(-near -position.z) / dir.z : far*sqrt(3.);
|
||||
vec3 direction = normalize(toClipSpace3(position+dir*rayLength)-clipPosition); //convert to clip space
|
||||
direction.xy = normalize(direction.xy);
|
||||
|
||||
//get at which length the ray intersects with the edge of the screen
|
||||
vec3 maxLengths = (step(0.,direction)-clipPosition) / direction;
|
||||
float mult = maxLengths.y;
|
||||
|
||||
vec3 stepv = direction * mult / quality*vec3(RENDER_SCALE,1.0) * dither;
|
||||
vec3 spos = clipPosition*vec3(RENDER_SCALE,1.0) ;
|
||||
|
||||
spos.xy += TAA_Offset*texelSize*0.5/RENDER_SCALE;
|
||||
|
||||
float biasdist = clamp(position.z*position.z/50.0,1,2); // shrink sample size as distance increases
|
||||
|
||||
for(int i = 0; i < int(quality); i++){
|
||||
spos += stepv;
|
||||
float sp = sqrt(texelFetch2D(colortex4,ivec2(spos.xy/texelSize/4),0).w/65000.0);
|
||||
float currZ = linZ(spos.z);
|
||||
|
||||
if( sp < currZ) {
|
||||
float dist = abs(sp-currZ)/currZ;
|
||||
if (abs(dist) < biasdist*0.05) return vec3(spos.xy, invLinZ(sp))/vec3(RENDER_SCALE,1.0);
|
||||
}
|
||||
spos += stepv;
|
||||
}
|
||||
return vec3(1.1);
|
||||
}
|
||||
|
||||
void frisvad(in vec3 n, out vec3 f, out vec3 r){
|
||||
if(n.z < -0.9) {
|
||||
f = vec3(0.,-1,0);
|
||||
r = vec3(-1, 0, 0);
|
||||
} else {
|
||||
float a = 1./(1.+n.z);
|
||||
float b = -n.x*n.y*a;
|
||||
f = vec3(1. - n.x*n.x*a, b, -n.x) ;
|
||||
r = vec3(b, 1. - n.y*n.y*a , -n.y);
|
||||
}
|
||||
}
|
||||
mat3 CoordBase(vec3 n){
|
||||
vec3 x,y;
|
||||
frisvad(n,x,y);
|
||||
return mat3(x,y,n);
|
||||
}
|
||||
float unpackRoughness(float x){
|
||||
float r = 1.0 - x;
|
||||
return clamp(r*r,0,1);
|
||||
}
|
||||
vec2 R2_samples_spec(int n){
|
||||
vec2 alpha = vec2(0.75487765, 0.56984026);
|
||||
return fract(alpha * n);
|
||||
}
|
||||
|
||||
vec3 sampleGGXVNDF(vec3 V_, float roughness, float U1, float U2){
|
||||
// stretch view
|
||||
vec3 V = normalize(vec3(roughness * V_.x, roughness * V_.y, V_.z));
|
||||
// orthonormal basis
|
||||
vec3 T1 = (V.z < 0.9999) ? normalize(cross(V, vec3(0,0,1))) : vec3(1,0,0);
|
||||
vec3 T2 = cross(T1, V);
|
||||
// sample point with polar coordinates (r, phi)
|
||||
float a = 1.0 / (1.0 + V.z);
|
||||
float r = sqrt(U1*0.25);
|
||||
float phi = (U2<a) ? U2/a * 3.141592653589793 : 3.141592653589793 + (U2-a)/(1.0-a) * 3.141592653589793;
|
||||
float P1 = r*cos(phi);
|
||||
float P2 = r*sin(phi)*((U2<a) ? 1.0 : V.z);
|
||||
// compute normal
|
||||
vec3 N = P1*T1 + P2*T2 + sqrt(max(0.0, 1.0 - P1*P1 - P2*P2))*V;
|
||||
// unstretch
|
||||
N = normalize(vec3(roughness*N.x, roughness*N.y, max(0.0, N.z)));
|
||||
return N;
|
||||
}
|
||||
|
||||
|
||||
vec3 rayTraceSpeculars(vec3 dir,vec3 position,float dither, float quality, bool hand){
|
||||
vec3 clipPosition = toClipSpace3(position);
|
||||
float rayLength = ((position.z + dir.z * far*sqrt(3.)) > -near) ?
|
||||
(-near -position.z) / dir.z : far*sqrt(3.);
|
||||
vec3 direction = normalize(toClipSpace3(position+dir*rayLength)-clipPosition); //convert to clip space
|
||||
direction.xy = normalize(direction.xy);
|
||||
|
||||
//get at which length the ray intersects with the edge of the screen
|
||||
vec3 maxLengths = (step(0.,direction)-clipPosition) / direction;
|
||||
float mult = min(min(maxLengths.x,maxLengths.y),maxLengths.z);
|
||||
|
||||
vec3 stepv = direction * mult / quality*vec3(RENDER_SCALE,1.0);
|
||||
|
||||
vec3 spos = clipPosition*vec3(RENDER_SCALE,1.0) + stepv*dither;
|
||||
|
||||
float minZ = spos.z+stepv.z;
|
||||
float maxZ = spos.z+stepv.z;
|
||||
|
||||
spos.xy += TAA_Offset*texelSize*0.5/RENDER_SCALE;
|
||||
|
||||
float dist = 1.0 + clamp(position.z*position.z/50.0,0,2); // shrink sample size as distance increases
|
||||
for (int i = 0; i <= int(quality); i++) {
|
||||
|
||||
// decode depth buffer
|
||||
vec2 testthing = hand ? spos.xy*texelSize : spos.xy/texelSize/4.0; // fix for ssr on hand
|
||||
float sp = sqrt(texelFetch2D(gaux1,ivec2(testthing),0).w/65000.0);
|
||||
sp = invLinZ(sp);
|
||||
|
||||
if(sp <= max(maxZ,minZ) && sp >= min(maxZ,minZ) ) return vec3(spos.xy/RENDER_SCALE,sp);
|
||||
spos += stepv;
|
||||
|
||||
//small bias
|
||||
float biasamount = 0.0002 / dist;
|
||||
if(hand) biasamount = 0.01;
|
||||
minZ = maxZ-biasamount / ld(spos.z);
|
||||
|
||||
maxZ += stepv.z;
|
||||
}
|
||||
return vec3(1.1);
|
||||
}
|
||||
|
||||
vec3 mix_vec3(vec3 X, vec3 Y, float A){
|
||||
return X * (1.0 - A) + Y * A;
|
||||
}
|
||||
float mix_float(float X, float Y, float A){
|
||||
return X * (1.0 - A) + Y * A;
|
||||
}
|
||||
|
||||
|
||||
// pain
|
||||
void MaterialReflections(
|
||||
inout vec3 Output,
|
||||
float roughness,
|
||||
vec3 f0,
|
||||
vec3 albedo,
|
||||
vec3 sunPos,
|
||||
vec3 sunCol,
|
||||
float diffuse,
|
||||
float lightmap,
|
||||
vec3 normal,
|
||||
vec3 np3,
|
||||
vec3 fragpos,
|
||||
vec3 noise,
|
||||
bool hand
|
||||
){
|
||||
vec3 Reflections_Final = Output;
|
||||
|
||||
float Outdoors = clamp((lightmap-0.6)*5.0, 0.0,1.0);
|
||||
// float Outdoors = clamp((lightmap-0.5) * , 0.0,1.0);
|
||||
|
||||
roughness = unpackRoughness(roughness);
|
||||
f0 = f0.y == 0.0 ? vec3(0.04) : f0;
|
||||
|
||||
// roughness = 0.0;
|
||||
// f0 = vec3(0.9);
|
||||
|
||||
mat3 basis = CoordBase(normal);
|
||||
vec3 normSpaceView = -np3*basis ;
|
||||
|
||||
// roughness stuff
|
||||
#ifdef Rough_reflections
|
||||
int seed = (frameCounter%40000);
|
||||
vec2 ij = fract(R2_samples_spec(seed) + noise.rg) ;
|
||||
|
||||
vec3 H = sampleGGXVNDF(normSpaceView, roughness, ij.x, ij.y);
|
||||
if(hand) H = normalize(vec3(0.0,0.0,1.0));
|
||||
#else
|
||||
vec3 H = normalize(vec3(0.0,0.0,1.0));
|
||||
#endif
|
||||
|
||||
vec3 Ln = reflect(-normSpaceView, clamp(H,-1.0,1.0));
|
||||
vec3 L = basis * Ln;
|
||||
|
||||
// fresnel stuff
|
||||
float fresnel = pow(clamp(1.0 + dot(-Ln, H),0.0,1.0),5.0);
|
||||
// vec3 F = f0 + (1.0 - f0) * fresnel;
|
||||
|
||||
vec3 F = mix(f0, vec3(1.0), fresnel);
|
||||
vec3 rayContrib = F;
|
||||
|
||||
|
||||
float NdotV = clamp(normalize(dot(np3, normal))*10000.,0.,1.);
|
||||
bool hasReflections = (f0.y * (1.0 - roughness * Roughness_Threshold)) > 0.01;
|
||||
|
||||
if (Roughness_Threshold == 1.0){ hasReflections = roughness > -1; NdotV = -1.0;}
|
||||
|
||||
if (!hasReflections || NdotV > 0.0 ) Outdoors = 0.0;
|
||||
|
||||
// SSR, Sky, and Sun reflections
|
||||
vec4 Reflections = vec4(0.0);
|
||||
vec3 SkyReflection = skyCloudsFromTex(L, colortex4).rgb / 150. * 5.;
|
||||
vec3 SunReflection = diffuse * GGX2(clamp(normal,-1,1), -np3, sunPos, roughness, f0) * 8./150./3. * sunCol * Sun_specular_Strength;
|
||||
|
||||
#ifndef Sky_reflection
|
||||
SkyReflection = Reflections_Final;
|
||||
#endif
|
||||
|
||||
#ifdef Screen_Space_Reflections
|
||||
if ( hasReflections && NdotV <= 0.0) { // Skip SSR if ray contribution is low
|
||||
#ifdef SCREENSHOT_MODE
|
||||
float rayQuality = reflection_quality;
|
||||
#else
|
||||
float rayQuality = mix_float(reflection_quality,0.0,sqrt(roughness)); // Scale quality with ray contribution
|
||||
#endif
|
||||
vec3 rtPos = rayTraceSpeculars( mat3(gbufferModelView) * L,fragpos.xyz, noise.b, rayQuality, hand);
|
||||
if (rtPos.z < 1. ){ // Reproject on previous frame
|
||||
vec3 previousPosition = mat3(gbufferModelViewInverse) * toScreenSpace(rtPos) + gbufferModelViewInverse[3].xyz + cameraPosition-previousCameraPosition;
|
||||
previousPosition = mat3(gbufferPreviousModelView) * previousPosition + gbufferPreviousModelView[3].xyz;
|
||||
previousPosition.xy = projMAD(gbufferPreviousProjection, previousPosition).xy / -previousPosition.z * 0.5 + 0.5;
|
||||
if (previousPosition.x > 0.0 && previousPosition.y > 0.0 && previousPosition.x < 1.0 && previousPosition.x < 1.0) {
|
||||
Reflections.a = 1.0;
|
||||
Reflections.rgb = texture2D(colortex5,previousPosition.xy).rgb;
|
||||
}
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
// check if the f0 is within the metal ranges, then tint by albedo if it's true.
|
||||
vec3 Metals = f0.y > 229.5/255.0 ? clamp(albedo + fresnel,0.0,1.0) : vec3(1.0);
|
||||
|
||||
Reflections.rgb *= Metals;
|
||||
SunReflection *= Metals;
|
||||
#ifdef Sky_reflection
|
||||
SkyReflection *= Metals;
|
||||
#endif
|
||||
float lumaRayContrib = luma(rayContrib);
|
||||
// darken albedos, and stop darkening where the sky gets occluded indoors
|
||||
Reflections_Final *= mix_float(1.0 - (Reflections.a*lumaRayContrib), 1.0 - lumaRayContrib, Outdoors);
|
||||
|
||||
// apply all reflections to the lighting
|
||||
Reflections_Final += Reflections.rgb * lumaRayContrib;
|
||||
Reflections_Final += SkyReflection * lumaRayContrib * (1.0-Reflections.a) * Outdoors ;
|
||||
|
||||
float visibilityFactor = clamp(exp2((pow(roughness,3.0) / f0.y) * -4),0,1);
|
||||
#ifdef Rough_reflections
|
||||
Output = hand ? mix_vec3(Output, Reflections_Final, visibilityFactor) : Reflections_Final;
|
||||
#else
|
||||
Output = mix_vec3(Output, Reflections_Final, visibilityFactor);
|
||||
#endif
|
||||
|
||||
Output += SunReflection ;
|
||||
}
|
48
shaders/lib/stars.glsl
Normal file
48
shaders/lib/stars.glsl
Normal file
@ -0,0 +1,48 @@
|
||||
//Original star code : https://www.shadertoy.com/view/Md2SR3 , optimised
|
||||
|
||||
|
||||
|
||||
// Return random noise in the range [0.0, 1.0], as a function of x.
|
||||
float hash12(vec2 p)
|
||||
{
|
||||
vec3 p3 = fract(vec3(p.xyx) * 0.1031);
|
||||
p3 += dot(p3, p3.yzx + 19.19);
|
||||
return fract((p3.x + p3.y) * p3.z);
|
||||
}
|
||||
// Convert Noise2d() into a "star field" by stomping everthing below fThreshhold to zero.
|
||||
float NoisyStarField( in vec2 vSamplePos, float fThreshhold )
|
||||
{
|
||||
float StarVal = hash12( vSamplePos );
|
||||
StarVal = clamp(StarVal/(1.0 - fThreshhold) - fThreshhold/(1.0 - fThreshhold),0.0,1.0);
|
||||
|
||||
return StarVal;
|
||||
}
|
||||
|
||||
// Stabilize NoisyStarField() by only sampling at integer values.
|
||||
float StableStarField( in vec2 vSamplePos, float fThreshhold )
|
||||
{
|
||||
// Linear interpolation between four samples.
|
||||
// Note: This approach has some visual artifacts.
|
||||
// There must be a better way to "anti alias" the star field.
|
||||
float fractX = fract( vSamplePos.x );
|
||||
float fractY = fract( vSamplePos.y );
|
||||
vec2 floorSample = floor( vSamplePos );
|
||||
float v1 = NoisyStarField( floorSample, fThreshhold );
|
||||
float v2 = NoisyStarField( floorSample + vec2( 0.0, 1.0 ), fThreshhold );
|
||||
float v3 = NoisyStarField( floorSample + vec2( 1.0, 0.0 ), fThreshhold );
|
||||
float v4 = NoisyStarField( floorSample + vec2( 1.0, 1.0 ), fThreshhold );
|
||||
|
||||
float StarVal = v1 * ( 1.0 - fractX ) * ( 1.0 - fractY )
|
||||
+ v2 * ( 1.0 - fractX ) * fractY
|
||||
+ v3 * fractX * ( 1.0 - fractY )
|
||||
+ v4 * fractX * fractY;
|
||||
return StarVal;
|
||||
}
|
||||
|
||||
float stars(vec3 fragpos){
|
||||
|
||||
float elevation = clamp(fragpos.y,0.,1.);
|
||||
vec2 uv = fragpos.xz/(1.5+elevation);
|
||||
|
||||
return StableStarField(uv*1500.,0.999)*0.5*(0.3-0.3*rainStrength);
|
||||
}
|
19
shaders/lib/texFiltering.glsl
Normal file
19
shaders/lib/texFiltering.glsl
Normal file
@ -0,0 +1,19 @@
|
||||
vec4 smoothfilter(in sampler2D tex, in vec2 uv, in vec2 textureResolution)
|
||||
{
|
||||
uv = uv*textureResolution + 0.5;
|
||||
vec2 iuv = floor( uv );
|
||||
vec2 fuv = fract( uv );
|
||||
uv = iuv + (fuv*fuv)*(3.0-2.0*fuv);
|
||||
uv = uv/textureResolution - 0.5/textureResolution;
|
||||
return texture2D( tex, uv);
|
||||
}
|
||||
|
||||
float shadowsmoothfilter(in sampler2DShadow tex, in vec3 uv,in float textureResolution)
|
||||
{
|
||||
uv.xy = uv.xy*textureResolution + 0.5;
|
||||
vec2 iuv = floor( uv.xy );
|
||||
vec2 fuv = fract( uv.xy );
|
||||
uv.xy = iuv + (fuv*fuv)*(3.0-2.0*fuv);
|
||||
uv.xy = uv.xy/textureResolution - 0.5/textureResolution;
|
||||
return shadow2D( tex, uv).x;
|
||||
}
|
196
shaders/lib/util.glsl
Normal file
196
shaders/lib/util.glsl
Normal file
@ -0,0 +1,196 @@
|
||||
#define TIME_MULT 1.0
|
||||
#define TIME (frameTimeCounter * TIME_MULT)
|
||||
|
||||
const float PI = acos(-1.0);
|
||||
const float TAU = PI * 2.0;
|
||||
const float hPI = PI * 0.5;
|
||||
const float rPI = 1.0 / PI;
|
||||
const float rTAU = 1.0 / TAU;
|
||||
|
||||
const float PHI = sqrt(5.0) * 0.5 + 0.5;
|
||||
const float rLOG2 = 1.0 / log(2.0);
|
||||
|
||||
const float goldenAngle = TAU / PHI / PHI;
|
||||
|
||||
#define clamp01(x) clamp(x, 0.0, 1.0)
|
||||
#define max0(x) max(x, 0.0)
|
||||
#define min0(x) min(x, 0.0)
|
||||
#define max3(a) max(max(a.x, a.y), a.z)
|
||||
#define min3(a) min(min(a.x, a.y), a.z)
|
||||
#define max4(a, b, c, d) max(max(a, b), max(c, d))
|
||||
#define min4(a, b, c, d) min(min(a, b), min(c, d))
|
||||
|
||||
#define fsign(x) (clamp01(x * 1e35) * 2.0 - 1.0)
|
||||
#define fstep(x,y) clamp01((y - x) * 1e35)
|
||||
|
||||
#define diagonal2(m) vec2((m)[0].x, (m)[1].y)
|
||||
#define diagonal3(m) vec3(diagonal2(m), m[2].z)
|
||||
#define diagonal4(m) vec4(diagonal3(m), m[2].w)
|
||||
|
||||
#define transMAD(mat, v) (mat3(mat) * (v) + (mat)[3].xyz)
|
||||
#define projMAD(mat, v) (diagonal3(mat) * (v) + (mat)[3].xyz)
|
||||
|
||||
#define encodeColor(x) (x * 0.00005)
|
||||
#define decodeColor(x) (x * 20000.0)
|
||||
|
||||
#define cubeSmooth(x) (x * x * (3.0 - 2.0 * x))
|
||||
|
||||
#define lumCoeff vec3(0.2125, 0.7154, 0.0721)
|
||||
|
||||
float facos(const float sx){
|
||||
float x = clamp(abs( sx ),0.,1.);
|
||||
float a = sqrt( 1. - x ) * ( -0.16882 * x + 1.56734 );
|
||||
return sx > 0. ? a : PI - a;
|
||||
//float c = clamp(-sx * 1e35, 0., 1.);
|
||||
//return c * pi + a * -(c * 2. - 1.); //no conditional version
|
||||
}
|
||||
|
||||
|
||||
vec2 sincos(float x){
|
||||
return vec2(sin(x), cos(x));
|
||||
}
|
||||
|
||||
vec2 circlemap(float i, float n){
|
||||
return sincos(i * n * goldenAngle) * sqrt(i);
|
||||
}
|
||||
|
||||
vec3 circlemapL(float i, float n){
|
||||
return vec3(sincos(i * n * goldenAngle), sqrt(i));
|
||||
}
|
||||
|
||||
vec3 calculateRoughSpecular(const float i, const float alpha2, const int steps) {
|
||||
|
||||
float x = (alpha2 * i) / (1.0 - i);
|
||||
float y = i * float(steps) * 64.0 * 64.0 * goldenAngle;
|
||||
|
||||
float c = inversesqrt(x + 1.0);
|
||||
float s = sqrt(x) * c;
|
||||
|
||||
return vec3(cos(y) * s, sin(y) * s, c);
|
||||
}
|
||||
|
||||
vec3 clampNormal(vec3 n, vec3 v){
|
||||
float NoV = clamp( dot(n, -v), 0., 1. );
|
||||
return normalize( NoV * v + n );
|
||||
}
|
||||
|
||||
vec3 srgbToLinear(vec3 srgb){
|
||||
return mix(
|
||||
srgb / 12.92,
|
||||
pow(.947867 * srgb + .0521327, vec3(2.4) ),
|
||||
step( .04045, srgb )
|
||||
);
|
||||
}
|
||||
|
||||
vec3 linearToSRGB(vec3 linear){
|
||||
return mix(
|
||||
linear * 12.92,
|
||||
pow(linear, vec3(1./2.4) ) * 1.055 - .055,
|
||||
step( .0031308, linear )
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
|
||||
vec3 blackbody(float Temp)
|
||||
{
|
||||
float t = pow(Temp, -1.5);
|
||||
float lt = log(Temp);
|
||||
|
||||
vec3 col = vec3(0.0);
|
||||
col.x = 220000.0 * t + 0.58039215686;
|
||||
col.y = 0.39231372549 * lt - 2.44549019608;
|
||||
col.y = Temp > 6500. ? 138039.215686 * t + 0.72156862745 : col.y;
|
||||
col.z = 0.76078431372 * lt - 5.68078431373;
|
||||
col = clamp01(col);
|
||||
col = Temp < 1000. ? col * Temp * 0.001 : col;
|
||||
|
||||
return srgbToLinear(col);
|
||||
}
|
||||
|
||||
float calculateHardShadows(float shadowDepth, vec3 shadowPosition, float bias) {
|
||||
if(shadowPosition.z >= 1.0) return 1.0;
|
||||
|
||||
return 1.0 - fstep(shadowDepth, shadowPosition.z - bias);
|
||||
}
|
||||
|
||||
vec3 genUnitVector(vec2 xy) {
|
||||
xy.x *= TAU; xy.y = xy.y * 2.0 - 1.0;
|
||||
return vec3(sincos(xy.x) * sqrt(1.0 - xy.y * xy.y), xy.y);
|
||||
}
|
||||
|
||||
vec2 rotate(vec2 x, float r){
|
||||
vec2 sc = sincos(r);
|
||||
return mat2(sc.x, -sc.y, sc.y, sc.x) * x;
|
||||
}
|
||||
|
||||
vec3 cartToSphere(vec2 coord) {
|
||||
coord *= vec2(TAU, PI);
|
||||
vec2 lon = sincos(coord.x) * sin(coord.y);
|
||||
return vec3(lon.x, 2.0/PI*coord.y-1.0, lon.y);
|
||||
}
|
||||
|
||||
vec2 sphereToCart(vec3 dir) {
|
||||
float lonlat = atan(-dir.x, -dir.z);
|
||||
return vec2(lonlat * rTAU +0.5,0.5*dir.y+0.5);
|
||||
}
|
||||
|
||||
mat3 getRotMat(vec3 x,vec3 y){
|
||||
float d = dot(x,y);
|
||||
vec3 cr = cross(y,x);
|
||||
|
||||
float s = length(cr);
|
||||
|
||||
float id = 1.-d;
|
||||
|
||||
vec3 m = cr/s;
|
||||
|
||||
vec3 m2 = m*m*id+d;
|
||||
vec3 sm = s*m;
|
||||
|
||||
vec3 w = (m.xy*id).xxy*m.yzz;
|
||||
|
||||
return mat3(
|
||||
m2.x, w.x-sm.z, w.y+sm.y,
|
||||
w.x+sm.z, m2.y, w.z-sm.x,
|
||||
w.y-sm.y, w.z+sm.x, m2.z
|
||||
);
|
||||
}
|
||||
|
||||
// No intersection if returned y component is < 0.0
|
||||
vec2 rsi(vec3 position, vec3 direction, float radius) {
|
||||
float PoD = dot(position, direction);
|
||||
float radiusSquared = radius * radius;
|
||||
|
||||
float delta = PoD * PoD + radiusSquared - dot(position, position);
|
||||
if (delta < 0.0) return vec2(-1.0);
|
||||
delta = sqrt(delta);
|
||||
|
||||
return -PoD + vec2(-delta, delta);
|
||||
}
|
||||
float HaltonSeq3(int index)
|
||||
{
|
||||
float r = 0.;
|
||||
float f = 1.;
|
||||
int i = index;
|
||||
while (i > 0)
|
||||
{
|
||||
f /= 3.0;
|
||||
r += f * (i % 3);
|
||||
i = int(i / 3.0);
|
||||
}
|
||||
return r;
|
||||
}
|
||||
float HaltonSeq2(int index)
|
||||
{
|
||||
float r = 0.;
|
||||
float f = 1.;
|
||||
int i = index;
|
||||
while (i > 0)
|
||||
{
|
||||
f /= 2.0;
|
||||
r += f * (i % 2);
|
||||
i = int(i / 2.0);
|
||||
}
|
||||
return r;
|
||||
}
|
436
shaders/lib/volumetricClouds.glsl
Normal file
436
shaders/lib/volumetricClouds.glsl
Normal file
@ -0,0 +1,436 @@
|
||||
#define VOLUMETRIC_CLOUDS// if you don't like the noise on the default cloud settings, turn up the cloud samples. if that hurts performance too much, turn down the clouds quality.
|
||||
|
||||
#define cloud_LevelOfDetail 1 // Number of fbm noise iterations for on-screen clouds (-1 is no fbm) [-1 0 1 2 3 4 5 6 7 8]
|
||||
#define cloud_ShadowLevelOfDetail 0 // Number of fbm noise iterations for the shadowing of on-screen clouds (-1 is no fbm) [-1 0 1 2 3 4 5 6 7 8]
|
||||
#define cloud_LevelOfDetailLQ 1 // Number of fbm noise iterations for reflected clouds (-1 is no fbm) [-1 0 1 2 3 4 5 6 7 8]
|
||||
#define cloud_ShadowLevelOfDetailLQ 0 // Number of fbm noise iterations for the shadowing of reflected clouds (-1 is no fbm) [-1 0 1 2 3 4 5 6 7 8]
|
||||
#define minRayMarchSteps 20 // Number of ray march steps towards zenith for on-screen clouds [20 25 30 35 40 45 50 55 60 65 70 75 80 85 90 95 100 105 110 115 120 125 130 135 140 145 150 155 160 165 170 175 180 185 190 195 200]
|
||||
#define maxRayMarchSteps 30 // Number of ray march steps towards horizon for on-screen clouds [5 10 15 20 25 30 35 40 45 50 55 60 65 70 75 80 85 90 95 100 105 110 115 120 125 130 135 140 145 150 155 160 165 170 175 180 185 190 195 200]
|
||||
#define minRayMarchStepsLQ 10 // Number of ray march steps towards zenith for reflected clouds [5 10 15 20 25 30 35 40 45 50 55 60 65 70 75 80 85 90 95 100]
|
||||
#define maxRayMarchStepsLQ 30 // Number of ray march steps towards horizon for reflected clouds [ 5 10 15 20 25 30 35 40 45 50 55 60 65 70 75 80 85 90 95 100]
|
||||
#define cloudMieG 0.5 // Values close to 1 will create a strong peak of luminance around the sun and weak elsewhere, values close to 0 means uniform fog. [0.01 0.02 0.03 0.04 0.05 0.06 0.07 0.08 0.09 0.1 0.11 0.12 0.13 0.14 0.15 0.16 0.17 0.18 0.19 0.2 0.21 0.22 0.23 0.24 0.25 0.26 0.27 0.28 0.29 0.3 0.31 0.32 0.33 0.34 0.35 0.36 0.37 0.38 0.39 0.4 0.41 0.42 0.43 0.44 0.45 0.46 0.47 0.48 0.49 0.5 0.51 0.52 0.53 0.54 0.55 0.56 0.57 0.58 0.59 0.6 0.61 0.62 0.63 0.64 0.65 0.66 0.67 0.68 0.69 0.7 0.71 0.72 0.73 0.74 0.75 0.76 0.77 0.78 0.79 0.8 0.81 0.82 0.83 0.84 0.85 0.86 0.87 0.88 0.89 0.9 0.91 0.92 0.93 0.94 0.95 0.96 0.97 0.98 0.99 ]
|
||||
#define cloudMieG2 0.9 // Multiple scattering approximation. Values close to 1 will create a strong peak of luminance around the sun and weak elsewhere, values close to 0 means uniform fog. [0.01 0.02 0.03 0.04 0.05 0.06 0.07 0.08 0.09 0.1 0.11 0.12 0.13 0.14 0.15 0.16 0.17 0.18 0.19 0.2 0.21 0.22 0.23 0.24 0.25 0.26 0.27 0.28 0.29 0.3 0.31 0.32 0.33 0.34 0.35 0.36 0.37 0.38 0.39 0.4 0.41 0.42 0.43 0.44 0.45 0.46 0.47 0.48 0.49 0.5 0.51 0.52 0.53 0.54 0.55 0.56 0.57 0.58 0.59 0.6 0.61 0.62 0.63 0.64 0.65 0.66 0.67 0.68 0.69 0.7 0.71 0.72 0.73 0.74 0.75 0.76 0.77 0.78 0.79 0.8 0.81 0.82 0.83 0.84 0.85 0.86 0.87 0.88 0.89 0.9 0.91 0.92 0.93 0.94 0.95 0.96 0.97 0.98 0.99 ]
|
||||
#define cloudMie2Multiplier 0.7 // Multiplier for multiple scattering approximation [0.01 0.02 0.03 0.04 0.05 0.06 0.07 0.08 0.09 0.1 0.11 0.12 0.13 0.14 0.15 0.16 0.17 0.18 0.19 0.2 0.21 0.22 0.23 0.24 0.25 0.26 0.27 0.28 0.29 0.3 0.31 0.32 0.33 0.34 0.35 0.36 0.37 0.38 0.39 0.4 0.41 0.42 0.43 0.44 0.45 0.46 0.47 0.48 0.49 0.5 0.51 0.52 0.53 0.54 0.55 0.56 0.57 0.58 0.59 0.6 0.61 0.62 0.63 0.64 0.65 0.66 0.67 0.68 0.69 0.7 0.71 0.72 0.73 0.74 0.75 0.76 0.77 0.78 0.79 0.8 0.81 0.82 0.83 0.84 0.85 0.86 0.87 0.88 0.89 0.9 0.91 0.92 0.93 0.94 0.95 0.96 0.97 0.98 0.99 ]
|
||||
|
||||
#define Cloud_top_cutoff 1.0 // the cutoff point on the top part of the cloud. [ 0.1 0.2 0.3 0.4 0.5 0.6 0.7 0.8 0.9 1.0 1.1 1.2 1.3 1.4 1.5 1.6 1.7 1.8 1.9 2.0 2.5 3.0 4 5 6 7 8 9]
|
||||
#define Cloud_base_cutoff 5.0 // the cutoff point on the base of the cloud. [0.1 1 2 4 6 8 10 12 14 16 18 20]
|
||||
|
||||
|
||||
#ifdef HQ_CLOUDS
|
||||
int maxIT_clouds = minRayMarchSteps;
|
||||
int maxIT = maxRayMarchSteps;
|
||||
#else
|
||||
int maxIT_clouds = minRayMarchStepsLQ;
|
||||
int maxIT = maxRayMarchStepsLQ;
|
||||
#endif
|
||||
|
||||
/////// shape
|
||||
#define cloudDensity 0.0514 // Cloud Density, 0.04-0.06 is around irl values [0.0010 0.0011 0.0013 0.0015 0.0017 0.0020 0.0023 0.0026 0.0030 0.0034 0.0039 0.0045 0.0051 0.0058 0.0067 0.0077 0.0088 0.0101 0.0115 0.0132 0.0151 0.0173 0.0199 0.0228 0.0261 0.0299 0.0342 0.0392 0.0449 0.0514 0.0589 0.0675 0.0773 0.0885 0.1014 0.1162 0.1331 0.1524 0.1746 0.2000 0.3 0.35 0.4 0.45 0.5 0.6 0.7 0.8 0.9 1.0]
|
||||
#define fbmAmount 0.50 // Amount of noise added to the cloud shape [0.00 0.02 0.04 0.06 0.08 0.10 0.12 0.14 0.16 0.18 0.20 0.22 0.24 0.26 0.28 0.30 0.32 0.34 0.36 0.38 0.40 0.42 0.44 0.46 0.48 0.50 0.52 0.54 0.56 0.58 0.60 0.62 0.64 0.66 0.68 0.70 0.72 0.74 0.76 0.78 0.80 0.82 0.84 0.86 0.88 0.90 0.92 0.94 0.96 0.98 1.00 1.02 1.04 1.06 1.08 1.10 1.12 1.14 1.16 1.18 1.20 1.22 1.24 1.26 1.28 1.30 1.32 1.34 1.36 1.38 1.40 1.42 1.44 1.46 1.48 1.50 1.52 1.54 1.56 1.58 1.60 1.62 1.64 1.66 1.68 1.70 1.72 1.74 1.76 1.78 1.80 1.82 1.84 1.86 1.88 1.90 1.92 1.94 1.96 1.98 2.00 2.02 2.04 2.06 2.08 2.10 2.12 2.14 2.16 2.18 2.20 2.22 2.24 2.26 2.28 2.30 2.32 2.34 2.36 2.38 2.40 2.42 2.44 2.46 2.48 2.50 2.52 2.54 2.56 2.58 2.60 2.62 2.64 2.66 2.68 2.70 2.72 2.74 2.76 2.78 2.80 2.82 2.84 2.86 2.88 2.90 2.92 2.94 2.96 2.98 3.00]
|
||||
#define fbmPower1 3.00 // Higher values increases high frequency details of the cloud shape [1.0 1.50 1.52 1.54 1.56 1.58 1.60 1.62 1.64 1.66 1.68 1.70 1.72 1.74 1.76 1.78 1.80 1.82 1.84 1.86 1.88 1.90 1.92 1.94 1.96 1.98 2.00 2.02 2.04 2.06 2.08 2.10 2.12 2.14 2.16 2.18 2.20 2.22 2.24 2.26 2.28 2.30 2.32 2.34 2.36 2.38 2.40 2.42 2.44 2.46 2.48 2.50 2.52 2.54 2.56 2.58 2.60 2.62 2.64 2.66 2.68 2.70 2.72 2.74 2.76 2.78 2.80 2.82 2.84 2.86 2.88 2.90 2.92 2.94 2.96 2.98 3.00 3.02 3.04 3.06 3.08 3.10 3.12 3.14 3.16 3.18 3.20 3.22 3.24 3.26 3.28 3.30 3.32 3.34 3.36 3.38 3.40 3.42 3.44 3.46 3.48 3.50 3.52 3.54 3.56 3.58 3.60 3.62 3.64 3.66 3.68 3.70 3.72 3.74 3.76 3.78 3.80 3.82 3.84 3.86 3.88 3.90 3.92 3.94 3.96 3.98 4.00 5. 6. 7. 8. 9. 10.]
|
||||
#define fbmPower2 1.50 // Lower values increases high frequency details of the cloud shape [1.00 1.50 1.52 1.54 1.56 1.58 1.60 1.62 1.64 1.66 1.68 1.70 1.72 1.74 1.76 1.78 1.80 1.82 1.84 1.86 1.88 1.90 1.92 1.94 1.96 1.98 2.00 2.02 2.04 2.06 2.08 2.10 2.12 2.14 2.16 2.18 2.20 2.22 2.24 2.26 2.28 2.30 2.32 2.34 2.36 2.38 2.40 2.42 2.44 2.46 2.48 2.50 2.52 2.54 2.56 2.58 2.60 2.62 2.64 2.66 2.68 2.70 2.72 2.74 2.76 2.78 2.80 2.82 2.84 2.86 2.88 2.90 2.92 2.94 2.96 2.98 3.00 3.02 3.04 3.06 3.08 3.10 3.12 3.14 3.16 3.18 3.20 3.22 3.24 3.26 3.28 3.30 3.32 3.34 3.36 3.38 3.40 3.42 3.44 3.46 3.48 3.50 3.52 3.54 3.56 3.58 3.60 3.62 3.64 3.66 3.68 3.70 3.72 3.74 3.76 3.78 3.80 3.82 3.84 3.86 3.88 3.90 3.92 3.94 3.96 3.98 4.00 5. 6. 7. 8. 9. 10.]
|
||||
|
||||
#define Cloud_Size 35 // [1 5 10 15 20 25 30 35 40 45 50 55 60 65 70 75 80 85 90 95 100]
|
||||
#define Cloud_Height 319 // [-300 -290 -280 -270 -260 -250 -240 -230 -220 -210 -200 -190 -180 -170 -160 -150 -140 -130 -120 -110 -100 -90 -80 -70 -60 -50 -40 -30 -20 -10 0 10 20 30 40 50 60 70 80 90 100 110 120 130 140 150 160 170 180 190 200 210 220 230 240 250 260 270 280 290 300 310 319 320]
|
||||
|
||||
/////// lighting
|
||||
#define Shadow_brightness 0.5 // how dark / bright you want the shadowed part of the clouds to be. low values can look weird. [ 0.1 0.2 0.3 0.4 0.5 0.6 0.7 0.8 0.9 1.0 1.1 1.2 1.3 1.4 1.5 1.6 1.7 1.8 1.9 2.0 3.0 4.0 5.0 6.0]
|
||||
#define self_shadow_samples 3.0 // amount of interations for cloud self shadows. longer/shorter cloud self shadows. [ 2.0 3.0 4.0 5.0 6.0 7.0 8.0 9.0 10.0 15 20 30 40 50]
|
||||
|
||||
|
||||
#define Dynamic_sky_day -1 // -1 MEANS THIS IS OFF. select which day of the 8 to the clouds should take shape in [0 1 2 3 4 5 6 7 ]
|
||||
#define Dynamic_Sky // day 1: partly cloudy. day 2: really cloudy, misty. day 3: mostly clear. day 4: cloudy. day 5: cloudy again. day 6: scattered clouds. day 7: partly cloudy. day 8: clear
|
||||
|
||||
#define High_Altitude_Clouds // a layer of clouds way up yonder
|
||||
#define Cumulus_Clouds
|
||||
|
||||
|
||||
/////// other
|
||||
#define flip_the_clouds 1 // what was once above is now below [1 -1]
|
||||
#define cloud_speed 1 // how [ 0.0 0.1 0.2 0.3 0.4 0.5 0.6 0.7 0.8 0.9 1.0 2.0 3.0 5.0 10.0 25.0 50.0 100.0 200.0]
|
||||
|
||||
#ifdef HQ_CLOUDS
|
||||
const int cloudLoD = cloud_LevelOfDetail;
|
||||
const int cloudShadowLoD = cloud_ShadowLevelOfDetail;
|
||||
#else
|
||||
const int cloudLoD = cloud_LevelOfDetailLQ;
|
||||
const int cloudShadowLoD = cloud_ShadowLevelOfDetailLQ;
|
||||
#endif
|
||||
|
||||
uniform float viewHeight;
|
||||
uniform float viewWidth;
|
||||
uniform sampler2D colortex4;//Skybox
|
||||
// uniform float lightningFlash;
|
||||
|
||||
// uniform vec4 Moon_Weather_properties;
|
||||
// float highCov = Dynamic_sky_day == 0 ? 0.4 : Dynamic_sky_day == 1 ? 0.6 : Dynamic_sky_day == 2 ? 0.4 : Dynamic_sky_day == 3 ? -1000 : Dynamic_sky_day == 4 ? 1 : Dynamic_sky_day == 5 ? -1000 : Dynamic_sky_day == 6 ? 0.6 : 0.4;
|
||||
// float lowCov = Dynamic_sky_day == 0 ? 0.4 : Dynamic_sky_day == 1 ? 0.9 : Dynamic_sky_day == 2 ? 0.0 : Dynamic_sky_day == 3 ? 0.5 : Dynamic_sky_day == 4 ? 0 : Dynamic_sky_day == 5 ? -1000 : Dynamic_sky_day == 6 ? -1000 : 0.8;
|
||||
// float FogDen = Dynamic_sky_day == 0 ? 0 : Dynamic_sky_day == 1 ? 0 : Dynamic_sky_day == 2 ? 0 : Dynamic_sky_day == 3 ? 0 : Dynamic_sky_day == 4 ? 0 : Dynamic_sky_day == 5 ? 0 : Dynamic_sky_day == 6 ? 0 : 0;
|
||||
// float CloudyFogden = Dynamic_sky_day == 0 ? 0 : Dynamic_sky_day == 1 ? 0 : Dynamic_sky_day == 2 ? 0 : Dynamic_sky_day == 3 ? 0 : Dynamic_sky_day == 4 ? 0 : Dynamic_sky_day == 5 ? 0 : Dynamic_sky_day == 6 ? 0 : 0;
|
||||
// vec4 custom_day = vec4(highCov, lowCov, FogDen, CloudyFogden);
|
||||
|
||||
|
||||
// #ifdef Dynamic_Sky
|
||||
|
||||
// #if Dynamic_sky_day < 0
|
||||
// vec4 Weather_properties = Moon_Weather_properties;
|
||||
// #endif
|
||||
|
||||
// #if Dynamic_sky_day >= 0
|
||||
// vec4 Weather_properties = custom_day;
|
||||
// #endif
|
||||
|
||||
// #else
|
||||
// vec4 Weather_properties = vec4(0);
|
||||
// #endif
|
||||
|
||||
#define WEATHERCLOUDS
|
||||
#include "/lib/climate_settings.glsl"
|
||||
|
||||
|
||||
|
||||
float maxHeight = 5000.;
|
||||
float cloud_height = 1500.;
|
||||
|
||||
// quick variables
|
||||
float rainCloudwetness = rainStrength ;
|
||||
float rainClouds = rainCloudwetness;
|
||||
|
||||
float cloud_movement1 = frameTimeCounter * cloud_speed * 0.001;
|
||||
|
||||
|
||||
//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);
|
||||
}
|
||||
|
||||
float cloudshape = 0.0;
|
||||
|
||||
float cloudCov(in vec3 pos,vec3 samplePos){
|
||||
|
||||
float CloudLarge = texture2D(noisetex, samplePos.xz/150000 + cloud_movement1).b;
|
||||
float CloudSmall = texture2D(noisetex, samplePos.xz/15000 - cloud_movement1 + vec2(1-CloudLarge,-CloudLarge)/5).r;
|
||||
|
||||
float coverage = CloudSmall-CloudLarge;
|
||||
|
||||
float mult = max( abs(pos.y-1750) / 5000, 0);
|
||||
|
||||
// #ifdef Dynamic_Sky
|
||||
// cloudshape = ( coverage + (-0.35+mix(Weather_properties.r, Rain_coverage, rainCloudwetness)*1.5) ) - mult;
|
||||
// // cloudshape = coverage - mult;
|
||||
// #else
|
||||
// cloudshape = ( coverage + (-0.35+mix(cloudCoverage, Rain_coverage, rainCloudwetness)*1.5) ) - mult ;
|
||||
// #endif
|
||||
|
||||
cloudshape = DailyWeather_LowAltitude(coverage) - mult;
|
||||
|
||||
return max(cloudshape,0.0);
|
||||
}
|
||||
//Erode cloud with 3d Perlin-worley noise, actual cloud value
|
||||
float cloudVol(in vec3 pos,in vec3 samplePos,in float cov, in int LoD){
|
||||
float noise = 0.0 ;
|
||||
float totalWeights = 0.0;
|
||||
float pw = log(fbmPower1);
|
||||
float pw2 = log(fbmPower2);
|
||||
|
||||
// samplePos.xyz -= cloud_movement1.xyz*400;
|
||||
|
||||
for (int i = 0; i <= LoD; i++){
|
||||
float weight = exp(-i*pw2);
|
||||
|
||||
noise += weight - densityAtPos(samplePos * 8 * exp(i*pw) )*weight ;
|
||||
totalWeights += weight ;
|
||||
}
|
||||
|
||||
noise *= clamp(1.0-cloudshape,0.0,1.0);
|
||||
noise /= totalWeights;
|
||||
noise = noise*noise;
|
||||
float cloud = max(cov-noise*noise*fbmAmount,0.0);
|
||||
|
||||
return cloud;
|
||||
}
|
||||
|
||||
float getCloudDensity(in vec3 pos, in int LoD){
|
||||
|
||||
|
||||
vec3 samplePos = pos*vec3(1.0,1./48.,1.0)/4 ;
|
||||
float coverageSP = cloudCov(pos,samplePos);
|
||||
|
||||
if (coverageSP > 0.001) {
|
||||
if (LoD < 0) return max(coverageSP - 0.27*fbmAmount,0.0);
|
||||
return cloudVol(pos,samplePos,coverageSP, LoD);
|
||||
} else return 0.0;
|
||||
}
|
||||
|
||||
float HighAltitudeClouds(vec3 pos){
|
||||
vec2 pos2d = pos.xz/100000.0 ;
|
||||
|
||||
float cloudLarge = texture2D(noisetex, pos2d/5. ).b;
|
||||
float cloudSmall = texture2D(noisetex, pos2d + vec2(-cloudLarge,cloudLarge)/10).b;
|
||||
|
||||
|
||||
// #ifdef Dynamic_Sky
|
||||
// coverage = max(10.3 - Weather_properties.g*10.,0.0);
|
||||
// // thickness = Weather_properties.g*3 ;
|
||||
// #endif
|
||||
|
||||
float coverage = 1;
|
||||
float thickness = 1;
|
||||
DailyWeather_HighAltitude(coverage, thickness);
|
||||
|
||||
float cirrusFinal = exp(pow((cloudSmall + cloudLarge),thickness) * -coverage );
|
||||
return max(cirrusFinal,0.0);
|
||||
}
|
||||
|
||||
//Mie phase function
|
||||
float phaseg(float x, float g){
|
||||
float gg = g * g;
|
||||
return (gg * -0.25 + 0.25) * pow(-2.0 * (g * x) + (gg + 1.0), -1.5) /3.14;
|
||||
}
|
||||
|
||||
// random magic number bullshit go!
|
||||
vec3 Cloud_lighting(
|
||||
vec3 Pos,
|
||||
float CloudShape,
|
||||
float SkyShadowing,
|
||||
float SunShadowing,
|
||||
float MoonShadowing,
|
||||
vec3 SkyColors,
|
||||
vec3 sunContribution,
|
||||
vec3 sunContributionMulti,
|
||||
vec3 moonContribution,
|
||||
vec3 moonContributionMulti,
|
||||
int cloudType
|
||||
){
|
||||
|
||||
// low altitude
|
||||
float powder = max(1.0 - exp2(-CloudShape*100.0),0.0);
|
||||
float ambientShading = (powder*0.8+0.2) * exp2(-SkyShadowing * 50.);
|
||||
vec3 ambientLighting = SkyColors * 4.0 * ambientShading;
|
||||
|
||||
if(cloudType == 1) ambientLighting = SkyColors * (1.0-powder/2);
|
||||
|
||||
vec3 sunLighting = ( exp2(-SunShadowing * 2.0 )*sunContribution + exp(-SunShadowing * 0.2 )*sunContributionMulti ) * powder;
|
||||
vec3 moonLighting = ( exp2(-MoonShadowing * 2.0 )*moonContribution + exp(-MoonShadowing * 0.2 )*moonContributionMulti ) * powder;
|
||||
|
||||
// if(cloudType == 0) sunLighting *= clamp((1.05-CirrusCoverage),0,1); // less sunlight hits low clouds if high clouds have alot of coverage
|
||||
|
||||
return ambientLighting + sunLighting + moonLighting;
|
||||
}
|
||||
|
||||
vec3 startOffset = vec3(0);
|
||||
vec4 renderClouds(
|
||||
vec3 fragpositi,
|
||||
vec3 color,
|
||||
float dither,
|
||||
vec3 sunColor,
|
||||
vec3 moonColor,
|
||||
vec3 avgAmbient,
|
||||
float dither2
|
||||
){
|
||||
#ifndef VOLUMETRIC_CLOUDS
|
||||
return vec4(0.0,0.0,0.0,1.0);
|
||||
#endif
|
||||
|
||||
float vL = 0.0;
|
||||
float total_extinction = 1.0;
|
||||
color = vec3(0.0);
|
||||
|
||||
//project pixel position into projected shadowmap space
|
||||
vec4 fragposition = gbufferModelViewInverse*vec4(fragpositi,1.0);
|
||||
|
||||
vec3 worldV = normalize(fragposition.rgb);
|
||||
float VdotU = worldV.y;
|
||||
|
||||
//project view origin into projected shadowmap space
|
||||
vec4 start = (gbufferModelViewInverse*vec4(0.0,0.0,0.,1.));
|
||||
|
||||
// vec3 dV_view = worldV;
|
||||
|
||||
// cloud plane curvature
|
||||
float curvature = 0.05;
|
||||
worldV.y += curvature;
|
||||
vec3 dV_view = worldV;
|
||||
worldV.y -= curvature;
|
||||
vec3 dV_view2 = worldV;
|
||||
|
||||
|
||||
|
||||
maxIT_clouds = int(clamp( maxIT_clouds / sqrt(exp2(VdotU)),0.0, maxIT));
|
||||
|
||||
worldV = normalize(worldV)*100000. + cameraPosition; //makes max cloud distance not dependant of render distance
|
||||
dV_view = normalize(dV_view);
|
||||
|
||||
float height = Cloud_Height;
|
||||
int flipClouds = 1;
|
||||
// if (worldV.y < cloud_height){
|
||||
// flipClouds = -1;
|
||||
// };
|
||||
|
||||
if (worldV.y < cloud_height || cameraPosition.y > 390. ) return vec4(0.,0.,0.,1.); //don't trace if no intersection is possible
|
||||
// if (worldV.y < cloud_height && flipClouds == -1) return vec4(0.,0.,0.,1.); //don't trace if no intersection is possible
|
||||
|
||||
//setup ray to start at the start of the cloud plane and end at the end of the cloud plane
|
||||
dV_view *= max(maxHeight - cloud_height, 0.0)/dV_view.y/(maxIT_clouds);
|
||||
startOffset = dV_view*dither;
|
||||
|
||||
vec3 camPos = ((cameraPosition*flipClouds)-height)*Cloud_Size;
|
||||
|
||||
vec3 progress_view = startOffset + camPos + dV_view*(cloud_height-camPos.y)/dV_view.y;
|
||||
|
||||
float shadowStep = 200.;
|
||||
vec3 dV_Sun = flipClouds * normalize(mat3(gbufferModelViewInverse)*sunVec)*shadowStep;
|
||||
float mult = length(dV_view);
|
||||
|
||||
float SdotV = dot(sunVec,normalize(fragpositi));
|
||||
|
||||
float spinX = sin(frameTimeCounter *3.14);
|
||||
float spinZ = sin(1.57 + frameTimeCounter*3.14);
|
||||
float SdotV_custom = dot(mat3(gbufferModelView) * normalize(vec3(0,0.1,0)),normalize(fragpositi));
|
||||
|
||||
float phaseLightning = phaseg(SdotV_custom, 0.7);
|
||||
|
||||
// direct light colors and shit for clouds
|
||||
// multiply everything by ~pi just for good luck :D
|
||||
float mieDayMulti = phaseg(SdotV, 0.35)*3.14;
|
||||
float mieDay = mix(phaseg(SdotV,0.75), mieDayMulti,0.8)*3.14;
|
||||
|
||||
float mieNightMulti = phaseg(-SdotV, 0.35)*3.14;
|
||||
float mieNight = mix(phaseg(-SdotV,0.9), mieNightMulti,0.5)*3.14;
|
||||
|
||||
vec3 sunContribution = mieDay*sunColor*6.14;
|
||||
vec3 sunContributionMulti = mieDayMulti*sunColor*3.14;
|
||||
|
||||
vec3 moonContribution = mieNight*moonColor*3.14;
|
||||
vec3 moonContributionMulti = mieNightMulti*moonColor*3.14;
|
||||
|
||||
float ambientMult = 1.0;
|
||||
vec3 skyCol0 = (avgAmbient * ambientMult) ;
|
||||
|
||||
vec3 progress_view_high = progress_view + (20000.0-progress_view.y) * dV_view / dV_view.y;
|
||||
float muEshD_high = 0.0;
|
||||
float muEshN_high = 0.0;
|
||||
|
||||
float cirrusShadowStep = 7.;
|
||||
float cirrusDensity = 0.03;
|
||||
|
||||
|
||||
float cloud = 0.0;
|
||||
for(int i=0;i<maxIT_clouds;i++) {
|
||||
|
||||
#ifdef Cumulus_Clouds
|
||||
cloud = getCloudDensity(progress_view, cloudLoD);
|
||||
#endif
|
||||
|
||||
float basefade = clamp( (progress_view.y - 1750 ) / 1750 ,0.0,1.0) ;
|
||||
|
||||
float densityofclouds = basefade*cloudDensity ;
|
||||
|
||||
if(cloud >= 0.0){
|
||||
float muS = cloud*densityofclouds;
|
||||
float muE = cloud*densityofclouds;
|
||||
|
||||
float muEshD = 0.0;
|
||||
if (sunContribution.g > 1e-5){
|
||||
for (int j=0; j < self_shadow_samples; j++){
|
||||
float sample = j+dither2;
|
||||
|
||||
#ifdef Cumulus_Clouds
|
||||
// low altitude clouds shadows
|
||||
vec3 shadowSamplePos = progress_view + dV_Sun * (sample + sample*2.0);
|
||||
|
||||
if (shadowSamplePos.y < maxHeight){
|
||||
float cloudS = getCloudDensity(vec3(shadowSamplePos), cloudShadowLoD);
|
||||
muEshD += cloudS*cloudDensity*shadowStep;
|
||||
}
|
||||
#endif
|
||||
|
||||
#ifdef High_Altitude_Clouds
|
||||
// high altitude clouds shadows
|
||||
vec3 shadowSamplePos_high = progress_view_high + dV_Sun * (sample + sample*2.0);
|
||||
float highAlt_cloudS = HighAltitudeClouds(shadowSamplePos_high);
|
||||
muEshD_high += highAlt_cloudS*cirrusDensity*cirrusShadowStep;
|
||||
#endif
|
||||
}
|
||||
}
|
||||
|
||||
float muEshN = 0.0;
|
||||
if (moonContribution.g > 1e-5){
|
||||
for (int j=0; j<self_shadow_samples; j++){
|
||||
float sample = j+dither2;
|
||||
|
||||
#ifdef Cumulus_Clouds
|
||||
// low altitude clouds shadows
|
||||
vec3 shadowSamplePos = progress_view - dV_Sun * (sample + sample*2.0);
|
||||
if (shadowSamplePos.y < maxHeight){
|
||||
float cloudS = getCloudDensity(vec3(shadowSamplePos), cloudShadowLoD);
|
||||
muEshN += cloudS*cloudDensity*shadowStep;
|
||||
}
|
||||
#endif
|
||||
|
||||
#ifdef High_Altitude_Clouds
|
||||
// high altitude clouds shadows
|
||||
vec3 shadowSamplePos_high = progress_view_high - dV_Sun * (sample + sample*2.0);
|
||||
float highAlt_cloudS = HighAltitudeClouds(shadowSamplePos_high);
|
||||
muEshN_high += highAlt_cloudS*cirrusDensity*cirrusShadowStep;
|
||||
#endif
|
||||
}
|
||||
}
|
||||
|
||||
#ifdef Cumulus_Clouds
|
||||
// clamp(abs(dV_Sun.y)/150.0,0.5,1.0)
|
||||
float muEshA = (cloud*cloudDensity) ;
|
||||
vec3 S = Cloud_lighting(progress_view, muE, muEshA, muEshD, muEshN, skyCol0 * max(abs(dV_Sun.y)/150.0,0.5), sunContribution, sunContributionMulti, moonContribution, moonContributionMulti, 0);
|
||||
|
||||
// float bottom = clamp( (progress_view.y-3250.*0.6) / 1000. ,0.0,1.0) ;
|
||||
// float location = bottom * (muEshA*5000) * pow(phaseLightning,1.5);
|
||||
// vec3 lightningLighting = lightningFlash * vec3(0.5,0.75,1) * location * max(dV_Sun.y,1.);
|
||||
// S += lightningLighting ;
|
||||
|
||||
vec3 Sint = (S - S * exp(-mult*muE)) / muE;
|
||||
color += max(muS*Sint*total_extinction,0.0);
|
||||
total_extinction *= max(exp(-muE*mult),0);
|
||||
|
||||
if (total_extinction < 1e-5) break;
|
||||
#endif
|
||||
}
|
||||
progress_view += dV_view;
|
||||
}
|
||||
|
||||
// do this aftewards because stinky
|
||||
#ifdef High_Altitude_Clouds
|
||||
float cirrus = HighAltitudeClouds(progress_view_high);
|
||||
if (cirrus >= 0.0){
|
||||
float muS = cirrus*cirrusDensity;
|
||||
float muE = cirrus*cirrusDensity;
|
||||
|
||||
float muEshA_high = cirrus*cirrusDensity;
|
||||
|
||||
vec3 S = Cloud_lighting(progress_view, muE, muEshA_high, muEshD_high, muEshN_high, skyCol0 * max(abs(dV_Sun.y)/150.0,0.5) , sunContribution, sunContributionMulti, moonContribution, moonContributionMulti, 1);
|
||||
|
||||
vec3 Sint = (S - S * exp(-mult*muE)) / muE;
|
||||
color += max(muS*Sint*total_extinction,0.0);
|
||||
total_extinction *= max(exp(-muE*mult),0);
|
||||
}
|
||||
#endif
|
||||
|
||||
vec3 normView = normalize(dV_view2)*flipClouds;
|
||||
// Assume fog color = sky gradient at long distance
|
||||
vec3 fogColor = skyFromTex(normView, colortex4)/150.;
|
||||
float dist = (cloud_height - (cameraPosition.y))/normalize(dV_view2).y;
|
||||
float fog = exp(-dist/15000.0*(1.0+rainCloudwetness*8.));
|
||||
return mix(vec4(fogColor,0.0), vec4(color,total_extinction), fog);
|
||||
// return vec4(color,total_extinction);
|
||||
}
|
184
shaders/lib/volumetricFog.glsl
Normal file
184
shaders/lib/volumetricFog.glsl
Normal file
@ -0,0 +1,184 @@
|
||||
#define VL_CLOUDS_SHADOWS
|
||||
#define CLOUDS_SHADOWS
|
||||
#define CLOUDS_SHADOWS_STRENGTH 1.0 //[0.1 0.125 0.15 0.2 0.25 0.3 0.35 0.4 0.45 0.5 0.55 0.6 0.65 0.7 0.75 0.8 0.9 1.0]
|
||||
#define VL_SAMPLES2 6 //[4 6 8 10 12 14 16 20 24 30 40 50]
|
||||
#define Ambient_Mult 1.0 //[0.1 0.2 0.3 0.4 0.5 0.6 0.7 0.75 0.8 0.85 0.9 0.95 1.0 1.5 2.0 3.0 4.0 5.0 6.0 10.0]
|
||||
#define SEA_LEVEL 70 //[0 10 20 30 40 50 60 70 80 90 100 110 120 130 150 170 190] //The volumetric light uses an altitude-based fog density, this is where fog density is the highest, adjust this value according to your world.
|
||||
#define ATMOSPHERIC_DENSITY 1.0 //[0.0 0.5 1.0 1.5 2.0 2.5 3.0 4.0 5.0 7.5 10.0 12.5 15.0 20.]
|
||||
#define fog_mieg1 0.40 //[0.1 0.2 0.3 0.4 0.5 0.6 0.7 0.75 0.8 0.85 0.9 0.95 1.0]
|
||||
#define fog_mieg2 0.10 //[0.1 0.2 0.3 0.4 0.5 0.6 0.7 0.75 0.8 0.85 0.9 0.95 1.0]
|
||||
#define fog_coefficientRayleighR 5.8 //[0.0 0.5 1.0 1.5 2.0 2.5 3.0 3.5 4.0 4.5 5.0 5.5 6.0 6.5 7.0 7.5 8.0 8.5 9.0 9.5 10.0]
|
||||
#define fog_coefficientRayleighG 1.35 //[0.0 0.5 1.0 1.5 2.0 2.5 3.0 3.5 4.0 4.5 5.0 5.5 6.0 6.5 7.0 7.5 8.0 8.5 9.0 9.5 10.0]
|
||||
#define fog_coefficientRayleighB 3.31 //[0.0 0.5 1.0 1.5 2.0 2.5 3.0 3.5 4.0 4.5 5.0 5.5 6.0 6.5 7.0 7.5 8.0 8.5 9.0 9.5 10.0]
|
||||
|
||||
#define fog_coefficientMieR 3.0 //[0.0 0.5 1.0 1.5 2.0 2.5 3.0 3.5 4.0 4.5 5.0 5.5 6.0 6.5 7.0 7.5 8.0 8.5 9.0 9.5 10.0]
|
||||
#define fog_coefficientMieG 3.0 //[0.0 0.5 1.0 1.5 2.0 2.5 3.0 3.5 4.0 4.5 5.0 5.5 6.0 6.5 7.0 7.5 8.0 8.5 9.0 9.5 10.0]
|
||||
#define fog_coefficientMieB 3.0 //[0.0 0.5 1.0 1.5 2.0 2.5 3.0 3.5 4.0 4.5 5.0 5.5 6.0 6.5 7.0 7.5 8.0 8.5 9.0 9.5 10.0]
|
||||
|
||||
// #define Cloudy_Fog_Density 5.0 //[0.0 0.5 1.0 1.5 2.0 2.5 3.0 3.5 4.0 4.5 5.0 5.5 6.0 6.5 7.0 7.5 8.0 8.5 9.0 9.5 10.0]
|
||||
// #define Uniform_Fog_Density 1.0 //[0.0 0.5 1.0 1.5 2.0 2.5 3.0 3.5 4.0 4.5 5.0 5.5 6.0 6.5 7.0 7.5 8.0 8.5 9.0 9.5 10.0]
|
||||
|
||||
// #define uniformfog_fade 10 // [5 10 20 30 40 50 60 70 80 90 100]
|
||||
// #define cloudyfog_fade 10 // [5 10 20 30 40 50 60 70 80 90 100]
|
||||
|
||||
float luma(vec3 color) {
|
||||
return dot(color,vec3(0.299, 0.587, 0.114));
|
||||
}
|
||||
|
||||
float phaseRayleigh(float cosTheta) {
|
||||
const vec2 mul_add = vec2(0.1, 0.28) /acos(-1.0);
|
||||
return cosTheta * mul_add.x + mul_add.y; // optimized version from [Elek09], divided by 4 pi for energy conservation
|
||||
}
|
||||
|
||||
|
||||
// #define TIMEOFDAYFOG
|
||||
// #include "/lib/climate_settings.glsl"
|
||||
// uniform int worldTime;
|
||||
|
||||
// void TimeOfDayFog( inout float Uniform, inout float Cloudy) {
|
||||
|
||||
// float Time = (worldTime%24000)*1.0;
|
||||
|
||||
// // set schedules for fog to appear at specific ranges of time in the day.
|
||||
// float Morning = clamp((Time-22000)/2000,0,1) + clamp((2000-Time)/2000,0,1);
|
||||
// float Noon = clamp(Time/2000,0,1) * clamp((12000-Time)/2000,0,1);
|
||||
// float Evening = clamp((Time-10000)/2000,0,1) * clamp((14000-Time)/2000,0,1) ;
|
||||
// float Night = clamp((Time-12000)/2000,0,1) * clamp((23000-Time)/2000,0,1) ;
|
||||
|
||||
// vec4 UniformDensity = vec4(0, 55, 0, 0);
|
||||
// vec4 CloudyDensity = vec4(0, 0, 0, 0);
|
||||
|
||||
|
||||
// Uniform *= Morning*UniformDensity.r + Noon*UniformDensity.g + Evening*UniformDensity.b + Night*UniformDensity.a;
|
||||
// Cloudy *= Morning*CloudyDensity.r + Noon*CloudyDensity.g + Evening*CloudyDensity.b + Night*CloudyDensity.a;
|
||||
// }
|
||||
|
||||
float cloudVol(in vec3 pos){
|
||||
|
||||
vec3 samplePos = pos*vec3(1.0,1./24.,1.0);
|
||||
vec3 samplePos2 = pos*vec3(1.0,1./48.,1.0);
|
||||
|
||||
|
||||
float mult = exp2( -max((pos.y - SEA_LEVEL) / 35.,0.0));
|
||||
|
||||
float fog_shape = 1-densityAtPos(samplePos * 24.0);
|
||||
float fog_eroded = densityAtPos( samplePos2 * 150.0);
|
||||
|
||||
float CloudyFog = max( (fog_shape*2.0 - fog_eroded*0.5) - 1.4, 0.0) * mult;
|
||||
float UniformFog = exp2( -max((pos.y - SEA_LEVEL) / 25.,0.0));
|
||||
|
||||
float RainFog = max(fog_shape*10. - 7.,0.5) * exp2( -max((pos.y - SEA_LEVEL) / 25.,0.0)) * 5. * rainStrength;
|
||||
|
||||
TimeOfDayFog(UniformFog, CloudyFog);
|
||||
|
||||
return RainFog + CloudyFog + UniformFog;
|
||||
}
|
||||
|
||||
mat2x3 getVolumetricRays(
|
||||
float dither,
|
||||
vec3 fragpos
|
||||
){
|
||||
//project pixel position into projected shadowmap space
|
||||
vec3 wpos = mat3(gbufferModelViewInverse) * fragpos + gbufferModelViewInverse[3].xyz;
|
||||
vec3 fragposition = mat3(shadowModelView) * wpos + shadowModelView[3].xyz;
|
||||
fragposition = diagonal3(shadowProjection) * fragposition + shadowProjection[3].xyz;
|
||||
|
||||
//project view origin into projected shadowmap space
|
||||
vec3 start = toShadowSpaceProjected(vec3(0.));
|
||||
|
||||
//rayvector into projected shadow map space
|
||||
//we can use a projected vector because its orthographic projection
|
||||
//however we still have to send it to curved shadow map space every step
|
||||
vec3 dV = fragposition-start;
|
||||
vec3 dVWorld = (wpos-gbufferModelViewInverse[3].xyz);
|
||||
|
||||
float maxLength = min(length(dVWorld),far)/length(dVWorld);
|
||||
dV *= maxLength;
|
||||
dVWorld *= maxLength;
|
||||
|
||||
//apply dither
|
||||
vec3 progress = start.xyz;
|
||||
vec3 progressW = gbufferModelViewInverse[3].xyz+cameraPosition;
|
||||
|
||||
vec3 vL = vec3(0.);
|
||||
|
||||
float SdotV = dot(sunVec,normalize(fragpos))*lightCol.a;
|
||||
float dL = length(dVWorld);
|
||||
|
||||
//Mie phase + somewhat simulates multiple scattering (Horizon zero down cloud approx)
|
||||
float mie = phaseg(SdotV,0.7)*5.0 + 1.0;
|
||||
float rayL = phaseRayleigh(SdotV);
|
||||
|
||||
// Makes fog more white idk how to simulate it correctly
|
||||
vec3 sunColor = lightCol.rgb / 5.0;
|
||||
vec3 skyCol0 = (ambientUp / 5.0 * 5.); // * max(abs(WsunVec.y)/150.0,0.);
|
||||
|
||||
vec3 rC = vec3(fog_coefficientRayleighR*1e-6, fog_coefficientRayleighG*1e-5, fog_coefficientRayleighB*1e-5);
|
||||
vec3 mC = vec3(fog_coefficientMieR*1e-6, fog_coefficientMieG*1e-6, fog_coefficientMieB*1e-6);
|
||||
|
||||
float mu = 1.0;
|
||||
float muS = mu;
|
||||
vec3 absorbance = vec3(1.0);
|
||||
float expFactor = 11.0;
|
||||
vec3 WsunVec = mat3(gbufferModelViewInverse) * sunVec * lightCol.a;
|
||||
|
||||
float cloudShadow = 1.0;
|
||||
|
||||
for (int i=0;i<VL_SAMPLES2;i++) {
|
||||
float d = (pow(expFactor, float(i+dither)/float(VL_SAMPLES2))/expFactor - 1.0/expFactor)/(1-1.0/expFactor);
|
||||
float dd = pow(expFactor, float(i+dither)/float(VL_SAMPLES2)) * log(expFactor) / float(VL_SAMPLES2)/(expFactor-1.0);
|
||||
progress = start.xyz + d*dV;
|
||||
progressW = gbufferModelViewInverse[3].xyz+cameraPosition + d*dVWorld;
|
||||
//project into biased shadowmap space
|
||||
float distortFactor = calcDistort(progress.xy);
|
||||
vec3 pos = vec3(progress.xy*distortFactor, progress.z);
|
||||
float densityVol = cloudVol(progressW);
|
||||
float sh = 1.0;
|
||||
if (abs(pos.x) < 1.0-0.5/2048. && abs(pos.y) < 1.0-0.5/2048){
|
||||
pos = pos*vec3(0.5,0.5,0.5/6.0)+0.5;
|
||||
sh = shadow2D( shadow, pos).x;
|
||||
}
|
||||
#ifdef VOLUMETRIC_CLOUDS
|
||||
#ifdef CLOUDS_SHADOWS
|
||||
#ifdef VL_CLOUDS_SHADOWS
|
||||
float max_height = clamp(400.0 - progressW.y, 0.0,1.0); // so it doesnt go beyond the height of the clouds
|
||||
vec3 campos = (progressW)-319;
|
||||
// get cloud position
|
||||
vec3 cloudPos = campos*Cloud_Size + WsunVec/abs(WsunVec.y) * (2250 - campos.y*Cloud_Size);
|
||||
// get the cloud density and apply it
|
||||
cloudShadow = getCloudDensity(cloudPos, 1);
|
||||
cloudShadow = exp(-cloudShadow*cloudDensity*200);
|
||||
// cloudShadow *= max_height;
|
||||
// cloudShadow *= 1000; //debug
|
||||
#endif
|
||||
#endif
|
||||
#endif
|
||||
|
||||
//Water droplets(fog)
|
||||
float density = densityVol*ATMOSPHERIC_DENSITY*mu*300.;
|
||||
|
||||
//Just air
|
||||
vec2 airCoef = exp(-max(progressW.y-SEA_LEVEL,0.0)/vec2(8.0e3, 1.2e3)*vec2(6.,7.0)) * 16;
|
||||
|
||||
//Pbr for air, yolo mix between mie and rayleigh for water droplets
|
||||
vec3 rL = rC*airCoef.x;
|
||||
vec3 m = (airCoef.y+density)*mC;
|
||||
|
||||
vec3 rainRays = (sunColor*sh*cloudShadow) * (rayL*phaseg(SdotV,0.6)) * clamp(pow(WsunVec.y,5)*2,0.0,1) * rainStrength;
|
||||
|
||||
vec3 DirectLight = (sunColor*sh*cloudShadow) * (rayL*rL+m*mie);
|
||||
vec3 AmbientLight = skyCol0 * m;
|
||||
|
||||
vec3 AtmosphericFog = skyCol0 * (rL+m) ;
|
||||
|
||||
vec3 vL0 = (DirectLight +AmbientLight+AtmosphericFog + rainRays) * max(eyeBrightnessSmooth.y,0)/240.;
|
||||
|
||||
#ifdef Biome_specific_environment
|
||||
BiomeFogColor(vL0);
|
||||
#endif
|
||||
vL += (vL0 - vL0 * exp(-(rL+m)*dd*dL)) / ((rL+m)+0.00000001)*absorbance;
|
||||
absorbance *= clamp(exp(-(rL+m)*dd*dL),0.0,1.0);
|
||||
|
||||
}
|
||||
return mat2x3(vL,absorbance);
|
||||
}
|
60
shaders/lib/waterBump.glsl
Normal file
60
shaders/lib/waterBump.glsl
Normal file
@ -0,0 +1,60 @@
|
||||
|
||||
//#define Vanilla_like_water // vanilla water texture along with shader water stuff
|
||||
|
||||
|
||||
float getWaterHeightmap(vec2 posxz, float waveM, float waveZ, float iswater) { // water waves
|
||||
vec2 pos = posxz;
|
||||
float moving = clamp(iswater*2.-1.0,0.0,1.0);
|
||||
vec2 movement = vec2(-0.035*frameTimeCounter*moving);
|
||||
float caustic = 0.0;
|
||||
float weightSum = 0.0;
|
||||
float radiance = 2.39996;
|
||||
mat2 rotationMatrix = mat2(vec2(cos(radiance), -sin(radiance)), vec2(sin(radiance), cos(radiance)));
|
||||
|
||||
const vec2 wave_size[4] = vec2[](
|
||||
vec2(600.),
|
||||
vec2(32.,16.),
|
||||
vec2(16.,32.),
|
||||
vec2(48.)
|
||||
);
|
||||
|
||||
for (int i = 0; i < 4; i++){
|
||||
pos = rotationMatrix * pos;
|
||||
|
||||
vec2 speed = movement;
|
||||
float waveStrength = 1.0;
|
||||
|
||||
if( i == 0) {
|
||||
speed *= 0.15;
|
||||
waveStrength = 7.0;
|
||||
}
|
||||
|
||||
float small_wave = texture2D(noisetex, pos / wave_size[i] + speed ).b * waveStrength;
|
||||
|
||||
caustic += small_wave;
|
||||
weightSum -= exp2(caustic);
|
||||
}
|
||||
return caustic / weightSum;
|
||||
}
|
||||
|
||||
vec3 getWaveHeight(vec2 posxz, float iswater){
|
||||
|
||||
vec2 coord = posxz;
|
||||
|
||||
float deltaPos = 0.25;
|
||||
|
||||
float waveZ = mix(20.0,0.25,iswater);
|
||||
float waveM = mix(0.0,4.0,iswater);
|
||||
|
||||
float h0 = getWaterHeightmap(coord, waveM, waveZ, iswater);
|
||||
float h1 = getWaterHeightmap(coord + vec2(deltaPos,0.0), waveM, waveZ, iswater);
|
||||
float h3 = getWaterHeightmap(coord + vec2(0.0,deltaPos), waveM, waveZ, iswater);
|
||||
|
||||
|
||||
float xDelta = ((h1-h0))/deltaPos*2.;
|
||||
float yDelta = ((h3-h0))/deltaPos*2.;
|
||||
|
||||
vec3 wave = normalize(vec3(xDelta,yDelta,1.0-pow(abs(xDelta+yDelta),2.0)));
|
||||
|
||||
return wave;
|
||||
}
|
21
shaders/lib/waterOptions.glsl
Normal file
21
shaders/lib/waterOptions.glsl
Normal file
@ -0,0 +1,21 @@
|
||||
#define Dirt_Amount 0.14 //How much dirt there is in water [0.0 0.04 0.08 0.12 0.16 0.2 0.24 0.28 0.32 0.36 0.4 0.44 0.48 0.52 0.56 0.6 0.64 0.68 0.72 0.76 0.8 0.84 0.88 0.92 0.96 1.0 1.04 1.08 1.12 1.16 1.2 1.24 1.28 1.32 1.36 1.4 1.44 1.48 1.52 1.56 1.6 1.64 1.68 1.72 1.76 1.8 1.84 1.88 1.92 1.96 2.0 ]
|
||||
|
||||
#define Dirt_Scatter_R 0.7 //How much dirt diffuses red [0.01 0.02 0.03 0.04 0.05 0.06 0.07 0.08 0.09 0.1 0.11 0.12 0.13 0.14 0.15 0.16 0.17 0.18 0.19 0.2 0.21 0.22 0.23 0.24 0.25 0.26 0.27 0.28 0.29 0.3 0.31 0.32 0.33 0.34 0.35 0.36 0.37 0.38 0.39 0.4 0.41 0.42 0.43 0.44 0.45 0.46 0.47 0.48 0.49 0.5 0.51 0.52 0.53 0.54 0.55 0.56 0.57 0.58 0.59 0.6 0.61 0.62 0.63 0.64 0.65 0.66 0.67 0.68 0.69 0.7 0.71 0.72 0.73 0.74 0.75 0.76 0.77 0.78 0.79 0.8 0.81 0.82 0.83 0.84 0.85 0.86 0.87 0.88 0.89 0.9 0.91 0.92 0.93 0.94 0.95 0.96 0.97 0.98 0.99 ]
|
||||
#define Dirt_Scatter_G 0.7 //How much dirt diffuses green [0.01 0.02 0.03 0.04 0.05 0.06 0.07 0.08 0.09 0.1 0.11 0.12 0.13 0.14 0.15 0.16 0.17 0.18 0.19 0.2 0.21 0.22 0.23 0.24 0.25 0.26 0.27 0.28 0.29 0.3 0.31 0.32 0.33 0.34 0.35 0.36 0.37 0.38 0.39 0.4 0.41 0.42 0.43 0.44 0.45 0.46 0.47 0.48 0.49 0.5 0.51 0.52 0.53 0.54 0.55 0.56 0.57 0.58 0.59 0.6 0.61 0.62 0.63 0.64 0.65 0.66 0.67 0.68 0.69 0.7 0.71 0.72 0.73 0.74 0.75 0.76 0.77 0.78 0.79 0.8 0.81 0.82 0.83 0.84 0.85 0.86 0.87 0.88 0.89 0.9 0.91 0.92 0.93 0.94 0.95 0.96 0.97 0.98 0.99 ]
|
||||
#define Dirt_Scatter_B 0.7 //How much dirt diffuses blue [0.01 0.02 0.03 0.04 0.05 0.06 0.07 0.08 0.09 0.1 0.11 0.12 0.13 0.14 0.15 0.16 0.17 0.18 0.19 0.2 0.21 0.22 0.23 0.24 0.25 0.26 0.27 0.28 0.29 0.3 0.31 0.32 0.33 0.34 0.35 0.36 0.37 0.38 0.39 0.4 0.41 0.42 0.43 0.44 0.45 0.46 0.47 0.48 0.49 0.5 0.51 0.52 0.53 0.54 0.55 0.56 0.57 0.58 0.59 0.6 0.61 0.62 0.63 0.64 0.65 0.66 0.67 0.68 0.69 0.7 0.71 0.72 0.73 0.74 0.75 0.76 0.77 0.78 0.79 0.8 0.81 0.82 0.83 0.84 0.85 0.86 0.87 0.88 0.89 0.9 0.91 0.92 0.93 0.94 0.95 0.96 0.97 0.98 0.99 ]
|
||||
|
||||
#define Dirt_Absorb_R 1.65 //How much dirt absorbs red [0.0 0.02 0.04 0.06 0.08 0.1 0.12 0.14 0.16 0.18 0.2 0.22 0.24 0.26 0.28 0.3 0.32 0.34 0.36 0.38 0.4 0.42 0.44 0.46 0.48 0.5 0.52 0.54 0.56 0.58 0.6 0.62 0.64 0.66 0.68 0.7 0.72 0.74 0.76 0.78 0.8 0.82 0.84 0.86 0.88 0.9 0.92 0.94 0.96 0.98 1.0 1.02 1.04 1.06 1.08 1.1 1.12 1.14 1.16 1.18 1.2 1.22 1.24 1.26 1.28 1.3 1.32 1.34 1.36 1.38 1.4 1.42 1.44 1.46 1.48 1.5 1.52 1.54 1.56 1.58 1.6 1.62 1.64 1.66 1.68 1.7 1.72 1.74 1.76 1.78 1.8 1.82 1.84 1.86 1.88 1.9 1.92 1.94 1.96 1.98 2.0 ]
|
||||
#define Dirt_Absorb_G 1.85 //How much dirt absorbs green [0.0 0.02 0.04 0.06 0.08 0.1 0.12 0.14 0.16 0.18 0.2 0.22 0.24 0.26 0.28 0.3 0.32 0.34 0.36 0.38 0.4 0.42 0.44 0.46 0.48 0.5 0.52 0.54 0.56 0.58 0.6 0.62 0.64 0.66 0.68 0.7 0.72 0.74 0.76 0.78 0.8 0.82 0.84 0.86 0.88 0.9 0.92 0.94 0.96 0.98 1.0 1.02 1.04 1.06 1.08 1.1 1.12 1.14 1.16 1.18 1.2 1.22 1.24 1.26 1.28 1.3 1.32 1.34 1.36 1.38 1.4 1.42 1.44 1.46 1.48 1.5 1.52 1.54 1.56 1.58 1.6 1.62 1.64 1.66 1.68 1.7 1.72 1.74 1.76 1.78 1.8 1.82 1.84 1.86 1.88 1.9 1.92 1.94 1.96 1.98 2.0 ]
|
||||
#define Dirt_Absorb_B 2.05 //How much dirt absorbs blue [0.0 0.02 0.04 0.06 0.08 0.1 0.12 0.14 0.16 0.18 0.2 0.22 0.24 0.26 0.28 0.3 0.32 0.34 0.36 0.38 0.4 0.42 0.44 0.46 0.48 0.5 0.52 0.54 0.56 0.58 0.6 0.62 0.64 0.66 0.68 0.7 0.72 0.74 0.76 0.78 0.8 0.82 0.84 0.86 0.88 0.9 0.92 0.94 0.96 0.98 1.0 1.02 1.04 1.06 1.08 1.1 1.12 1.14 1.16 1.18 1.2 1.22 1.24 1.26 1.28 1.3 1.32 1.34 1.36 1.38 1.4 1.42 1.44 1.46 1.48 1.5 1.52 1.54 1.56 1.58 1.6 1.62 1.64 1.66 1.68 1.7 1.72 1.74 1.76 1.78 1.8 1.82 1.84 1.86 1.88 1.9 1.92 1.94 1.96 1.98 2.0 ]
|
||||
|
||||
#define Water_Absorb_R 0.2629 //How much water absorbs red [0.0 0.0025 0.005 0.0075 0.01 0.0125 0.015 0.0175 0.02 0.0225 0.025 0.0275 0.03 0.0325 0.035 0.0375 0.04 0.0425 0.045 0.0475 0.05 0.0525 0.055 0.0575 0.06 0.0625 0.065 0.0675 0.07 0.0725 0.075 0.0775 0.08 0.0825 0.085 0.0875 0.09 0.0925 0.095 0.0975 0.1 0.1025 0.105 0.1075 0.11 0.1125 0.115 0.1175 0.12 0.1225 0.125 0.1275 0.13 0.1325 0.135 0.1375 0.14 0.1425 0.145 0.1475 0.15 0.1525 0.155 0.1575 0.16 0.1625 0.165 0.1675 0.17 0.1725 0.175 0.1775 0.18 0.1825 0.185 0.1875 0.19 0.1925 0.195 0.1975 0.2 0.2025 0.205 0.2075 0.21 0.2125 0.215 0.2175 0.22 0.2225 0.225 0.2275 0.23 0.2325 0.235 0.2375 0.24 0.2425 0.245 0.2475 0.25 ]
|
||||
#define Water_Absorb_G 0.0565 //How much water absorbs green [0.0 0.0025 0.005 0.0075 0.01 0.0125 0.015 0.0175 0.02 0.0225 0.025 0.0275 0.03 0.0325 0.035 0.0375 0.04 0.0425 0.045 0.0475 0.05 0.0525 0.055 0.0575 0.06 0.0625 0.065 0.0675 0.07 0.0725 0.075 0.0775 0.08 0.0825 0.085 0.0875 0.09 0.0925 0.095 0.0975 0.1 0.1025 0.105 0.1075 0.11 0.1125 0.115 0.1175 0.12 0.1225 0.125 0.1275 0.13 0.1325 0.135 0.1375 0.14 0.1425 0.145 0.1475 0.15 0.1525 0.155 0.1575 0.16 0.1625 0.165 0.1675 0.17 0.1725 0.175 0.1775 0.18 0.1825 0.185 0.1875 0.19 0.1925 0.195 0.1975 0.2 0.2025 0.205 0.2075 0.21 0.2125 0.215 0.2175 0.22 0.2225 0.225 0.2275 0.23 0.2325 0.235 0.2375 0.24 0.2425 0.245 0.2475 0.25 ]
|
||||
#define Water_Absorb_B 0.01011 //How much water absorbs blue [0.0 0.0025 0.005 0.0075 0.01 0.0125 0.015 0.0175 0.02 0.0225 0.025 0.0275 0.03 0.0325 0.035 0.0375 0.04 0.0425 0.045 0.0475 0.05 0.0525 0.055 0.0575 0.06 0.0625 0.065 0.0675 0.07 0.0725 0.075 0.0775 0.08 0.0825 0.085 0.0875 0.09 0.0925 0.095 0.0975 0.1 0.1025 0.105 0.1075 0.11 0.1125 0.115 0.1175 0.12 0.1225 0.125 0.1275 0.13 0.1325 0.135 0.1375 0.14 0.1425 0.145 0.1475 0.15 0.1525 0.155 0.1575 0.16 0.1625 0.165 0.1675 0.17 0.1725 0.175 0.1775 0.18 0.1825 0.185 0.1875 0.19 0.1925 0.195 0.1975 0.2 0.2025 0.205 0.2075 0.21 0.2125 0.215 0.2175 0.22 0.2225 0.225 0.2275 0.23 0.2325 0.235 0.2375 0.24 0.2425 0.245 0.2475 0.25 ]
|
||||
|
||||
#define Dirt_Mie_Phase 0.4 //Values close to 1 will create a strong peak around the sun and weak elsewhere, values close to 0 means uniform fog. [0.01 0.02 0.03 0.04 0.05 0.06 0.07 0.08 0.09 0.1 0.11 0.12 0.13 0.14 0.15 0.16 0.17 0.18 0.19 0.2 0.21 0.22 0.23 0.24 0.25 0.26 0.27 0.28 0.29 0.3 0.31 0.32 0.33 0.34 0.35 0.36 0.37 0.38 0.39 0.4 0.41 0.42 0.43 0.44 0.45 0.46 0.47 0.48 0.49 0.5 0.51 0.52 0.53 0.54 0.55 0.56 0.57 0.58 0.59 0.6 0.61 0.62 0.63 0.64 0.65 0.66 0.67 0.68 0.69 0.7 0.71 0.72 0.73 0.74 0.75 0.76 0.77 0.78 0.79 0.8 0.81 0.82 0.83 0.84 0.85 0.86 0.87 0.88 0.89 0.9 0.91 0.92 0.93 0.94 0.95 0.96 0.97 0.98 0.99 ]
|
||||
|
||||
#define rayMarchSampleCount 2 //Number of samples used for the volumetric underwater fog [1 2 3 4 6 8 12 16 32 64]
|
||||
|
||||
#define Water_Top_Layer 62.90 // When under water and when lightMapDepthEstimate is turned off. Assumes the top layer of the water is at this height (minecraft y position) for underwater lighting calculations. If not set correctly, underwater will look incorrect.[0.90 1.90 2.90 3.90 4.90 5.90 6.90 7.90 8.90 9.90 10.90 11.90 12.90 13.90 14.90 15.90 16.90 17.90 18.90 19.90 20.90 21.90 22.90 23.90 24.90 25.90 26.90 27.90 28.90 29.90 30.90 31.90 32.90 33.90 34.90 35.90 36.90 37.90 38.90 39.90 40.90 41.90 42.90 43.90 44.90 45.90 46.90 47.90 48.90 49.90 50.90 51.90 52.90 53.90 54.90 55.90 56.90 57.90 58.90 59.90 60.90 61.90 62.90 63.90 64.90 65.90 66.90 67.90 68.90 69.90 70.90 71.90 72.90 73.90 74.90 75.90 76.90 77.90 78.90 79.90 80.90 81.90 82.90 83.90 84.90 85.90 86.90 87.90 88.90 89.90 90.90 91.90 92.90 93.90 94.90 95.90 96.90 97.90 98.90 99.90 100.90 101.90 102.90 103.90 104.90 105.90 106.90 107.90 108.90 109.90 110.90 111.90 112.90 113.90 114.90 115.90 116.90 117.90 118.90 119.90 120.90 121.90 122.90 123.90 124.90 125.90 126.90 127.90 128.90 129.90 130.90 131.90 132.90 133.90 134.90 135.90 136.90 137.90 138.90 139.90 140.90 141.90 142.90 143.90 144.90 145.90 146.90 147.90 148.90 149.90 150.90 151.90 152.90 153.90 154.90 155.90 156.90 157.90 158.90 159.90 160.90 161.90 162.90 163.90 164.90 165.90 166.90 167.90 168.90 169.90 170.90 171.90 172.90 173.90 174.90 175.90 176.90 177.90 178.90 179.90 180.90 181.90 182.90 183.90 184.90 185.90 186.90 187.90 188.90 189.90 190.90 191.90 192.90 193.90 194.90 195.90 196.90 197.90 198.90 199.90]
|
||||
|
||||
//#define lightMapDepthEstimation // If turned off, will use the player eye position and the Water_Top_Layer option to determine how deep the player is in water. It can look wrong in a lot of cases, and using minecraft light levels instead improves this but will look worse in oceans, lakes and rivers.
|
Reference in New Issue
Block a user