feat: Initialize shader background vertex buffer with full-screen quad data and bind to all programs, replacing previous 4-vertex buffer setup.
This commit is contained in:
parent
d2a8edb004
commit
12592e3726
@ -927,6 +927,61 @@ export function ShaderBackground() {
|
|||||||
)
|
)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
|
const posBuffer = gl.createBuffer();
|
||||||
|
gl.bindBuffer(gl.ARRAY_BUFFER, posBuffer);
|
||||||
|
gl.bufferData(
|
||||||
|
gl.ARRAY_BUFFER,
|
||||||
|
new Float32Array([-1, -1, 1, -1, -1, 1, -1, 1, 1, -1, 1, 1]),
|
||||||
|
gl.STATIC_DRAW
|
||||||
|
);
|
||||||
|
|
||||||
|
{
|
||||||
|
gl.useProgram(buffer_1_program);
|
||||||
|
const posAttrLocation = gl.getAttribLocation(
|
||||||
|
buffer_1_program,
|
||||||
|
"a_position"
|
||||||
|
);
|
||||||
|
gl.vertexAttribPointer(posAttrLocation, 2, gl.FLOAT, false, 0, 0);
|
||||||
|
gl.enableVertexAttribArray(posAttrLocation);
|
||||||
|
}
|
||||||
|
|
||||||
|
{
|
||||||
|
gl.useProgram(buffer_2_program);
|
||||||
|
const posAttrLocation = gl.getAttribLocation(
|
||||||
|
buffer_2_program,
|
||||||
|
"a_position"
|
||||||
|
);
|
||||||
|
gl.vertexAttribPointer(posAttrLocation, 2, gl.FLOAT, false, 0, 0);
|
||||||
|
gl.enableVertexAttribArray(posAttrLocation);
|
||||||
|
}
|
||||||
|
|
||||||
|
{
|
||||||
|
gl.useProgram(buffer_3_program);
|
||||||
|
const posAttrLocation = gl.getAttribLocation(
|
||||||
|
buffer_3_program,
|
||||||
|
"a_position"
|
||||||
|
);
|
||||||
|
gl.vertexAttribPointer(posAttrLocation, 2, gl.FLOAT, false, 0, 0);
|
||||||
|
gl.enableVertexAttribArray(posAttrLocation);
|
||||||
|
}
|
||||||
|
|
||||||
|
{
|
||||||
|
gl.useProgram(buffer_4_program);
|
||||||
|
const posAttrLocation = gl.getAttribLocation(
|
||||||
|
buffer_4_program,
|
||||||
|
"a_position"
|
||||||
|
);
|
||||||
|
gl.vertexAttribPointer(posAttrLocation, 2, gl.FLOAT, false, 0, 0);
|
||||||
|
gl.enableVertexAttribArray(posAttrLocation);
|
||||||
|
}
|
||||||
|
|
||||||
|
{
|
||||||
|
gl.useProgram(finalProgram);
|
||||||
|
const posAttrLocation = gl.getAttribLocation(finalProgram, "a_position");
|
||||||
|
gl.vertexAttribPointer(posAttrLocation, 2, gl.FLOAT, false, 0, 0);
|
||||||
|
gl.enableVertexAttribArray(posAttrLocation);
|
||||||
|
}
|
||||||
|
|
||||||
function setResolution(
|
function setResolution(
|
||||||
program: WebGLProgram,
|
program: WebGLProgram,
|
||||||
canvas: HTMLCanvasElement,
|
canvas: HTMLCanvasElement,
|
||||||
@ -1034,14 +1089,6 @@ export function ShaderBackground() {
|
|||||||
console.log("Framebuffer is unknown");
|
console.log("Framebuffer is unknown");
|
||||||
}
|
}
|
||||||
|
|
||||||
const posBuffer = gl.createBuffer();
|
|
||||||
gl.bindBuffer(gl.ARRAY_BUFFER, posBuffer);
|
|
||||||
gl.bufferData(
|
|
||||||
gl.ARRAY_BUFFER,
|
|
||||||
new Float32Array([0, 0, 1, 0, 0, 1, 1, 1]),
|
|
||||||
gl.STATIC_DRAW
|
|
||||||
);
|
|
||||||
|
|
||||||
const ichannel0_location_buffer_1 = gl.getUniformLocation(
|
const ichannel0_location_buffer_1 = gl.getUniformLocation(
|
||||||
buffer_1_program as WebGLProgram,
|
buffer_1_program as WebGLProgram,
|
||||||
"iChannel0"
|
"iChannel0"
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user