Need inverse(modelMatrix) uniform in shaders

Description of the problem

Currently, there is no way to expose the inverse of the modelMatrix to a shader, which means you must write an inverse function in the shader, which is slow on older devices.

It would seem there is no way to expose this without hacking the Three.js source.

For reference, Unity provides this matrix as a built-in value:
https://docs.unity3d.com/Manual/SL-UnityShaderVariables.html

Three.js version
  • all
Browser
  • All of them
OS
  • All of them
Hardware Requirements (graphics card, VR Device, …)

N/A

Author: Fantashit

3 thoughts on “Need inverse(modelMatrix) uniform in shaders

  1. which means you must write an inverse function in the shader

    Not necessarily. See the section Transforming Points with the Inverse Matrix in this link.

  2. @pailhead I’m glad we’re starting to understand each other 🙂

    I’ll hack up the onBeforeRender approach and see how it works, though I’m pretty strapped for time currently. I’m still more in favor of what I’m proposing, but you and @WestLangley are right, I should definitely give it a try, look at the resulting code, and run some profiles.

Comments are closed.