Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 4 additions & 4 deletions examples/jsm/tsl/display/BloomNode.js
Original file line number Diff line number Diff line change
Expand Up @@ -312,8 +312,8 @@ class BloomNode extends TempNode {
*/
setSize( width, height ) {

let resx = Math.round( width * this._resolutionScale );
let resy = Math.round( height * this._resolutionScale );
let resx = Math.floor( width * this._resolutionScale );
let resy = Math.floor( height * this._resolutionScale );

this._renderTargetBright.setSize( resx, resy );

Expand All @@ -324,8 +324,8 @@ class BloomNode extends TempNode {

this._separableBlurMaterials[ i ].invSize.value.set( 1 / resx, 1 / resy );

resx = Math.round( resx / 2 );
resy = Math.round( resy / 2 );
resx = Math.floor( resx / 2 );
resy = Math.floor( resy / 2 );

}

Expand Down
39 changes: 6 additions & 33 deletions src/nodes/display/PassNode.js
Original file line number Diff line number Diff line change
Expand Up @@ -227,15 +227,6 @@ class PassNode extends TempNode {
*/
this.options = options;

/**
* The pass's pixel ratio. Will be kept automatically kept in sync with the renderer's pixel ratio.
*
* @private
* @type {number}
* @default 1
*/
this._pixelRatio = 1;

/**
* The pass's pixel width. Will be kept automatically kept in sync with the renderer's width.
* @private
Expand All @@ -252,7 +243,7 @@ class PassNode extends TempNode {
*/
this._height = 1;

const renderTarget = new RenderTarget( this._width * this._pixelRatio, this._height * this._pixelRatio, { type: HalfFloatType, ...options, } );
const renderTarget = new RenderTarget( this._width, this._height, { type: HalfFloatType, ...options, } );
renderTarget.texture.name = 'output';

let depthTexture = null;
Expand Down Expand Up @@ -792,13 +783,11 @@ class PassNode extends TempNode {
const { scene } = this;

let camera;
let pixelRatio;

const outputRenderTarget = renderer.getOutputRenderTarget();

if ( outputRenderTarget && outputRenderTarget.isXRRenderTarget === true ) {

pixelRatio = 1;
camera = renderer.xr.getCamera();

renderer.xr.updateCamera( camera );
Expand All @@ -808,14 +797,11 @@ class PassNode extends TempNode {
} else {

camera = this.camera;
pixelRatio = renderer.getPixelRatio();

renderer.getSize( _size );
renderer.getDrawingBufferSize( _size );

}

this._pixelRatio = pixelRatio;

this.setSize( _size.width, _size.height );

const currentRenderTarget = renderer.getRenderTarget();
Expand Down Expand Up @@ -900,16 +886,16 @@ class PassNode extends TempNode {
this._width = width;
this._height = height;

const effectiveWidth = Math.floor( this._width * this._pixelRatio * this._resolutionScale );
const effectiveHeight = Math.floor( this._height * this._pixelRatio * this._resolutionScale );
const effectiveWidth = Math.floor( this._width * this._resolutionScale );
const effectiveHeight = Math.floor( this._height * this._resolutionScale );

this.renderTarget.setSize( effectiveWidth, effectiveHeight );

// scissor

if ( this._scissor !== null ) {

this.renderTarget.scissor.copy( this._scissor ).multiplyScalar( this._pixelRatio * this._resolutionScale ).floor();
this.renderTarget.scissor.copy( this._scissor ).multiplyScalar( this._resolutionScale ).floor();
this.renderTarget.scissorTest = true;

} else {
Expand All @@ -922,7 +908,7 @@ class PassNode extends TempNode {

if ( this._viewport !== null ) {

this.renderTarget.viewport.copy( this._viewport ).multiplyScalar( this._pixelRatio * this._resolutionScale ).floor();
this.renderTarget.viewport.copy( this._viewport ).multiplyScalar( this._resolutionScale ).floor();

}

Expand Down Expand Up @@ -997,19 +983,6 @@ class PassNode extends TempNode {

}

/**
* Sets the pixel ratio the pass's render target and updates the size.
*
* @param {number} pixelRatio - The pixel ratio to set.
*/
setPixelRatio( pixelRatio ) {

this._pixelRatio = pixelRatio;

this.setSize( this._width, this._height );

}

/**
* Frees internal resources. Should be called when the node is no longer in use.
*/
Expand Down
72 changes: 38 additions & 34 deletions src/nodes/utils/RTTNode.js
Original file line number Diff line number Diff line change
Expand Up @@ -74,14 +74,6 @@ class RTTNode extends TextureNode {
*/
this.height = height;

/**
* The pixel ratio
*
* @type {number}
* @default 1
*/
this.pixelRatio = 1;

/**
* The render target
*
Expand All @@ -105,6 +97,15 @@ class RTTNode extends TextureNode {
*/
this.autoUpdate = true;

/**
* The resolution scale
*
* @private
* @type {number}
* @default 1
*/
this._resolutionScale = 1;

/**
* The node which is used with the quad mesh for RTT.
*
Expand Down Expand Up @@ -164,11 +165,8 @@ class RTTNode extends TextureNode {
*/
setSize( width, height ) {

this.width = width;
this.height = height;

const effectiveWidth = width * this.pixelRatio;
const effectiveHeight = height * this.pixelRatio;
const effectiveWidth = Math.floor( width * this._resolutionScale );
const effectiveHeight = Math.floor( height * this._resolutionScale );

this.renderTarget.setSize( effectiveWidth, effectiveHeight );

Expand All @@ -177,15 +175,34 @@ class RTTNode extends TextureNode {
}

/**
* Sets the pixel ratio. This will also resize the render target.
* Sets the resolution scale.
* The resolution scale is a factor that is multiplied with the renderer's width and height.
*
* @param {number} pixelRatio - The pixel ratio to set.
* @param {number} resolutionScale - The resolution scale to set. A value of `1` means full resolution.
* @returns {RTTNode} A reference to this node.
*/
setPixelRatio( pixelRatio ) {
setResolutionScale( resolutionScale ) {

this._resolutionScale = resolutionScale;

this.pixelRatio = pixelRatio;
if ( this.autoResize === false ) {

this.setSize( this.width, this.height );
this.setSize( this.width, this.height );

}

return this;

}

/**
* Gets the resolution scale.
*
* @returns {number} The resolution scale.
*/
getResolutionScale() {

return this._resolutionScale;

}

Expand All @@ -201,23 +218,10 @@ class RTTNode extends TextureNode {

if ( this.autoResize === true ) {

let effectiveWidth;
let effectiveHeight;

if ( currentRenderTarget ) {

effectiveWidth = currentRenderTarget.width;
effectiveHeight = currentRenderTarget.height;
const size = renderer.getDrawingBufferSize( _size );

} else {

const pixelRatio = renderer.getPixelRatio();
const size = renderer.getSize( _size );

effectiveWidth = Math.floor( size.width * pixelRatio );
effectiveHeight = Math.floor( size.height * pixelRatio );

}
const effectiveWidth = Math.floor( size.width * this._resolutionScale );
const effectiveHeight = Math.floor( size.height * this._resolutionScale );

if ( effectiveWidth !== this.renderTarget.width || effectiveHeight !== this.renderTarget.height ) {

Expand Down