surprise commit

new stuff

reworked clouds, general lighting, end and nether shaders still WIP

lighting is more balanced in general.
This commit is contained in:
Xonk
2023-04-16 16:18:26 -04:00
parent 7fc3d17c05
commit 2ee6634935
223 changed files with 8807 additions and 16872 deletions

186
shaders/lib/PhotonGTAO.glsl Normal file
View File

@ -0,0 +1,186 @@
// Common constants
const float eps = 1e-6;
const float e = exp(1.0);
const float tau = 2.0 * pi;
const float half_pi = 0.5 * pi;
const float rcp_pi = 1.0 / pi;
const float degree = tau / 360.0; // Size of one degree in radians, useful because radians() is not a constant expression on all platforms
const float golden_ratio = 0.5 + 0.5 * sqrt(5.0);
const float golden_angle = tau / golden_ratio / golden_ratio;
const float hand_depth = 0.56;
#if defined TAA && defined TAAU
const float taau_render_scale = TAAU_RENDER_SCALE;
#else
const float taau_render_scale = 1.0;
#endif
// Helper functions
#define rcp(x) (1.0 / (x))
#define clamp01(x) clamp(x, 0.0, 1.0) // free on operation output
#define max0(x) max(x, 0.0)
#define min1(x) min(x, 1.0)
float sqr(float x) { return x * x; }
vec2 sqr(vec2 v) { return v * v; }
vec3 sqr(vec3 v) { return v * v; }
vec4 sqr(vec4 v) { return v * v; }
float cube(float x) { return x * x * x; }
float max_of(vec2 v) { return max(v.x, v.y); }
float max_of(vec3 v) { return max(v.x, max(v.y, v.z)); }
float max_of(vec4 v) { return max(v.x, max(v.y, max(v.z, v.w))); }
float min_of(vec2 v) { return min(v.x, v.y); }
float min_of(vec3 v) { return min(v.x, min(v.y, v.z)); }
float min_of(vec4 v) { return min(v.x, min(v.y, min(v.z, v.w))); }
float length_squared(vec2 v) { return dot(v, v); }
float length_squared(vec3 v) { return dot(v, v); }
vec2 normalize_safe(vec2 v) { return v == vec2(0.0) ? v : normalize(v); }
vec3 normalize_safe(vec3 v) { return v == vec3(0.0) ? v : normalize(v); }
float rcp_length(vec2 v) { return inversesqrt(dot(v, v)); }
float rcp_length(vec3 v) { return inversesqrt(dot(v, v)); }
float fast_acos(float x) {
const float C0 = 1.57018;
const float C1 = -0.201877;
const float C2 = 0.0464619;
float res = (C2 * abs(x) + C1) * abs(x) + C0; // p(x)
res *= sqrt(1.0 - abs(x));
return x >= 0 ? res : pi - res; // Undo range reduction
}
vec2 fast_acos(vec2 v) { return vec2(fast_acos(v.x), fast_acos(v.y)); }
uniform vec2 view_res;
uniform vec2 view_pixel_size;
float linear_step(float edge0, float edge1, float x) {
return clamp01((x - edge0) / (edge1 - edge0));
}
vec2 linear_step(vec2 edge0, vec2 edge1, vec2 x) {
return clamp01((x - edge0) / (edge1 - edge0));
}
vec4 project(mat4 m, vec3 pos) {
return vec4(m[0].x, m[1].y, m[2].zw) * pos.xyzz + m[3];
}
vec3 project_and_divide(mat4 m, vec3 pos) {
vec4 homogenous = project(m, pos);
return homogenous.xyz / homogenous.w;
}
vec3 screen_to_view_space(vec3 screen_pos, bool handle_jitter) {
vec3 ndc_pos = 2.0 * screen_pos - 1.0;
return project_and_divide(gbufferProjectionInverse, ndc_pos);
}
vec3 view_to_screen_space(vec3 view_pos, bool handle_jitter) {
vec3 ndc_pos = project_and_divide(gbufferProjection, view_pos);
return ndc_pos * 0.5 + 0.5;
}
// ---------------------
// ambient occlusion
// ---------------------
#define GTAO_SLICES 2
#define GTAO_HORIZON_STEPS 3
#define GTAO_RADIUS 2.0
#define GTAO_FALLOFF_START 0.75
float integrate_arc(vec2 h, float n, float cos_n) {
vec2 tmp = cos_n + 2.0 * h * sin(n) - cos(2.0 * h - n);
return 0.25 * (tmp.x + tmp.y);
}
float calculate_maximum_horizon_angle(
vec3 view_slice_dir,
vec3 viewer_dir,
vec3 screen_pos,
vec3 view_pos,
float dither
) {
const float step_size = GTAO_RADIUS * rcp(float(GTAO_HORIZON_STEPS));
float max_cos_theta = -1.0;
vec2 ray_step = (view_to_screen_space(view_pos + view_slice_dir * step_size, true) - screen_pos).xy;
vec2 ray_pos = screen_pos.xy + ray_step * (dither + max_of(view_pixel_size) * rcp_length(ray_step));
for (int i = 0; i < GTAO_HORIZON_STEPS; ++i, ray_pos += ray_step) {
float depth = texelFetch(depthtex1, ivec2(clamp(ray_pos,0.0,1.0) * view_res * taau_render_scale - 0.5), 0).x;
if (depth == 1.0 || depth < hand_depth || depth == screen_pos.z) continue;
vec3 offset = screen_to_view_space(vec3(ray_pos, depth), true) - view_pos;
float len_sq = length_squared(offset);
float norm = inversesqrt(len_sq);
float distance_falloff = linear_step(GTAO_FALLOFF_START * GTAO_RADIUS, GTAO_RADIUS, len_sq * norm);
float cos_theta = dot(viewer_dir, offset) * norm;
cos_theta = mix(cos_theta, -1.0, distance_falloff);
max_cos_theta = max(cos_theta, max_cos_theta);
}
return fast_acos(clamp(max_cos_theta, -1.0, 1.0));
}
float ambient_occlusion(vec3 screen_pos, vec3 view_pos, vec3 view_normal, vec2 dither , inout vec3 debug) {
float ao = 0.0;
vec3 bent_normal = vec3(0.0);
// Construct local working space
vec3 viewer_dir = normalize(-view_pos);
vec3 viewer_right = normalize(cross(vec3(0.0, 1.0, 0.0), viewer_dir));
vec3 viewer_up = cross(viewer_dir, viewer_right);
mat3 local_to_view = mat3(viewer_right, viewer_up, viewer_dir);
for (int i = 0; i < GTAO_SLICES; ++i) {
float slice_angle = (i + dither.x) * (pi / float(GTAO_SLICES));
vec3 slice_dir = vec3(cos(slice_angle), sin(slice_angle), 0.0);
vec3 view_slice_dir = local_to_view * slice_dir;
vec3 ortho_dir = slice_dir - dot(slice_dir, viewer_dir) * viewer_dir;
vec3 axis = cross(slice_dir, viewer_dir);
vec3 projected_normal = view_normal - axis * dot(view_normal, axis);
float len_sq = dot(projected_normal, projected_normal);
float norm = inversesqrt(len_sq);
float sgn_gamma = sign(dot(ortho_dir, projected_normal));
float cos_gamma = clamp01(dot(projected_normal, viewer_dir) * norm);
float gamma = sgn_gamma * fast_acos(cos_gamma);
vec2 max_horizon_angles;
max_horizon_angles.x = calculate_maximum_horizon_angle(-view_slice_dir, viewer_dir, screen_pos, view_pos, dither.y);
max_horizon_angles.y = calculate_maximum_horizon_angle( view_slice_dir, viewer_dir, screen_pos, view_pos, dither.y);
max_horizon_angles = gamma + clamp(vec2(-1.0, 1.0) * max_horizon_angles - gamma, -half_pi, half_pi);
vec3 max_horizon_angles2 = mat3(gbufferModelViewInverse) * projected_normal;
ao += integrate_arc(max_horizon_angles, gamma, cos_gamma) * len_sq * norm * max_horizon_angles.y;
}
ao *= rcp(float(GTAO_SLICES));
return ao;
}

View File

@ -3,8 +3,10 @@
uniform float Day;
uniform float worldDay;
// 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);
@ -23,23 +25,36 @@ float day7 = clamp(clamp(Day-7, 0.0,1.0)*clamp(9-Day, 0.0,1.0),0.0,1.0);
/////////////////////////////////////////////////////////////////////////////// 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 SummerCol = vec3(Summer_R, Summer_G, Summer_B);
vec3 AutumnCol = vec3(Fall_R, Fall_G, Fall_B);
vec3 WinterCol = vec3(Winter_R, Winter_G, Winter_B) ;
vec3 SpringCol = vec3(Spring_R, Spring_G, Spring_B) * glcolor;
vec3 SpringCol = vec3(Spring_R, Spring_G, Spring_B);
// decide if you want to replace biome colors or tint them.
SummerCol *= glcolor;
AutumnCol *= glcolor;
WinterCol *= glcolor;
SpringCol *= 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;
SummerCol = vec3(Summer_Leaf_R, Summer_Leaf_G, Summer_Leaf_B);
AutumnCol = vec3(Fall_Leaf_R, Fall_Leaf_G, Fall_Leaf_B);
WinterCol = vec3(Winter_Leaf_R, Winter_Leaf_G, Winter_Leaf_B);
SpringCol = vec3(Spring_Leaf_R, Spring_Leaf_G, Spring_Leaf_B);
SummerCol *= glcolor;
AutumnCol *= glcolor;
WinterCol *= glcolor;
SpringCol *= glcolor;
}
// length of each season in minecraft days
@ -64,7 +79,7 @@ float day7 = clamp(clamp(Day-7, 0.0,1.0)*clamp(9-Day, 0.0,1.0),0.0,1.0);
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;
FinalColor = SpringToSummer;
}
#endif
#endif
@ -107,7 +122,7 @@ float day7 = clamp(clamp(Day-7, 0.0,1.0)*clamp(9-Day, 0.0,1.0),0.0,1.0);
#ifdef Daily_Weather
Coverage += day0 * 0.3 + day1 * 0.8 + day2 * 0.2 + day3 * 0.0 + day4 * 0.8 + day5 * 0.5 + day6 * -0.5 + day7 * 0.6;
#else
Coverage += cloudCoverage;
Coverage += mix(Cumulus_coverage, Rain_coverage, rainStrength);
// Coverage = mix(Coverage, Rain_coverage, rainStrength);
#endif
@ -138,7 +153,7 @@ float day7 = clamp(clamp(Day-7, 0.0,1.0)*clamp(9-Day, 0.0,1.0),0.0,1.0);
Thickness = CirrusThickness;
}
#else
Coverage = 0.5;
Coverage = 0.7;
Thickness = 0.05;
#endif
@ -187,7 +202,7 @@ float day7 = clamp(clamp(Day-7, 0.0,1.0)*clamp(9-Day, 0.0,1.0),0.0,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));
BiomeColors *= dot(FinalFogColor,vec3(0.33));
// these range 0.0-1.0. they will never overlap.
float Inbiome = isJungles+isSwamps;
@ -204,8 +219,8 @@ float day7 = clamp(clamp(Day-7, 0.0,1.0)*clamp(9-Day, 0.0,1.0),0.0,1.0);
float Inbiome = isJungles+isSwamps;
vec2 BiomeFogDensity; // x = uniform || y = cloudy
BiomeFogDensity.x = isSwamps*5 + isJungles*5;
BiomeFogDensity.y = isSwamps*50 + isJungles*2;
BiomeFogDensity.x = isSwamps*1 + isJungles*5;
BiomeFogDensity.y = isSwamps*5 + isJungles*2;
UniformDensity = mix(UniformDensity, vec4(BiomeFogDensity.x), Inbiome);
CloudyDensity = mix(CloudyDensity, vec4(BiomeFogDensity.y), Inbiome);
@ -229,8 +244,9 @@ float day7 = clamp(clamp(Day-7, 0.0,1.0)*clamp(9-Day, 0.0,1.0),0.0,1.0);
float Night = clamp((Time-13000)/2000,0,1) * clamp((23000-Time)/2000,0,1) ;
// set densities. morn, noon, even, night
vec4 UniformDensity = vec4(0.0, 0.0, 0.0, 0.0);
vec4 CloudyDensity = vec4(0.0, 0.0, 0.0, 0.0);
vec4 UniformDensity = TOD_Fog_mult * vec4(Morning_Uniform_Fog, Noon_Uniform_Fog, Evening_Uniform_Fog, Night_Uniform_Fog);
vec4 CloudyDensity = TOD_Fog_mult * vec4(Morning_Cloudy_Fog, Noon_Cloudy_Fog, Evening_Cloudy_Fog, Night_Cloudy_Fog);
#ifdef Daily_Weather
DailyWeather_FogDensity(UniformDensity, CloudyDensity); // let daily weather influence fog densities.

View File

@ -0,0 +1,61 @@
// in this here file im doing all the lighting for sunlight, ambient light, torches, for solids and translucents.
//// OVERWORLD ////
vec3 DoAmbientLighting (vec3 SkyColor, vec3 TorchColor, vec2 Lightmap, float skyLightDir){
// Lightmap.x = 0.0;
// Lightmap.y = 1.0;
SkyColor = SkyColor * 2.0 * ambient_brightness;
vec3 TorchLight = TorchColor * pow(1.0-pow(1.0-clamp(Lightmap.x,0.0,1.0) ,0.1),2);
TorchLight = exp(TorchLight * 30) - 1.0;
// vec3 SkyLight = max((SkyColor * 8./150./3.) * pow(Lightmap.y,3.0) , vec3(0.2,0.4,1.0) * (MIN_LIGHT_AMOUNT*0.01)) ;
vec3 SkyLight = max((SkyColor * 8./150./3.) * pow(Lightmap.y,3.0),0.0) ;
return SkyLight * skyLightDir + TorchLight;
}
vec3 DoDirectLighting(vec3 SunColor, float Shadow, float NdotL, float SubsurfaceScattering){
// vec3 SunLight = max(NdotL * Shadow, SubsurfaceScattering) * SunColor;
vec3 SunLight = NdotL * Shadow * SunColor;
return SunLight;
}
//// NETHER ////
vec3 DoAmbientLighting_Nether(vec3 FogColor, vec3 TorchColor, float Lightmap, vec3 Normal, vec3 np3, vec3 WorldPos){
vec3 TorchLight = TorchColor * clamp(pow(Lightmap,3.0),0.0,1.0);
vec3 LavaGlow = vec3(TORCH_R,TORCH_G,TORCH_B);
LavaGlow *= pow(clamp(1.0-max(Normal.y,0.0) + dot(Normal,np3),0.0,1.0),3.0);
LavaGlow *= clamp(exp2(-max((WorldPos.y - 50.0) / 5,0.0)),0.0,1.0);
LavaGlow *= pow(Lightmap,0.2);
vec3 AmbientLight = vec3(0.1) + FogColor*clamp(1.1 + dot(Normal,np3),0.0,1.0);
return AmbientLight + TorchLight + LavaGlow;
}
//// END ////
vec3 DoAmbientLighting_End(vec3 FogColor, vec3 TorchColor, float Lightmap, vec3 Normal, vec3 np3){
// vec3 TorchLight = TorchColor * clamp(pow(Lightmap,3.0),0.0,1.0);
vec3 TorchLight = TorchColor * pow(1.0-pow(1.0-clamp(Lightmap,0.0,1.0) ,0.1),2);
TorchLight = exp(TorchLight * 30) - 1.0;
FogColor = (FogColor / pow(0.00001 + dot(FogColor,vec3(0.3333)),1.0) ) * 0.1;
// vec3 AmbientLight = sqrt( clamp(1.25 + dot(Normal,np3),0.0,1.0)) * (vec3(0.5,0.75,1.0) * 0.05);
vec3 AmbientLight = sqrt( clamp(1.25 + dot(Normal,np3),0.0,1.0)*0.5) * FogColor;
return TorchLight + AmbientLight;
}

346
shaders/lib/end_fog.glsl Normal file
View File

@ -0,0 +1,346 @@
vec3 srgbToLinear2(vec3 srgb){
return mix(
srgb / 12.92,
pow(.947867 * srgb + .0521327, vec3(2.4) ),
step( .04045, srgb )
);
}
vec3 blackbody2(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 = clamp(col,0.0,1.0);
col = Temp < 1000. ? col * Temp * 0.001 : col;
return srgbToLinear2(col);
}
// Integer Hash - II
// - Inigo Quilez, Integer Hash - II, 2017
// https://www.shadertoy.com/view/XlXcW4
uvec3 iqint2(uvec3 x)
{
const uint k = 1103515245u;
x = ((x>>8U)^x.yzx)*k;
x = ((x>>8U)^x.yzx)*k;
x = ((x>>8U)^x.yzx)*k;
return x;
}
uvec3 hash(vec2 s)
{
uvec4 u = uvec4(s, uint(s.x) ^ uint(s.y), uint(s.x) + uint(s.y)); // Play with different values for 3rd and 4th params. Some hashes are okay with constants, most aren't.
return iqint2(u.xyz);
}
vec3 hash31(float p)
{
vec3 p3 = fract(vec3(p) * vec3(.1031, .1030, .0973));
p3 += dot(p3, p3.yzx+33.33);
return fract((p3.xxy+p3.yzz)*p3.zyx);
}
// uniform float ifEndBoss;
// uniform float isSneaking;
// uniform float EndSequence1;
// uniform float EndSequence2;
// position related stuff
// vec2 SEED = vec2(sin(frameTimeCounter*5) + 1);
// uvec3 HASH = hash(SEED);
// vec3 RandomPosition = clamp(vec3(HASH) * (1.0/float(0xffffffffu)), 0.0, 1.0);
vec3 RandomPosition = hash31(1);
// vec3 ManualLightPos = vec3(109.25, 128.73, 1189.4) ;
// vec3 ManualLightPos = vec3(307.96, 141.00, 1107.05) - vec3(sin(frameTimeCounter), 0, -cos(frameTimeCounter))*25;
// ManualLightPos -= vec3(sin(frameTimeCounter), 0, -cos(frameTimeCounter))*100;
vec3 ManualLightPos = vec3(ORB_X, ORB_Y, ORB_Z);
///////////////// POSITION
///////////////// POSITION
///////////////// POSITION
vec3 LightSourcePosition(vec3 WorldPos, vec3 CameraPos){
vec3 Origin = WorldPos ;
vec3 RandomPosition2 = hash31(Origin.y);
// make the swirl only happen within a radius
float SwirlBounds = clamp(sqrt(length(vec3(Origin.x,Origin.y-100,Origin.z)) / 150.0 - 1.0) ,0.0,1.0);
if( SwirlBounds < 1.0) {
Origin.y -= 200;
} else {
Origin = WorldPos - cameraPosition - ManualLightPos ;
// Origin -= RandomPosition * 100;
}
#ifdef THE_ORB
Origin = WorldPos - ManualLightPos;
#endif
return Origin;
}
///////////////// COLOR
///////////////// COLOR
///////////////// COLOR
vec3 LightSourceColor(float SwirlBounds){
vec3 Color = vec3(0.0);
if( SwirlBounds < 1.0) {
//////// STAGE 1
Color = vec3(0.5, 0.5, 1.0);
//////// STAGE 2
// Color = mix(Color, vec3(1.0,0.3,0.3), pow(EndSequence1,3.0));
// //////// STAGE 3
// // yes rico, kaboom
// Color = mix(Color, vec3(1.0,0.0,1.0) * (1.0-EndSequence2), EndSequence2);
} else {
// Color = vec3(0.6, 0.8 ,1.0);
Color = vec3(ORB_R, ORB_G, ORB_B) * ORB_ColMult;
// float Timing = dot(RandomPosition, vec3(1.0/3.0));
// float Flash = max(sin(frameTimeCounter*10) * Timing,0.0);
// Color *= blackbody2(RandomPosition.y*4000 + 1000);
// Color *= Flash;
}
#ifdef THE_ORB
Color = vec3(ORB_R, ORB_G, ORB_B) * ORB_ColMult;
#endif
return Color;
}
///////////////// SHAPE
///////////////// SHAPE
///////////////// SHAPE
vec3 LightSourceShape(vec3 WorldPos){
vec3 Shapes = vec3(0.0);
vec3 Origin = WorldPos ;
// make the swirl only happen within a radius
float SwirlBounds = clamp(sqrt(length(Origin) / 200.0 - 1.0) ,0.0,1.0);
if( SwirlBounds < 1.0) {
// vec3 Origin = WorldPos;
Origin.y -= 200;
vec3 Origin2 = Origin;
Origin2.y += 100 ;
Origin2.y *= 0.8;
float Center = length(Origin);
float AltCenter = length(Origin2);
//////// STAGE 1
// when the ender dragon is alive, restrict the fog in this shape
// the max of a sphere is another smaller sphere. this creates a hollow sphere.
Shapes.r = max(1.0 - AltCenter / 75.0, max(AltCenter / 150.0 - 1.0, 0.0));
float radius = 200.0;
float thickness = 50.0 * radius;
Shapes.r = (thickness - clamp(pow(sqrt(pow(Origin2.x,2) + pow(Origin2.z,2)) - radius,2) + pow(Origin2.y*0.75,2.0) - radius,0,thickness)) / thickness ;
Shapes.r = max(Shapes.r, max(1.0 - AltCenter / 75.0, 0.0));
radius = 50.0;
thickness = 5.0 * radius;
Shapes.b = (thickness - clamp(pow(sqrt(pow(Origin2.x,2) + pow(Origin2.y,2)) - radius,2) + pow(Origin2.z*0.75,2.0) - radius,0,thickness)) / thickness ;
}
return Shapes;
}
float densityAtPosFog(in vec3 pos){
pos /= 18.;
pos.xz *= 0.5;
vec3 p = floor(pos);
vec3 f = fract(pos);
f = (f*f) * (3.-2.*f);
vec2 uv = p.xz + f.xz + p.y * vec2(0.0,193.0);
vec2 coord = uv / 512.0;
vec2 xy = texture2D(noisetex, coord).yx;
return mix(xy.r,xy.g, f.y);
}
float cloudVol(in vec3 pos, int LOD){
// THE OOOOOOOOOOOOOOOOOOOOOORB
vec3 Shapes = LightSourceShape(pos);
vec3 samplePos = pos*vec3(1.0,1./32.,1.0);
vec3 samplePos2 = pos*vec3(1.0,1./48.,1.0);
// #ifndef THE_ORB
// ender dragon battle area swirling effect.
// if(EndSequence2 < 1.0){
float radiance = 2.39996 + samplePos.y + frameTimeCounter/10;
mat2 rotationMatrix = mat2(vec2(cos(radiance), -sin(radiance)), vec2(sin(radiance), cos(radiance)));
// make the swirl only happen within a radius
float SwirlBounds = clamp(sqrt(length(vec3(pos.x,pos.y-100,pos.z)) / 200.0 - 1.0) ,0.0,1.0);
samplePos.xz = mix(samplePos.xz * rotationMatrix, samplePos.xz, SwirlBounds);
samplePos2.xz = mix(samplePos2.xz * rotationMatrix, samplePos2.xz, SwirlBounds);
// }
// #endif
samplePos2.y -= frameTimeCounter/15;
float finalfog = 0;
finalfog += max(0.6-densityAtPosFog(samplePos * 16.0) * 2,0.0);
// finalfog = exp(finalfog*5)-1;
float smallnoise = max(densityAtPosFog(samplePos2 * (160. - finalfog*3))-0.1,0.0);
finalfog -= ((1-smallnoise) - max(0.15 - abs(smallnoise * 2.0 - 0.55) * 0.5,0.0)*1.5) * 0.3;
// make the eye of the swirl have no fog, so you can actually see.
finalfog = max(finalfog - Shapes.r, 0.0);
// dragon death sequence
// finalfog = Shapes.b;
return finalfog;
}
mat2x3 getVolumetricRays(float dither,vec3 fragpos,float dither2) {
int SAMPLES = 16;
//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 = vec3(0.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),32.0 * 12.0)/length(dVWorld);
dV *= maxLength;
dVWorld *= maxLength;
//apply dither
vec3 progress = start.xyz;
vec3 progressW = gbufferModelViewInverse[3].xyz+cameraPosition;
vec3 vL = vec3(0.);
float dL = length(dVWorld);
vec3 absorbance = vec3(1.0);
float expFactor = 11.0;
vec3 fogColor = (gl_Fog.color.rgb / pow(dot(gl_Fog.color.rgb,vec3(0.3333)),1.1) ) ;
for (int i=0;i<SAMPLES;i++) {
float d = (pow(expFactor, float(i+dither)/float(SAMPLES))/expFactor - 1.0/expFactor)/(1-1.0/expFactor);
float dd = pow(expFactor, float(i+dither)/float(SAMPLES)) * log(expFactor) / float(SAMPLES)/(expFactor-1.0);
progressW = gbufferModelViewInverse[3].xyz+cameraPosition + d*dVWorld;
float densityVol = cloudVol(progressW,1);
float density = min(densityVol,0.1);
float air = 0.005;
/// THE OOOOOOOOOOOOOOOOOOOOOORB
vec3 LightColor = LightSourceColor(clamp(sqrt(length(vec3(progressW.x,progressW.y-100,progressW.z)) / 150.0 - 1.0) ,0.0,1.0));
vec3 LightPos = LightSourcePosition(progressW, cameraPosition);
// float OrbMie = exp(length(LightPos) * -0.03) * 64.0;
// float OrbMie = max(exp2(4.0 + length(LightPos) / -20),0.0);
float OrbMie = max(1.0-length(LightPos)/200,0.0);
float N = 2.50;
OrbMie = pow(1.0-pow(1.0-OrbMie,1.0/N),N);
OrbMie *= 10.0;
// LightColor *= OrbMie;
float CastLight = 0.0;
for (int j=0; j < 3; j++){
vec3 shadowSamplePos = progressW - LightPos * (pow(j+dither2/3,0.75)*0.3);
// vec3 shadowSamplePos = progressW - LightPos * (pow(j+dither2,0.75)*0.25);
float densityVol2 = cloudVol(shadowSamplePos,1);
CastLight += densityVol2;
}
vec3 CastedLight = LightColor * OrbMie * exp(CastLight * 15 * (LightColor*(1.0-CastLight/3)-1.50)) ;
CastedLight += (LightColor * vec3(1.0,1.3,1.0)) * exp(abs(densityVol*2.0 - 0.3) * 15 * (LightColor*CastLight)) * (max(OrbMie - density*10,0.0)/10);
#ifdef THE_ORB
density += clamp((1.0 - length(LightPos) / 10.0) * 10 ,0.0,1.0) ;
InnerLight = vec3(0.0);
#endif
vec3 AmbientLight = fogColor * 0.05 * pow(exp(density * -2),20);
vec3 vL0 = AmbientLight + CastedLight;
vec3 vL1 = vec3(0.5,0.75,1.0) * 0.05 ;
// vL1 += (LightColor* vec3(1.0,1.3,1.0)) * max(LightColor - (exp(CastLight * 5)-OrbMie),0.0) * OrbMie;
vL += (vL0 - vL0*exp(-density*dd*dL)) * absorbance;
vL += (vL1 - vL1*exp(-air*dd*dL)) * absorbance;
absorbance *= exp(-(density+air)*dd*dL);
}
return mat2x3(vL,absorbance);
}
float GetCloudShadow(vec3 WorldPos, vec3 LightPos, float noise){
float Shadow = 0.0;
for (int i=0; i < 3; i++){
vec3 shadowSamplePos = WorldPos - LightPos * (0.25 + pow(i,0.75)*0.25);
float Cast = cloudVol(shadowSamplePos,1);
Shadow += Cast;
}
return clamp(exp(-Shadow*5),0.0,1.0);
// return (Shadow);
}
float GetCloudShadow2(vec3 WorldPos){
float Shadow = cloudVol(WorldPos,1);
return clamp( exp2(Shadow * -3),0.0,1.0);
}

168
shaders/lib/nether_fog.glsl Normal file
View File

@ -0,0 +1,168 @@
///////////////// POSITION
///////////////// POSITION
///////////////// POSITION
vec3 ManualLightPos = vec3(ORB_X, ORB_Y, ORB_Z);
vec3 lighting_pos = vec3(0, -1, 0);
vec3 lightSource = normalize(lighting_pos);
vec3 viewspace_sunvec = mat3(gbufferModelView) * lightSource;
vec3 WsunVec = normalize(mat3(gbufferModelViewInverse) * viewspace_sunvec);
///////////////// COLOR
///////////////// COLOR
///////////////// COLOR
vec3 LightSourceColor(){
vec3 Color = vec3(1.0,0.75,0.5);
return Color;
}
///////////////// SHAPE
///////////////// SHAPE
///////////////// SHAPE
vec3 LightSourceShape(vec3 WorldPos){
vec3 Shapes = vec3(0.0);
vec3 Origin = WorldPos ;
return Shapes;
}
float densityAtPosFog(in vec3 pos){
pos /= 18.;
pos.xz *= 0.5;
vec3 p = floor(pos);
vec3 f = fract(pos);
f = (f*f) * (3.-2.*f);
vec2 uv = p.xz + f.xz + p.y * vec2(0.0,193.0);
vec2 coord = uv / 512.0;
vec2 xy = texture2D(noisetex, coord).yx;
return mix(xy.r,xy.g, f.y);
}
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 fog_shape = 1-densityAtPosFog(samplePos * 16.0);
// float fog_eroded = 1-densityAtPosFog(samplePos2 * (200 + fog_shape*25));
// float finalfog = clamp( (fog_shape*2.0 - fog_eroded*0.3) - 1.5, 0.0, 1.0);
float finalfog = 1-exp(max(samplePos.y - 60,0.0) / -1);
return finalfog;
}
// float GetCloudShadow(vec3 WorldPos, vec3 LightPos, float noise){
// float Shadow = 0.0;
// for (int i=0; i < 3; i++){
// // vec3 shadowSamplePos = WorldPos - LightPos.y/abs(LightPos.y) * (0.25 + pow(i,0.75)*0.25);
// vec3 shadowSamplePos = WorldPos + LightPos * (i * 20);
// float Cast = cloudVol(shadowSamplePos);
// Shadow += Cast;
// }
// return clamp(exp(-Shadow*30),0.0,1.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;
// }
mat2x3 getVolumetricRays(float dither,vec3 fragpos,float dither2) {
int SAMPLES = 16;
//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 = vec3(0.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),32.0 * 12.0)/length(dVWorld);
dV *= maxLength;
dVWorld *= maxLength;
//apply dither
vec3 progress = start.xyz;
vec3 progressW = gbufferModelViewInverse[3].xyz+cameraPosition;
vec3 vL = vec3(0.);
float dL = length(dVWorld);
vec3 absorbance = vec3(1.0);
float expFactor = 11.0;
vec3 fogColor = gl_Fog.color.rgb;
// float SdotV = dot(normalize(viewspace_sunvec), normalize(fragpos));
// float OrbMie = phaseg(SdotV, 0.8);
for (int i=0;i<SAMPLES;i++) {
float d = (pow(expFactor, float(i+dither)/float(SAMPLES))/expFactor - 1.0/expFactor)/(1-1.0/expFactor);
float dd = pow(expFactor, float(i+dither)/float(SAMPLES)) * log(expFactor) / float(SAMPLES)/(expFactor-1.0);
progressW = gbufferModelViewInverse[3].xyz+cameraPosition + d*dVWorld;
float densityVol = cloudVol(progressW) ;
float density = min(densityVol,0.1);
float air = 0.005;
/// THE OOOOOOOOOOOOOOOOOOOOOORB
vec3 LightColor = LightSourceColor();
// vec3 LightPos = LightSourcePosition(progressW, cameraPosition);
// float OrbMie = exp(length(LightPos) * -0.03) * 64.0;
float OrbMie = clamp(exp((progressW.y - 30) / -10.) * 5,0,1);
LightColor *= OrbMie;
float CastLight = 0.0;
for (int j=0; j < 5; j++){
vec3 shadowSamplePos = progressW + WsunVec * (0.5 + j * 5);
// vec3 shadowSamplePos = progressW - LightPos.y * (j*30);
float densityVol2 = cloudVol(shadowSamplePos);
CastLight += densityVol2;
}
vec3 CastedLight = LightColor * exp(CastLight * -15);
// #ifdef THE_ORB
// density += clamp((1.0 - length(LightPos) / 10.0) * 10 ,0.0,1.0) ;
// #endif
vec3 AmbientLight = fogColor* exp(density * -25);
vec3 vL0 = AmbientLight;
vec3 vL1 = vec3(1.0,0.75,0.5) * 0.1;
vL += (vL0 - vL0*exp(-density*dd*dL)) * absorbance;
vL += (vL1 - vL1*exp(-air*dd*dL)) * absorbance;
absorbance *= exp(-(density+air)*dd*dL);
}
return mat2x3(vL,absorbance);
}

120
shaders/lib/oceans.glsl Normal file
View File

@ -0,0 +1,120 @@
// THIS FILE IS PUBLIC DOMAIN SO USE IT HOWEVER YOU WANT!
// to make it compatible with your shaderpack use:
#define PHYSICS_OCEAN_SUPPORT
// at the top of your file. When used my mod no longer injects code into
// your shaderpack. It replaces this define statement (before compilation) with
#define PHYSICS_OCEAN
// so you can use
// #ifdef PHYSICS_OCEAN
// #endif
// to customize the water for the physics ocean
// just some basic consts for the wave function based on afl_ext's shader https://www.shadertoy.com/view/Xdlczl
// the overall shape must stay consistent because it is also computed on the CPU side
// to offset entities (though a custom CPU integration of your shader is possible by
// contacting me on my discord server https://discord.gg/VsNs9xP)
const int PHYSICS_ITERATIONS_OFFSET = 13;
const float PHYSICS_DRAG_MULT = 0.048;
const float PHYSICS_XZ_SCALE = 0.035;
const float PHYSICS_TIME_MULTIPLICATOR = 0.45;
const float PHYSICS_W_DETAIL = 0.75;
const float PHYSICS_FREQUENCY = 6.0;
const float PHYSICS_SPEED = 2.0;
const float PHYSICS_WEIGHT = 0.8;
const float PHYSICS_FREQUENCY_MULT = 1.18;
const float PHYSICS_SPEED_MULT = 1.07;
const float PHYSICS_ITER_INC = 12.0;
const float PHYSICS_NORMAL_STRENGTH = 0.6;
// this is the surface detail from the physics options, ranges from 13 to 48 (yeah I know weird)
uniform int physics_iterationsNormal;
// used to offset the 0 point of wave meshes to keep the wave function consistent even
// though the mesh totally changes
uniform vec2 physics_waveOffset;
// used for offsetting the local position to fetch the right pixel of the waviness texture
uniform ivec2 physics_textureOffset;
// time in seconds that can go faster dependent on weather conditions (affected by weather strength
// multiplier in ocean settings
uniform float physics_gameTime;
// base value is 13 and gets multiplied by wave height in ocean settings
uniform float physics_oceanHeight;
// basic texture to determine how shallow/far away from the shore the water is
uniform sampler2D physics_waviness;
// basic scale for the horizontal size of the waves
uniform float physics_oceanWaveHorizontalScale;
#ifdef PHYSICSMOD_VERTEX
// for the vertex shader stage
out vec3 physics_localPosition;
out float physics_localWaviness;
#endif
#ifdef PHYSICSMOD_FRAGMENT
// for the fragment shader stage
in vec3 physics_localPosition;
in float physics_localWaviness;
#endif
float physics_waveHeight(vec2 position, int iterations, float factor, float time) {
position = (position - physics_waveOffset) * PHYSICS_XZ_SCALE * physics_oceanWaveHorizontalScale;
float iter = 0.0;
float frequency = PHYSICS_FREQUENCY;
float speed = PHYSICS_SPEED;
float weight = 1.0;
float height = 0.0;
float waveSum = 0.0;
float modifiedTime = time * PHYSICS_TIME_MULTIPLICATOR;
for (int i = 0; i < iterations; i++) {
vec2 direction = vec2(sin(iter), cos(iter));
float x = dot(direction, position) * frequency + modifiedTime * speed;
float wave = exp(sin(x) - 1.0);
float result = wave * cos(x);
vec2 force = result * weight * direction;
position -= force * PHYSICS_DRAG_MULT;
height += wave * weight;
iter += PHYSICS_ITER_INC;
waveSum += weight;
weight *= PHYSICS_WEIGHT;
frequency *= PHYSICS_FREQUENCY_MULT;
speed *= PHYSICS_SPEED_MULT;
}
return height / waveSum * physics_oceanHeight * factor - physics_oceanHeight * factor * 0.5;
}
vec2 physics_waveDirection(vec2 position, int iterations, float time) {
position = (position - physics_waveOffset) * PHYSICS_XZ_SCALE * physics_oceanWaveHorizontalScale;
float iter = 0.0;
float frequency = PHYSICS_FREQUENCY;
float speed = PHYSICS_SPEED;
float weight = 1.0;
float waveSum = 0.0;
float modifiedTime = time * PHYSICS_TIME_MULTIPLICATOR;
vec2 dx = vec2(0.0);
for (int i = 0; i < iterations; i++) {
vec2 direction = vec2(sin(iter), cos(iter));
float x = dot(direction, position) * frequency + modifiedTime * speed;
float wave = exp(sin(x) - 1.0);
float result = wave * cos(x);
vec2 force = result * weight * direction;
dx += force / pow(weight, PHYSICS_W_DETAIL);
position -= force * PHYSICS_DRAG_MULT;
iter += PHYSICS_ITER_INC;
waveSum += weight;
weight *= PHYSICS_WEIGHT;
frequency *= PHYSICS_FREQUENCY_MULT;
speed *= PHYSICS_SPEED_MULT;
}
return vec2(dx / pow(waveSum, 1.0 - PHYSICS_W_DETAIL));
}
vec3 physics_waveNormal(vec2 position, float factor, float time) {
vec2 wave = -physics_waveDirection(position.xy, physics_iterationsNormal, time);
float oceanHeightFactor = physics_oceanHeight / 13.0;
float totalFactor = oceanHeightFactor * factor;
return normalize(vec3(wave.x * totalFactor, PHYSICS_NORMAL_STRENGTH, wave.y * totalFactor));
}

View File

@ -20,7 +20,7 @@
#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.
//#define Vanilla_like_water // vanilla water texture along with shader water stuff
#define Texture_MipMap_Bias -1.00 // Uses a another mip level for textures. When reduced will increase texture detail but may induce a lot of shimmering. [-5.00 -4.75 -4.50 -4.25 -4.00 -3.75 -3.50 -3.25 -3.00 -2.75 -2.50 -2.25 -2.00 -1.75 -1.50 -1.25 -1.00 -0.75 -0.50 -0.25 0.00 0.25 0.50 0.75 1.00 1.25 1.50 1.75 2.00 2.25 2.50 2.75 3.00 3.25 3.50 3.75 4.00 4.25 4.50 4.75 5.00]
#define Texture_MipMap_Bias 0.0 // Uses a another mip level for textures. When reduced will increase texture detail but may induce a lot of shimmering. [-5.00 -4.75 -4.50 -4.25 -4.00 -3.75 -3.50 -3.25 -3.00 -2.75 -2.50 -2.25 -2.00 -1.75 -1.50 -1.25 -1.00 -0.75 -0.50 -0.25 0.00 0.25 0.50 0.75 1.00 1.25 1.50 1.75 2.00 2.25 2.50 2.75 3.00 3.25 3.50 3.75 4.00 4.25 4.50 4.75 5.00]
// --- AMBIENT LIGHT ---
@ -42,6 +42,7 @@
#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 AO_in_sunlight // control if ambient occlusion appears in sunlit areas.
// --- DOF ---
@ -75,8 +76,7 @@
#define CaveFogColor_G 0.2 // [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 CaveFogColor_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 display_LUT // aaaaaaaaaaaaaaaaaaaaaaa
#define CLOUDS_SHADOWS
#define VL_CLOUDS_SHADOWS // Casts shadows from clouds on VL (slow)
#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_SAMPLES 8 //[4 6 8 10 12 14 16 20 24 30 40 50]
#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.
@ -89,29 +89,38 @@
#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]intervalMult
#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 // does not change rain or cave fog [5 10 20 30 40 50 60 70 80 90 100]
#define cloudyfog_fade 10 // does not change rain or cave fog [5 10 20 30 40 50 60 70 80 90 100]
#define RainFog_amount 5 // [0 1 2 3 4 5 6 7 8 9 10 15 20 25]
#define CaveFog_amount 5 // [0 1 2 3 4 5 6 7 8 9 10 15 20 25]
#define cloudray_amount 0.2 // rain boost this [0.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]
#define UniformFog_amount 1.0 // [0.0 0.2 0.4 0.6 0.8 1.0 1.25 1.5 1.75 2.0 3.0 4.0 5.0 10.0 20.0 30.0 50.0 100.0 150.0 200.0]
#define CloudyFog_amount 1.0 // [0.0 0.2 0.4 0.6 0.8 1.0 1.25 1.5 1.75 2.0 3.0 4.0 5.0 10 20 30 40 50 100 500 10000]
#define TimeOfDayFog_multiplier 1.0 // Influence of time of day on fog amount [0.0 0.2 0.4 0.6 0.8 1.0 1.25 1.5 1.75 2.0 3.0 4.0 5.0]
#define Haze_amount 1.0 // [0.0 0.2 0.4 0.6 0.8 1.0 1.25 1.5 1.75 2.0 3.0 4.0 5.0]
// #define fog_selfShadowing // make the fog cast a shadow onto itself
#define HQ_CLOUDS //Renders detailled clouds for viewport
#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 BASE_FOG_AMOUNT 1.0 //[0.0 0.2 0.4 0.6 0.8 1.0 1.25 1.5 1.75 2.0 3.0 4.0 5.0 10.0 20.0 30.0 50.0 100.0 150.0 200.0] Base fog amount amount (does not change the "cloudy" fog)
#define CLOUDY_FOG_AMOUNT 1.0 //[0.0 0.2 0.4 0.6 0.8 1.0 1.25 1.5 1.75 2.0 3.0 4.0 5.0]
#define FOG_TOD_MULTIPLIER 1.0 //[0.0 0.2 0.4 0.6 0.8 1.0 1.25 1.5 1.75 2.0 3.0 4.0 5.0] //Influence of time of day on fog amount
#define FOG_RAIN_MULTIPLIER 1.0 //[0.0 0.2 0.4 0.6 0.8 1.0 1.25 1.5 1.75 2.0 3.0 4.0 5.0] //Influence of rain on fog amount
#define BLOOMY_FOG 2.0 //[0.0 0.25 0.5 0.75 1.0 1.25 1.5 1.75 2.0 3.0 4.0 6.0 10.0 15.0 20.0]
#define BLOOM_STRENGTH 4.0 //[0.0 0.25 0.5 0.75 1.0 1.25 1.5 1.75 2.0 3.0 4.0]
// --- LABPBR ---
#define Haze_amount 1.0 // [0.0 0.2 0.4 0.6 0.8 1.0 1.25 1.5 1.75 2.0 3.0 4.0 5.0]
#define RainFog_amount 5 // [0 1 2 3 4 5 6 7 8 9 10 15 20 25]
#define CaveFog_amount 5 // [0 1 2 3 4 5 6 7 8 9 10 15 20 25]
#define Morning_Uniform_Fog 1.0 // [0. 1. 2. 3. 4. 5. 6. 7. 8. 9. 10. 15. 20. 25. 30. 35. 40. 45. 50. 75. 100. 125. 150. 175. 200. 255.]
#define Noon_Uniform_Fog 0.0 // [0. 1. 2. 3. 4. 5. 6. 7. 8. 9. 10. 15. 20. 25. 30. 35. 40. 45. 50. 75. 100. 125. 150. 175. 200. 255.]
#define Evening_Uniform_Fog 10.0 // [0. 1. 2. 3. 4. 5. 6. 7. 8. 9. 10. 15. 20. 25. 30. 35. 40. 45. 50. 75. 100. 125. 150. 175. 200. 255.]
#define Night_Uniform_Fog 10.0 // [0. 1. 2. 3. 4. 5. 6. 7. 8. 9. 10. 15. 20. 25. 30. 35. 40. 45. 50. 75. 100. 125. 150. 175. 200. 255.]
#define Morning_Cloudy_Fog 1.0 // [0. 1. 2. 3. 4. 5. 6. 7. 8. 9. 10. 15. 20. 25. 30. 35. 40. 45. 50. 75. 100. 125. 150. 175. 200. 255.]
#define Noon_Cloudy_Fog 0.0 // [0. 1. 2. 3. 4. 5. 6. 7. 8. 9. 10. 15. 20. 25. 30. 35. 40. 45. 50. 75. 100. 125. 150. 175. 200. 255.]
#define Evening_Cloudy_Fog 50.0 // [0. 1. 2. 3. 4. 5. 6. 7. 8. 9. 10. 15. 20. 25. 30. 35. 40. 45. 50. 75. 100. 125. 150. 175. 200. 255.]
#define Night_Cloudy_Fog 5.0 // [0. 1. 2. 3. 4. 5. 6. 7. 8. 9. 10. 15. 20. 25. 30. 35. 40. 45. 50. 75. 100. 125. 150. 175. 200. 255.]
#define TOD_Fog_mult 1.0 // [0.0 0.25 0.5 0.75 1.0 2.0 3.0 4.0 5.0 10.0 15.0 20.0 25.0 50.0 75.0 100.0]
#define NetherFog_brightness 0.5 // [0.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]
// --- LABPBR ---
//#define SPECULARTEX
#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 ]
@ -123,16 +132,16 @@
// #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 Horrible_slope_normals
//#define Horrible_slope_normals // really only good on low resoltution packs. alot of aliasing/flickering at high resoltions
//#define POM
#define mob_SSS
#define misc_block_SSS
#define POM_DEPTH 0.25 // [0.025 0.05 0.075 0.1 0.125 0.15 0.20 0.25 0.30 0.50 0.75 1.0] //Increase to increase POM strength
#define POM_DEPTH 0.25 // [0.025 0.05 0.075 0.1 0.125 0.15 0.20 0.25 0.30 0.50 0.75 1.0] // IN CENTIMETERS. Increase to increase POM strength.
#define Adaptive_Step_length // make only used parts of the POM depth get samples, to increase overall quality. DOWNSIDE: at sheer angles, it looks kinda buggy.
#define MAX_ITERATIONS 50 // [5 10 15 20 25 30 40 50 60 70 80 90 100 125 150 200 400] //Improves quality at grazing angles (reduces performance)
#define MAX_DIST 25.0 // [5.0 10.0 15.0 20.0 25.0 30.0 40.0 50.0 60.0 70.0 80.0 90.0 100.0 125.0 150.0 200.0 400.0] //Increases distance at which POM is calculated
#define DISABLE_ALPHA_MIPMAPS //Disables mipmaps on the transparency of alpha-tested things like foliage, may cost a few fps in some cases
// #define DISABLE_ALPHA_MIPMAPS //Disables mipmaps on the transparency of alpha-tested things like foliage, may cost a few fps in some cases
// #define Porosity
#define texture_ao // ambient occlusion on the texture
// --- WEATHER/SKY ---
@ -155,6 +164,7 @@
#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
@ -162,6 +172,8 @@
#define sunColorBase blackbody(Sun_temp) * sun_illuminance
#define moonColorBase blackbody(Moon_temp) * moon_illuminance //Fake Purkinje effect
#endif
// #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 TAA
@ -196,9 +208,9 @@
#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 Rain_coverage 0.8 // 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)
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 ambientOcclusionLevel = 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 ]
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 ]
#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]
@ -218,11 +230,11 @@ const float shadowDistanceRenderMul = -1.0; //[-1.0 1.0] Can help to increase sh
#define SHADOW_DISABLE_ALPHA_MIPMAPS // Disables mipmaps on the transparency of alpha-tested things like foliage, may cost a few fps in some cases
#define Stochastic_Transparent_Shadows // Highly recommanded to enable SHADOW_DISABLE_ALPHA_MIPMAPS with it. Uses noise to simulate transparent objects' shadows (not colored). It is also recommended to increase Min_Shadow_Filter_Radius with this.
// --- SSGI/RTAO ---
// #define SSGI
//#define RTAO // I recommend turning ambientOcclusionLevel to zero with this on. like ssao, but rt, nicer, noiser, and slower. SSAO will turn OFF when this is ON
#define indirect_effect 1 // 0 = none. 1 = SSAO. 2 = RTAO. 3 = SSGI. [0 1 2 3 4]
#define indirect_effect 1 // vanilla AO is what minecraft normally uses. SSAO is basic, and fast, this setting includes vanilla AO. GTAO is high quality, low noise, medium speed. RTAO is raytraced ambient occlusion, noisy and slow. SSGI is raytraced global illumination, and ambient occlusion, very slow and noisy. [0 1 2 3 4]
#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.]
@ -230,7 +242,7 @@ const float shadowDistanceRenderMul = -1.0; //[-1.0 1.0] Can help to increase sh
#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 SSAO // screen-space ambient occlusion.
// --- REFLECTIONS ---
@ -248,7 +260,30 @@ const float shadowDistanceRenderMul = -1.0; //[-1.0 1.0] Can help to increase sh
// --- CLOUDS ---
#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 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 CLOUDS_SHADOWS // Casts shadows from clouds on the world
#ifndef VOLUMETRIC_CLOUDS
#undef CLOUDS_SHADOWS
#endif
#define VL_CLOUDS_SHADOWS // Casts shadows from clouds on VL
#ifndef CLOUDS_SHADOWS
#undef VL_CLOUDS_SHADOWS
#endif
#define Cumulus // a layer of puffy clouds up yonder.
#define Cumulus_coverage 0.4 // [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 Cumulus_density 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.00]
#define Altostratus // a layer of clouds WAAAY up yonder
#define Alto_coverage 0.5 // [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 Alto_density 0.05 // [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.00]
#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]
@ -262,19 +297,17 @@ const float shadowDistanceRenderMul = -1.0; //[-1.0 1.0] Can help to increase sh
#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]
#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 cloudDensity 0.5 // 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 fbmPower2 2.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]
#define Cloud_Height 300 // [-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]
#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
#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]
#define VL_SAMPLES2 6 //[4 6 8 10 12 14 16 20 24 30 40 50]
@ -302,4 +335,19 @@ const float shadowDistanceRenderMul = -1.0; //[-1.0 1.0] Can help to increase sh
#define Purkinje_Multiplier 5.0 // How much the purkinje effect increases brightness [0.05 0.1 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.85 0.9 0.95 1.0 1.05 1.1 1.15 1.2 1.25 1.3 1.35 1.4 1.45 1.5 1.55 1.6 1.65 1.7 1.75 1.8 1.85 1.9 1.95 2.0 2.05 2.1 2.15 2.2 2.25 2.3 2.35 2.4 2.45 2.5 2.55 2.6 2.65 2.7 2.75 2.8 2.85 2.9 2.95 3.0 3.05 3.1 3.15 3.2 3.25 3.3 3.35 3.4 3.45 3.5 3.55 3.6 3.65 3.7 3.75 3.8 3.85 3.9 3.95 4.0 4.05 4.1 4.15 4.2 4.25 4.3 4.35 4.4 4.45 4.5 4.55 4.6 4.65 4.7 4.75 4.8 4.85 4.9 4.95 5.0 5.05 5.1 5.15 5.2 5.25 5.3 5.35 5.4 5.45 5.5 5.55 5.6 5.65 5.7 5.75 5.8 5.85 5.9 5.95 6.0 6.05 6.1 6.15 6.2 6.25 6.3 6.35 6.4 6.45 6.5 6.55 6.6 6.65 6.7 6.75 6.8 6.85 6.9 6.95 7.0 7.05 7.1 7.15 7.2 7.25 7.3 7.35 7.4 7.45 7.5 7.55 7.6 7.65 7.7 7.75 7.8 7.85 7.9 7.95 8.0 8.05 8.1 8.15 8.2 8.25 8.3 8.35 8.4 8.45 8.5 8.55 8.6 8.65 8.7 8.75 8.8 8.85 8.9 8.95 9.0 9.05 9.1 9.15 9.2 9.25 9.3 9.35 9.4 9.45 9.5 9.55 9.6 9.65 9.7 9.75 9.8 9.85 9.9 9.95 ]
// #define AEROCHROME_MODE // Infra-red film colors ^~^
#define AEROCHROME_PINKNESS 0.3 // How pink it is from red [0.0 0.1 0.2 0.3 0.4 0.5 0.6 0.7 0.8 0.9 1.0]
//#define AEROCHROME_WOOL_ENABLED // Technically wool things should be affected but it affects a lot of builds and stuff
//#define AEROCHROME_WOOL_ENABLED // Technically wool things should be affected but it affects a lot of builds and stuff
// -- END SPECIFIC STUFF ---
// #define DEBUG_endfog
// #define THE_ORB
#define ORB_X 0 // [-200 -195 -190 -185 -180 -175 -170 -165 -160 -155 -150 -145 -140 -135 -130 -125 -120 -115 -110 -105 -100 -95 -90 -85 -80 -75 -70 -65 -60 -55 -50 -45 -40 -35 -30 -25 -20 -15 -10 -5 0 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 ORB_Y 0 // [-200 -195 -190 -185 -180 -175 -170 -165 -160 -155 -150 -145 -140 -135 -130 -125 -120 -115 -110 -105 -100 -95 -90 -85 -80 -75 -70 -65 -60 -55 -50 -45 -40 -35 -30 -25 -20 -15 -10 -5 0 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 ORB_Z 0 // [-200 -195 -190 -185 -180 -175 -170 -165 -160 -155 -150 -145 -140 -135 -130 -125 -120 -115 -110 -105 -100 -95 -90 -85 -80 -75 -70 -65 -60 -55 -50 -45 -40 -35 -30 -25 -20 -15 -10 -5 0 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 ORB_R 1.0 // [0.00 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 ORB_G 1.0 // [0.00 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 ORB_B 1.0 // [0.00 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 ORB_ColMult 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 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 ]

View File

@ -81,7 +81,7 @@ vec4 skyCloudsFromTex(vec3 pos,sampler2D sampler){
vec2 p = sphereToCarte(pos);
return texture2D(sampler,p*texelSize*256.+vec2(18.5+257.,1.5)*texelSize);
}
vec4 skyCloudsFromTex_Spec(vec3 pos,sampler2D sampler, int LOD){
vec4 skyCloudsFromTexLOD(vec3 pos,sampler2D sampler, float LOD){
vec2 p = sphereToCarte(pos);
return texture2DLod(sampler,p*texelSize*256.+vec2(18.5+257.,1.5)*texelSize, LOD);
return texture2DLod(sampler,p*texelSize*256.+vec2(18.5+257.,1.5)*texelSize,LOD);
}

View File

@ -12,39 +12,18 @@ const vec2[8] offsets = vec2[8](vec2(1./8.,-3./8.),
vec2(7.,-7.)/8.);
// sun specular stuff
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;
}
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
@ -62,71 +41,7 @@ float linZ(float depth) {
// 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) + stepv*dither;
float minZ = clipPosition.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++) {
float sp = texelFetch2D(depthtex1,ivec2(spos.xy/texelSize),0).r;
if(sp <= max(maxZ,minZ) && sp >= min(maxZ,minZ)) return vec3(spos.xy/RENDER_SCALE,sp);
spos += stepv;
//small bias
minZ = maxZ-(0.0001/dist)/ld(spos.z);
maxZ += stepv.z;
}
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) {
@ -153,28 +68,44 @@ vec2 R2_samples_spec(int n){
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, N.z));
return 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) + stepv*dither;
float minZ = clipPosition.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++) {
float sp = texelFetch2D(depthtex1,ivec2(spos.xy/texelSize),0).r;
if(sp <= max(maxZ,minZ) && sp >= min(maxZ,minZ)) return vec3(spos.xy/RENDER_SCALE,sp);
spos += stepv;
//small bias
minZ = maxZ-(0.0001/dist)/ld(spos.z);
maxZ += stepv.z;
}
return vec3(1.1);
}
vec3 rayTraceSpeculars(vec3 dir,vec3 position,float dither, float quality, bool hand, inout float reflectLength){
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.);
@ -197,11 +128,10 @@ vec3 rayTraceSpeculars(vec3 dir,vec3 position,float dither, float quality, bool
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);
float sp = sqrt((texelFetch2D(colortex4,ivec2(testthing),0).a+0.1)/65000.0);
sp = invLinZ(sp);
if(sp <= max(maxZ,minZ) && sp >= min(maxZ,minZ) ) return vec3(spos.xy/RENDER_SCALE,sp);
spos += stepv;
@ -209,58 +139,94 @@ vec3 rayTraceSpeculars(vec3 dir,vec3 position,float dither, float quality, bool
float biasamount = 0.0002 / dist;
if(hand) biasamount = 0.01;
minZ = maxZ-biasamount / ld(spos.z);
maxZ += stepv.z;
reflectLength += 1.0 / quality; // for shit
}
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;
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, N.z));
return N;
}
vec3 GGX (vec3 n, vec3 v, vec3 l, float r, vec3 F0) {
r = pow(r,2.5);
// r*=r;
vec3 h = l + v;
float hn = inversesqrt(dot(h, h));
float dotLH = clamp(dot(h,l)*hn,0.,1.);
float dotNH = clamp(dot(h,n)*hn,0.,1.) ;
float dotNL = clamp(dot(n,l),0.,1.);
float dotNHsq = dotNH*dotNH;
float denom = dotNHsq * r - dotNHsq + 1.;
float D = r / (3.141592653589793 * denom * denom);
vec3 F = F0 + (1. - F0) * exp2((-5.55473*dotLH-6.98316)*dotLH);
float k2 = .25 * r;
return dotNL * D * F / (dotLH*dotLH*(1.0-k2)+k2);
}
// pain
void MaterialReflections(
vec2 texcoord,
inout vec3 Output,
float roughness,
vec3 f0,
vec3 albedo,
vec3 sunPos,
vec3 sunCol,
float diffuse,
vec3 directlighting,
float lightmap,
vec3 normal,
vec3 np3,
vec3 fragpos,
vec3 noise,
bool hand
bool hand,
bool isEntities
){
vec3 Reflections_Final = Output;
vec3 SkyReflection = Output;
vec3 SunReflection;
vec4 Reflections;
float reflectLength;
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;
f0 = f0.y == 0.0 ? vec3(0.02) : f0;
// roughness = 0.2;
// f0 = vec3(0.04);
// f0 = vec3(0.0);
// roughness = 0.0;
mat3 basis = CoordBase(normal);
vec3 normSpaceView = -np3*basis ;
// roughness stuff
#ifdef Rough_reflections
int seed = (frameCounter%40000);
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));
@ -271,59 +237,137 @@ void MaterialReflections(
// fresnel stuff
float fresnel = pow(clamp(1.0 + dot(-Ln, H),0.0,1.0),5.0);
vec3 F = mix_vec3(f0, vec3(1.0), fresnel);
vec3 rayContrib = F;
float fresnel2 = dot(-np3, H);
float VisibilityFactor = rayContrib.x * pow(1.0-roughness,3.0);
// vec3 F = f0 + (1.0 - f0) * fresnel;
bool hasReflections = Roughness_Threshold == 1.0 ? true : (f0.y * (1.0 - roughness * Roughness_Threshold)) > 0.01;
float hasReflections2 = max(1.0 - roughness*1.75,0.0);
// // if (!hasReflections) Outdoors = 0.0;
// SunReflection = directlighting * SunGGX(normal, -np3, sunPos, roughness, f0.y) / 5.0;
SunReflection = directlighting * GGX(normal, -np3, sunPos, roughness, f0.yyy);
//
if (hasReflections) { // Skip sky reflection and SSR if its just not very visible anyway
#ifdef Sky_reflection
SkyReflection = skyCloudsFromTex(L, colortex4).rgb / 150. * 5.;
#endif
#ifdef Screen_Space_Reflections
// #ifdef SCREENSHOT_MODE
// float rayQuality = reflection_quality;
// #else
float rayQuality = mix_float(reflection_quality,4,luma(rayContrib)); // Scale quality with ray contribution
// #endif
// float rayQuality = reflection_quality;
vec3 rtPos = rayTraceSpeculars( mat3(gbufferModelView) * L,fragpos.xyz, noise.b, reflection_quality, hand, reflectLength);
float LOD = clamp(reflectLength * 6.0, 0.0,6.0) ;
if(hand || isEntities) LOD = 6.0;
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 = texture2DLod(colortex5,previousPosition.xy,LOD).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);
SunReflection *= Metals;
#ifdef Sky_reflection
SkyReflection *= Metals;
#endif
#ifdef Screen_Space_Reflections
Reflections.rgb *= Metals;
#endif
// background reflections
SkyReflection = mix_vec3(Output, SkyReflection, Outdoors);
// composite background and SSR.
Reflections.rgb = mix_vec3(SkyReflection, Reflections.rgb, Reflections.a);
// put reflections onto the scene
#ifdef Rough_reflections
Output = hand ? mix_vec3(Output, Reflections.rgb, VisibilityFactor) : mix_vec3(Output, Reflections.rgb, luma(rayContrib));
#else
Output = mix_vec3(Output, Reflections.rgb, VisibilityFactor);
#endif
Output += SunReflection;
}
void MaterialReflections_N(
inout vec3 Output,
float roughness,
vec3 f0,
vec3 albedo,
vec3 normal,
vec3 np3,
vec3 fragpos,
vec3 noise,
bool hand
){
vec3 Reflections_Final = Output;
float reflectLength = 0.0;
roughness = unpackRoughness(roughness);
f0 = f0.y == 0.0 ? vec3(0.02) : f0;
// roughness = 0.0;
// f0 = vec3(0.9);
float visibilityFactor = clamp(exp2((pow(roughness,3.0) / f0.y) * -4),0,1);
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, H);
vec3 L = basis * Ln;
// fresnel stuff
float fresnel = pow(clamp(1.0 + dot(-Ln, H),0.0,1.0),5.0);
vec3 F = mix(f0, vec3(1.0), fresnel);
vec3 rayContrib = F;
// float NdotV = clamp(normalize(dot(np3, L))*10000.,0.,1.);
bool hasReflections = (f0.y * (1.0 - roughness * Roughness_Threshold)) > 0.01;
bool hasReflections = (f0.y * (1.0 - roughness * Roughness_Threshold)) >= 0.0;
if (Roughness_Threshold == 1.0){ hasReflections = true; }
if (Roughness_Threshold == 1.0){ hasReflections = roughness > -1; }
if (!hasReflections ) Outdoors = 0.0;
// if(hand){
// LOD_controller = 6;
// // noise.b = 0.5;
// }
// SSR, Sky, and Sun reflections
vec4 Reflections = vec4(0.0);
// vec3 SkyReflection = skyCloudsFromTex_Spec(L, colortex4,int(LOD_controller)).rgb / 150. * 5.;
vec3 SkyReflection = skyCloudsFromTex(L, colortex4).rgb / 150. * 5.;
vec3 SunReflection = diffuse * GGX2(normal, -np3, sunPos, roughness, f0) * 8./150./3. * sunCol * Sun_specular_Strength;
#ifndef Sky_reflection
SkyReflection = Reflections_Final;
#endif
vec3 FogReflection = vec3(0.0);
#ifdef Screen_Space_Reflections
if ( hasReflections ) { // Skip SSR if ray contribution is low
#ifdef SCREENSHOT_MODE
float rayQuality = reflection_quality;
#else
float rayQuality = mix_float(reflection_quality,0.0,dot(rayContrib,vec3(0.33))); // Scale quality with ray contribution
#endif
vec3 rtPos = rayTraceSpeculars( mat3(gbufferModelView) * L,fragpos.xyz, noise.b, reflection_quality, hand);
// float test = dot(vec2(-rtPos.x,-rtPos.y), vec2(rtPos.x,rtPos.y));
// float LOD_controller = clamp((1-pow(test*0.5+1.0,25)) * 10,0.0,6.0) ;
// LOD_controller = 0;
float rayQuality = reflection_quality;
vec3 rtPos = rayTraceSpeculars( mat3(gbufferModelView) * L,fragpos.xyz, noise.b, reflection_quality, hand, reflectLength);
float LOD = clamp( reflectLength * 6.0 ,0.0,6.0);
if (rtPos.z < 1. ){ // Reproject on previous frame
vec3 previousPosition = mat3(gbufferModelViewInverse) * toScreenSpace(rtPos) + gbufferModelViewInverse[3].xyz + cameraPosition-previousCameraPosition;
@ -331,39 +375,137 @@ void MaterialReflections(
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 = texture2DLod(colortex5,previousPosition.xy,0).rgb;
Reflections.rgb = texture2DLod(colortex5,previousPosition.xy,LOD).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 = pow(luma(rayContrib),1.0);
float oneminus_lumaRayContrib = pow(1.0-luma(rayContrib),1.0);
// darken albedos, and stop darkening where the sky gets occluded indoors
Reflections_Final *= mix_float(1.0 - (Reflections.a*lumaRayContrib), oneminus_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 Sky_reflection
// reflect nether fog color instead of a sky.
FogReflection = gl_Fog.color.rgb * 0.5 * NetherFog_brightness;
FogReflection *= 1.0 + sqrt(roughness) * 15.0; // brighten rough spots for some highlights that look neat
FogReflection *= Metals;
FogReflection = mix(Output, FogReflection, pow(fresnel, 0.2)+0.1); // make sure the background contains the fog reflection.
#else
FogReflection = Output;
#endif
Reflections.rgb = mix(FogReflection, Reflections.rgb, Reflections.a); // make background only where ssr is not.
Reflections_Final = mix(Output, Reflections.rgb, luma(rayContrib)); // apply reflections to final scene color.
#ifdef Rough_reflections
Output = hand ? mix_vec3(Output, Reflections_Final, visibilityFactor) : Reflections_Final;
#else
Output = mix_vec3(Output, Reflections_Final, visibilityFactor);
#endif
Output += SunReflection ;
// float aaaa = dot(vec2(-rtPos.x,-rtPos.y), vec2(rtPos.x,rtPos.y));
// test = pow(test*0.5+1.0,2);
// Output = vec3(0,test,0) ;
// Output = vec3(reflectLength);
}
void MaterialReflections_E(
inout vec3 Output,
float roughness,
vec3 f0,
vec3 albedo,
vec3 normal,
vec3 np3,
vec3 fragpos,
vec3 noise,
bool hand,
vec3 lightCol,
vec3 lightDir,
bool isEntities
){
vec3 Reflections_Final = Output;
float reflectLength = 0.0;
roughness = unpackRoughness(roughness);
f0 = f0.y == 0.0 ? vec3(0.02) : f0;
// roughness = 0.0;
// f0 = vec3(0.9);
float visibilityFactor = clamp(exp2((pow(roughness,3.0) / f0.y) * -4),0,1);
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, H);
vec3 L = basis * Ln;
// fresnel stuff
float fresnel = pow(clamp(1.0 + dot(-Ln, H),0.0,1.0),5.0);
vec3 F = mix(f0, vec3(1.0), fresnel);
vec3 rayContrib = F;
// float NdotV = clamp(normalize(dot(np3, L))*10000.,0.,1.);
bool hasReflections = (f0.y * (1.0 - roughness * Roughness_Threshold)) >= 0.0;
if (Roughness_Threshold == 1.0){ hasReflections = true; }
vec3 Ln_2 = reflect(-normSpaceView, normalize(vec3(0.0,0.0,1.0)));
vec3 L_2 = basis * Ln_2;
vec3 FogReflection = skyCloudsFromTexLOD(L_2, colortex4, sqrt(roughness) * 9.0).rgb / 150.0;
FogReflection = mix(FogReflection, lightCol * 2 * clamp(dot(L_2, lightDir),0,1), roughness);
FogReflection *= 1.0 + roughness * 2.0;
vec4 Reflections = vec4(0.0);
#ifdef Screen_Space_Reflections
if ( hasReflections ) { // Skip SSR if ray contribution is low
float rayQuality = reflection_quality;
vec3 rtPos = rayTraceSpeculars( mat3(gbufferModelView) * L,fragpos.xyz, noise.b, reflection_quality, hand, reflectLength);
float LOD = clamp( reflectLength * 6.0 ,0.0,6.0);
if(hand) LOD = 6.0;
if(isEntities) LOD = 4.0;
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 = texture2DLod(colortex5,previousPosition.xy,LOD).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;
FogReflection *= Metals;
Reflections.rgb = mix(FogReflection, Reflections.rgb, Reflections.a); // make background only where ssr is not.
Reflections_Final = mix(Output, Reflections.rgb, luma(rayContrib)); // apply reflections to final scene color.
#ifdef Rough_reflections
Output = hand ? mix_vec3(Output, Reflections_Final, visibilityFactor) : Reflections_Final;
#else
Output = mix_vec3(Output, Reflections_Final, visibilityFactor);
#endif
}

View File

@ -1,5 +1,3 @@
#ifdef HQ_CLOUDS
int maxIT_clouds = minRayMarchSteps;
int maxIT = maxRayMarchSteps;
@ -19,21 +17,17 @@
uniform float viewHeight;
uniform float viewWidth;
uniform sampler2D colortex4;//Skybox
// uniform float lightningFlash;
#define WEATHERCLOUDS
#include "/lib/climate_settings.glsl"
float CumulusHeight = 250;
float MaxCumulusHeight = CumulusHeight + 100;
float maxHeight = 5000.;
float cloud_height = 1500.;
// quick variables
float rainCloudwetness = rainStrength ;
float rainClouds = rainCloudwetness;
float cloud_movement1 = frameTimeCounter * cloud_speed * 0.001;
float AltostratusHeight = 2000;
float rainCloudwetness = rainStrength;
float cloud_movement = 0;
//3D noise from 2d texture
float densityAtPos(in vec3 pos){
@ -45,47 +39,33 @@ float densityAtPos(in vec3 pos){
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 + cloud_movement) / 5000 ).b;
float CloudSmall = texture2D(noisetex, (samplePos.xz - cloud_movement) / 500 ).r;
float coverage = abs(pow(CloudLarge,1)*2.0 - 1.2)*0.5 - (1.0-CloudSmall) + 0.3;
float Topshape = max(pos.y - (MaxCumulusHeight + CumulusHeight)*0.46, 0.0) / 200;
Topshape += max(exp((pos.y - MaxCumulusHeight) / 10.0 ), 0.0) ;
float FinalShape = DailyWeather_LowAltitude(coverage) - Topshape;
// cap the top and bottom for reasons
float capbase = sqrt(max(CumulusHeight*1.05 - pos.y, 0.0)/50) ;
float captop = max(pos.y - MaxCumulusHeight, 0.0);
// 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;
FinalShape = FinalShape - capbase - captop ;
// float coverage = CloudSmall-CloudLarge;
// // float mult = max( abs(pos.y - (maxHeight+cloud_height)*0.4 ) / 5000, 0);
// float mult = max( abs(pos.y-1750) / 5000, 0);
// cloudshape = DailyWeather_LowAltitude(coverage) - mult ;
// return max(cloudshape,0.0);
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) - pow(CloudLarge*0.5+0.5,1.5);
float mult = max( abs(pos.y - (maxHeight+cloud_height)*0.4 ) / 5000, 0);
// float mult = max( abs(pos.y-1750) / 5000, 0);
cloudshape = DailyWeather_LowAltitude(coverage) - mult;
return max(cloudshape,0.0);
return max(FinalShape,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 ;
@ -93,73 +73,48 @@ float cloudVol(in vec3 pos,in vec3 samplePos,in float cov, in int LoD){
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);
// // noise = (1.0 - densityAtPos(samplePos * 4.));
// // samplePos = floor(samplePos*)/16;
// noise += ((1.0 - densityAtPos(samplePos * 16.))*0.5+0.5) * (1.0 - densityAtPos(samplePos * 4.));
// // noise += (1.0 - densityAtPos(samplePos / 160 * 1000.));
// noise *= clamp(pow(1.0-cloudshape,0.5),0.0,1.0);
// float cloud = max(cov - noise*noise*noise,0.0) ;
samplePos.xz -= cloud_movement/4;
noise += 1.0-densityAtPos(samplePos * 200.) ;
float smallnoise = densityAtPos(samplePos * 600.);
if (LoD > 0) noise += ((1-smallnoise) - max(0.15 - abs(smallnoise * 2.0 - 0.55) * 0.5,0.0)*1.5) * 0.5;
noise *= 1.0-cov;
noise = noise*noise;
float cloud = max(cov - noise*noise*fbmAmount,0.0);
return cloud;
}
float getCloudDensity(in vec3 pos, in int LoD){
float GetCumulusDensity(in vec3 pos, in int LoD){
// vec3 samplePos = floor((pos*vec3(1.0,1./48.,1.0)/4 ) /512)*512 ;
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);
return cloudVol(pos,samplePos,coverageSP,LoD);
} else return 0.0;
}
float HighAltitudeClouds(vec3 pos){
vec2 pos2d = pos.xz/100000.0 ;
float GetAltostratusDensity(vec3 pos){
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 large = texture2D(noisetex, pos.xz/100000. ).b;
float small = texture2D(noisetex, pos.xz/10000. - vec2(-large,1-large)/5).b;
float coverage = 1;
float thickness = 1;
DailyWeather_HighAltitude(coverage, thickness);
float shape = (small + pow((1.0-large),2.0))/2.0;
float cirrusFinal = exp(pow((cloudSmall + cloudLarge),thickness) * -coverage );
return max(cirrusFinal,0.0);
shape = pow(max(shape + Alto_coverage - 0.5,0.0),2.0);
return shape;
}
//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,
@ -168,252 +123,229 @@ vec3 Cloud_lighting(
vec3 sunContribution,
vec3 sunContributionMulti,
vec3 moonContribution,
vec3 moonContributionMulti,
float AmbientShadow,
int cloudType
){
// low altitude
float powder = 1.0 - exp(-CloudShape * 400.0);
float ambientShading = exp(-SkyShadowing * 50. + powder)*powder ;
vec3 ambientLighting = SkyColors * ambientShading;
// if(cloudType == 1) ambientLighting = SkyColors * powder;
float coeeff = -30;
// float powder = 1.0 - exp((CloudShape*CloudShape) * -800);
float powder = 1.0 - exp(CloudShape * coeeff/3);
float lesspowder = powder*0.4+0.6;
vec3 sunLighting = exp(-SunShadowing)*sunContribution + exp(-SunShadowing * 0.2)*sunContributionMulti;
sunLighting *= powder;
vec3 skyLighting = SkyColors * exp(SkyShadowing * AmbientShadow * coeeff/2 ) * lesspowder ;
vec3 moonLighting = ( exp2(-MoonShadowing * 2.0 )*moonContribution + exp(-MoonShadowing * 0.2 )*moonContributionMulti ) * powder;
if(cloudType == 1){
coeeff = -10;
skyLighting = SkyColors * exp(SkyShadowing * coeeff/15) * lesspowder;
}
return ambientLighting + sunLighting ;
vec3 sunLighting = exp(SunShadowing * coeeff + powder) * sunContribution;
sunLighting += exp(SunShadowing * coeeff/4 + powder*2) * sunContributionMulti;
vec3 moonLighting = exp(MoonShadowing * coeeff / 3) * moonContribution * powder;
// 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;
return skyLighting + moonLighting + sunLighting ;
}
vec3 pixelCoord (vec3 Coordinates, int Resolution){
return floor(Coordinates / Resolution) * Resolution;
//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;
}
float CustomPhase(float LightPos, float S_1, float S_2){
float SCALE = S_2; // remember the epislons 0.001 is fine.
float N = S_1;
float N2 = N / SCALE;
float R = 1;
float A = pow(1.0 - pow(max(R-LightPos,0.0), N2 ),N);
return A;
}
vec3 startOffset = vec3(0);
vec4 renderClouds(
vec3 fragpositi,
vec3 color,
float dither,
vec3 sunColor,
vec3 moonColor,
vec3 avgAmbient,
float dither2
vec3 FragPosition,
vec2 Dither,
vec3 SunColor,
vec3 MoonColor,
vec3 SkyColor
){
#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);
vec3 color = vec3(0.0);
//project pixel position into projected shadowmap space
vec4 fragposition = gbufferModelViewInverse*vec4(fragpositi,1.0);
vec4 fragpos = normalize(gbufferModelViewInverse*vec4(FragPosition,1.0));
vec3 worldV = normalize(fragposition.rgb);
float VdotU = worldV.y;
maxIT_clouds = int(clamp( maxIT_clouds / sqrt(exp2(fragpos.y)),0.0, maxIT));
//project view origin into projected shadowmap space
vec4 start = (gbufferModelViewInverse*vec4(0.0,0.0,0.,1.));
vec3 dV_view = normalize(fragpos.xyz);
dV_view.y += 0.05;
vec3 dV_view2 = dV_view;
float mult2 = length(dV_view2);
// 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);
// dV_view = floor(dV_view/1000)*1000;
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;
// progress_view = floor
float shadowStep = 200.;
vec3 dV_Sun = flipClouds * normalize(mat3(gbufferModelViewInverse)*sunVec)*shadowStep;
dV_view *= max(MaxCumulusHeight - CumulusHeight, 0.0)/abs(dV_view.y)/maxIT_clouds;
float mult = length(dV_view);
float SdotV = dot(sunVec,normalize(fragpositi));
// i want the samples to stay at one point in the world, but as the height coordinates go negative everything goes insideout, so this is a work around....
float startFlip = mix(max(cameraPosition.y - MaxCumulusHeight,0.0), max(CumulusHeight-cameraPosition.y,0), clamp(dV_view.y,0,1));
// vec3 progress_view = dV_view*Dither.x + cameraPosition + (dV_view/abs(dV_view.y))*startFlip;
vec3 progress_view = dV_view*Dither.x + cameraPosition + (dV_view/abs(dV_view.y))*startFlip;
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 mieDayMulti = phaseg(SdotV, 0.35);
float mieDay = (phaseg(SdotV,0.75) + mieDayMulti)*2.0;
float mieNightMulti = phaseg(-SdotV, 0.35)*3.14;
float mieNight = mix(phaseg(-SdotV,0.9), mieNightMulti,0.5)*3.14;
vec3 sunContribution = mieDay*sunColor*3.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;
// progress_view = floor(progress_view/512)*512;
float cloud = 0.0;
for(int i=0;i<maxIT_clouds;i++) {
#ifdef Cumulus_Clouds
cloud = getCloudDensity(progress_view, cloudLoD);
#endif
// thank you emin for this world interseciton thing
// float lViewPosM = length(FragPosition) < far * 1.5 ? length(FragPosition) - 1.0 : 1000000000.0;
// bool IntersecTerrain = false;
// float basefade = clamp( (progress_view.y - 1750 ) / 1750 ,0.0,1.0) ;
float basefade = clamp( (progress_view.y - (maxHeight+cloud_height)*0.25) / ((maxHeight+cloud_height)*0.5) ,0.0,1.0) ;
// float basefade = clamp( exp( (progress_view.y - (maxHeight+cloud_height)*0.5 ) / 5/00) ,0.0,1.0) ;
////// lighitng stuff
float shadowStep = 200.;
vec3 dV_Sun = normalize(mat3(gbufferModelViewInverse)*sunVec)*shadowStep;
float densityofclouds = basefade*cloudDensity ;
if(cloud >= 0.0){
float muS = cloud*densityofclouds;
float muE = cloud*densityofclouds;
float SdotV = dot(sunVec,normalize(FragPosition));
float muEshD = 0.0;
if (sunContribution.g > 1e-5){
SkyColor *= clamp(abs(dV_Sun.y)/100.,0.75,1.0);
SunColor = SunColor * clamp(dV_Sun.y ,0.0,1.0);
MoonColor *= clamp(-dV_Sun.y,0.0,1.0);
if(dV_Sun.y/shadowStep < -0.1) dV_Sun = -dV_Sun;
float mieDay = phaseg(SdotV, 0.75) * 2;
float mieDayMulti = phaseg(SdotV, 0.35) * 2;
vec3 sunContribution = SunColor * mieDay;
vec3 sunContributionMulti = SunColor * mieDayMulti ;
float mieNight = (phaseg(-SdotV,0.8) + phaseg(-SdotV, 0.35)*4) * 6.0;
vec3 moonContribution = MoonColor * mieNight;
#ifdef Cumulus
for(int i=0;i<maxIT_clouds;i++) {
// IntersecTerrain = length(progress_view - cameraPosition) > lViewPosM;
// if(IntersecTerrain) break;
float cumulus = GetCumulusDensity(progress_view, cloudLoD);
float alteredDensity = Cumulus_density * clamp(exp( (progress_view.y - (MaxCumulusHeight + CumulusHeight)*0.455) / 9.0 ),0.0,1.0);
if(cumulus > 1e-5){
float muE = cumulus*alteredDensity;
float Sunlight = 0.0;
float MoonLight = 0.0;
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);
vec3 shadowSamplePos = progress_view + dV_Sun * (1+j+Dither.y/2)*0.15;
float shadow = GetCumulusDensity(shadowSamplePos, 0) * Cumulus_density;
Sunlight += shadow;
MoonLight += shadow;
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 Altostratus
// cast a shadow from higher clouds onto lower clouds
vec3 HighAlt_shadowPos = progress_view + dV_Sun/abs(dV_Sun.y) * max(AltostratusHeight - progress_view.y,0.0);
float HighAlt_shadow = GetAltostratusDensity(HighAlt_shadowPos) * Alto_density ;
Sunlight += HighAlt_shadow;
#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 ;
float ambientlightshadow = 1.0-clamp(exp((progress_view.y - (MaxCumulusHeight + CumulusHeight)*0.5) / 100.0),0.0,1.0);
vec3 S = Cloud_lighting(muE, cumulus*Cumulus_density, Sunlight, MoonLight, SkyColor, sunContribution, sunContributionMulti, moonContribution, ambientlightshadow, 0);
vec3 Sint = (S - S * exp(-mult*muE)) / muE;
color += max(muS*Sint*total_extinction,0.0);
total_extinction *= max(exp(-muE*mult),0);
color += max(muE*Sint*total_extinction,0.0);
total_extinction *= max(exp(-mult*muE),0.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);
}
progress_view += dV_view;
}
#endif
vec3 normView = normalize(dV_view2)*flipClouds;
#ifdef Altostratus
if (max(AltostratusHeight-cameraPosition.y,0.0)/max(normalize(dV_view).y,0.0) / 100000.0 < AltostratusHeight) {
vec3 progress_view_high = dV_view2 + cameraPosition + dV_view2/dV_view2.y * max(AltostratusHeight-cameraPosition.y,0.0);
float altostratus = GetAltostratusDensity(progress_view_high) * Alto_density;
float Sunlight = 0.0;
float MoonLight = 0.0;
if(altostratus > 1e-5){
for (int j = 0; j < 2; j++){
vec3 shadowSamplePos_high = progress_view_high + dV_Sun * float(j+Dither.y);
float shadow = GetAltostratusDensity(shadowSamplePos_high) * Alto_density;
Sunlight += shadow;
}
vec3 S = Cloud_lighting(altostratus, altostratus, Sunlight, MoonLight, SkyColor, sunContribution, sunContributionMulti, moonContribution, 1, 1);
vec3 Sint = (S - S * exp(-20*altostratus)) / altostratus;
color += max(altostratus*Sint*total_extinction,0.0);
total_extinction *= max(exp(-20*altostratus),0.0);
}
}
#endif
vec3 normView = normalize(dV_view);
// 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.));
vec3 fogColor = skyFromTex(normView, colortex4)/150. * 5.0;
float dist = max(cameraPosition.y+CumulusHeight,CumulusHeight)/abs(normView.y);
float fog = exp(dist / -5000.0 * (1.0+rainCloudwetness*8.));
// if(IntersecTerrain) fog = 1.0;
return mix(vec4(fogColor,0.0), vec4(color,total_extinction), fog);
// return vec4(color,total_extinction);
}
float GetCloudShadow(vec3 eyePlayerPos){
vec3 playerPos = eyePlayerPos + cameraPosition;
playerPos.y += 0.05;
float shadow;
// assume a flat layer of cloud, and stretch the sampled density along the sunvector, starting from some vertical layer in the cloud.
#ifdef Cumulus
vec3 lowShadowStart = playerPos + WsunVec/abs(WsunVec.y) * max((MaxCumulusHeight + CumulusHeight)*0.44 - playerPos.y,0.0) ;
shadow += GetCumulusDensity(lowShadowStart,1)*cloudDensity;
#endif
#ifdef Altostratus
vec3 highShadowStart = playerPos + WsunVec/abs(WsunVec.y) * max(AltostratusHeight - playerPos.y,0.0);
shadow += GetAltostratusDensity(highShadowStart) * Alto_density;
#endif
shadow = clamp(exp(-shadow*10.0),0.0,1.0);
return shadow;
}
float GetCloudShadow_VLFOG(vec3 WorldPos){
float shadow;
// assume a flat layer of cloud, and stretch the sampled density along the sunvector, starting from some vertical layer in the cloud.
#ifdef Cumulus
vec3 lowShadowStart = WorldPos + WsunVec/abs(WsunVec.y) * max((MaxCumulusHeight + CumulusHeight)*0.435 - WorldPos.y,0.0) ;
shadow += GetCumulusDensity(lowShadowStart,0)*cloudDensity;
#endif
#ifdef Altostratus
vec3 highShadowStart = WorldPos + WsunVec/abs(WsunVec.y) * max(AltostratusHeight - WorldPos.y,0.0);
shadow += GetAltostratusDensity(highShadowStart) * Alto_density;
#endif
shadow = clamp(exp(-shadow*15.0),0.0,1.0);
// do not allow it to exist above the lowest cloud plane
shadow *= clamp(((MaxCumulusHeight + CumulusHeight)*0.435 - WorldPos.y)/100,0.0,1.0) ;
return shadow;
}

View File

@ -1,35 +1,19 @@
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 densityAtPosFog(in vec3 pos){
pos /= 18.;
pos.xz *= 0.5;
vec3 p = floor(pos);
vec3 f = fract(pos);
f = (f*f) * (3.-2.*f);
vec2 uv = p.xz + f.xz + p.y * vec2(0.0,193.0);
vec2 coord = uv / 512.0;
vec2 xy = texture2D(noisetex, coord).yx;
return mix(xy.r,xy.g, f.y);
}
float cloudVol(in vec3 pos){
@ -37,24 +21,28 @@ float cloudVol(in vec3 pos){
vec3 samplePos2 = pos*vec3(1.0,1./48.,1.0);
float mult = exp2( -max((pos.y - SEA_LEVEL) / 35.,0.0));
float mult = exp( -max((pos.y - SEA_LEVEL) / 35.,0.0));
float fog_shape = 1-densityAtPos(samplePos * 24.0);
float fog_eroded = densityAtPos( samplePos2 * 150.0);
float fog_shape = 1.0 - densityAtPosFog(samplePos * 24.0);
float fog_eroded = 1.0 - densityAtPosFog( samplePos2 * 200.0);
// float CloudyFog = max( (fog_shape*2.0 - fog_eroded*0.5) - 1.2, max(fog_shape-0.8,0.0)) * mult;
float CloudyFog = max((fog_shape*1.2 - fog_eroded*0.2) - 0.75,0.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;
float RainFog = max(fog_shape*10. - 7.,0.5) * exp2( -max((pos.y - SEA_LEVEL) / 25.,0.0)) * 5. * rainStrength * RainFog_amount;
TimeOfDayFog(UniformFog, CloudyFog);
return RainFog + CloudyFog + UniformFog;
return CloudyFog + UniformFog + RainFog;
}
mat2x3 getVolumetricRays(
vec4 getVolumetricRays(
vec3 fragpos,
float dither,
vec3 fragpos
vec3 AmbientColor
){
//project pixel position into projected shadowmap space
vec3 wpos = mat3(gbufferModelViewInverse) * fragpos + gbufferModelViewInverse[3].xyz;
@ -76,7 +64,6 @@ mat2x3 getVolumetricRays(
//apply dither
vec3 progress = start.xyz;
vec3 progressW = gbufferModelViewInverse[3].xyz+cameraPosition;
vec3 vL = vec3(0.);
@ -88,23 +75,23 @@ mat2x3 getVolumetricRays(
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 sunColor = lightCol.rgb / 80.0;
vec3 skyCol0 = AmbientColor / 150. * 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 absorbance = 1.0;
float expFactor = 11.0;
vec3 WsunVec = mat3(gbufferModelViewInverse) * sunVec * lightCol.a;
float cloudShadow = 1.0;
vec3 progressW = gbufferModelViewInverse[3].xyz+cameraPosition;
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);
for (int i=0;i<VL_SAMPLES;i++) {
float d = (pow(expFactor, float(i+dither)/float(VL_SAMPLES))/expFactor - 1.0/expFactor)/(1-1.0/expFactor);
float dd = pow(expFactor, float(i+dither)/float(VL_SAMPLES)) * log(expFactor) / float(VL_SAMPLES)/(expFactor-1.0);
progress = start.xyz + d*dV;
progressW = gbufferModelViewInverse[3].xyz+cameraPosition + d*dVWorld;
//project into biased shadowmap space
@ -112,51 +99,44 @@ mat2x3 getVolumetricRays(
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
sh *= GetCloudShadow_VLFOG(progressW);
#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;
vec2 airCoef = exp(-max(progressW.y-SEA_LEVEL,0.0)/vec2(8.0e3, 1.2e3)*vec2(6.,7.0)) * 24 * Haze_amount;
//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 DirectLight = (sunColor*sh) * (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);
// extra fog effects
vec3 rainRays = (sunColor*sh) * (rayL*phaseg(SdotV,0.5)) * clamp(pow(WsunVec.y,5)*2,0.0,1) * rainStrength * RainFog_amount;
vec3 CaveRays = (sunColor*sh) * phaseg(SdotV,0.7) * 0.001 * (1.0 - max(eyeBrightnessSmooth.y,0)/240.);
// vec3 RAAAAY = (sunColor*sh) * (rayL*phaseg(SdotV,0.5)) ;
vec3 vL0 = (DirectLight + AmbientLight + AtmosphericFog + rainRays) * max(eyeBrightnessSmooth.y,0)/240. + CaveRays ;
#ifdef Biome_specific_environment
BiomeFogColor(vL0); // ?????
#endif
vL += (vL0 - vL0 * exp(-(rL+m)*dd*dL)) / ((rL+m)+0.00000001)*absorbance;
absorbance *= dot(clamp(exp(-(rL+m)*dd*dL),0.0,1.0), vec3(0.333333));
}
return mat2x3(vL,absorbance);
return vec4(vL,absorbance);
}

View File

@ -1,41 +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;
vec2 movement = vec2(frameTimeCounter*0.05);
vec2 pos = posxz ;
float caustic = 1.0;
float weightSum = 0.0;
float radiance = 2.39996;
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.)
const vec2 wave_size[3] = vec2[](
vec2(48.,12.),
vec2(12.,48.),
vec2(32.)
);
for (int i = 0; i < 4; i++){
pos = rotationMatrix * pos;
float WavesLarge = clamp( pow(1.0-pow(1.0-texture2D(noisetex, pos / 600.0 ).b, 5.0),5.0),0.1,1.0);
// float WavesLarge = pow(abs(0.5-texture2D(noisetex, pos / 600.0 ).b),2);
vec2 speed = movement;
float waveStrength = 1.0;
for (int i = 0; i < 3; i++){
pos = rotationMatrix * pos ;
if( i == 0) {
speed *= 0.15;
waveStrength = 7.0;
}
float Waves = texture2D(noisetex, pos / wave_size[i] + (1.0-WavesLarge)*0.5 + movement).b;
float small_wave = texture2D(noisetex, pos / wave_size[i] + speed ).b * waveStrength;
caustic += small_wave;
weightSum -= exp2(caustic);
caustic += exp2(pow(Waves,3.0) * -5.0);
weightSum += exp2(-(3.0-caustic*pow(WavesLarge,2)));
}
return caustic / weightSum;
return ((3.0-caustic) * weightSum / (30.0 * 3.0));
}
// float getWaterHeightmap(vec2 posxz, float waveM, float waveZ, float iswater) { // water waves
// vec2 movement = vec2(frameTimeCounter*0.025);
// vec2 pos = posxz ;
// float caustic = 1.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[3] = vec2[](
// vec2(60.,30.),
// vec2(30.,60.),
// vec2(45.)
// );
// float WavesLarge = pow(abs(0.5-texture2D(noisetex, pos / 600.0 ).b),2);
// for (int i = 0; i < 3; i++){
// pos = rotationMatrix * pos ;
// float Waves = 1.0-exp(pow(abs(0.5-texture2D(noisetex, pos / (wave_size[i] ) + movement).b),1.3) * -10) ;
// caustic += Waves*0.1;
// weightSum += exp2(-caustic*pow(WavesLarge,2));
// }
// return caustic * weightSum/ 30;
// }
vec3 getWaveHeight(vec2 posxz, float iswater){
@ -57,4 +76,4 @@ vec3 getWaveHeight(vec2 posxz, float iswater){
vec3 wave = normalize(vec3(xDelta,yDelta,1.0-pow(abs(xDelta+yDelta),2.0)));
return wave;
}
}