Working with lights and shadows

This commit is contained in:
Vladislav Khorev 2026-06-04 16:35:01 +03:00
parent e3542b59f7
commit ed8d6f2e92
8 changed files with 32 additions and 6 deletions

View File

@ -406,6 +406,7 @@
"name": "Room_Cover_Bath_W_N_2_001",
"texturePath": "resources/black.png",
"meshPath": "resources/w/dorm2/Room_Cover_North_West_1_Bath_001.txt",
"castShadowNight" : false,
"rotationX": 0.0,
"rotationY": 0.0,
"rotationZ": 0.0,
@ -419,6 +420,7 @@
"name": "Room_Cover_LivingRoom_W_N_2_001",
"texturePath": "resources/black.png",
"meshPath": "resources/w/dorm2/Room_Cover_North_West_1_RoomB_001.txt",
"castShadowNight" : false,
"rotationX": 0.0,
"rotationY": 0.0,
"rotationZ": 0.0,
@ -432,6 +434,7 @@
"name": "Room_Cover_LivingRoom_W_S_2_001",
"texturePath": "resources/black.png",
"meshPath": "resources/w/dorm2/Room_Cover_South_West_1_RoomB_001.txt",
"castShadowNight" : false,
"rotationX": 0.0,
"rotationY": 0.0,
"rotationZ": 0.0,
@ -445,6 +448,7 @@
"name": "Room_Cover_Main_Hall_And_Corridors_002",
"texturePath": "resources/black.png",
"meshPath": "resources/w/dorm2/Room_Cover_Main_Hall_Corridor_001.txt",
"castShadowNight" : false,
"rotationX": 0.0,
"rotationY": 0.0,
"rotationZ": 0.0,
@ -458,6 +462,7 @@
"name": "Room_Cover_Others_001",
"texturePath": "resources/black.png",
"meshPath": "resources/w/dorm2/Room_Cover_All_001.txt",
"castShadowNight" : false,
"rotationX": 0.0,
"rotationY": 0.0,
"rotationZ": 0.0,
@ -471,6 +476,7 @@
"name": "Room_Cover_Utility_W_N_3_001",
"texturePath": "resources/black.png",
"meshPath": "resources/w/dorm2/Room_Cover_North_West_2_Utility_001.txt",
"castShadowNight" : false,
"rotationX": 0.0,
"rotationY": 0.0,
"rotationZ": 0.0,
@ -484,6 +490,7 @@
"name": "Room_Cover_Utility_W_S_3_001",
"texturePath": "resources/black.png",
"meshPath": "resources/w/dorm2/Room_Cover_South_West_2_Utility_001.txt",
"castShadowNight" : false,
"rotationX": 0.0,
"rotationY": 0.0,
"rotationZ": 0.0,

View File

@ -307,6 +307,7 @@
"name": "Room_Cover_Corridor_001",
"texturePath": "resources/black.png",
"meshPath": "resources/w/interior/Room_Cover_Corridor_002.txt",
"castShadowNight" : false,
"rotationX": 0.0,
"rotationY": 0.0,
"rotationZ": 0.0,
@ -323,6 +324,7 @@
"name": "Room_Cover_Main_Hall_001",
"texturePath": "resources/black.png",
"meshPath": "resources/w/interior/Room_Cover_Main_Hall_002.txt",
"castShadowNight" : false,
"rotationX": 0.0,
"rotationY": 0.0,
"rotationZ": 0.0,
@ -339,6 +341,7 @@
"name": "Room_Cover_North_1_001",
"texturePath": "resources/black.png",
"meshPath": "resources/w/interior/Room_Cover_North_1_002.txt",
"castShadowNight" : false,
"rotationX": 0.0,
"rotationY": 0.0,
"rotationZ": 0.0,
@ -355,6 +358,7 @@
"name": "Room_Cover_South_1_001",
"texturePath": "resources/black.png",
"meshPath": "resources/w/interior/Room_Cover_South_1_002.txt",
"castShadowNight" : false,
"rotationX": 0.0,
"rotationY": 0.0,
"rotationZ": 0.0,
@ -371,6 +375,7 @@
"name": "Room_Cover_North_2_001",
"texturePath": "resources/black.png",
"meshPath": "resources/w/interior/Room_Cover_North_2_002.txt",
"castShadowNight" : false,
"rotationX": 0.0,
"rotationY": 0.0,
"rotationZ": 0.0,
@ -387,6 +392,7 @@
"name": "Room_Cover_South_2_001",
"texturePath": "resources/black.png",
"meshPath": "resources/w/interior/Room_Cover_South_2_002.txt",
"castShadowNight" : false,
"rotationX": 0.0,
"rotationY": 0.0,
"rotationZ": 0.0,
@ -403,6 +409,7 @@
"name": "Room_Cover_North_3_001",
"texturePath": "resources/black.png",
"meshPath": "resources/w/interior/Room_Cover_North_3_002.txt",
"castShadowNight" : false,
"rotationX": 0.0,
"rotationY": 0.0,
"rotationZ": 0.0,
@ -419,6 +426,7 @@
"name": "Room_Cover_South_3_001",
"texturePath": "resources/black.png",
"meshPath": "resources/w/interior/Room_Cover_South_3_002.txt",
"castShadowNight" : false,
"rotationX": 0.0,
"rotationY": 0.0,
"rotationZ": 0.0,

View File

@ -53,8 +53,8 @@ void main()
if (color.a < 0.1)
discard;
float ambient = 0.4;
float diffuseStrength = 0.6;
float ambient = 0.75;
float diffuseStrength = 0.25;
// Compute diffuse term; if normals are missing (zero-length) treat as fully lit
float diffuse = 1.0;

View File

@ -53,8 +53,8 @@ void main()
if (color.a < 0.1)
discard;
float ambient = 0.4;
float diffuseStrength = 0.6;
float ambient = 0.75;
float diffuseStrength = 0.25;
float diffuse = 1.0;
vec3 n = fragNormal;

View File

@ -713,7 +713,7 @@ namespace ZL
}
for (auto& intObj : interactiveObjects) {
if (intObj.isActive && intObj.loadedObject.texture) {
if (intObj.castShadow && intObj.loadedObject.texture) {
renderer.PushMatrix();
renderer.TranslateMatrix(intObj.position);
renderer.DrawVertexRenderStruct(intObj.loadedObject.mesh);
@ -957,7 +957,7 @@ namespace ZL
renderer.DrawVertexRenderStruct(gameObj.mesh);
}
for (auto& intObj : interactiveObjects) {
if (intObj.isActive && intObj.loadedObject.texture) {
if (intObj.castShadowNight && intObj.loadedObject.texture) {
renderer.PushMatrix();
renderer.TranslateMatrix(intObj.position);
renderer.DrawVertexRenderStruct(intObj.loadedObject.mesh);

View File

@ -94,6 +94,9 @@ namespace ZL {
data.base = parseGameObjectData(item);
data.interactionRadius = item.value("interactionRadius", 2.0f);
data.approachRadius = item.value("approachRadius", data.interactionRadius);
data.castShadow = item.value("castShadow", true);
data.castShadowNight = item.value("castShadowNight", true);
data.isActive = item.value("isActive", true);
data.activateFunctionName = item.value("activateFunction", "");
data.pivotX = item.value("pivotX", 0.0f);
data.pivotY = item.value("pivotY", 0.0f);
@ -196,6 +199,9 @@ namespace ZL {
intObj.loadedObject = buildLoadedObject(data.base, renderer, zipPath);
intObj.interactionRadius = data.interactionRadius;
intObj.approachRadius = data.approachRadius;
intObj.castShadow = data.castShadow;
intObj.castShadowNight = data.castShadowNight;
intObj.isActive = data.isActive;
intObj.activateFunctionName = data.activateFunctionName;
intObj.pivot = Eigen::Vector3f(data.pivotX, data.pivotY, data.pivotZ);
intObj.boundsMin = Eigen::Vector3f(data.boundsMinX, data.boundsMinY, data.boundsMinZ);

View File

@ -38,6 +38,9 @@ namespace ZL {
float boundsMaxX = 0.0f, boundsMaxY = 0.0f, boundsMaxZ = 0.0f;
bool hasInteractionPosition = false;
float interactionPositionX = 0.0f, interactionPositionY = 0.0f, interactionPositionZ = 0.0f;
bool castShadow = true;
bool castShadowNight = true;
bool isActive = true;
};
struct NpcData {

View File

@ -42,6 +42,8 @@ namespace ZL {
bool hasInteractionPosition = false;
bool isActive = true;
bool isAnimating = false; // true while a timed animation is running
bool castShadow = true; // included in day shadow depth pass regardless of isActive
bool castShadowNight = true; // included in night shadow depth pass regardless of isActive
std::string activateFunctionName;
struct AnimTask {