Add motion blur and better interpolation when OES_texture_float_linear is not available
This commit is contained in:
parent
2889fd54db
commit
7803bbeaee
7 changed files with 50 additions and 8 deletions
|
|
@ -18,8 +18,8 @@ export class DistanceTexture extends Texture {
|
|||
|
||||
const bufferFloatExtension = tryEnableExtension(gl, 'EXT_color_buffer_float');
|
||||
const floatLinearExtension = tryEnableExtension(gl, 'OES_texture_float_linear');
|
||||
this.floatLinearEnabled = !!bufferFloatExtension && !!floatLinearExtension;
|
||||
|
||||
this.floatLinearEnabled = !!bufferFloatExtension && !!floatLinearExtension;
|
||||
gl.insights.floatInterpolationEnabled = this.floatLinearEnabled;
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -11,9 +11,18 @@ export const getUniversalRenderingContext = (
|
|||
canvas: HTMLCanvasElement,
|
||||
ignoreWebGL2 = false
|
||||
): UniversalRenderingContext => {
|
||||
const contextAttributes: WebGLContextAttributes = {
|
||||
alpha: true,
|
||||
antialias: false,
|
||||
depth: false,
|
||||
desynchronized: true,
|
||||
preserveDrawingBuffer: true,
|
||||
powerPreference: 'high-performance',
|
||||
};
|
||||
|
||||
const context: WebGL2RenderingContext | WebGLRenderingContext | null = ignoreWebGL2
|
||||
? null
|
||||
: canvas.getContext('webgl2');
|
||||
: canvas.getContext('webgl2', contextAttributes);
|
||||
|
||||
let result = context as UniversalRenderingContext;
|
||||
|
||||
|
|
@ -23,10 +32,13 @@ export const getUniversalRenderingContext = (
|
|||
}
|
||||
} else {
|
||||
result = (canvas.getContext('webgl') ||
|
||||
canvas.getContext('experimental-webgl')) as UniversalRenderingContext;
|
||||
canvas.getContext('experimental-webgl', {
|
||||
...contextAttributes,
|
||||
alpha: false,
|
||||
})) as UniversalRenderingContext;
|
||||
|
||||
if (!result) {
|
||||
throw new Error('Neither WebGL or WebGL2 is supported');
|
||||
throw new Error('Neither WebGL nor WebGL2 is supported');
|
||||
}
|
||||
|
||||
result.isWebGL2 = false;
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue