Add textures
This commit is contained in:
parent
5723b91b32
commit
7bfad8711b
25 changed files with 407 additions and 104 deletions
|
|
@ -1,5 +1,6 @@
|
|||
import { vec2 } from 'gl-matrix';
|
||||
import { Drawable } from '../../../drawables/drawable';
|
||||
import { Texture } from '../../graphics-library/texture/texture';
|
||||
import { Insights } from '../insights';
|
||||
import { RenderPass } from './render-pass';
|
||||
|
||||
|
|
@ -14,7 +15,7 @@ export class DistanceRenderPass extends RenderPass {
|
|||
this.drawables.push(drawable);
|
||||
}
|
||||
|
||||
public render(commonUniforms: any, ...inputTextures: Array<WebGLTexture>) {
|
||||
public render(commonUniforms: any, ...inputTextures: Array<Texture>) {
|
||||
this.frame.bindAndClear(inputTextures);
|
||||
|
||||
const stepsInUV = 1 / this.tileMultiplier;
|
||||
|
|
|
|||
|
|
@ -1,6 +1,7 @@
|
|||
import { vec2 } from 'gl-matrix';
|
||||
import { LightDrawable } from '../../../drawables/lights/light-drawable';
|
||||
import { clamp01 } from '../../../helper/clamp';
|
||||
import { Texture } from '../../graphics-library/texture/texture';
|
||||
import { Insights } from '../insights';
|
||||
import { RenderPass } from './render-pass';
|
||||
|
||||
|
|
@ -13,7 +14,14 @@ export class LightsRenderPass extends RenderPass {
|
|||
this.drawables.push(drawable);
|
||||
}
|
||||
|
||||
public render(commonUniforms: any, ...inputTextures: Array<WebGLTexture>) {
|
||||
public render(
|
||||
commonUniforms: any,
|
||||
distanceTexture: WebGLTexture,
|
||||
inputTextures: Array<Texture>
|
||||
) {
|
||||
this.gl.activeTexture(this.gl.TEXTURE0);
|
||||
this.gl.bindTexture(this.gl.TEXTURE_2D, distanceTexture);
|
||||
|
||||
this.frame.bindAndClear(inputTextures);
|
||||
|
||||
const tileCenterWorldCoordinates = vec2.transformMat2d(
|
||||
|
|
|
|||
|
|
@ -8,21 +8,22 @@ import { UniversalRenderingContext } from '../../graphics-library/universal-rend
|
|||
export abstract class RenderPass {
|
||||
protected program: UniformArrayAutoScalingProgram;
|
||||
|
||||
constructor(gl: UniversalRenderingContext, protected frame: FrameBuffer) {
|
||||
constructor(
|
||||
protected readonly gl: UniversalRenderingContext,
|
||||
protected frame: FrameBuffer
|
||||
) {
|
||||
this.program = new UniformArrayAutoScalingProgram(gl);
|
||||
}
|
||||
|
||||
public async initialize(
|
||||
shaderSources: [string, string],
|
||||
descriptors: Array<DrawableDescriptor>,
|
||||
substitutions: { [name: string]: any } = {},
|
||||
compiler: ParallelCompiler
|
||||
compiler: ParallelCompiler,
|
||||
substitutions: { [name: string]: any } = {}
|
||||
): Promise<void> {
|
||||
await this.program.initialize(shaderSources, descriptors, substitutions, compiler);
|
||||
await this.program.initialize(shaderSources, descriptors, compiler, substitutions);
|
||||
}
|
||||
|
||||
public abstract render(commonUniforms: any, inputTexture?: WebGLTexture): void;
|
||||
|
||||
public destroy(): void {
|
||||
this.frame.destroy();
|
||||
this.program.destroy();
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue