Permalink
Browse files

Environment improvements

  • Loading branch information...
gecko0307 committed Dec 4, 2017
1 parent 6b5cc0d commit 9195f92261673b02da8f4a46eb4fea4e6c5bf33c
@@ -70,12 +70,12 @@ class Environment: Owner
Color4f skyZenithColor = Color4f(0.223, 0.572, 0.752, 1.0);
Color4f skyHorizonColor = Color4f(0.9, 1.0, 1.0, 1.0);
Color4f skyZenithColorAtMidday = Color4f(0.223, 0.572, 0.752, 1.0);
Color4f skyZenithColorAtSunset = Color4f(0.149, 0.243, 0.290, 1.0);
Color4f skyZenithColorAtNight = Color4f(0.1, 0.2, 0.4, 1.0);
Color4f skyZenithColorAtMidday = Color4f(0.4, 0.6, 0.8, 1.0);
Color4f skyZenithColorAtSunset = Color4f(0.1, 0.13, 0.14, 1.0);
Color4f skyZenithColorAtNight = Color4f(0.01, 0.05, 0.1, 1.0);
Color4f skyHorizonColorAtMidday = Color4f(0.9, 1.0, 1.0, 1.0);
Color4f skyHorizonColorAtSunset = Color4f(0.5, 0.2, 0.1, 1.0);
Color4f skyHorizonColorAtMidday = Color4f(0.5, 0.6, 0.65, 1.0);
Color4f skyHorizonColorAtSunset = Color4f(0.87, 0.44, 0.1, 1.0);
Color4f skyHorizonColorAtNight = Color4f(0.1, 0.1, 0.1, 1.0);
bool useSkyColors = false;
@@ -229,10 +229,10 @@ class PBRClusteredBackend: GLSLMaterialBackend
return s;
}
float weight(in vec4 tc)
float weight(in vec4 tc, in float coef)
{
vec2 proj = vec2(tc.x / tc.w, tc.y / tc.w);
proj = (1.0 - abs(proj * 2.0 - 1.0)) * 8.0;
proj = (1.0 - abs(proj * 2.0 - 1.0)) * coef;
proj = clamp(proj, 0.0, 1.0);
return min(proj.x, proj.y);
}
@@ -265,7 +265,7 @@ class PBRClusteredBackend: GLSLMaterialBackend
{
float lambert = max(0.0, dot(-wSunDir, wNormal));
float sun = pow(lambert, 200.0);
vec3 horizon = mix(skyHorizonColor, sunColor, lambert);
vec3 horizon = mix(skyHorizonColor, skyHorizonColor + sunColor * 0.2, lambert);
vec3 zen = mix(groundColor * sunColor, skyZenithColor, float(wNormal.y > 0.0));
vec3 skyColor = mix(zen, horizon, pow(length(wNormal.xz), 128.0 * gloss));
return skyColor;
@@ -330,9 +330,9 @@ class PBRClusteredBackend: GLSLMaterialBackend
s1 = pcf(shadowTextureArray, 0.0, shadowCoord1, 2.0, 0.0);
s2 = pcf(shadowTextureArray, 1.0, shadowCoord2, 1.0, 0.0);
s3 = pcf(shadowTextureArray, 2.0, shadowCoord3, 1.0, 0.0);
float w1 = weight(shadowCoord1);
float w2 = weight(shadowCoord2);
float w3 = weight(shadowCoord3);
float w1 = weight(shadowCoord1, 8.0);
float w2 = weight(shadowCoord2, 8.0);
float w3 = weight(shadowCoord3, 2.0);
s3 = mix(1.0, s3, w3);
s2 = mix(s3, s2, w2);
s1 = mix(s2, s1, w1); // s1 stores resulting shadow value
@@ -87,7 +87,7 @@ class SkyBackend: GLSLMaterialBackend
vec3 normalWorldN = normalize(worldNormal);
float lambert = max(0.0, dot(-sunDirection, normalWorldN));
float sun = pow(lambert, 200.0);
vec3 horizon = mix(skyHorizonColor, sunColor, lambert);
vec3 horizon = mix(skyHorizonColor, skyHorizonColor + sunColor * 0.2, lambert);
vec3 skyColor = mix(skyZenithColor, horizon, pow(length(normalWorldN.xz), 96.0));
frag_color = vec4(skyColor + sunColor * sun, 1.0);
}
@@ -446,7 +446,7 @@ class BaseScene3D: Scene
lightManager = New!ClusteredLightManager(200.0f, 100, assetManager);
defaultMaterialBackend = New!BlinnPhongClusteredBackend(lightManager, assetManager);
shadowMap = New!CascadedShadowMap(1024, this, 10, 50, 400, -100, 100, assetManager);
shadowMap = New!CascadedShadowMap(1024, this, 10, 30, 100, -100, 100, assetManager);
defaultMaterialBackend.shadowMap = shadowMap;
defaultMaterial3D = createMaterial();

0 comments on commit 9195f92

Please sign in to comment.