Try to fix the lighting

This commit is contained in:
schmelczerandras 2020-07-25 14:20:11 +02:00
parent affb1b4f4f
commit e6782a9a98
7 changed files with 51 additions and 59 deletions

View file

@ -1,5 +1,5 @@
import { FragmentShaderOnlyProgram } from './fragment-shader-only-program';
import { vec2 } from 'gl-matrix';
import { FragmentShaderOnlyProgram } from './fragment-shader-only-program';
export abstract class FrameBuffer {
public renderScale = 1;
@ -13,11 +13,11 @@ export abstract class FrameBuffer {
protected programs: Array<FragmentShaderOnlyProgram>
) {}
public render(uniforms: any, input?: WebGLTexture) {
public render(uniforms: any, colorInput?: WebGLTexture) {
this.gl.bindFramebuffer(this.gl.FRAMEBUFFER, this.frameBuffer);
if (input !== null) {
this.gl.bindTexture(this.gl.TEXTURE_2D, input);
if (colorInput !== null) {
this.gl.bindTexture(this.gl.TEXTURE_2D, colorInput);
}
this.gl.viewport(0, 0, this.size.x, this.size.y);

View file

@ -19,7 +19,7 @@ export class IntermediateFrameBuffer extends FrameBuffer {
this.setSize();
}
public get texture(): WebGLTexture {
public get colorTexture(): WebGLTexture {
return this.frameTexture;
}
@ -43,7 +43,11 @@ export class IntermediateFrameBuffer extends FrameBuffer {
private configureTexture() {
this.gl.bindTexture(this.gl.TEXTURE_2D, this.frameTexture);
this.gl.texParameteri(
this.gl.TEXTURE_2D,
this.gl.TEXTURE_MAG_FILTER,
this.gl.NEAREST
);
this.gl.texParameteri(
this.gl.TEXTURE_2D,
this.gl.TEXTURE_MIN_FILTER,

View file

@ -1,4 +1,3 @@
import { WebGl2Renderer } from '../webgl2-renderer';
import { InfoText } from '../../objects/types/info-text';
// https://www.khronos.org/registry/webgl/extensions/EXT_disjoint_timer_query_webgl2/

View file

@ -34,7 +34,7 @@ export class WebGl2Renderer implements Drawer {
new FragmentShaderOnlyProgram(this.gl, ...shaderSources[1]),
]);
this.distanceFieldFrameBuffer.renderScale = 1;
this.distanceFieldFrameBuffer.renderScale = 0.5;
this.lightingFrameBuffer.renderScale = 1;
try {
@ -55,7 +55,7 @@ export class WebGl2Renderer implements Drawer {
this.distanceFieldFrameBuffer.render(this.uniforms);
this.lightingFrameBuffer.render(
this.uniforms,
this.distanceFieldFrameBuffer.texture
this.distanceFieldFrameBuffer.colorTexture
);
this.stopwatch?.stop();
@ -96,6 +96,7 @@ export class WebGl2Renderer implements Drawer {
worldToDistanceUV,
cursorPosition,
ndcToWorld,
viewBoxSize: this.viewBox.size,
});
}