forked from mrdoob/three.js
-
Notifications
You must be signed in to change notification settings - Fork 32
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
WebXR: Implement antialiased multiview using OCULUS_multiview #15
Merged
Merged
Changes from 3 commits
Commits
Show all changes
4 commits
Select commit
Hold shift + click to select a range
2988e59
WebXR: Implement antialiased multiview using OCULUS_multiview
felixtrz fbbac6f
remove this. pointers in WebGLTextures
felixtrz 62ff215
remove this. pointers in WebGLTextures
felixtrz c8a9c8c
remove unnecessary condition when setting texture params
felixtrz File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
/** | ||
* @author fernandojsg / http://fernandojsg.com | ||
* @author Takahiro https://github.com/takahirox | ||
*/ | ||
|
||
import { WebGLRenderTarget } from './WebGLRenderTarget.js'; | ||
|
||
class WebGLMultiviewRenderTarget extends WebGLRenderTarget { | ||
|
||
constructor( width, height, numViews, options = {} ) { | ||
|
||
super( width, height, options ); | ||
|
||
this.depthBuffer = false; | ||
this.stencilBuffer = false; | ||
|
||
this.numViews = numViews; | ||
|
||
} | ||
|
||
copy( source ) { | ||
|
||
super.copy( source ); | ||
|
||
this.numViews = source.numViews; | ||
|
||
return this; | ||
|
||
} | ||
|
||
} | ||
|
||
WebGLMultiviewRenderTarget.prototype.isWebGLMultiviewRenderTarget = true; | ||
|
||
export { WebGLMultiviewRenderTarget }; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,100 @@ | ||
/** | ||
* @author fernandojsg / http://fernandojsg.com | ||
* @author Takahiro https://github.com/takahirox | ||
*/ | ||
import { Matrix3 } from '../../math/Matrix3.js'; | ||
import { Matrix4 } from '../../math/Matrix4.js'; | ||
|
||
class WebGLMultiview { | ||
|
||
constructor( renderer, extensions, gl ) { | ||
|
||
this.renderer = renderer; | ||
|
||
this.DEFAULT_NUMVIEWS = 2; | ||
this.maxNumViews = 0; | ||
this.gl = gl; | ||
|
||
this.extensions = extensions; | ||
|
||
this.available = this.extensions.has( 'OCULUS_multiview' ); | ||
|
||
if ( this.available ) { | ||
|
||
const extension = this.extensions.get( 'OCULUS_multiview' ); | ||
|
||
this.maxNumViews = this.gl.getParameter( extension.MAX_VIEWS_OVR ); | ||
|
||
this.mat4 = []; | ||
this.mat3 = []; | ||
this.cameraArray = []; | ||
|
||
for ( var i = 0; i < this.maxNumViews; i ++ ) { | ||
|
||
this.mat4[ i ] = new Matrix4(); | ||
this.mat3[ i ] = new Matrix3(); | ||
|
||
} | ||
|
||
} | ||
|
||
} | ||
|
||
// | ||
getCameraArray( camera ) { | ||
|
||
if ( camera.isArrayCamera ) return camera.cameras; | ||
|
||
this.cameraArray[ 0 ] = camera; | ||
|
||
return this.cameraArray; | ||
|
||
} | ||
|
||
updateCameraProjectionMatricesUniform( camera, uniforms ) { | ||
|
||
var cameras = this.getCameraArray( camera ); | ||
|
||
for ( var i = 0; i < cameras.length; i ++ ) { | ||
|
||
this.mat4[ i ].copy( cameras[ i ].projectionMatrix ); | ||
|
||
} | ||
|
||
uniforms.setValue( this.gl, 'projectionMatrices', this.mat4 ); | ||
|
||
} | ||
|
||
updateCameraViewMatricesUniform( camera, uniforms ) { | ||
|
||
var cameras = this.getCameraArray( camera ); | ||
|
||
for ( var i = 0; i < cameras.length; i ++ ) { | ||
|
||
this.mat4[ i ].copy( cameras[ i ].matrixWorldInverse ); | ||
|
||
} | ||
|
||
uniforms.setValue( this.gl, 'viewMatrices', this.mat4 ); | ||
|
||
} | ||
|
||
updateObjectMatricesUniforms( object, camera, uniforms ) { | ||
|
||
var cameras = this.getCameraArray( camera ); | ||
|
||
for ( var i = 0; i < cameras.length; i ++ ) { | ||
|
||
this.mat4[ i ].multiplyMatrices( cameras[ i ].matrixWorldInverse, object.matrixWorld ); | ||
this.mat3[ i ].getNormalMatrix( this.mat4[ i ] ); | ||
|
||
} | ||
|
||
uniforms.setValue( this.gl, 'modelViewMatrices', this.mat4 ); | ||
uniforms.setValue( this.gl, 'normalMatrices', this.mat3 ); | ||
|
||
} | ||
|
||
} | ||
|
||
export { WebGLMultiview }; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is this needed related to multiview?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
According to @snagy: the WebGLBackground code has some special casing and is not multiview-aware, the original dimension of 1x1x1 becomes really obvious as a box around your head with multiview, and making the box really big effectively negates this effect.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I see. concern is that this might affect non-vr (2D) applications perhaps causing the background to be clipped? 10,000 is 10km