VR Quest Multiview missing content

I have a scene with normal Standard Material meshes, custom shaders and lines. In the browser (also with the simulated VR cam) it show up fine. On the Quest it works fine as well, however if I turn on Multiview the axis/lines and custom shaders on not visible. The simplest case is is here. Note its fine in the browser, even in Firefox Reality on the Quest, but as soon as you go click the VR headset icon it is not longer visible.

Firefox remote debugging spews a bunch of…
WebGL warning: drawElements: Multiview count mismatch: shader: 1, framebuffer: 2

Are there some settings that have to be enabled to make Multiview work properly?

Yeah multiview is complicated to implement as you need to update your shader to take care of the specific info that are required by the multiview extension.

First you need to add
#extension GL_OVR_multiview2 : require\nlayout (num_views = 2) in at the beginning of your shader

then you need to know that you will receive 2 viewProjection matrices like here:

What we do automatically for you is that if your defines contain “MULTIVIEW” we will add the extension declaration
then you need to test for #ifdef MULTIVIEW and add the shader code:

Cool I try to update my GLSL to include this.

@Deltakosh what about the example given above where its using builtin Mesh.CreateLines?

Yeah line shaders do not support it (yet) Do you mind adding an issue for it in the repo?

done

1 Like

I shamelessly pinged @RaananW to see if he can help :wink:

I was summoned from hibernation!
Sure, I’ll take care of this :blush:

1 Like

@Deltakosh

so here was my current shader

precision highp float;

// Attributes
attribute vec3 position;
attribute vec3 normal;
attribute vec2 uv;

// Uniforms
uniform mat4 worldViewProjection;

// Varying
varying vec4 vPosition;
varying vec3 vNormal;

varying vec2 vUV;
float median(float r, float g, float b) {
return max(min(r, g), min(max(r, g), b));
}

void main() {
vec4 p = vec4( position, 1. );
vPosition = p;
vNormal = normal;
vUV = uv;
gl_Position = worldViewProjection * p;
} 

adding
#extension GL_OVR_multiview2 : require
layout (num_views = 2)

gives error

effect.js?67a6:344 Uncaught TypeError: Cannot read property '0' of undefined
at Effect.getAttributeLocation (effect.js?67a6:344)
at Engine._bindVertexBuffersAttributes (engine.js?a942:2069)
at Engine.recordVertexArrayObject (engine.js?a942:2106)
at Geometry._bind (geometry.js?ca4e:299)
at Mesh._bind (mesh.js?c003:1134)
at Mesh.render (mesh.js?c003:1410)
at SubMesh.render (subMesh.js?0b55:272)...

My guess is I’d need to use layout everywhere for this to work. Is that correct?

Actually no need to add it as long as you define MULTIVIEW when compiling the effect (like the Background.vertex.fx file I mentioned earlier: