antvis / G

💥 A flexible rendering engine for visualization.
https://g.antv.antgroup.com/
1.04k stars 192 forks source link

fix: support cameras array #1688

Closed xiaoiver closed 1 month ago

xiaoiver commented 1 month ago

🤔 This is a ...

🔗 Related issue link

In WebXR there're multiple XRViews e.g. left and right eyes. So we need to support rendering to cameras instead of a single camera.

https://threejs.org/docs/#api/en/cameras/ArrayCamera

💡 Background and solution

Since we use RenderGraph now, each camera should have its own render pass.

this.cameras.forEach(({ viewport }) => {
    // main render pass
    this.builder.pushPass((pass) => {});
});

📝 Changelog

Language Changelog
🇺🇸 English
🇨🇳 Chinese

☑️ Self Check before Merge

xiaoiver commented 1 month ago

目前确实能根据左右眼相机渲染两次:

截屏2024-05-20 下午5 44 27

但右眼相机渲染完才设置 viewport,导致重合在一起:

截屏2024-05-20 下午5 45 21
xiaoiver commented 1 month ago

第二个问题是 z-fighting 导致的闪烁: IMG_9449

https://threejs.org/examples/webgl_camera_logarithmicdepthbuffer.html