Skip to content

Commit

Permalink
Refactor: Simplify the RSW directional light computation
Browse files Browse the repository at this point in the history
This also accounts for the inverted Y axis, but makes it clearer that the sunlight origin is located directly above the map.
  • Loading branch information
rdw-software committed Jan 30, 2024
1 parent 9ba4550 commit 743dc11
Showing 1 changed file with 2 additions and 4 deletions.
6 changes: 2 additions & 4 deletions Core/FileFormats/RagnarokRSW.lua
Original file line number Diff line number Diff line change
Expand Up @@ -253,16 +253,14 @@ function RagnarokRSW:DecodeEnvironmentalLightSources()
end

function RagnarokRSW:ComputeSunRayDirection(latitudeInDegrees, longitudeInDegrees)
local sunRayDirection = Vector3D(0, 1, 0)
local sunRayDirection = Vector3D(0, -1, 0)

local rotationAroundX = Matrix3D:CreateAxisRotationX(latitudeInDegrees)
local rotationAroundX = Matrix3D:CreateAxisRotationX(-latitudeInDegrees) -- Account for inverted Y axis
local rotationAroundY = Matrix3D:CreateAxisRotationY(longitudeInDegrees)

sunRayDirection:Transform(rotationAroundX)
sunRayDirection:Transform(rotationAroundY)

sunRayDirection.y = -1 * sunRayDirection.y

return sunRayDirection
end

Expand Down

0 comments on commit 743dc11

Please sign in to comment.