Allow albedo over 1 if supported
This commit is contained in:
parent
53781f32a3
commit
346fc96df8
1 changed files with 10 additions and 2 deletions
|
|
@ -1,4 +1,5 @@
|
||||||
import { vec2 } from 'gl-matrix';
|
import { vec2 } from 'gl-matrix';
|
||||||
|
import { tryEnableExtension } from '../helper/enable-extension';
|
||||||
import { UniversalRenderingContext } from '../universal-rendering-context';
|
import { UniversalRenderingContext } from '../universal-rendering-context';
|
||||||
import { Texture } from './texture';
|
import { Texture } from './texture';
|
||||||
import { FilteringOptions } from './texture-options';
|
import { FilteringOptions } from './texture-options';
|
||||||
|
|
@ -7,24 +8,31 @@ import { FilteringOptions } from './texture-options';
|
||||||
export class ColorTexture extends Texture {
|
export class ColorTexture extends Texture {
|
||||||
public static readonly textureUnitId = 0;
|
public static readonly textureUnitId = 0;
|
||||||
|
|
||||||
|
private floatEnabled = false;
|
||||||
|
|
||||||
constructor(gl: UniversalRenderingContext) {
|
constructor(gl: UniversalRenderingContext) {
|
||||||
super(gl, ColorTexture.textureUnitId, {
|
super(gl, ColorTexture.textureUnitId, {
|
||||||
minFilter: FilteringOptions.LINEAR,
|
minFilter: FilteringOptions.LINEAR,
|
||||||
maxFilter: FilteringOptions.LINEAR,
|
maxFilter: FilteringOptions.LINEAR,
|
||||||
});
|
});
|
||||||
|
|
||||||
|
const bufferFloatExtension = tryEnableExtension(gl, 'EXT_color_buffer_float');
|
||||||
|
const floatLinearExtension = tryEnableExtension(gl, 'OES_texture_float_linear');
|
||||||
|
this.floatEnabled = gl.isWebGL2 && !!bufferFloatExtension && !!floatLinearExtension;
|
||||||
}
|
}
|
||||||
|
|
||||||
public setSize(size: vec2) {
|
public setSize(size: vec2) {
|
||||||
this.bind();
|
this.bind();
|
||||||
|
const gl2 = this.gl as WebGL2RenderingContext;
|
||||||
this.gl.texImage2D(
|
this.gl.texImage2D(
|
||||||
this.gl.TEXTURE_2D,
|
this.gl.TEXTURE_2D,
|
||||||
0,
|
0,
|
||||||
this.gl.RGBA,
|
this.floatEnabled ? gl2.RGBA16F : this.gl.RGBA,
|
||||||
size.x,
|
size.x,
|
||||||
size.y,
|
size.y,
|
||||||
0,
|
0,
|
||||||
this.gl.RGBA,
|
this.gl.RGBA,
|
||||||
this.gl.UNSIGNED_BYTE,
|
this.floatEnabled ? gl2.HALF_FLOAT : this.gl.UNSIGNED_BYTE,
|
||||||
null
|
null
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue