Skip to content

Commit

Permalink
Remove WebGLMultisampleRenderTarget (#147)
Browse files Browse the repository at this point in the history
* WebGLMultipleRenderTargets: Add Options to Constructor (mrdoob#22772)

* WebGLMultipleRenderTargets: Add Options to Constructor

* Update WebGLMultipleRenderTargets Documentation with new options

* Add line break

* WebGLMultipleRenderTargets: Use default parameter.

Co-authored-by: Michael Herzog <michael.herzog@human-interactive.org>

* WebGLRenderTarget: Clone depthTexture in copy(). (mrdoob#23462)

* Remove WebGLMultisampleRenderTarget. (mrdoob#23455)

* Remove WebGLMultisampleRenderTarget.

* THREE.Legacy.js: Add WebGLMultisampleRenderTarget.

* Exampels: Clean up.

* WebGLRenderer: Use multisampling when possible without reporting errors.

* Update WebGLRenderer.js

Co-authored-by: mrdoob <info@mrdoob.com>

* WebGLTextures: Fix depth textures with multisampling. (mrdoob#23611)

* WebGLRenderer: Fix setRenderTargetTextures(). (mrdoob#23644)

* fix transmission use multisample rtt error

* delete type definition of WebGLMultisampleRenderTarget

---------

Co-authored-by: Johnathon Selstad <makeshifted@gmail.com>
Co-authored-by: Michael Herzog <michael.herzog@human-interactive.org>
Co-authored-by: mrdoob <info@mrdoob.com>
  • Loading branch information
4 people committed Apr 10, 2024
1 parent cc97670 commit fd67fb1
Show file tree
Hide file tree
Showing 20 changed files with 126 additions and 295 deletions.
10 changes: 8 additions & 2 deletions docs/api/en/renderers/WebGLMultipleRenderTargets.html
Original file line number Diff line number Diff line change
Expand Up @@ -27,12 +27,18 @@ <h2>Examples</h2>
<h2>Constructor</h2>


<h3>[name]([param:Number width], [param:Number height], [param:Number count])</h3>
<h3>[name]([param:Number width], [param:Number height], [param:Number count], [param:Object options])</h3>

<p>
[page:Number width] - The width of the render target. <br />
[page:Number height] - The height of the render target.<br />
[page:Number count] - The number of render targets.
[page:Number count] - The number of render targets.<br />

options - (optional object that holds texture parameters for an auto-generated target
texture and depthBuffer/stencilBuffer booleans.

For an explanation of the texture parameters see [page:Texture Texture].
For a list of valid options, see [page:WebGLRenderTarget WebGLRenderTarget].<br /><br />
</p>

<h2>Properties</h2>
Expand Down
57 changes: 0 additions & 57 deletions docs/api/en/renderers/WebGLMultisampleRenderTarget.html

This file was deleted.

4 changes: 4 additions & 0 deletions docs/api/en/renderers/WebGLRenderTarget.html
Original file line number Diff line number Diff line change
Expand Up @@ -93,6 +93,10 @@ <h3>[property:DepthTexture depthTexture]</h3>
If set, the scene depth will be rendered to this texture. Default is null.
</p>

<h3>[property:Number samples]</h3>
<p>
Defines the count of MSAA samples. Can only be used with WebGL 2. Default is *0*.
</p>

<h2>Methods</h2>

Expand Down
57 changes: 0 additions & 57 deletions docs/api/zh/renderers/WebGLMultisampleRenderTarget.html

This file was deleted.

4 changes: 4 additions & 0 deletions docs/api/zh/renderers/WebGLRenderTarget.html
Original file line number Diff line number Diff line change
Expand Up @@ -89,6 +89,10 @@ <h3>[property:DepthTexture depthTexture]</h3>
如果设置,那么场景的深度将会被渲染到此纹理上。默认为null
</p>

<h3>[property:Number samples]</h3>
<p>
Defines the count of MSAA samples. Can only be used with WebGL 2. Default is *0*.
</p>

<h2>方法</h2>

Expand Down
2 changes: 0 additions & 2 deletions docs/list.json
Original file line number Diff line number Diff line change
Expand Up @@ -283,7 +283,6 @@

"Renderers": {
"WebGLMultipleRenderTargets": "api/en/renderers/WebGLMultipleRenderTargets",
"WebGLMultisampleRenderTarget": "api/en/renderers/WebGLMultisampleRenderTarget",
"WebGLRenderer": "api/en/renderers/WebGLRenderer",
"WebGL1Renderer": "api/en/renderers/WebGL1Renderer",
"WebGLRenderTarget": "api/en/renderers/WebGLRenderTarget",
Expand Down Expand Up @@ -782,7 +781,6 @@

"渲染器": {
"WebGLMultipleRenderTargets": "api/zh/renderers/WebGLMultipleRenderTargets",
"WebGLMultisampleRenderTarget": "api/zh/renderers/WebGLMultisampleRenderTarget",
"WebGLRenderer": "api/zh/renderers/WebGLRenderer",
"WebGL1Renderer": "api/zh/renderers/WebGL1Renderer",
"WebGLRenderTarget": "api/zh/renderers/WebGLRenderTarget",
Expand Down
3 changes: 2 additions & 1 deletion examples/jsm/objects/Reflector.js
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ class Reflector extends Mesh {
const textureHeight = options.textureHeight || 512;
const clipBias = options.clipBias || 0;
const shader = options.shader || Reflector.ReflectorShader;
const multisample = ( options.multisample !== undefined ) ? options.multisample : 4;

//

Expand All @@ -44,7 +45,7 @@ class Reflector extends Mesh {
const textureMatrix = new Matrix4();
const virtualCamera = new PerspectiveCamera();

const renderTarget = new WebGLRenderTarget( textureWidth, textureHeight );
const renderTarget = new WebGLRenderTarget( textureWidth, textureHeight, { samples: multisample } );

const material = new ShaderMaterial( {
uniforms: UniformsUtils.clone( shader.uniforms ),
Expand Down
3 changes: 2 additions & 1 deletion examples/jsm/objects/Refractor.js
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ class Refractor extends Mesh {
const textureHeight = options.textureHeight || 512;
const clipBias = options.clipBias || 0;
const shader = options.shader || Refractor.RefractorShader;
const multisample = ( options.multisample !== undefined ) ? options.multisample : 4;

//

Expand All @@ -41,7 +42,7 @@ class Refractor extends Mesh {

// render target

const renderTarget = new WebGLRenderTarget( textureWidth, textureHeight );
const renderTarget = new WebGLRenderTarget( textureWidth, textureHeight, { samples: multisample } );

// material

Expand Down
4 changes: 2 additions & 2 deletions examples/webgl2_multisampled_renderbuffers.html
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,7 @@
group = new THREE.Group();

const geometry = new THREE.SphereGeometry( 10, 64, 40 );
const material = new THREE.MeshLambertMaterial( { color: 0xee0808 } );
const material = new THREE.MeshLambertMaterial( { color: 0xee0808 } );
const material2 = new THREE.MeshBasicMaterial( { color: 0xffffff, wireframe: true } );

for ( let i = 0; i < 10; i ++ ) {
Expand Down Expand Up @@ -127,7 +127,7 @@
//

const size = renderer.getDrawingBufferSize( new THREE.Vector2() );
const renderTarget = new THREE.WebGLMultisampleRenderTarget( size.width, size.height );
const renderTarget = new THREE.WebGLRenderTarget( size.width, size.height, { samples: 4 } );

const renderPass = new RenderPass( scene, camera );
const copyPass = new ShaderPass( CopyShader );
Expand Down
9 changes: 9 additions & 0 deletions src/Three.Legacy.js
Original file line number Diff line number Diff line change
Expand Up @@ -1975,3 +1975,12 @@ export function ImmediateRenderObject() {
console.error( 'THREE.ImmediateRenderObject has been removed.' );

}

export function WebGLMultisampleRenderTarget( width, height, options ) {

console.error( 'THREE.WebGLMultisampleRenderTarget has been removed. Use a normal render target and set the "samples" property to greater 0 to enable multisampling.' );
const renderTarget = new WebGLRenderTarget( width, height, options );
renderTarget.samples = 4;
return renderTarget;

}
1 change: 0 additions & 1 deletion src/Three.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -176,7 +176,6 @@ export * from './objects/Group';
/**
* Renderers
*/
export * from './renderers/WebGLMultisampleRenderTarget';
export * from './renderers/WebGLCubeRenderTarget';
export * from './renderers/WebGLMultipleRenderTargets';
export * from './renderers/WebGLRenderTarget';
Expand Down
1 change: 0 additions & 1 deletion src/Three.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ import { REVISION } from './constants.js';

export { platform } from './platform.js';
export { WebGLMultipleRenderTargets } from './renderers/WebGLMultipleRenderTargets.js';
export { WebGLMultisampleRenderTarget } from './renderers/WebGLMultisampleRenderTarget.js';
export { WebGLCubeRenderTarget } from './renderers/WebGLCubeRenderTarget.js';
export { WebGLRenderTarget } from './renderers/WebGLRenderTarget.js';
export { WebGLRenderer } from './renderers/WebGLRenderer.js';
Expand Down
4 changes: 2 additions & 2 deletions src/renderers/WebGLMultipleRenderTargets.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,9 @@ import { WebGLRenderTarget } from './WebGLRenderTarget.js';

class WebGLMultipleRenderTargets extends WebGLRenderTarget {

constructor( width, height, count ) {
constructor( width, height, count, options = {} ) {

super( width, height );
super( width, height, options );

const texture = this.texture;

Expand Down
13 changes: 0 additions & 13 deletions src/renderers/WebGLMultisampleRenderTarget.d.ts

This file was deleted.

33 changes: 0 additions & 33 deletions src/renderers/WebGLMultisampleRenderTarget.js

This file was deleted.

1 change: 1 addition & 0 deletions src/renderers/WebGLRenderTarget.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ export interface WebGLRenderTargetOptions {
generateMipmaps?: boolean | undefined; // true;
depthTexture?: DepthTexture | undefined;
encoding?: TextureEncoding | undefined;
samples?: number | undefined; // 0
}

export class WebGLRenderTarget extends EventDispatcher {
Expand Down
7 changes: 6 additions & 1 deletion src/renderers/WebGLRenderTarget.js
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ class WebGLRenderTarget extends EventDispatcher {

this.depthBuffer = options.depthBuffer !== undefined ? options.depthBuffer : true;
this.stencilBuffer = options.stencilBuffer !== undefined ? options.stencilBuffer : false;

this.depthTexture = options.depthTexture !== undefined ? options.depthTexture : null;

/**
Expand All @@ -43,6 +44,7 @@ class WebGLRenderTarget extends EventDispatcher {
* see WebGlTextures.setupRenderBufferStorage
* */
platform.properties && ( this.useDEPTH_COMPONENT24 = platform.properties.rendertargetUseDEPTH_COMPONENT24 );
this.samples = options.samples !== undefined ? options.samples : 0;

}

Expand Down Expand Up @@ -101,7 +103,10 @@ class WebGLRenderTarget extends EventDispatcher {

this.depthBuffer = source.depthBuffer;
this.stencilBuffer = source.stencilBuffer;
this.depthTexture = source.depthTexture;

if ( source.depthTexture !== null ) this.depthTexture = source.depthTexture.clone();

this.samples = source.samples;

return this;

Expand Down
Loading

0 comments on commit fd67fb1

Please sign in to comment.