Skip to content
GitLab
    • GitLab: the DevOps platform
    • Explore GitLab
    • Install GitLab
    • How GitLab compares
    • Get started
    • GitLab docs
    • GitLab Learn
  • Pricing
  • Talk to an expert
  • /
  • Help
    • Help
    • Support
    • Community forum
    • Submit feedback
    • Contribute to GitLab
    • Switch to GitLab Next
    Projects Groups Topics Snippets
  • Register
  • Sign in
  • openmw openmw
  • Project information
    • Project information
    • Activity
    • Labels
    • Members
  • Repository
    • Repository
    • Files
    • Commits
    • Branches
    • Tags
    • Contributor statistics
    • Graph
    • Compare revisions
    • Locked files
  • Issues 833
    • Issues 833
    • List
    • Boards
    • Service Desk
    • Milestones
    • Iterations
  • Merge requests 34
    • Merge requests 34
  • CI/CD
    • CI/CD
    • Pipelines
    • Jobs
    • Schedules
    • Test cases
  • Deployments
    • Deployments
    • Releases
  • Analytics
    • Analytics
    • Value stream
    • CI/CD
    • Code review
    • Insights
    • Issue
    • Repository
  • Activity
  • Graph
  • Create a new issue
  • Jobs
  • Commits
  • Issue Boards
Collapse sidebar
  • OpenMWOpenMW
  • openmwopenmw
  • Issues
  • #5995
Closed
Open
Issue created Apr 30, 2021 by Alexei Kotov@CapostrophicDeveloper

NiUVController doesn't calculate the UV offset properly

Found by Kurp. Problem 10 in #5988.

NiUVController is a controller that animates UV transformations. It can change the texture's offset and scale and is commonly used in Morrowind to simulate liquid movement (moving water, lava and lava crust).

The movement is currently implemented through a texture transformation matrix. Originally after the OSG port it scaled the texture relative to its origin (lower left corner in OpenGL) and then added the UV offsets to the texture coordinates. All of these operations are wrong, as NiUVController
a) is supposed to scale the texture relative to its center;
b) uses a coordinate system where the X axis is directed west and Y axis is directed south. while OpenGL uses a coordinate system where the Y axis is directed north.

The last mentioned issue was later attempted to be corrected by scrawl, but he used a flip matrix that still only makes sense if you flip the texture relative to a corner origin and not the center, so while it fixed Vivec waterfalls:

#3203 (closed)
model: Ex_Vivec_waterfall_01.nif

it only made the other offset issues worse, as Kurp found out (see the relevant model and report in #5988).

And this model demonstrates the flipped horizontal offset issue: testxoffset.nif

In both Morrowind and NifSkope the picture is moving to the lower left corner while in the current OpenMW it is moving to the lower right corner.

So the calculated UV offset needs to be adjusted to make the scaling relative to the origin while both the horizontal and the vertical offset need to be subtracted from the texture coordinates. The resulting transformation should roughly be the same as in NifSkope and Greatness7's Blender NIF plugin (which in their turn act the same as SceneImmerse, which in its turn should be identical to Morrowind) except NifSkope doesn't flip the vertical offset as it doesn't need to.

Edited Apr 30, 2021 by Alexei Kotov
Assignee
Assign to
Time tracking