fix: adopt with the latest version of glcat-ts

This commit is contained in:
FMS-Cat
2021-04-04 05:37:11 +09:00
parent a2bb3d0442
commit 1ff24c3034
29 changed files with 74 additions and 102 deletions

View File

@@ -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 ) {

View File

@@ -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', () => {

View File

@@ -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,
);

View File

@@ -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 );

View File

@@ -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 ) {

View File

@@ -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,

View File

@@ -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 ) {

View File

@@ -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 ) {

View File

@@ -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 )!
);
} );
}

View File

@@ -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', () => {

View File

@@ -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 ) {

View File

@@ -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;
}

View File

@@ -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,

View File

@@ -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 );
}
}

View File

@@ -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 );
}
}

View File

@@ -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,
);

View File

@@ -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 ) {

View File

@@ -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 {

View File

@@ -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 ) {

View File

@@ -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 ) {

View File

@@ -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 ) {

View File

@@ -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 ) {

View File

@@ -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 ) {

View File

@@ -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 ) {

View File

@@ -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 ----------------------------------------------------------------------------------

View File

@@ -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 } ) => {

View File

@@ -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 ----------------------------------------------------------------------------------

View File

@@ -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 );
} );
}

View File

@@ -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 ),
);
}