diff --git a/src/entities/Antialias.ts b/src/entities/Antialias.ts index 67e05a9..34a5b1d 100644 --- a/src/entities/Antialias.ts +++ b/src/entities/Antialias.ts @@ -25,7 +25,7 @@ export class Antialias extends Entity { fxaaFrag, { initOptions: { geometry: quadGeometry, target: dummyRenderTarget } }, ); - material.addUniformTexture( 'sampler0', options.input.texture ); + material.addUniformTextures( 'sampler0', options.input.texture ); if ( process.env.DEV ) { if ( module.hot ) { diff --git a/src/entities/BigBlur.ts b/src/entities/BigBlur.ts index 59abe2a..a368e93 100644 --- a/src/entities/BigBlur.ts +++ b/src/entities/BigBlur.ts @@ -52,7 +52,7 @@ export class BigBlur extends Entity { bigBlurFrag, { initOptions: { geometry: quadGeometry, target: dummyRenderTarget } }, ); - materialH.addUniformTexture( 'sampler0', options.input.texture ); + materialH.addUniformTextures( 'sampler0', options.input.texture ); if ( module.hot ) { module.hot.accept( '../shaders/big-blur.frag', () => { @@ -76,7 +76,7 @@ export class BigBlur extends Entity { initOptions: { geometry: quadGeometry, target: dummyRenderTarget } }, ); - materialV.addUniformTexture( 'sampler0', targetH.texture ); + materialV.addUniformTextures( 'sampler0', targetH.texture ); if ( module.hot ) { module.hot.accept( '../shaders/big-blur.frag', () => { diff --git a/src/entities/Bloom.ts b/src/entities/Bloom.ts index e58f060..7bd508a 100644 --- a/src/entities/Bloom.ts +++ b/src/entities/Bloom.ts @@ -54,7 +54,7 @@ export class Bloom extends Entity { ); material.addUniform( 'level', '1f', i ); - material.addUniformTexture( + material.addUniformTextures( 'sampler0', isFirst ? options.input.texture : swap.i.texture, ); @@ -88,7 +88,7 @@ export class Bloom extends Entity { ); material.addUniform( 'level', '1f', i ); - material.addUniformTexture( + material.addUniformTextures( 'sampler0', swap.i.texture, ); diff --git a/src/entities/Condition.ts b/src/entities/Condition.ts index 0510829..46f22b5 100644 --- a/src/entities/Condition.ts +++ b/src/entities/Condition.ts @@ -123,7 +123,7 @@ export class Condition extends Entity { const materials = { cubemap, deferred }; objectValuesMap( materials, ( material ) => { - material.addUniformTexture( 'samplerSvg', texture ); + material.addUniformTextures( 'samplerSvg', texture ); auto( 'Condition/phaseWidth', ( { value } ) => { material.addUniform( 'phaseWidth', '1f', value ); diff --git a/src/entities/DVi.ts b/src/entities/DVi.ts index f79b3de..92f25a7 100644 --- a/src/entities/DVi.ts +++ b/src/entities/DVi.ts @@ -33,8 +33,8 @@ export class DVi extends Entity { dviFrag, { initOptions: { geometry: quadGeometry, target: dummyRenderTarget } }, ); - material.addUniformTexture( 'sampler0', options.input.texture ); - material.addUniformTexture( 'samplerRandom', randomTexture.texture ); + material.addUniformTextures( 'sampler0', options.input.texture ); + material.addUniformTextures( 'samplerRandom', randomTexture.texture ); if ( process.env.DEV ) { if ( module.hot ) { diff --git a/src/entities/DeferredCamera.ts b/src/entities/DeferredCamera.ts index 4512fe4..f95cd7c 100644 --- a/src/entities/DeferredCamera.ts +++ b/src/entities/DeferredCamera.ts @@ -79,13 +79,13 @@ export class DeferredCamera extends Entity { } ); for ( let i = 0; i < 2; i ++ ) { // it doesn't need 2 and 3 - aoMaterial.addUniformTexture( + aoMaterial.addUniformTextures( 'sampler' + i, - this.cameraTarget.getTexture( gl.COLOR_ATTACHMENT0 + i ) + this.cameraTarget.getTexture( gl.COLOR_ATTACHMENT0 + i )!, ); } - aoMaterial.addUniformTexture( 'samplerRandom', randomTexture.texture ); + aoMaterial.addUniformTextures( 'samplerRandom', randomTexture.texture ); const aoQuad = new Quad( { material: aoMaterial, @@ -146,16 +146,16 @@ export class DeferredCamera extends Entity { } ); for ( let i = 0; i < 4; i ++ ) { - shadingMaterial.addUniformTexture( + shadingMaterial.addUniformTextures( 'sampler' + i, - this.cameraTarget.getTexture( gl.COLOR_ATTACHMENT0 + i ) + this.cameraTarget.getTexture( gl.COLOR_ATTACHMENT0 + i )!, ); } - shadingMaterial.addUniformTexture( 'samplerAo', aoTarget.texture ); - shadingMaterial.addUniformTexture( 'samplerIBLLUT', options.textureIBLLUT ); - shadingMaterial.addUniformTexture( 'samplerEnv', options.textureEnv ); - shadingMaterial.addUniformTexture( 'samplerRandom', randomTexture.texture ); + shadingMaterial.addUniformTextures( 'samplerAo', aoTarget.texture ); + shadingMaterial.addUniformTextures( 'samplerIBLLUT', options.textureIBLLUT ); + shadingMaterial.addUniformTextures( 'samplerEnv', options.textureEnv ); + shadingMaterial.addUniformTextures( 'samplerRandom', randomTexture.texture ); this.components.push( this.camera, diff --git a/src/entities/EnvironmentMap.ts b/src/entities/EnvironmentMap.ts index 5b11436..3f82f90 100644 --- a/src/entities/EnvironmentMap.ts +++ b/src/entities/EnvironmentMap.ts @@ -53,8 +53,8 @@ export class EnvironmentMap extends Entity { { initOptions: { geometry: quadGeometry, target: dummyRenderTarget } }, ); materialIntegrate.addUniform( 'uniformSeed', '4f', rng.gen(), rng.gen(), rng.gen(), rng.gen() ); - materialIntegrate.addUniformTexture( 'sampler0', swap.i.texture ); - materialIntegrate.addUniformCubemap( 'samplerCubemap', cubemap.texture ); + materialIntegrate.addUniformTextures( 'sampler0', swap.i.texture ); + materialIntegrate.addUniformTextures( 'samplerCubemap', cubemap.texture ); if ( process.env.DEV ) { if ( module.hot ) { @@ -78,7 +78,7 @@ export class EnvironmentMap extends Entity { environmentMapMergeFrag, { initOptions: { geometry: quadGeometry, target: dummyRenderTarget } }, ); - materialMerge.addUniformTexture( 'sampler0', swap.i.texture ); + materialMerge.addUniformTextures( 'sampler0', swap.i.texture ); if ( process.env.DEV ) { if ( module.hot ) { diff --git a/src/entities/FlickyParticles.ts b/src/entities/FlickyParticles.ts index 8a6d06f..b1387f0 100644 --- a/src/entities/FlickyParticles.ts +++ b/src/entities/FlickyParticles.ts @@ -30,7 +30,7 @@ export class FlickyParticles extends Entity { materialCompute.addUniform( 'particlesSqrt', '1f', PARTICLES_SQRT ); materialCompute.addUniform( 'particles', '1f', PARTICLES ); - materialCompute.addUniformTexture( 'samplerRandom', randomTexture.texture ); + materialCompute.addUniformTextures( 'samplerRandom', randomTexture.texture ); if ( process.env.DEV ) { if ( module.hot ) { @@ -91,7 +91,7 @@ export class FlickyParticles extends Entity { const materialsRender = { forward, cubemap: forward, depth }; objectValuesMap( materialsRender, ( material ) => { - material.addUniformTexture( 'samplerRandomStatic', randomTextureStatic.texture ); + material.addUniformTextures( 'samplerRandomStatic', randomTextureStatic.texture ); } ); if ( process.env.DEV ) { diff --git a/src/entities/GPUParticles.ts b/src/entities/GPUParticles.ts index 2dc0de1..5042be1 100644 --- a/src/entities/GPUParticles.ts +++ b/src/entities/GPUParticles.ts @@ -85,15 +85,15 @@ export class GPUParticles extends Entity { for ( let i = 0; i < computeNumBuffers; i ++ ) { const attachment = gl.COLOR_ATTACHMENT0 + i; - materialCompute.addUniformTexture( + materialCompute.addUniformTextures( `samplerCompute${ i }`, - swapCompute.i.getTexture( attachment ) + swapCompute.i.getTexture( attachment )! ); objectValuesMap( materialsRender, ( material ) => { - material?.addUniformTexture( + material?.addUniformTextures( `samplerCompute${ i }`, - swapCompute.o.getTexture( attachment ) + swapCompute.o.getTexture( attachment )! ); } ); } diff --git a/src/entities/Glitch.ts b/src/entities/Glitch.ts index 705f6d6..1e3070d 100644 --- a/src/entities/Glitch.ts +++ b/src/entities/Glitch.ts @@ -49,7 +49,7 @@ export class Glitch extends Entity { glitchFrag, { initOptions: { geometry: quadGeometry, target: dummyRenderTarget } }, ); - this.material.addUniformTexture( 'sampler0', options.input.texture ); + this.material.addUniformTextures( 'sampler0', options.input.texture ); if ( module.hot ) { module.hot.accept( '../shaders/glitch.frag', () => { diff --git a/src/entities/Greetings.ts b/src/entities/Greetings.ts index 15ea657..3a0ace3 100644 --- a/src/entities/Greetings.ts +++ b/src/entities/Greetings.ts @@ -125,7 +125,7 @@ const spritesheets = styles.map( ( style, iStyle ) => { let texture: GLCatTexture = textureSpriteSheet; ( style.preprocessorMaterials ?? [] ).map( ( material, i ) => { - material.addUniformTexture( + material.addUniformTextures( 'sampler0', i === 0 ? textureSpriteSheet : swapIntermediate.o.texture, ); @@ -144,7 +144,7 @@ const spritesheets = styles.map( ( style, iStyle ) => { name: process.env.DEV && `Greetings/spriteSheet${ iStyle }`, } ); - materialBlurH.addUniformTexture( 'sampler0', texture ); + materialBlurH.addUniformTextures( 'sampler0', texture ); quadPreprocessor.material = materialBlurH; quadPreprocessor.target = dest; @@ -263,7 +263,7 @@ export class Greetings extends Entity { const materials = { forward }; - forward.addUniformTextureArray( 'samplerSpriteSheets', spritesheets ); + forward.addUniformTextures( 'samplerSpriteSheets', ...spritesheets ); if ( process.env.DEV ) { if ( module.hot ) { diff --git a/src/entities/IBLLUT.ts b/src/entities/IBLLUT.ts index dc654ab..82747a8 100644 --- a/src/entities/IBLLUT.ts +++ b/src/entities/IBLLUT.ts @@ -49,7 +49,7 @@ export class IBLLUT extends Entity { ); material.addUniform( 'samples', '1f', samples ); material.addUniform( 'vdc', '1f', vdc( samples, 2.0 ) ); - material.addUniformTexture( 'sampler0', this.swap.i.texture ); + material.addUniformTextures( 'sampler0', this.swap.i.texture ); const quad = new Quad( { target: this.swap.o, @@ -68,7 +68,7 @@ export class IBLLUT extends Entity { } else { material.addUniform( 'samples', '1f', samples ); material.addUniform( 'vdc', '1f', vdc( samples, 2.0 ) ); - material.addUniformTexture( 'sampler0', this.swap.i.texture ); + material.addUniformTextures( 'sampler0', this.swap.i.texture ); quad.target = this.swap.o; } diff --git a/src/entities/LightEntity.ts b/src/entities/LightEntity.ts index 668d48e..7bf7030 100644 --- a/src/entities/LightEntity.ts +++ b/src/entities/LightEntity.ts @@ -82,7 +82,7 @@ export class LightEntity extends Entity { { initOptions: { geometry: quadGeometry, target: dummyRenderTarget } }, ); material.addUniform( 'isVert', '1i', i ); - material.addUniformTexture( 'sampler0', swap.i.texture ); + material.addUniformTextures( 'sampler0', swap.i.texture ); this.components.push( new Quad( { target: swap.o, diff --git a/src/entities/LightShaft.ts b/src/entities/LightShaft.ts index 224b724..bd69f60 100644 --- a/src/entities/LightShaft.ts +++ b/src/entities/LightShaft.ts @@ -49,8 +49,8 @@ export class LightShaft extends Entity { forward.addUniform( 'intensity', '1f', intensity ?? 0.01 ); - forward.addUniformTexture( 'samplerRandom', randomTexture.texture ); - forward.addUniformTexture( 'samplerShadow', light.shadowMap.texture ); + forward.addUniformTextures( 'samplerRandom', randomTexture.texture ); + forward.addUniformTextures( 'samplerShadow', light.shadowMap.texture ); const materials = { forward }; @@ -95,6 +95,6 @@ export class LightShaft extends Entity { * どうやってフレームバッファのデプスを取るかわかりませんでした 許してほしい */ public setDefferedCameraTarget( deferredCameraTarget: BufferRenderTarget ): void { - this.__forward.addUniformTexture( 'samplerDeferred0', deferredCameraTarget.texture ); + this.__forward.addUniformTextures( 'samplerDeferred0', deferredCameraTarget.texture ); } } diff --git a/src/entities/Phantom.ts b/src/entities/Phantom.ts index c5285a0..7203b5e 100644 --- a/src/entities/Phantom.ts +++ b/src/entities/Phantom.ts @@ -28,7 +28,7 @@ export class Phantom extends Entity { ); forward.addUniform( 'range', '4f', -1.0, -1.0, 1.0, 1.0 ); - forward.addUniformTexture( 'samplerRandom', randomTexture.texture ); + forward.addUniformTextures( 'samplerRandom', randomTexture.texture ); if ( process.env.DEV && module.hot ) { module.hot.accept( [ '../shaders/phantom.frag' ], () => { @@ -76,6 +76,6 @@ export class Phantom extends Entity { * どうやってフレームバッファのデプスを取るかわかりませんでした 許してほしい */ public setDefferedCameraTarget( deferredCameraTarget: BufferRenderTarget ): void { - this.__forward.addUniformTexture( 'samplerDeferred0', deferredCameraTarget.texture ); + this.__forward.addUniformTextures( 'samplerDeferred0', deferredCameraTarget.texture ); } } diff --git a/src/entities/PixelSorter.ts b/src/entities/PixelSorter.ts index f5401de..3b112ba 100644 --- a/src/entities/PixelSorter.ts +++ b/src/entities/PixelSorter.ts @@ -81,11 +81,11 @@ export class PixelSorter extends Entity { { initOptions: { geometry: quadGeometry, target: dummyRenderTarget } }, ); material.addUniform( 'mul', '1f', mul ); - material.addUniformTexture( + material.addUniformTextures( 'sampler0', options.input.texture, ); - material.addUniformTexture( + material.addUniformTextures( 'sampler1', this.swapBuffer.o.texture, ); @@ -118,11 +118,11 @@ export class PixelSorter extends Entity { ); material.addUniform( 'dir', '1f', dir ); material.addUniform( 'comp', '1f', comp ); - material.addUniformTexture( + material.addUniformTextures( 'sampler0', ( isFirst ? options.input : this.swapBuffer.o ).texture, ); - material.addUniformTexture( + material.addUniformTextures( 'sampler1', bufferIndex.texture, ); diff --git a/src/entities/Post.ts b/src/entities/Post.ts index 7e9d870..a806595 100644 --- a/src/entities/Post.ts +++ b/src/entities/Post.ts @@ -45,8 +45,8 @@ export class Post extends Entity { postFrag, { initOptions: { geometry: quadGeometry, target: dummyRenderTarget } }, ); - material.addUniformTexture( 'sampler0', options.input.texture ); - material.addUniformTexture( 'samplerRandom', randomTexture.texture ); + material.addUniformTextures( 'sampler0', options.input.texture ); + material.addUniformTextures( 'samplerRandom', randomTexture.texture ); if ( process.env.DEV ) { if ( module.hot ) { diff --git a/src/entities/RTInspector.ts b/src/entities/RTInspector.ts index 961fdd1..da3b778 100644 --- a/src/entities/RTInspector.ts +++ b/src/entities/RTInspector.ts @@ -133,8 +133,8 @@ export class RTInspector extends Entity { return; } - const texture = target.getTexture( attachment ); - this.materialSingle.addUniformTexture( 'sampler0', texture ); + const texture = target.getTexture( attachment )!; + this.materialSingle.addUniformTextures( 'sampler0', texture ); this.entitySingle.active = true; } else { diff --git a/src/entities/Racer.ts b/src/entities/Racer.ts index 926f1ea..14b1572 100644 --- a/src/entities/Racer.ts +++ b/src/entities/Racer.ts @@ -30,7 +30,7 @@ export class Racer extends Entity { materialCompute.addUniform( 'trails', '1f', TRAILS ); materialCompute.addUniform( 'trailLength', '1f', TRAIL_LENGTH ); - materialCompute.addUniformTexture( 'samplerRandom', randomTexture.texture ); + materialCompute.addUniformTextures( 'samplerRandom', randomTexture.texture ); if ( process.env.DEV ) { if ( module.hot ) { diff --git a/src/entities/SSR.ts b/src/entities/SSR.ts index a0aa942..1e2871a 100644 --- a/src/entities/SSR.ts +++ b/src/entities/SSR.ts @@ -56,16 +56,16 @@ export class SSR extends Entity { }, ); - material.addUniformTexture( 'samplerRandom', randomTexture.texture ); + material.addUniformTextures( 'samplerRandom', randomTexture.texture ); for ( let i = 0; i < 4; i ++ ) { - material.addUniformTexture( + material.addUniformTextures( 'sampler' + i, - options.camera.cameraTarget.getTexture( gl.COLOR_ATTACHMENT0 + i ) + options.camera.cameraTarget.getTexture( gl.COLOR_ATTACHMENT0 + i )!, ); } - material.addUniformTexture( 'samplerShaded', options.shaded.texture ); + material.addUniformTextures( 'samplerShaded', options.shaded.texture ); if ( process.env.DEV ) { if ( module.hot ) { diff --git a/src/entities/Serial.ts b/src/entities/Serial.ts index 8836ad1..12484ac 100644 --- a/src/entities/Serial.ts +++ b/src/entities/Serial.ts @@ -55,8 +55,8 @@ export class Serial extends Entity { serialEncodeFrag, { initOptions: { geometry: quadGeometry, target: dummyRenderTarget } }, ); - materialEncode.addUniformTexture( 'sampler0', options.input.texture ); - materialEncode.addUniformTexture( 'samplerRandom', randomTexture.texture ); + materialEncode.addUniformTextures( 'sampler0', options.input.texture ); + materialEncode.addUniformTextures( 'samplerRandom', randomTexture.texture ); if ( process.env.DEV ) { if ( module.hot ) { @@ -84,8 +84,8 @@ export class Serial extends Entity { serialDecodeFrag, { initOptions: { geometry: quadGeometry, target: dummyRenderTarget } }, ); - materialDecode.addUniformTexture( 'sampler0', bufferEncode.texture ); - materialDecode.addUniformTexture( 'samplerRandom', randomTexture.texture ); + materialDecode.addUniformTextures( 'sampler0', bufferEncode.texture ); + materialDecode.addUniformTextures( 'samplerRandom', randomTexture.texture ); if ( process.env.DEV ) { if ( module.hot ) { diff --git a/src/entities/SphereParticles.ts b/src/entities/SphereParticles.ts index afed292..e975765 100644 --- a/src/entities/SphereParticles.ts +++ b/src/entities/SphereParticles.ts @@ -29,7 +29,7 @@ export class SphereParticles extends Entity { materialCompute.addUniform( 'particlesSqrt', '1f', PARTICLES_SQRT ); materialCompute.addUniform( 'particles', '1f', PARTICLES ); - materialCompute.addUniformTexture( 'samplerRandom', randomTexture.texture ); + materialCompute.addUniformTextures( 'samplerRandom', randomTexture.texture ); if ( process.env.DEV ) { if ( module.hot ) { @@ -88,8 +88,8 @@ export class SphereParticles extends Entity { const materialsRender = { deferred, depth }; - deferred.addUniformTexture( 'samplerRandomStatic', randomTextureStatic.texture ); - depth.addUniformTexture( 'samplerRandomStatic', randomTextureStatic.texture ); + deferred.addUniformTextures( 'samplerRandomStatic', randomTextureStatic.texture ); + depth.addUniformTextures( 'samplerRandomStatic', randomTextureStatic.texture ); if ( process.env.DEV ) { if ( module.hot ) { diff --git a/src/entities/SufferTexts.ts b/src/entities/SufferTexts.ts index 2863fb5..78853c4 100644 --- a/src/entities/SufferTexts.ts +++ b/src/entities/SufferTexts.ts @@ -94,8 +94,8 @@ export class SufferTexts extends Entity { const materialsRender = { forward }; - forward.addUniformTexture( 'samplerRandomStatic', randomTextureStatic.texture ); - forward.addUniformTexture( 'samplerTinyChar', tinyCharTexture ); + forward.addUniformTextures( 'samplerRandomStatic', randomTextureStatic.texture ); + forward.addUniformTextures( 'samplerTinyChar', tinyCharTexture ); if ( process.env.DEV ) { if ( module.hot ) { diff --git a/src/entities/TestScreen.ts b/src/entities/TestScreen.ts index fa2090f..2787aa0 100644 --- a/src/entities/TestScreen.ts +++ b/src/entities/TestScreen.ts @@ -26,7 +26,7 @@ export class TestScreen extends Entity { }, ); - material.addUniformTexture( 'samplerRandom', randomTexture.texture ); + material.addUniformTextures( 'samplerRandom', randomTexture.texture ); if ( process.env.DEV ) { if ( module.hot ) { diff --git a/src/entities/Tetrahedron.ts b/src/entities/Tetrahedron.ts index 8872ec6..3a18846 100644 --- a/src/entities/Tetrahedron.ts +++ b/src/entities/Tetrahedron.ts @@ -59,8 +59,8 @@ export class Tetrahedron extends Entity { } objectValuesMap( materials, ( material ) => { - material.addUniformTexture( 'samplerRandom', randomTexture.texture ); - material.addUniformTexture( 'samplerRandomStatic', randomTextureStatic.texture ); + material.addUniformTextures( 'samplerRandom', randomTexture.texture ); + material.addUniformTextures( 'samplerRandomStatic', randomTextureStatic.texture ); } ); // -- updater ---------------------------------------------------------------------------------- diff --git a/src/entities/TextOverlay.ts b/src/entities/TextOverlay.ts index 7f43656..8f3005a 100644 --- a/src/entities/TextOverlay.ts +++ b/src/entities/TextOverlay.ts @@ -79,7 +79,7 @@ export class TextOverlay extends Entity { blend: [ gl.ONE, gl.ONE ], }, ); - material.addUniformTexture( 'sampler0', textures[ 0 ] ); + material.addUniformTextures( 'sampler0', textures[ 0 ] ); if ( process.env.DEV ) { if ( module.hot ) { @@ -98,7 +98,7 @@ export class TextOverlay extends Entity { // -- auto ------------------------------------------------------------------------------------- auto( 'TextOverlay/texture', ( { value } ) => { - material.addUniformTexture( 'sampler0', textures[ value ] ); + material.addUniformTextures( 'sampler0', textures[ value ] ); } ); auto( 'TextOverlay/amp', ( { value } ) => { diff --git a/src/entities/Wobbleball.ts b/src/entities/Wobbleball.ts index add1228..451cb72 100644 --- a/src/entities/Wobbleball.ts +++ b/src/entities/Wobbleball.ts @@ -62,8 +62,8 @@ export class Wobbleball extends Entity { } objectValuesMap( materials, ( material ) => { - material.addUniformTexture( 'samplerRandom', randomTexture.texture ); - material.addUniformTexture( 'samplerRandomStatic', randomTextureStatic.texture ); + material.addUniformTextures( 'samplerRandom', randomTexture.texture ); + material.addUniformTextures( 'samplerRandomStatic', randomTextureStatic.texture ); } ); // -- updater ---------------------------------------------------------------------------------- diff --git a/src/heck/Material.ts b/src/heck/Material.ts index 490f3bc..6f51bfd 100644 --- a/src/heck/Material.ts +++ b/src/heck/Material.ts @@ -1,4 +1,4 @@ -import { GLCatProgram, GLCatProgramLinkOptions, GLCatProgramUniformMatrixVectorType, GLCatProgramUniformType, GLCatProgramUniformVectorType, GLCatTexture, GLCatTextureCubemap } from '@fms-cat/glcat-ts'; +import { GLCatProgram, GLCatProgramLinkOptions, GLCatProgramUniformMatrixVectorType, GLCatProgramUniformType, GLCatProgramUniformVectorType, GLCatTexture } from '@fms-cat/glcat-ts'; import { Geometry } from './Geometry'; import { RenderTarget } from './RenderTarget'; import { SHADERPOOL } from './ShaderPool'; @@ -46,23 +46,11 @@ export class Material { } = {}; protected __uniformTextures: { - [ name: string ]: { - texture: GLCatTexture | null; - }; - } = {}; - - protected __uniformTextureArrays: { [ name: string ]: { textures: GLCatTexture[]; }; } = {}; - protected __uniformCubemaps: { - [ name: string ]: { - texture: GLCatTextureCubemap | null; - }; - } = {}; - private __vert: string; public get vert(): string { @@ -138,16 +126,8 @@ export class Material { this.__uniformMatrixVectors[ name ] = { type, value }; } - public addUniformTexture( name: string, texture: GLCatTexture | null ): void { - this.__uniformTextures[ name ] = { texture }; - } - - public addUniformTextureArray( name: string, textures: GLCatTexture[] ): void { - this.__uniformTextureArrays[ name ] = { textures }; - } - - public addUniformCubemap( name: string, texture: GLCatTextureCubemap | null ): void { - this.__uniformCubemaps[ name ] = { texture }; + public addUniformTextures( name: string, ...textures: GLCatTexture[] ): void { + this.__uniformTextures[ name ] = { textures }; } public setUniforms(): void { @@ -167,16 +147,8 @@ export class Material { } ); - Object.entries( this.__uniformTextures ).forEach( ( [ name, { texture } ] ) => { - program.uniformTexture( name, texture ); - } ); - - Object.entries( this.__uniformTextureArrays ).forEach( ( [ name, { textures } ] ) => { - program.uniformTextures( name, textures ); - } ); - - Object.entries( this.__uniformCubemaps ).forEach( ( [ name, { texture } ] ) => { - program.uniformCubemap( name, texture ); + Object.entries( this.__uniformTextures ).forEach( ( [ name, { textures } ] ) => { + program.uniformTexture( name, ...textures ); } ); } diff --git a/src/utils/setLightUniforms.ts b/src/utils/setLightUniforms.ts index c9dc28c..57eba50 100644 --- a/src/utils/setLightUniforms.ts +++ b/src/utils/setLightUniforms.ts @@ -50,8 +50,8 @@ export function setLightUniforms( ) ).flat(), ); - material.addUniformTextureArray( + material.addUniformTextures( 'samplerShadow', - activeLights.map( ( light ) => light.shadowMap.texture ), + ...activeLights.map( ( light ) => light.shadowMap.texture ), ); }