Skip to content

Examples: Remove some more RGBFormat usage. #23211

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

Merged
merged 1 commit into from
Jan 12, 2022
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
7 changes: 2 additions & 5 deletions examples/jsm/cameras/CinematicCamera.js
Original file line number Diff line number Diff line change
@@ -1,10 +1,8 @@
import {
LinearFilter,
Mesh,
OrthographicCamera,
PerspectiveCamera,
PlaneGeometry,
RGBFormat,
Scene,
ShaderMaterial,
UniformsUtils,
Expand Down Expand Up @@ -125,9 +123,8 @@ class CinematicCamera extends PerspectiveCamera {

this.postprocessing.scene.add( this.postprocessing.camera );

const pars = { minFilter: LinearFilter, magFilter: LinearFilter, format: RGBFormat };
this.postprocessing.rtTextureDepth = new WebGLRenderTarget( window.innerWidth, window.innerHeight, pars );
this.postprocessing.rtTextureColor = new WebGLRenderTarget( window.innerWidth, window.innerHeight, pars );
this.postprocessing.rtTextureDepth = new WebGLRenderTarget( window.innerWidth, window.innerHeight );
this.postprocessing.rtTextureColor = new WebGLRenderTarget( window.innerWidth, window.innerHeight );

const bokeh_shader = BokehShader;

Expand Down
17 changes: 9 additions & 8 deletions examples/jsm/modifiers/CurveModifier.js
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
// Original src: https://github.com/zz85/threejs-path-flow
const BITS = 3;
const CHANNELS = 4;
const TEXTURE_WIDTH = 1024;
const TEXTURE_HEIGHT = 4;

import {
DataTexture,
RGBFormat,
RGBAFormat,
FloatType,
RepeatWrapping,
Mesh,
Expand All @@ -22,12 +22,12 @@ import {
*/
export function initSplineTexture( numberOfCurves = 1 ) {

const dataArray = new Float32Array( TEXTURE_WIDTH * TEXTURE_HEIGHT * numberOfCurves * BITS );
const dataArray = new Float32Array( TEXTURE_WIDTH * TEXTURE_HEIGHT * numberOfCurves * CHANNELS );
const dataTexture = new DataTexture(
dataArray,
TEXTURE_WIDTH,
TEXTURE_HEIGHT * numberOfCurves,
RGBFormat,
RGBAFormat,
FloatType
);

Expand Down Expand Up @@ -80,10 +80,11 @@ function setTextureValue( texture, index, x, y, z, o ) {

const image = texture.image;
const { data } = image;
const i = BITS * TEXTURE_WIDTH * o; // Row Offset
data[ index * BITS + i + 0 ] = x;
data[ index * BITS + i + 1 ] = y;
data[ index * BITS + i + 2 ] = z;
const i = CHANNELS * TEXTURE_WIDTH * o; // Row Offset
data[ index * CHANNELS + i + 0 ] = x;
data[ index * CHANNELS + i + 1 ] = y;
data[ index * CHANNELS + i + 2 ] = z;
data[ index * CHANNELS + i + 3 ] = 1;

}

Expand Down
12 changes: 0 additions & 12 deletions examples/jsm/objects/ReflectorForSSRPass.js
Original file line number Diff line number Diff line change
@@ -1,11 +1,8 @@
import {
Color,
LinearFilter,
MathUtils,
Matrix4,
Mesh,
PerspectiveCamera,
RGBFormat,
ShaderMaterial,
UniformsUtils,
Vector2,
Expand Down Expand Up @@ -104,20 +101,11 @@ class ReflectorForSSRPass extends Mesh {
}

const parameters = {
minFilter: LinearFilter,
magFilter: LinearFilter,
format: RGBFormat,
depthTexture: useDepthTexture ? depthTexture : null,
};

const renderTarget = new WebGLRenderTarget( textureWidth, textureHeight, parameters );

if ( ! MathUtils.isPowerOfTwo( textureWidth ) || ! MathUtils.isPowerOfTwo( textureHeight ) ) {

renderTarget.texture.generateMipmaps = false;

}

const material = new ShaderMaterial( {
transparent: useDepthTexture,
defines: Object.assign( {}, ReflectorForSSRPass.ReflectorShader.defines, {
Expand Down
13 changes: 2 additions & 11 deletions examples/jsm/postprocessing/SMAAPass.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 1 addition & 3 deletions examples/jsm/postprocessing/SavePass.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,4 @@
import {
LinearFilter,
RGBFormat,
ShaderMaterial,
UniformsUtils,
WebGLRenderTarget
Expand Down Expand Up @@ -34,7 +32,7 @@ class SavePass extends Pass {

if ( this.renderTarget === undefined ) {

this.renderTarget = new WebGLRenderTarget( window.innerWidth, window.innerHeight, { minFilter: LinearFilter, magFilter: LinearFilter, format: RGBFormat } );
this.renderTarget = new WebGLRenderTarget( window.innerWidth, window.innerHeight );
this.renderTarget.texture.name = 'SavePass.rt';

}
Expand Down
14 changes: 10 additions & 4 deletions examples/misc_exporter_gltf.html
Original file line number Diff line number Diff line change
Expand Up @@ -146,19 +146,25 @@
document.body.appendChild( container );

// Make linear gradient texture
const data = new Uint8ClampedArray( 100 * 100 * 3 );

const data = new Uint8ClampedArray( 100 * 100 * 4 );

for ( let y = 0; y < 100; y ++ ) {

for ( let x = 0; x < 100; x ++ ) {

data[ 3 * ( 100 * y + x ) ] = Math.round( 255 * y / 99 );
data[ 3 * ( 100 * y + x ) + 1 ] = Math.round( 255 - 255 * y / 99 );
const stride = 4 * ( 100 * y + x );

data[ stride ] = Math.round( 255 * y / 99 );
data[ stride + 1 ] = Math.round( 255 - 255 * y / 99 );
data[ stride + 2 ] = 0;
data[ stride + 3 ] = 1;

}

}

const gradientTexture = new THREE.DataTexture( data, 100, 100, THREE.RGBFormat );
const gradientTexture = new THREE.DataTexture( data, 100, 100, THREE.RGBAFormat );
gradientTexture.minFilter = THREE.LinearFilter;
gradientTexture.magFilter = THREE.LinearFilter;
gradientTexture.needsUpdate = true;
Expand Down
6 changes: 1 addition & 5 deletions examples/webgl2_multisampled_renderbuffers.html
Original file line number Diff line number Diff line change
Expand Up @@ -114,12 +114,8 @@

//

const parameters = {
format: THREE.RGBFormat
};

const size = renderer.getDrawingBufferSize( new THREE.Vector2() );
const renderTarget = new THREE.WebGLMultisampleRenderTarget( size.width, size.height, parameters );
const renderTarget = new THREE.WebGLMultisampleRenderTarget( size.width, size.height );

const renderPass = new RenderPass( scene, camera );
const copyPass = new ShaderPass( CopyShader );
Expand Down
3 changes: 0 additions & 3 deletions examples/webgl_depth_texture.html
Original file line number Diff line number Diff line change
Expand Up @@ -143,12 +143,9 @@
const type = parseFloat( params.type );

target = new THREE.WebGLRenderTarget( window.innerWidth, window.innerHeight );
target.texture.format = THREE.RGBFormat;
target.texture.minFilter = THREE.NearestFilter;
target.texture.magFilter = THREE.NearestFilter;
target.texture.generateMipmaps = false;
target.stencilBuffer = ( format === THREE.DepthStencilFormat ) ? true : false;
target.depthBuffer = true;
target.depthTexture = new THREE.DepthTexture();
target.depthTexture.format = format;
target.depthTexture.type = type;
Expand Down
5 changes: 3 additions & 2 deletions examples/webgl_framebuffer_texture.html
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,7 @@

//

texture = new THREE.FramebufferTexture( textureSize, textureSize, THREE.RGBFormat );
texture = new THREE.FramebufferTexture( textureSize, textureSize, THREE.RGBAFormat );
texture.minFilter = THREE.NearestFilter;
texture.magFilter = THREE.NearestFilter;

Expand All @@ -110,7 +110,8 @@

//

renderer = new THREE.WebGLRenderer( { antialias: true } );
renderer = new THREE.WebGLRenderer( { antialias: true, alpha: true } );
renderer.setClearAlpha( 1 );
renderer.setPixelRatio( window.devicePixelRatio );
renderer.setSize( window.innerWidth, window.innerHeight );
renderer.autoClear = false;
Expand Down
14 changes: 8 additions & 6 deletions examples/webgl_gpgpu_birds_gltf.html
Original file line number Diff line number Diff line change
Expand Up @@ -249,13 +249,13 @@
const tHeight = nextPowerOf2( durationAnimation );
const tWidth = nextPowerOf2( birdGeo.getAttribute( 'position' ).count );
vertexPerBird = birdGeo.getAttribute( 'position' ).count;
const tData = new Float32Array( 3 * tWidth * tHeight );
const tData = new Float32Array( 4 * tWidth * tHeight );

for ( let i = 0; i < tWidth; i ++ ) {

for ( let j = 0; j < tHeight; j ++ ) {

const offset = j * tWidth * 3;
const offset = j * tWidth * 4;

const curMorph = Math.floor( j / durationAnimation * morphAttributes.length );
const nextMorph = ( Math.floor( j / durationAnimation * morphAttributes.length ) + 1 ) % morphAttributes.length;
Expand All @@ -268,25 +268,27 @@
d0 = morphAttributes[ curMorph ].array[ i * 3 ];
d1 = morphAttributes[ nextMorph ].array[ i * 3 ];

if ( d0 !== undefined && d1 !== undefined ) tData[ offset + i * 3 ] = Math.lerp( d0, d1, lerpAmount );
if ( d0 !== undefined && d1 !== undefined ) tData[ offset + i * 4 ] = Math.lerp( d0, d1, lerpAmount );

d0 = morphAttributes[ curMorph ].array[ i * 3 + 1 ];
d1 = morphAttributes[ nextMorph ].array[ i * 3 + 1 ];

if ( d0 !== undefined && d1 !== undefined ) tData[ offset + i * 3 + 1 ] = Math.lerp( d0, d1, lerpAmount );
if ( d0 !== undefined && d1 !== undefined ) tData[ offset + i * 4 + 1 ] = Math.lerp( d0, d1, lerpAmount );

d0 = morphAttributes[ curMorph ].array[ i * 3 + 2 ];
d1 = morphAttributes[ nextMorph ].array[ i * 3 + 2 ];

if ( d0 !== undefined && d1 !== undefined ) tData[ offset + i * 3 + 2 ] = Math.lerp( d0, d1, lerpAmount );
if ( d0 !== undefined && d1 !== undefined ) tData[ offset + i * 4 + 2 ] = Math.lerp( d0, d1, lerpAmount );

tData[ offset + i * 4 + 3 ] = 1;

}

}

}

textureAnimation = new THREE.DataTexture( tData, tWidth, tHeight, THREE.RGBFormat, THREE.FloatType );
textureAnimation = new THREE.DataTexture( tData, tWidth, tHeight, THREE.RGBAFormat, THREE.FloatType );
textureAnimation.needsUpdate = true;

const vertices = [], color = [], reference = [], seeds = [], indices = [];
Expand Down
2 changes: 1 addition & 1 deletion examples/webgl_materials_nodes.html
Original file line number Diff line number Diff line change
Expand Up @@ -3139,7 +3139,7 @@

// RTT ( get back distance )

rtTexture = new THREE.WebGLRenderTarget( window.innerWidth, window.innerHeight, { minFilter: THREE.LinearFilter, magFilter: THREE.NearestFilter, format: THREE.RGBFormat } );
rtTexture = new THREE.WebGLRenderTarget( window.innerWidth, window.innerHeight );

library[ rtTexture.texture.uuid ] = rtTexture.texture;

Expand Down
12 changes: 2 additions & 10 deletions examples/webgl_portal.html
Original file line number Diff line number Diff line change
Expand Up @@ -88,22 +88,14 @@
topLeftCorner = new THREE.Vector3();
reflectedPosition = new THREE.Vector3();

leftPortalTexture = new THREE.WebGLRenderTarget( 256, 256, {
minFilter: THREE.LinearFilter,
magFilter: THREE.LinearFilter,
format: THREE.RGBFormat
} );
leftPortalTexture = new THREE.WebGLRenderTarget( 256, 256 );
leftPortal = new THREE.Mesh( planeGeo, new THREE.MeshBasicMaterial( { map: leftPortalTexture.texture } ) );
leftPortal.position.x = - 30;
leftPortal.position.y = 20;
leftPortal.scale.set( 0.35, 0.35, 0.35 );
scene.add( leftPortal );

rightPortalTexture = new THREE.WebGLRenderTarget( 256, 256, {
minFilter: THREE.LinearFilter,
magFilter: THREE.LinearFilter,
format: THREE.RGBFormat
} );
rightPortalTexture = new THREE.WebGLRenderTarget( 256, 256 );
rightPortal = new THREE.Mesh( planeGeo, new THREE.MeshBasicMaterial( { map: rightPortalTexture.texture } ) );
rightPortal.position.x = 30;
rightPortal.position.y = 20;
Expand Down
3 changes: 0 additions & 3 deletions examples/webgl_postprocessing_advanced.html
Original file line number Diff line number Diff line change
Expand Up @@ -171,9 +171,6 @@
//

const rtParameters = {
minFilter: THREE.LinearFilter,
magFilter: THREE.LinearFilter,
format: THREE.RGBFormat,
stencilBuffer: true
};

Expand Down
3 changes: 1 addition & 2 deletions examples/webgl_postprocessing_crossfade.html
Original file line number Diff line number Diff line change
Expand Up @@ -173,8 +173,7 @@
const mesh = generateInstancedMesh( geometry, material, 500 );
scene.add( mesh );

const renderTargetParameters = { minFilter: THREE.LinearFilter, magFilter: THREE.LinearFilter, format: THREE.RGBFormat };
this.fbo = new THREE.WebGLRenderTarget( window.innerWidth, window.innerHeight, renderTargetParameters );
this.fbo = new THREE.WebGLRenderTarget( window.innerWidth, window.innerHeight );

this.render = function ( delta, rtt ) {

Expand Down
5 changes: 2 additions & 3 deletions examples/webgl_postprocessing_dof2.html
Original file line number Diff line number Diff line change
Expand Up @@ -317,9 +317,8 @@

postprocessing.scene.add( postprocessing.camera );

const pars = { minFilter: THREE.LinearFilter, magFilter: THREE.LinearFilter, format: THREE.RGBFormat };
postprocessing.rtTextureDepth = new THREE.WebGLRenderTarget( window.innerWidth, window.innerHeight, pars );
postprocessing.rtTextureColor = new THREE.WebGLRenderTarget( window.innerWidth, window.innerHeight, pars );
postprocessing.rtTextureDepth = new THREE.WebGLRenderTarget( window.innerWidth, window.innerHeight );
postprocessing.rtTextureColor = new THREE.WebGLRenderTarget( window.innerWidth, window.innerHeight );

const bokeh_shader = BokehShader;

Expand Down
11 changes: 5 additions & 6 deletions examples/webgl_postprocessing_godrays.html
Original file line number Diff line number Diff line change
Expand Up @@ -141,8 +141,7 @@

postprocessing.scene.add( postprocessing.camera );

const pars = { minFilter: THREE.LinearFilter, magFilter: THREE.LinearFilter, format: THREE.RGBFormat };
postprocessing.rtTextureColors = new THREE.WebGLRenderTarget( renderTargetWidth, renderTargetHeight, pars );
postprocessing.rtTextureColors = new THREE.WebGLRenderTarget( renderTargetWidth, renderTargetHeight );

// Switching the depth formats to luminance from rgb doesn't seem to work. I didn't
// investigate further for now.
Expand All @@ -151,15 +150,15 @@
// I would have this quarter size and use it as one of the ping-pong render
// targets but the aliasing causes some temporal flickering

postprocessing.rtTextureDepth = new THREE.WebGLRenderTarget( renderTargetWidth, renderTargetHeight, pars );
postprocessing.rtTextureDepthMask = new THREE.WebGLRenderTarget( renderTargetWidth, renderTargetHeight, pars );
postprocessing.rtTextureDepth = new THREE.WebGLRenderTarget( renderTargetWidth, renderTargetHeight );
postprocessing.rtTextureDepthMask = new THREE.WebGLRenderTarget( renderTargetWidth, renderTargetHeight );

// The ping-pong render targets can use an adjusted resolution to minimize cost

const adjustedWidth = renderTargetWidth * godrayRenderTargetResolutionMultiplier;
const adjustedHeight = renderTargetHeight * godrayRenderTargetResolutionMultiplier;
postprocessing.rtTextureGodRays1 = new THREE.WebGLRenderTarget( adjustedWidth, adjustedHeight, pars );
postprocessing.rtTextureGodRays2 = new THREE.WebGLRenderTarget( adjustedWidth, adjustedHeight, pars );
postprocessing.rtTextureGodRays1 = new THREE.WebGLRenderTarget( adjustedWidth, adjustedHeight );
postprocessing.rtTextureGodRays2 = new THREE.WebGLRenderTarget( adjustedWidth, adjustedHeight );

// god-ray shaders

Expand Down
3 changes: 0 additions & 3 deletions examples/webgl_postprocessing_masking.html
Original file line number Diff line number Diff line change
Expand Up @@ -67,9 +67,6 @@
const outputPass = new ShaderPass( CopyShader );

const parameters = {
minFilter: THREE.LinearFilter,
magFilter: THREE.LinearFilter,
format: THREE.RGBFormat,
stencilBuffer: true
};

Expand Down
2 changes: 1 addition & 1 deletion examples/webgl_rtt.html
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,7 @@
light.position.set( 0, 0, - 1 ).normalize();
sceneRTT.add( light );

rtTexture = new THREE.WebGLRenderTarget( window.innerWidth, window.innerHeight, { minFilter: THREE.LinearFilter, magFilter: THREE.NearestFilter, format: THREE.RGBFormat } );
rtTexture = new THREE.WebGLRenderTarget( window.innerWidth, window.innerHeight );

material = new THREE.ShaderMaterial( {

Expand Down