<h5 dir="auto">Description of the problem</h5>
<p dir="auto">Feature request: Add <code class="notranslate">modelViewProjection</code> matrix to all shaders as a global uniform. Right now every vertex shader I see using three js has to do a <code class="notranslate">projectionMatrix * modelViewMatrix</code> in order to get the object to clip position.</p>
<p dir="auto">The multiplication should be able to be done on the CPU in something like a onPreRender callback and sent down to the shader as a <code class="notranslate">mat4 modelViewProjection</code> uniform. This saves a matrix multiply in the vertex shader. The clip position can then be computed via <code class="notranslate">modelViewProjection * objPosition</code>.</p>
<h5 dir="auto">Three.js version</h5>
<ul class="contains-task-list">
<li class="task-list-item"><input type="checkbox" id="" disabled="" class="task-list-item-checkbox" checked=""> r106</li>
</ul>
<h5 dir="auto">Browser</h5>
<ul class="contains-task-list">
<li class="task-list-item"><input type="checkbox" id="" disabled="" class="task-list-item-checkbox" checked=""> All of them</li>
</ul>
<h5 dir="auto">OS</h5>
<ul class="contains-task-list">
<li class="task-list-item"><input type="checkbox" id="" disabled="" class="task-list-item-checkbox" checked=""> All of them</li>
</ul>
<p dir="auto">Right now shaders do this to transform a vertex:</p>
<div class="snippet-clipboard-content notranslate position-relative overflow-auto" data-snippet-clipboard-copy-content="gl_Position = projectionMatrix * modelViewMatrix * vec4( position, 1.0 );"><pre class="notranslate"><code class="notranslate">gl_Position = projectionMatrix * modelViewMatrix * vec4( position, 1.0 );
</code></pre></div>
<p dir="auto">Instead we could have this, saving one matrix multiplication per transformation:</p>
<div class="snippet-clipboard-content notranslate position-relative overflow-auto" data-snippet-clipboard-copy-content="gl_Position = modelViewProjectionMatrix * vec4( position, 1.0 );"><pre class="notranslate"><code class="notranslate">gl_Position = modelViewProjectionMatrix * vec4( position, 1.0 );
</code></pre></div>
<p dir="auto">So we introduce a new premultiplied <code class="notranslate">uniform mat4 modelViewProjectionMatrix</code>.</p>
<p dir="auto">Any comments?</p>