made file explorer look much better, actually implemented Assimp properly this time, added lighting support and added independant material support
(gosh that took me like 4 days of work 😭)
This commit is contained in:
@@ -2,7 +2,7 @@
|
||||
out vec4 FragColor;
|
||||
in vec3 fragPos;
|
||||
|
||||
uniform float timeOfDay; // 0..1 (0.0 = midnight)
|
||||
uniform float timeOfDay;
|
||||
|
||||
float hash(vec3 p) {
|
||||
p = fract(p * 0.3183099 + 0.1);
|
||||
@@ -13,23 +13,20 @@ float hash(vec3 p) {
|
||||
vec3 getSkyColor(vec3 dir, float tod) {
|
||||
float height = dir.y;
|
||||
|
||||
// Continuous rotation – no midnight jump
|
||||
float t = fract(tod);
|
||||
float angle = t * 6.28318530718;
|
||||
vec3 sunDir = normalize(vec3(cos(angle), sin(angle) * 0.5, sin(angle)));
|
||||
float sunDot = max(dot(dir, sunDir), 0.0);
|
||||
|
||||
// Your original colors (unchanged)
|
||||
vec3 nightTop = vec3(0.01, 0.01, 0.05);
|
||||
vec3 nightHorizon = vec3(0.05, 0.05, 0.15);
|
||||
vec3 dayTop = vec3(0.3, 0.5, 0.9);
|
||||
vec3 dayHorizon = vec3(0.6, 0.7, 0.9);
|
||||
vec3 sunriseTop = vec3(0.4, 0.3, 0.5);
|
||||
vec3 sunriseHorizon= vec3(1.0, 0.5, 0.3);
|
||||
vec3 sunsetTop = vec3(0.5, 0.3, 0.4);
|
||||
vec3 sunsetHorizon = vec3(1.0, 0.4, 0.2);
|
||||
vec3 nightTop = vec3(0.01, 0.03, 0.08);
|
||||
vec3 nightHorizon = vec3(0.04, 0.06, 0.12);
|
||||
vec3 dayTop = vec3(0.25, 0.55, 1.00);
|
||||
vec3 dayHorizon = vec3(0.75, 0.88, 1.00);
|
||||
vec3 sunriseTop = vec3(0.45, 0.32, 0.55);
|
||||
vec3 sunriseHorizon = vec3(1.10, 0.60, 0.30);
|
||||
vec3 sunsetTop = vec3(0.55, 0.35, 0.45);
|
||||
vec3 sunsetHorizon = vec3(1.05, 0.45, 0.20);
|
||||
|
||||
// Same 4-phase interpolation as you had
|
||||
vec3 skyTop, skyHorizon;
|
||||
if (t < 0.25) {
|
||||
float f = t * 4.0;
|
||||
@@ -49,21 +46,30 @@ vec3 getSkyColor(vec3 dir, float tod) {
|
||||
skyHorizon = mix(sunsetHorizon, nightHorizon, f);
|
||||
}
|
||||
|
||||
vec3 skyColor = mix(skyHorizon, skyTop, smoothstep(-0.3, 0.3, height));
|
||||
float horizonMix = smoothstep(-0.2, 0.45, height);
|
||||
vec3 skyColor = mix(skyHorizon, skyTop, horizonMix);
|
||||
|
||||
// Warm haze near the horizon for softer day transitions
|
||||
float hazeAmount = exp(-max(height, 0.0) * 12.0);
|
||||
vec3 hazeColor = mix(skyHorizon * 0.8, vec3(1.0, 0.95, 0.9), 0.6);
|
||||
|
||||
// Sun (exactly like yours)
|
||||
vec3 sunCol = vec3(1.0, 0.95, 0.8);
|
||||
float sunGlow = pow(sunDot, 128.0) * 2.0;
|
||||
float sunGlow = pow(sunDot, 128.0) * 2.5;
|
||||
float sunDisc = smoothstep(0.9995, 0.9998, sunDot);
|
||||
float atmGlow = pow(sunDot, 8.0) * 0.5;
|
||||
float atmGlow = pow(sunDot, 8.0) * 0.6;
|
||||
float mie = pow(sunDot, 12.0);
|
||||
|
||||
float sunVisibility = smoothstep(-0.12, 0.15, sunDir.y); // smooth fade in/out
|
||||
skyColor += sunCol * (sunDisc + atmGlow + sunGlow*0.3) * sunVisibility;
|
||||
skyColor += sunCol * (sunDisc + atmGlow + sunGlow * 0.35) * sunVisibility;
|
||||
|
||||
// Forward-scattered haze brightens the horizon when the sun is low
|
||||
vec3 forwardHaze = hazeColor * mie * 0.25 * sunVisibility;
|
||||
skyColor += forwardHaze;
|
||||
skyColor += hazeColor * hazeAmount * 0.18 * (0.3 + sunVisibility);
|
||||
|
||||
// ——— STARS: now actually visible and pretty ———
|
||||
float night = 1.0 - sunVisibility;
|
||||
if (night > 0.0) {
|
||||
vec3 p = dir * 160.0; // denser grid
|
||||
vec3 p = dir * 160.0;
|
||||
vec3 i = floor(p);
|
||||
vec3 f = fract(p);
|
||||
|
||||
@@ -74,18 +80,26 @@ vec3 getSkyColor(vec3 dir, float tod) {
|
||||
vec3 o = vec3(x,y,z);
|
||||
vec3 pos = i + o;
|
||||
float h = hash(pos);
|
||||
if (h > 0.99) { // only the brightest 1%
|
||||
if (h > 0.99) {
|
||||
vec3 center = o + 0.5 + (hash(pos+vec3(7,13,21))-0.5)*0.8;
|
||||
float d = length(f - center);
|
||||
float star = 1.0 - smoothstep(0.0, 0.12, d); // tiny sharp dot
|
||||
star *= (h - 0.99)*100.0; // brightness variation
|
||||
float star = 1.0 - smoothstep(0.0, 0.12, d);
|
||||
star *= (h - 0.99)*100.0;
|
||||
stars += star;
|
||||
}
|
||||
}
|
||||
stars = pow(stars, 1.4);
|
||||
stars *= night;
|
||||
stars *= smoothstep(-0.1, 0.25, height); // fade near horizon
|
||||
skyColor += vec3(1.0, 0.95, 0.9) * stars * 2.5;
|
||||
stars *= smoothstep(-0.1, 0.25, height);
|
||||
|
||||
// Subtle Milky Way band to add structure to the night sky
|
||||
vec3 galaxyAxis = normalize(vec3(0.2, 0.85, -0.5));
|
||||
float galaxyBand = 1.0 - abs(dot(dir, galaxyAxis)); // highest when perpendicular to the axis
|
||||
galaxyBand = pow(max(galaxyBand, 0.0), 2.5); // soften and widen
|
||||
vec3 galaxyCol = vec3(0.65, 0.78, 1.0) * galaxyBand * 0.5;
|
||||
galaxyCol *= smoothstep(-0.15, 0.25, height);
|
||||
|
||||
skyColor += vec3(1.0, 0.95, 0.9) * stars * 2.5 + galaxyCol;
|
||||
}
|
||||
|
||||
return skyColor;
|
||||
|
||||
Reference in New Issue
Block a user