Fixing lights and shadows
This commit is contained in:
1 parent
9f4d60036d
commit
bba493ee7c
18 files changed
+308
-126
No files matched your search
@@ -1,82 +1,92 @@
|
||||
{
|
||||
"lights": [
|
||||
{
|
||||
"id" : "main_hall",
|
||||
"positionX": -3.5951,
|
||||
"positionY": 6.0,
|
||||
"positionZ": 0.280929,
|
||||
"directionX": 0.0,
|
||||
"directionY": -1.0,
|
||||
"directionZ": 0.0,
|
||||
"colorR": 4.0,
|
||||
"colorG": 3.2,
|
||||
"colorB": 2.4
|
||||
},
|
||||
{
|
||||
"id" : "player_room",
|
||||
"autoLight": true,
|
||||
"autoLightDistance": 6.0,
|
||||
"positionX": 4.92215,
|
||||
"positionY": 4.0,
|
||||
"positionZ": -14.62,
|
||||
"directionX": 0.0,
|
||||
"directionY": -1.0,
|
||||
"directionZ": 0.0,
|
||||
"colorR": 2.0,
|
||||
"colorG": 1.6,
|
||||
"colorB": 1.2
|
||||
},
|
||||
{
|
||||
"id" : "laundry",
|
||||
"autoLight": true,
|
||||
"autoLightDistance": 6.0,
|
||||
"positionX": 4.65392,
|
||||
"positionY": 4.0,
|
||||
"positionZ": -20.0,
|
||||
"directionX": 0.0,
|
||||
"directionY": -1.0,
|
||||
"directionZ": 0.0,
|
||||
"colorR": 2.0,
|
||||
"colorG": 1.6,
|
||||
"colorB": 1.2
|
||||
},
|
||||
{
|
||||
"id" : "kitchen",
|
||||
"autoLight": true,
|
||||
"autoLightDistance": 6.0,
|
||||
"positionX": -5.21995,
|
||||
"positionY": 4.0,
|
||||
"positionZ": -20,
|
||||
"directionX": 0.0,
|
||||
"directionY": -1.0,
|
||||
"directionZ": 0.0,
|
||||
"colorR": 2.0,
|
||||
"colorG": 1.6,
|
||||
"colorB": 1.2
|
||||
},
|
||||
{
|
||||
"id" : "streetlight1",
|
||||
"positionX": -14.5,
|
||||
"positionY": 4.0,
|
||||
"positionZ": -14,
|
||||
"directionX": 0.0,
|
||||
"directionY": -1.0,
|
||||
"directionZ": 0.0,
|
||||
"colorR": 2.0,
|
||||
"colorG": 1.6,
|
||||
"colorB": 1.2
|
||||
},
|
||||
{
|
||||
"id" : "streetlight2",
|
||||
"positionX": -14.5,
|
||||
"positionY": 4.0,
|
||||
"positionZ": 14.0,
|
||||
"directionX": 0.0,
|
||||
"directionY": -1.0,
|
||||
"directionZ": 0.0,
|
||||
"colorR": 2.0,
|
||||
"colorG": 1.6,
|
||||
"colorB": 1.2
|
||||
}
|
||||
]
|
||||
}
|
||||
"lights": [
|
||||
{
|
||||
"id": "main_hall",
|
||||
"positionX": -3.1,
|
||||
"positionY": 6.0,
|
||||
"positionZ": 0.0,
|
||||
"directionX": 0.0,
|
||||
"directionY": -1.0,
|
||||
"directionZ": 0.0,
|
||||
"colorR": 4.0,
|
||||
"colorG": 3.2,
|
||||
"colorB": 2.4
|
||||
},
|
||||
{
|
||||
"id": "player_room",
|
||||
"autoLight": true,
|
||||
"autoLightLimitX": 3.75,
|
||||
"autoLightLimitY": 2.75,
|
||||
"limitX": 3.75,
|
||||
"limitY": 2.75,
|
||||
"positionX": 4.95,
|
||||
"positionY": 3.0,
|
||||
"positionZ": -14.25,
|
||||
"directionX": 0.0,
|
||||
"directionY": -1.0,
|
||||
"directionZ": 0.0,
|
||||
"colorR": 2.0,
|
||||
"colorG": 1.6,
|
||||
"colorB": 1.2
|
||||
},
|
||||
{
|
||||
"id": "laundry",
|
||||
"autoLight": true,
|
||||
"autoLightLimitX": 3.75,
|
||||
"autoLightLimitY": 2.75,
|
||||
"limitX": 3.75,
|
||||
"limitY": 2.75,
|
||||
"positionX": 4.95,
|
||||
"positionY": 4.0,
|
||||
"positionZ": -19.95,
|
||||
"directionX": 0.0,
|
||||
"directionY": -1.0,
|
||||
"directionZ": 0.0,
|
||||
"colorR": 2.0,
|
||||
"colorG": 1.6,
|
||||
"colorB": 1.2
|
||||
},
|
||||
{
|
||||
"id": "kitchen",
|
||||
"autoLight": true,
|
||||
"autoLightDistance": 6.0,
|
||||
"autoLightLimitX": 3.75,
|
||||
"autoLightLimitY": 2.75,
|
||||
"limitX": 3.75,
|
||||
"limitY": 2.75,
|
||||
"positionX": -4.95,
|
||||
"positionY": 4.0,
|
||||
"positionZ": -19.95,
|
||||
"directionX": 0.0,
|
||||
"directionY": -1.0,
|
||||
"directionZ": 0.0,
|
||||
"colorR": 2.0,
|
||||
"colorG": 1.6,
|
||||
"colorB": 1.2
|
||||
},
|
||||
{
|
||||
"id": "streetlight1",
|
||||
"positionX": -14.5,
|
||||
"positionY": 4.0,
|
||||
"positionZ": -14,
|
||||
"directionX": 0.0,
|
||||
"directionY": -1.0,
|
||||
"directionZ": 0.0,
|
||||
"colorR": 2.0,
|
||||
"colorG": 1.6,
|
||||
"colorB": 1.2
|
||||
},
|
||||
{
|
||||
"id": "streetlight2",
|
||||
"positionX": -14.5,
|
||||
"positionY": 4.0,
|
||||
"positionZ": 14.0,
|
||||
"directionX": 0.0,
|
||||
"directionY": -1.0,
|
||||
"directionZ": 0.0,
|
||||
"colorR": 2.0,
|
||||
"colorG": 1.6,
|
||||
"colorB": 1.2
|
||||
}
|
||||
]
|
||||
}
|
||||
@@ -2,9 +2,9 @@
|
||||
"lights": [
|
||||
{
|
||||
"id": "lamp_library",
|
||||
"positionX": 3.76222,
|
||||
"positionX": 3.750,
|
||||
"positionY": 5.0,
|
||||
"positionZ": 4.16035,
|
||||
"positionZ": 4.000,
|
||||
"directionX": 0.0,
|
||||
"directionY": -1.0,
|
||||
"directionZ": 0.0,
|
||||
@@ -12,13 +12,16 @@
|
||||
"colorG": 3.2,
|
||||
"colorB": 2.4,
|
||||
"autoLight": true,
|
||||
"autoLightDistance": 6.0
|
||||
"autoLightLimitX": 2.15,
|
||||
"autoLightLimitY": 3.9,
|
||||
"limitX": 2.15,
|
||||
"limitY": 3.9
|
||||
},
|
||||
{
|
||||
"id": "lamp_teacher_room",
|
||||
"positionX": -4.15666,
|
||||
"positionX": -3.750,
|
||||
"positionY": 5.0,
|
||||
"positionZ": 4.27091,
|
||||
"positionZ": 4.000,
|
||||
"directionX": 0.0,
|
||||
"directionY": -1.0,
|
||||
"directionZ": 0.0,
|
||||
@@ -26,13 +29,16 @@
|
||||
"colorG": 3.2,
|
||||
"colorB": 2.4,
|
||||
"autoLight": true,
|
||||
"autoLightDistance": 6.0
|
||||
"autoLightLimitX": 2.15,
|
||||
"autoLightLimitY": 3.9,
|
||||
"limitX": 2.15,
|
||||
"limitY": 3.9
|
||||
},
|
||||
{
|
||||
"id": "lamp_student_room",
|
||||
"positionX": 3.60541,
|
||||
"positionX": 3.750,
|
||||
"positionY": 5.0,
|
||||
"positionZ": -4.36552,
|
||||
"positionZ": -4.000,
|
||||
"directionX": 0.0,
|
||||
"directionY": -1.0,
|
||||
"directionZ": 0.0,
|
||||
@@ -40,13 +46,16 @@
|
||||
"colorG": 3.2,
|
||||
"colorB": 2.4,
|
||||
"autoLight": true,
|
||||
"autoLightDistance": 6.0
|
||||
"autoLightLimitX": 2.15,
|
||||
"autoLightLimitY": 3.9,
|
||||
"limitX": 2.15,
|
||||
"limitY": 3.9
|
||||
},
|
||||
{
|
||||
"id": "lamp_s1_room",
|
||||
"positionX": -3.90337,
|
||||
"positionX": -3.750,
|
||||
"positionY": 5.0,
|
||||
"positionZ": -4.00563,
|
||||
"positionZ": -4.000,
|
||||
"directionX": 0.0,
|
||||
"directionY": -1.0,
|
||||
"directionZ": 0.0,
|
||||
@@ -54,13 +63,16 @@
|
||||
"colorG": 3.2,
|
||||
"colorB": 2.4,
|
||||
"autoLight": true,
|
||||
"autoLightDistance": 6.0
|
||||
"autoLightLimitX": 2.15,
|
||||
"autoLightLimitY": 3.9,
|
||||
"limitX": 2.15,
|
||||
"limitY": 3.9
|
||||
},
|
||||
{
|
||||
"id": "lamp_s0_room",
|
||||
"positionX": -3.90337,
|
||||
"positionX": -3.750,
|
||||
"positionY": 5.0,
|
||||
"positionZ": -12.485,
|
||||
"positionZ": -12.0,
|
||||
"directionX": 0.0,
|
||||
"directionY": -1.0,
|
||||
"directionZ": 0.0,
|
||||
@@ -68,13 +80,16 @@
|
||||
"colorG": 3.2,
|
||||
"colorB": 2.4,
|
||||
"autoLight": true,
|
||||
"autoLightDistance": 6.0
|
||||
"autoLightLimitX": 2.15,
|
||||
"autoLightLimitY": 3.9,
|
||||
"limitX": 2.15,
|
||||
"limitY": 3.9
|
||||
},
|
||||
{
|
||||
"id": "lamp_hall_room",
|
||||
"positionX": 0.0,
|
||||
"positionY": 5.0,
|
||||
"positionZ": 11.7949,
|
||||
"positionZ": 12.0,
|
||||
"directionX": 0.0,
|
||||
"directionY": -1.0,
|
||||
"directionZ": 0.0,
|
||||
@@ -82,7 +97,10 @@
|
||||
"colorG": 3.2,
|
||||
"colorB": 2.4,
|
||||
"autoLight": true,
|
||||
"autoLightDistance": 6.0
|
||||
"autoLightLimitX": 5.8,
|
||||
"autoLightLimitY": 3.9,
|
||||
"limitX": 5.8,
|
||||
"limitY": 3.9
|
||||
}
|
||||
]
|
||||
}
|
||||
@@ -419,7 +419,7 @@
|
||||
"fadeInMs": 500,
|
||||
"endFadeOutMs": 0,
|
||||
"endFadeInMs": 500,
|
||||
"onFadeInCallback": "",
|
||||
"onFadeInCallback": "on_sleep_cutscene",
|
||||
"imageSegments": [
|
||||
{
|
||||
"path": "resources/black.png",
|
||||
|
||||
@@ -6,6 +6,7 @@ varying vec2 texCoord;
|
||||
varying float fogDistance;
|
||||
varying vec3 fragViewPos;
|
||||
varying vec3 fragNormal;
|
||||
varying vec2 fragWorldXZ;
|
||||
|
||||
uniform mat4 ProjectionModelViewMatrix;
|
||||
uniform mat4 ModelViewMatrix;
|
||||
@@ -19,4 +20,5 @@ void main()
|
||||
texCoord = vTexCoord;
|
||||
fragViewPos = eyePos.xyz;
|
||||
fragNormal = mat3(ModelViewMatrix) * vNormal;
|
||||
fragWorldXZ = vPosition.xz;
|
||||
}
|
||||
@@ -4,6 +4,8 @@ uniform int uPointLightCount;
|
||||
uniform vec3 uPointLightPos[4];
|
||||
uniform vec3 uPointLightDir[4];
|
||||
uniform vec3 uPointLightColor[4];
|
||||
uniform vec2 uPointLightWorldXZ[4];
|
||||
uniform vec2 uPointLightLimitXZ[4];
|
||||
uniform vec3 uAmbientColor;
|
||||
uniform vec3 uFogColor;
|
||||
|
||||
@@ -11,6 +13,7 @@ varying vec2 texCoord;
|
||||
varying float fogDistance;
|
||||
varying vec3 fragViewPos;
|
||||
varying vec3 fragNormal;
|
||||
varying vec2 fragWorldXZ;
|
||||
|
||||
// cos(45 deg) = half-angle for a 90-degree full-angle spotlight
|
||||
const float SPOT_COS_OUTER = 0.7071;
|
||||
@@ -44,7 +47,11 @@ void main()
|
||||
float atten = 1.0 / (1.0 + 0.35 * dist + 0.15 * dist * dist);
|
||||
float diff = hasNormal ? max(dot(N, lightDir), 0.0) : 1.0;
|
||||
|
||||
lighting += uPointLightColor[i] * diff * atten * spotAtten;
|
||||
vec2 worldDelta = abs(fragWorldXZ - uPointLightWorldXZ[i]);
|
||||
float rectX = 1.0 - smoothstep(uPointLightLimitXZ[i].x - 0.5, uPointLightLimitXZ[i].x + 0.5, worldDelta.x);
|
||||
float rectY = 1.0 - smoothstep(uPointLightLimitXZ[i].y - 0.5, uPointLightLimitXZ[i].y + 0.5, worldDelta.y);
|
||||
|
||||
lighting += uPointLightColor[i] * diff * atten * spotAtten * rectX * rectY;
|
||||
}
|
||||
|
||||
color.rgb *= lighting;
|
||||
|
||||
@@ -7,6 +7,7 @@ varying vec4 fragPosLightSpace;
|
||||
varying vec3 fragNormal;
|
||||
varying float fogDistance;
|
||||
varying vec3 fragViewPos;
|
||||
varying vec2 fragWorldXZ;
|
||||
|
||||
uniform mat4 ProjectionModelViewMatrix;
|
||||
uniform mat4 ModelViewMatrix;
|
||||
@@ -22,4 +23,5 @@ void main()
|
||||
fragViewPos = eyePos.xyz;
|
||||
fragNormal = mat3(ModelViewMatrix) * vNormal;
|
||||
fragPosLightSpace = uLightFromCamera * eyePos;
|
||||
fragWorldXZ = vPosition.xz;
|
||||
}
|
||||
@@ -6,6 +6,8 @@ uniform int uPointLightCount;
|
||||
uniform vec3 uPointLightPos[4];
|
||||
uniform vec3 uPointLightDir[4];
|
||||
uniform vec3 uPointLightColor[4];
|
||||
uniform vec2 uPointLightWorldXZ[4];
|
||||
uniform vec2 uPointLightLimitXZ[4];
|
||||
uniform vec3 uAmbientColor;
|
||||
uniform vec3 uFogColor;
|
||||
|
||||
@@ -14,6 +16,7 @@ varying vec4 fragPosLightSpace;
|
||||
varying vec3 fragNormal;
|
||||
varying float fogDistance;
|
||||
varying vec3 fragViewPos;
|
||||
varying vec2 fragWorldXZ;
|
||||
|
||||
const float SPOT_COS_OUTER = 0.7071;
|
||||
const float SPOT_COS_INNER = 0.82;
|
||||
@@ -83,7 +86,11 @@ void main()
|
||||
float atten = 1.0 / (1.0 + 0.35 * dist + 0.15 * dist * dist);
|
||||
float diff = hasNormal ? max(dot(N, lightDir), 0.0) : 1.0;
|
||||
|
||||
lighting += uPointLightColor[i] * diff * atten * spotAtten * (1.0 - shadow);
|
||||
vec2 worldDelta = abs(fragWorldXZ - uPointLightWorldXZ[i]);
|
||||
float rectX = 1.0 - smoothstep(uPointLightLimitXZ[i].x - 0.5, uPointLightLimitXZ[i].x + 0.5, worldDelta.x);
|
||||
float rectY = 1.0 - smoothstep(uPointLightLimitXZ[i].y - 0.5, uPointLightLimitXZ[i].y + 0.5, worldDelta.y);
|
||||
|
||||
lighting += uPointLightColor[i] * diff * atten * spotAtten * rectX * rectY * (1.0 - shadow);
|
||||
}
|
||||
|
||||
color.rgb *= lighting;
|
||||
|
||||
@@ -8,6 +8,8 @@ uniform int uPointLightCount;
|
||||
uniform vec3 uPointLightPos[4];
|
||||
uniform vec3 uPointLightDir[4];
|
||||
uniform vec3 uPointLightColor[4];
|
||||
uniform vec2 uPointLightWorldXZ[4];
|
||||
uniform vec2 uPointLightLimitXZ[4];
|
||||
uniform vec3 uAmbientColor;
|
||||
uniform vec3 uFogColor;
|
||||
|
||||
@@ -16,6 +18,7 @@ varying vec4 fragPosLightSpace;
|
||||
varying vec3 fragNormal;
|
||||
varying float fogDistance;
|
||||
varying vec3 fragViewPos;
|
||||
varying vec2 fragWorldXZ;
|
||||
|
||||
const float SPOT_COS_OUTER = 0.7071;
|
||||
const float SPOT_COS_INNER = 0.82;
|
||||
@@ -85,7 +88,11 @@ void main()
|
||||
float atten = 1.0 / (1.0 + 0.35 * dist + 0.15 * dist * dist);
|
||||
float diff = hasNormal ? max(dot(N, lightDir), 0.0) : 1.0;
|
||||
|
||||
lighting += uPointLightColor[i] * diff * atten * spotAtten * (1.0 - shadow);
|
||||
vec2 worldDelta = abs(fragWorldXZ - uPointLightWorldXZ[i]);
|
||||
float rectX = 1.0 - smoothstep(uPointLightLimitXZ[i].x - 0.5, uPointLightLimitXZ[i].x + 0.5, worldDelta.x);
|
||||
float rectY = 1.0 - smoothstep(uPointLightLimitXZ[i].y - 0.5, uPointLightLimitXZ[i].y + 0.5, worldDelta.y);
|
||||
|
||||
lighting += uPointLightColor[i] * diff * atten * spotAtten * rectX * rectY * (1.0 - shadow);
|
||||
}
|
||||
|
||||
color.rgb *= lighting;
|
||||
|
||||
@@ -10,9 +10,11 @@ varying vec2 texCoord;
|
||||
varying float fogDistance;
|
||||
varying vec3 fragViewPos;
|
||||
varying vec3 fragNormal;
|
||||
varying vec2 fragWorldXZ;
|
||||
|
||||
uniform mat4 ProjectionModelViewMatrix;
|
||||
uniform mat4 ModelViewMatrix;
|
||||
uniform mat4 uViewInverse;
|
||||
uniform mat4 uBoneMatrices[58];
|
||||
uniform vec3 uPlayerEyePos;
|
||||
|
||||
@@ -65,4 +67,5 @@ void main()
|
||||
texCoord = vTexCoord;
|
||||
fragViewPos = eyePos.xyz;
|
||||
fragNormal = mat3(ModelViewMatrix) * skinnedNormal;
|
||||
fragWorldXZ = (uViewInverse * eyePos).xz;
|
||||
}
|
||||
@@ -11,10 +11,12 @@ varying vec4 fragPosLightSpace;
|
||||
varying vec3 fragNormal;
|
||||
varying float fogDistance;
|
||||
varying vec3 fragViewPos;
|
||||
varying vec2 fragWorldXZ;
|
||||
|
||||
uniform mat4 ProjectionModelViewMatrix;
|
||||
uniform mat4 ModelViewMatrix;
|
||||
uniform mat4 uLightFromCamera;
|
||||
uniform mat4 uViewInverse;
|
||||
uniform mat4 uBoneMatrices[58];
|
||||
uniform vec3 uPlayerEyePos;
|
||||
|
||||
@@ -68,4 +70,5 @@ void main()
|
||||
fragViewPos = eyePos.xyz;
|
||||
fragNormal = mat3(ModelViewMatrix) * skinnedNormal;
|
||||
fragPosLightSpace = uLightFromCamera * eyePos;
|
||||
fragWorldXZ = (uViewInverse * eyePos).xz;
|
||||
}
|
||||
@@ -6,6 +6,8 @@ uniform int uPointLightCount;
|
||||
uniform vec3 uPointLightPos[4];
|
||||
uniform vec3 uPointLightDir[4];
|
||||
uniform vec3 uPointLightColor[4];
|
||||
uniform vec2 uPointLightWorldXZ[4];
|
||||
uniform vec2 uPointLightLimitXZ[4];
|
||||
uniform vec3 uAmbientColor;
|
||||
uniform vec3 uFogColor;
|
||||
|
||||
@@ -13,6 +15,7 @@ varying vec2 texCoord;
|
||||
varying float fogDistance;
|
||||
varying vec3 fragViewPos;
|
||||
varying vec3 fragNormal;
|
||||
varying vec2 fragWorldXZ;
|
||||
|
||||
// cos(45 deg) = half-angle for a 90-degree full-angle spotlight
|
||||
const float SPOT_COS_OUTER = 0.7071;
|
||||
@@ -46,7 +49,11 @@ void main()
|
||||
float atten = 1.0 / (1.0 + 0.35 * dist + 0.15 * dist * dist);
|
||||
float diff = hasNormal ? max(dot(N, lightDir), 0.0) : 1.0;
|
||||
|
||||
lighting += uPointLightColor[i] * diff * atten * spotAtten;
|
||||
vec2 worldDelta = abs(fragWorldXZ - uPointLightWorldXZ[i]);
|
||||
float rectX = 1.0 - smoothstep(uPointLightLimitXZ[i].x - 0.5, uPointLightLimitXZ[i].x + 0.5, worldDelta.x);
|
||||
float rectY = 1.0 - smoothstep(uPointLightLimitXZ[i].y - 0.5, uPointLightLimitXZ[i].y + 0.5, worldDelta.y);
|
||||
|
||||
lighting += uPointLightColor[i] * diff * atten * spotAtten * rectX * rectY;
|
||||
}
|
||||
|
||||
color.rgb *= lighting;
|
||||
|
||||
Reference in new issue
Block a user