<p dir="auto">When working on the Multiview PR <a class="issue-link js-issue-link" data-error-text="Failed to load title" data-id="436163421" data-permission-text="Title is private" data-url="https://github.com/mrdoob/three.js/issues/16316" data-hovercard-type="pull_request" data-hovercard-url="/mrdoob/three.js/pull/16316/hovercard" href="https://github.com/mrdoob/three.js/pull/16316">#16316</a> I'm facing a problem with the shader generation: If you are going to use multiview you need to add an specific directive on the shader: <code class="notranslate">layout(num_views = 2) in;</code>. This will require a FBO with a TextureArray2D attached with two views.</p>
<p dir="auto">Typically if we require a multiview session is because we are going to use an <code class="notranslate">ArrayCamera</code> with multiple views (as a CAD software) or we want to render both eyes in VR so we will get a huge improvement. But if we render just 1 view it will add a penalty because we will sill be using a two-dimensional FBO.</p>
<p dir="auto">Ideally we could have a "simple" way to compile the same program for different "app's presets" so we could switch between the programs as the presets change.<br>
For example we could compile the with or without multiview and use these shaders depending if we are in VR presenting or just painting in 2D to the canvas.</p>
<p dir="auto">Is there any ideas or any similar work already done in this area?</p>
<p dir="auto">It would be necessary to have multiple multiple webglprogram on a single material to solve <a class="issue-link js-issue-link" data-error-text="Failed to load title" data-id="231769076" data-permission-text="Title is private" data-url="https://github.com/mrdoob/three.js/issues/11400" data-hovercard-type="issue" data-hovercard-url="/mrdoob/three.js/issues/11400/hovercard" href="https://github.com/mrdoob/three.js/issues/11400">#11400</a>.</p>
<p dir="auto">This would require several steps to be taken to get this done:</p>
<ul class="contains-task-list">
<li class="task-list-item"><input type="checkbox" id="" disabled="" class="task-list-item-checkbox" checked=""> Figuring out what parameters are necessary to generate a webglprogram and use a single parameter source to create it. (<a class="issue-link js-issue-link" data-error-text="Failed to load title" data-id="544223064" data-permission-text="Title is private" data-url="https://github.com/mrdoob/three.js/issues/18279" data-hovercard-type="pull_request" data-hovercard-url="/mrdoob/three.js/pull/18279/hovercard" href="https://github.com/mrdoob/three.js/pull/18279">#18279</a>)</li>
<li class="task-list-item"><input type="checkbox" id="" disabled="" class="task-list-item-checkbox"> Build single parameter source from 4 parameter sources: material, object, renderer, scene.
<ul class="contains-task-list">
<li class="task-list-item"><input type="checkbox" id="" disabled="" class="task-list-item-checkbox"> Material parameter: gets regenerated when needsUpdate is true</li>
<li class="task-list-item"><input type="checkbox" id="" disabled="" class="task-list-item-checkbox"> Renderer parameter: gets regenerated every render</li>
<li class="task-list-item"><input type="checkbox" id="" disabled="" class="task-list-item-checkbox"> Scene parameter: gets regenerated every render</li>
<li class="task-list-item"><input type="checkbox" id="" disabled="" class="task-list-item-checkbox"> object parameter: gets regenerated every ??</li>
</ul>
</li>
<li class="task-list-item"><input type="checkbox" id="" disabled="" class="task-list-item-checkbox"> Create keys based of the 4 parameter sources to figure out if something changed.</li>
<li class="task-list-item"><input type="checkbox" id="" disabled="" class="task-list-item-checkbox"> Use single parameter source as key to figure out if program needs to be created.</li>
<li class="task-list-item"><input type="checkbox" id="" disabled="" class="task-list-item-checkbox"> Use single parameter source as key to figure out which program to use.</li>
</ul>
<p dir="auto">We would also need to track which program gets used by which material to make sure that the programs get deleted when the material gets disposed of.</p>