Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -490,7 +490,7 @@ private void PrepareItems()
Yaw = ToTrAngle(instance.RotationY),
Pitch = ToTrAngle(instance.RotationX),
Roll = ToTrAngle(-instance.Roll),
Color = new Vector4(instance.Color.X, instance.Color.Y, instance.Color.Z, 1.0f),
Color = new Vector4(instance.Color.X * 0.5f, instance.Color.Y * 0.5f, instance.Color.Z * 0.5f, 1.0f), // Normalize to 0...1 range
OCB = instance.Ocb,
Flags = unchecked((ushort)flags),
LuaName = instance.LuaName ?? string.Empty
Expand Down
22 changes: 11 additions & 11 deletions TombLib/TombLib/LevelData/Compilers/TombEngine/Rooms.cs
Original file line number Diff line number Diff line change
Expand Up @@ -123,7 +123,8 @@ private Vector3 CalculateLightForCustomVertex(Room room, Vector3 position, Vecto
output += RoomGeometry.CalculateLightForVertex(room, light, position, normal, false, false);
}

return Vector3.Max(output, new Vector3()) * (1.0f / 128.0f);
// Normalize to 0...1 range
return Vector3.Max(output, new Vector3()) * (1.0f / 255.0f);
}

private TombEngineRoom BuildRoom(Room room)
Expand Down Expand Up @@ -167,7 +168,7 @@ private TombEngineRoom BuildRoom(Room room)
newRoom.AlternateKind = AlternateKind.BaseRoom;

// Store ambient intensity
newRoom.AmbientLight = room.Properties.AmbientLight;
newRoom.AmbientLight = room.Properties.AmbientLight * 0.5f; // Normalize to 0...1 range

// Room flags
if (room.Properties.FlagHorizon)
Expand Down Expand Up @@ -474,12 +475,12 @@ private TombEngineRoom BuildRoom(Room room)
// Apply Shade factor
color *= shade;
// Apply Instance Color
color *= staticMesh.Color;
color *= staticMesh.Color * 0.5f; // Normalize to 0...1 range
}
else
{
color = CalculateLightForCustomVertex(room, position, normal, false, staticMesh.Color * 128);
//Apply Shade factor
// Apply Shade factor
color *= shade;
}

Expand Down Expand Up @@ -623,8 +624,7 @@ private TombEngineRoom BuildRoom(Room room)
}
else
{
var color = room.Properties.AmbientLight;
trVertex.Color = color;
trVertex.Color = room.Properties.AmbientLight * 0.5f; // Normalize to 0...1 range
}

// HACK: Find a vertex with same coordinates and merge with it.
Expand Down Expand Up @@ -904,10 +904,10 @@ private TombEngineRoom BuildRoom(Room room)
Scale = instance.Scale,
ObjectID = checked((ushort)instance.WadObjectId.TypeId),
Flags = (ushort)(0x0007), // FIXME: later let user choose if solid (0x0007) or soft (0x0005)!
Color = new Vector4(instance.Color.X, instance.Color.Y, instance.Color.Z, 1.0f),
HitPoints = 0,
Color = new Vector4(instance.Color.X * 0.5f, instance.Color.Y * 0.5f, instance.Color.Z * 0.5f, 1.0f), // Normalize to 0...1 range
HitPoints = 0,
LuaName = instance.LuaName ?? string.Empty
}) ;
});
}

ConvertLights(room, newRoom);
Expand All @@ -921,7 +921,7 @@ private static int GetOrAddVertex(Room room, Dictionary<int, int> roomVerticesDi
var trVertex = new TombEngineVertex();

trVertex.Position = new Vector3(Position.X, -(Position.Y + room.WorldPos.Y), Position.Z);
trVertex.Color = color;
trVertex.Color = color * 0.5f; // Normalize to 0...1 range
trVertex.IsOnPortal = false;
trVertex.IndexInPoly = index;

Expand Down Expand Up @@ -955,7 +955,7 @@ private void ConvertLights(Room room, TombEngineRoom newRoom)
(int)Math.Round(newRoom.Info.X + light.Position.X),
(int)-Math.Round(light.Position.Y + room.WorldPos.Y),
(int)Math.Round(newRoom.Info.Z + light.Position.Z)),
Color = light.Color,
Color = light.Color * 0.5f, // Normalize to 0...1 range
Intensity = light.Intensity
};

Expand Down