forked from mrdoob/three.js
-
Notifications
You must be signed in to change notification settings - Fork 32
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
WebXR: Implement antialiased multiview using OCULUS_multiview (#15)
* WebXR: Implement antialiased multiview using OCULUS_multiview * remove this. pointers in WebGLTextures * remove this. pointers in WebGLTextures * remove unnecessary condition when setting texture params
- Loading branch information
Showing
9 changed files
with
476 additions
and
44 deletions.
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.