Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Lots of new Layer features; #816

Merged
merged 5 commits into from
Dec 7, 2024
Merged

Lots of new Layer features; #816

merged 5 commits into from
Dec 7, 2024

Conversation

bjornbytes
Copy link
Owner

@bjornbytes bjornbytes commented Dec 6, 2024

  • Add Layer:setCurve for curved layers. Curved. Layers.
  • Add new sphere and cube layer types (existing layers are quad layers now). cube layers are cubemap textures, and sphere layers are equirectangular images. These are mainly intended to be used for backgrounds that have higher sampling quality, more stable tracking, and don't need to be re-rendered every frame. Currently sphere/cube layers always render underneath the main layer.
  • Remove Layer:get/setViewMask. Instead, there's a stereo flag in newLayer, which will create an array texture and put each layer in the corresponding eye, just like how the main layer works. This works for all layer types, so you can have stereo cubemaps and stuff.
  • lovr.headset.setLayers takes a main key that can be used to disable the main layer, which can be useful for overlay apps that don't need to render any 3D content.
  • There is a new static flag in newLayer which can be used for static content. The layer can only be changed once, but it uses a lot less VRAM.
  • There is a new transparent flag in newLayer. Disabling transparency may improve performance slightly.
  • Add Layer:get/setColor, so you can change a layer's color or fade it in/out without rerendering it.
  • You can initialize a layer from an Image/Texture/filename, or a table of images/filenames.
  • New HeadsetFeatures: layerCube, layerSphere, layerCurve.
  • Default errhand disables layers now.

- Add Layer:get/setCurve for curved layers.  Curved.  Layers.
- Add new `sphere` and `cube` layer types (existing layers are `quad`
  layers now).  `cube` layers are cubemap textures, and `sphere` layers
  are equirectangular images.  These are mainly intended to be used for
  backgrounds that have higher sampling quality, more stable tracking,
  and don't need to be re-rendered every frame.  Currently sphere/cube
  layers always render underneath the main layer.
- Remove Layer:get/setViewMask.  Instead, there's a `stereo` flag in
  newLayer, which will create an array texture and put each layer in the
  corresponding eye, just like how the main layer works.  This works for
  all layer types, so you can have stereo cubemaps and stuff.
- `lovr.headset.setLayers` takes a `main` key that can be used to
  disable the main layer, which can be useful for overlay apps that
  don't need to render any 3D content.
- There is a new `static` flag in newLayer which can be used for static
  content.  The layer can only be changed once, but it uses a lot less VRAM.
- There is a new `transparent` flag in newLayer.  Disabling transparency
  may improve performance slightly.
- New HeadsetFeatures: `layerCube`, `layerSphere`, `layerCurve`.
- Default errhand disables layers now.
@bjornbytes
Copy link
Owner Author

  • Should cube/sphere layers be named cubemap and equirect instead? It's more clear but less cute.
  • Should transparent default to true or false?
  • Premultiplied alpha is not working right. Also, does it need to be configurable?

@bjornbytes
Copy link
Owner Author

  • Could add Layer:get/setColor via XR_KHR_composition_layer_color_scale_bias.
  • Could expose sampler settings for layers via XR_FB_swapchain_update_state_vulkan, but it's kinda niche, may want to wait until someone needs it. Same for mipmaps I guess.

@jmiskovic
Copy link
Contributor

Why differentiate between cube and sphere layer type in API, is there anything user-facing that makes it worth to expose it? I imagine I would expect to pass in the equirect or cubemap texture and the layer would internally figure it out.

Would it be possible to fetch the underlying Layer texture after the init? Not really that important but nice to have.

@bjornbytes
Copy link
Owner Author

LayerType needs to be exposed because if you create a Layer from a 2D texture, lovr doesn't know if you want that to be a quad or a sphere. And if you create an empty layer with a width/height, it isn't clear what type of layer that should be. There's already some auto-detect logic for textures to make it easier, though. For example, you can do lovr.headset.newLayer(cubemapTexture) and it will make a cube layer.

Regarding the texture: Yes, you can call Layer:getTexture to get the texture, but note that it's backed by a swapchain (ringbuffer of textures) so it returns a new (blank) texture each frame, expecting you to render to it. Layer:getPass is also a convenience function that will return a Pass that renders to the Layer.

@bjornbytes bjornbytes merged commit 1c04e6c into dev Dec 7, 2024
10 checks passed
@bjornbytes bjornbytes deleted the cool-layer-stuff branch December 7, 2024 19:21
@bjornbytes
Copy link
Owner Author

I'm actually trying out a simpler API on the background-layers branch where there is just a lovr.headset.setBackground(Image|Texture) function used to set a single cube/sphere background layer, and the Layer object is just used for quad panels now. It means that background layers are a little bit less flexible, but it simplifies the Layer object immensely.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants