diff --git a/webxrlayers-1.bs b/webxrlayers-1.bs index 0c3e178..361c9af 100755 --- a/webxrlayers-1.bs +++ b/webxrlayers-1.bs @@ -502,18 +502,12 @@ The ignoreDepthValues attribute, if is false it indicates that the content of the depth buffer attachment will be used by the [=XR Compositor=] and is expected to be representative of the scene rendered into the layer. -
- - The deltaPose attribute controls the amount of foveation used by the -[=XR Compositor=]. If the user agent or device does not support this attribute or the -"[=feature descriptor/space-warp=]" [=feature descriptor=] was not requested, they -should return null on getting, and setting should be a no-op. This attribute describes the -incremental application-applied transform, if any, since the previous frame that affects the view. When artificial -locomotion happens, the experience transforms the whole world from one application pose to another pose between frames -and {{XRProjectionLayer/deltaPose}} MUST be populated with the difference in the scene's world position. -The {{XRProjectionLayer/deltaPose}} should be identity when there is no transformation between the previous and the current {{XRFrame}}. - -
+The deltaPose attribute describes the incremental application-applied transform, if any, since the previous frame that affects the view. +If the user agent or device does not support this attribute or the "[=feature descriptor/space-warp=]" [=feature descriptor=] was not requested, the user agent should return null on getting, and setting should be a no-op. +A null value indicates that no application-applied transform is being supplied. +The value of {{XRProjectionLayer/deltaPose}} persists until the author changes it; the user agent does not reset it at the end of an {{XRSession/requestAnimationFrame()}} callback. +When artificial locomotion transforms the world from one application pose to another between frames, setting {{XRProjectionLayer/deltaPose}} to the difference between those poses helps the [=XR Compositor=] synthesize missing frames. +Authors should update {{XRProjectionLayer/deltaPose}} when that transform changes and set it to null or an identity transform for frames where no application-applied transform occurred. XRQuadLayer {#xrquadlayertype} ----------- @@ -786,8 +780,6 @@ The {{XRWebGLSubImage}} object is used during rendering of the layer. readonly attribute unsigned long colorTextureHeight; readonly attribute unsigned long? depthStencilTextureWidth; readonly attribute unsigned long? depthStencilTextureHeight; - readonly attribute unsigned long? motionVectorTextureWidth; - readonly attribute unsigned long? motionVectorTextureHeight; }; @@ -796,29 +788,17 @@ The colorTexture attribute returns th The depthStencilTexture attribute returns the depth/stencil [=opaque texture=] for the {{XRCompositionLayer}}. If the layer was created without depth/stencil, this attribute returns null. -
- The motionVectorTexture attribute returns the motion [=opaque texture=] for the {{XRProjectionLayer}}. If the {{XRSession}} was created without the [=feature descriptor/space-warp=] [=feature descriptor=] or the layer is not a {{XRProjectionLayer}}, this attribute MUST return null. -
- The imageIndex attribute returns the offset into the texture array. Valid only for layers that were requested with {{texture-array}}. -The colorTextureWidth and depthStencilTextureHeight attributes -return the width and height in pixels of the GL depth attachments - -
- -The depthStencilTextureWidth and colorTextureHeight attributes -return the width and height in pixels of the GL color attachments. If the layer was created without depth/stencil, this attribute returns null. +The colorTextureWidth and colorTextureHeight attributes +return the width and height in pixels of the GL color attachments. -The motionVectorTextureWidth and motionVectorTextureHeight attributes -return the width and height in pixels of the GL motion vector attachments. -If the {{XRSession}} was created without the [=feature descriptor/space-warp=] [=feature descriptor=] or the layer is not a {{XRProjectionLayer}}, these attributes MUST return null. - -
+The depthStencilTextureWidth and depthStencilTextureHeight attributes +return the width and height in pixels of the GL depth/stencil attachments. If the layer was created without depth/stencil, these attributes return null. XRTextureType {#xrtexturetype} ------------- @@ -1259,16 +1239,18 @@ To allocate color textures for projection layers using an {{XRProject
To allocate depth textures for projection layers using an {{XRProjectionLayer}} |layer|, an {{XRTextureType}} |textureType|, a {{GLenum}} |textureFormat| and a float |scaleFactor|, the user agent MUST run the following steps: - 1. Let |array| be a [=new=] array in the [=relevant realm=] of |context|. 1. Let |context| be |layer|'s [=XRCompositionLayer/context=]. + 1. Let |array| be a [=new=] array in the [=relevant realm=] of |context|. 1. Let |session| be |layer|'s [=XRCompositionLayer/session=]. 1. If |textureFormat| is 0, return |array| and abort these steps. 1. If |context| is a {{WebGLRenderingContext}} and the {{WEBGL_depth_texture}} [=extension=] is not enabled in |context|, return |array| and abort these steps. 1. If |textureFormat| is not in the [=list of depth formats for projection layers=], throw a {{NotSupportedError}} and abort these steps. 1. let |numViews| be the number of the |session|'s [=list of views=] excluding the [=secondary view|secondary views=]. 1. Let |view| be the first entry in the |session|'s [=list of views=] that is not a [=secondary view=]. - 1. Let |width| be the width of |view|'s [=recommended WebGL depth texture resolution=] multiplied by |scaleFactor|. - 1. Let |height| be the height of |view|'s [=recommended WebGL depth texture resolution=] multiplied by |scaleFactor|. + 1. Let |recommendedDepthResolution| be |view|'s [=recommended WebGL depth texture resolution=]. + 1. If |session| was created with the "[=space-warp=]" [=feature descriptor=], set |recommendedDepthResolution| to |view|'s [=recommended motion vector texture resolution=]. + 1. Let |width| be the width of |recommendedDepthResolution| multiplied by |scaleFactor|. + 1. Let |height| be the height of |recommendedDepthResolution| multiplied by |scaleFactor|. 1. If |layer|'s {{XRCompositionLayer/layout}} is {{XRLayerLayout/"mono"}} or {{XRLayerLayout/"default"}}:
If |textureType| is {{"texture-array"}}: @@ -1278,14 +1260,17 @@ To allocate depth textures for projection layers using an {{XRProject
Otherwise
For each |view| in the |session|'s [=list of views=]: 1. If |view| is a [=secondary view=], continue. - 1. Let |width| be the width of |view|'s [=recommended WebGL depth texture resolution=] multiplied by |scaleFactor|. - 1. Let |height| be the height of |view|'s [=recommended WebGL depth texture resolution=] multiplied by |scaleFactor|. + 1. Let |recommendedDepthResolution| be |view|'s [=recommended WebGL depth texture resolution=]. + 1. If |session| was created with the "[=space-warp=]" [=feature descriptor=], set |recommendedDepthResolution| to |view|'s [=recommended motion vector texture resolution=]. + 1. Let |width| be the width of |recommendedDepthResolution| multiplied by |scaleFactor|. + 1. Let |height| be the height of |recommendedDepthResolution| multiplied by |scaleFactor|. 1. let |texture| be a [=new=] instance of an [=opaque texture=] in the [=relevant realm=] of |context| created as a {{TEXTURE_2D}} texture with |context|, |textureFormat|, |stencil|, |width| and |height|. 1. If the |texture| was unable to be created for any reason, throw an {{OperationError}} and abort these steps. 1. Append |texture| to |array|.
Return |array| and abort these steps.
- 1. If the session’s [=view|views=] in the [=list of views=] don't all have the same [=recommended WebGL color texture resolution=] excluding the [=secondary view|secondary views=], throw a {{NotSupportedError}} and abort these steps. + 1. If |session| was created with the "[=space-warp=]" [=feature descriptor=] and the session’s [=view|views=] in the [=list of views=] don't all have the same [=recommended motion vector texture resolution=] excluding the [=secondary view|secondary views=], throw a {{NotSupportedError}} and abort these steps. + 1. If |session| was not created with the "[=space-warp=]" [=feature descriptor=] and the session’s [=view|views=] in the [=list of views=] don't all have the same [=recommended WebGL depth texture resolution=] excluding the [=secondary view|secondary views=], throw a {{NotSupportedError}} and abort these steps. 1. If |layer|'s {{XRCompositionLayer/layout}} is {{XRLayerLayout/stereo-left-right}}, initialize |array| with 1 [=new=] instance of an [=opaque texture=] in the [=relevant realm=] of |context| created as a |textureType| texture using |context|, |textureFormat|, |stencil|, |numViews| multiplied by |width| and |height|. 1. If |layer|'s {{XRCompositionLayer/layout}} is {{XRLayerLayout/stereo-top-bottom}}, initialize |array| with 1 [=new=] instance of an [=opaque texture=] in the [=relevant realm=] of |context| created as a |textureType| texture using |context|, |textureFormat|, |stencil|, |width| and |numViews| multiplied by |height|. 1. If the [=opaque texture=] was unable to be created for any reason, throw an {{OperationError}} and abort these steps. @@ -1295,9 +1280,9 @@ To allocate depth textures for projection layers using an {{XRProject
-To allocate motion vector textures for projection layers using an {{XRProjectionLayer}} |layer|, the user agent MUST run the following steps: - 1. Let |array| be a [=new=] array in the [=relevant realm=] of |context|. +To allocate motion vector textures for projection layers using an {{XRProjectionLayer}} |layer|, an {{XRTextureType}} |textureType| and a float |scaleFactor|, the user agent MUST run the following steps: 1. Let |context| be |layer|'s [=XRCompositionLayer/context=]. + 1. Let |array| be a [=new=] array in the [=relevant realm=] of |context|. 1. Let |session| be |layer|'s [=XRCompositionLayer/session=]. 1. If |session| was not created with the "[=space-warp=]" [=feature descriptor=], return |array| and abort these steps. 1. If |context| is a {{WebGLRenderingContext}} and the {{WEBGL_depth_texture}} [=extension=] is not enabled in |context|, return |array| and abort these steps. @@ -1455,6 +1440,8 @@ When this method is invoked, the user agent MUST run the following steps: 1. Initialize |layer|'s [=XRCompositionLayer/isStatic=] to false. 1. Initialize |layer|'s {{XRProjectionLayer/ignoreDepthValues}} as follows:
+
If |session| was created with the "[=space-warp=]" [=feature descriptor=] +
Initialize |layer|'s {{XRProjectionLayer/ignoreDepthValues}} to false
If |init|'s {{XRProjectionLayerInit/depthFormat}} is false and the [=XR Compositor=] will make use of depth values
Initialize |layer|'s {{XRProjectionLayer/ignoreDepthValues}} to false
Otherwise @@ -1468,7 +1455,7 @@ When this method is invoked, the user agent MUST run the following steps: 1. Initialize |layer|'s {{XRCompositionLayer/needsRedraw}} to true. 1. let |layer|'s [=colorTextures=] be the result of [=allocate color textures for projection layers|allocating color textures for projection layers=] with |layer|, |init|'s {{XRProjectionLayerInit/textureType}}, |init|'s {{XRProjectionLayerInit/colorFormat}} and |init|'s {{XRProjectionLayerInit/scaleFactor}}. 1. let |layer|'s [=depthStencilTextures=] be the result of [=allocate depth textures for projection layers|allocating depth textures for projection layers=] with |layer|, |init|'s {{XRProjectionLayerInit/textureType}}, |init|'s {{XRProjectionLayerInit/depthFormat}} and |init|'s {{XRProjectionLayerInit/scaleFactor}}. - 1. let |layer|'s [=motionVectorTextures=] be the result of [=allocate motion vector textures for projection layers|allocating motion vector textures for projection layers=] with |layer|, |init|'s {{XRProjectionLayerInit/depthFormat}} and |init|'s {{XRProjectionLayerInit/scaleFactor}}. + 1. let |layer|'s [=motionVectorTextures=] be the result of [=allocate motion vector textures for projection layers|allocating motion vector textures for projection layers=] with |layer|, |init|'s {{XRProjectionLayerInit/textureType}} and |init|'s {{XRProjectionLayerInit/scaleFactor}}. 1. Initialize the [=XRProjectionLayer/colortextures for secondary views=] as follows:
If the |session| was created with "[=secondary view/secondary-views=]" enabled @@ -1727,7 +1714,7 @@ When this method is invoked on an {{XRWebGLBinding}} |binding|, it MUST run the
Otherwise
Initialize |subimage|'s {{XRWebGLSubImage/depthStencilTexture}} with the first element of |layer|'s [=depthStencilTextures=] array.
- 1. Initialize |subimage|'s {{XRWebGLSubImage/motionVectorTexture}}, {{XRWebGLSubImage/motionVectorTextureWidth}} and {{XRWebGLSubImage/motionVectorTextureHeight}} with null. + 1. Initialize |subimage|'s {{XRWebGLSubImage/depthStencilTextureWidth}}, {{XRWebGLSubImage/depthStencilTextureHeight}}, and {{XRWebGLSubImage/motionVectorTexture}} with null. 1. Set |subimage|'s {{XRWebGLSubImage/colorTextureWidth}} to the pixel width of |subimage|'s {{XRWebGLSubImage/colorTexture}}. 1. Set |subimage|'s {{XRWebGLSubImage/colorTextureHeight}} to the pixel height of |subimage|'s {{XRWebGLSubImage/colorTexture}}. 1. If |subimage|'s {{XRWebGLSubImage/depthStencilTexture}} is not null, set |subimage|'s {{XRWebGLSubImage/depthStencilTextureWidth}} to the pixel width of the first texture in the {{XRWebGLSubImage/depthStencilTexture}} array. @@ -1803,10 +1790,9 @@ When this method is invoked on an {{XRWebGLBinding}} |binding|, it MUST run the
1. Set |subimage|'s {{XRWebGLSubImage/colorTextureWidth}} to the pixel width of |subimage|'s {{XRWebGLSubImage/colorTexture}}. 1. Set |subimage|'s {{XRWebGLSubImage/colorTextureHeight}} to the pixel height of |subimage|'s {{XRWebGLSubImage/colorTexture}}. + 1. Initialize |subimage|'s {{XRWebGLSubImage/depthStencilTextureWidth}} and {{XRWebGLSubImage/depthStencilTextureHeight}} with null. 1. If |subimage|'s {{XRWebGLSubImage/depthStencilTexture}} is not null, set |subimage|'s {{XRWebGLSubImage/depthStencilTextureWidth}} to the pixel width of the first texture in the {{XRWebGLSubImage/depthStencilTexture}} array. 1. If |subimage|'s {{XRWebGLSubImage/depthStencilTexture}} is not null, set |subimage|'s {{XRWebGLSubImage/depthStencilTextureHeight}} to the pixel height of the first texture in the {{XRWebGLSubImage/depthStencilTexture}} array. - 1. If |subimage|'s {{XRWebGLSubImage/motionVectorTexture}} is not null, set |subimage|'s {{XRWebGLSubImage/motionVectorTextureWidth}} to the pixel width of the first texture in the {{XRWebGLSubImage/motionVectorTexture}} array. - 1. If |subimage|'s {{XRWebGLSubImage/motionVectorTexture}} is not null, set |subimage|'s {{XRWebGLSubImage/motionVectorTextureHeight}} to the pixel height of the first texture in the {{XRWebGLSubImage/motionVectorTexture}} array. 1. Run [=initialize the viewport=] on |subimage|'s {{XRSubImage/viewport}} with |subimage|'s {{XRWebGLSubImage/colorTexture}}, |layer|'s {{XRCompositionLayer/layout}}, |index| and the number of the |session|'s [=list of views=]. 1. Set {{XRCompositionLayer/needsRedraw}} to false. 1. return |subimage| @@ -2097,18 +2083,22 @@ Other layers types MUST continue to be sorted as before. Space warp {#spacewarp} ========== -
Space warp is a technology that improves the [=XR Compositor=]'s reprojection. By submitting a {{XRWebGLSubImage/motionVectorTexture}} along with a {{XRWebGLSubImage/depthStencilTexture}} -the [=XR Compositor=] can do high quality frame extrapolation and reprojection which allows the user agent to run at a reduced framerate but still provide a smooth experience to users. +the [=XR Compositor=] can do high quality frame extrapolation and reprojection which allows the user agent to run at a reduced framerate but still provide a smooth experience to users. The rate at which {{XRSession/requestAnimationFrame()}} callbacks are delivered may be lower than the display's native refresh rate. The [=XR Compositor=] will synthesize the missing frames using the motion vectors and depth information provided by the experience. To enable [=space warp=] the {{XRSession}} MUST be created with the "space-warp" [=feature descriptor=]. If "[=space-warp=]" is enabled, the [=XR Compositor=] MUST make use of depth values, {{XRProjectionLayer/ignoreDepthValues}} MUST be set to `false` and {{XRWebGLBinding/usesDepthValues}} MUST be set to `true`. -The {{XRWebGLSubImage/motionVectorTexture}} MUST be in {{RGBA16F}} format. The author SHOULD fill in the RGB components of this texture with the speed in meters per second of that area with the red pixel corresponding with the x axis, green the y axis and blue the z axis. +When the [=feature descriptor/space-warp=] [=feature descriptor=] is enabled, the experience should render representative depth values into the {{XRWebGLSubImage/depthStencilTexture}} for each {{XRProjectionLayer}} it submits. +The {{XRWebGLSubImage/depthStencilTexture}} and {{XRWebGLSubImage/motionVectorTexture}} will have the same dimensions, which may be different from the dimensions of the {{XRWebGLSubImage/colorTexture}}. +Authors can use {{XRWebGLSubImage/depthStencilTextureWidth}} and {{XRWebGLSubImage/depthStencilTextureHeight}} to determine the dimensions of both the depth/stencil and motion vector attachments. -
+NOTE: Since the depth/stencil attachment can have different dimensions than the color attachment, it is not intended to be attached to the framebuffer used to render into the {{XRWebGLSubImage/colorTexture}}. +Authors should render depth/stencil information separately at the depth/stencil attachment dimensions. + +The {{XRWebGLSubImage/motionVectorTexture}} MUST be in {{RGBA16F}} format. The author SHOULD fill in the RG components of this texture with the 2D screen-space motion vector for that area, expressed as a delta in Normalized Device Coordinates (NDC) between the current frame and the previous frame. The motion vector is computed as `(currentClipPos / currentW) - (prevClipPos / prevW)`, where `currentClipPos` and `prevClipPos` are the clip space positions of the fragment in the current and previous frames, respectively. The red channel corresponds to the delta in [=NDC=] X (horizontal), and the green channel corresponds to the delta in [=NDC=] Y (vertical). The blue channel MAY contain the delta in [=NDC=] Z (depth), and the alpha channel is unused. WebXR Device API Integration {#webxrintegration} ============================ @@ -2184,8 +2174,9 @@ resolution large enough to contain the view. If the {{XRSession}} was created with the "[=feature descriptor/space-warp=]" [=feature descriptor=], each [=view=] MUST define a recommended motion vector texture resolution which is based on the [=recommended WebGL color texture resolution=]. -Each [=view=] MUST also define a recommended WebGL depth texture resolution which is based on the [=recommended WebGL color texture resolution=] and [=recommended motion vector texture resolution=]. The user agent MAY decide to reduce the -[=recommended WebGL depth texture resolution=] if "[=feature descriptor/space-warp=]" is enabled. +Each [=view=] MUST also define a recommended WebGL depth texture resolution which represents a best estimate of the WebGL depth texture +resolution large enough to contain the view. +If the {{XRSession}} was created with the "[=feature descriptor/space-warp=]" [=feature descriptor=], the [=recommended WebGL depth texture resolution=] MUST be equal to the [=recommended motion vector texture resolution=].