From f61ef623f791fab02523e6428db3ae9a7de64b81 Mon Sep 17 00:00:00 2001 From: ienaga Date: Fri, 13 Dec 2024 22:49:34 +0900 Subject: [PATCH] =?UTF-8?q?#154=20=E6=8F=8F=E7=94=BB=E5=87=A6=E7=90=86?= =?UTF-8?q?=E3=82=92=E6=94=B9=E4=BF=AE?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- index.html | 42 +++++++++---------- .../Fragment/FragmentShaderSourceTexture.ts | 10 ++--- .../src/Shader/Vertex/VertexShaderSource.ts | 8 ++-- .../VertexArrayObjectBindAttributeUseCase.ts | 7 +++- 4 files changed, 35 insertions(+), 32 deletions(-) diff --git a/index.html b/index.html index 68052157..873c3d3b 100644 --- a/index.html +++ b/index.html @@ -10,27 +10,27 @@ diff --git a/packages/webgl/src/Shader/Fragment/FragmentShaderSourceTexture.ts b/packages/webgl/src/Shader/Fragment/FragmentShaderSourceTexture.ts index 6dfc11ab..e6712179 100644 --- a/packages/webgl/src/Shader/Fragment/FragmentShaderSourceTexture.ts +++ b/packages/webgl/src/Shader/Fragment/FragmentShaderSourceTexture.ts @@ -44,19 +44,19 @@ precision mediump float; uniform sampler2D u_texture; -in vec4 mul; -in vec4 add; +in vec4 v_mul; +in vec4 v_add; in vec2 v_coord; out vec4 o_color; void main() { vec4 src = texture(u_texture, v_coord); - if (mul.x != 1.0 || mul.y != 1.0 || mul.z != 1.0 || mul.w != 1.0 - || add.x != 0.0 || add.y != 0.0 || add.z != 0.0 || add.w != 0.0 + if (v_mul.x != 1.0 || v_mul.y != 1.0 || v_mul.z != 1.0 || v_mul.w != 1.0 + || v_add.x != 0.0 || v_add.y != 0.0 || v_add.z != 0.0 || v_add.w != 0.0 ) { src.rgb /= max(0.0001, src.a); - src = clamp(src * mul + add, 0.0, 1.0); + src = clamp(src * v_mul + v_add, 0.0, 1.0); src.rgb *= src.a; } diff --git a/packages/webgl/src/Shader/Vertex/VertexShaderSource.ts b/packages/webgl/src/Shader/Vertex/VertexShaderSource.ts index 09e25ff6..ef0fc38c 100644 --- a/packages/webgl/src/Shader/Vertex/VertexShaderSource.ts +++ b/packages/webgl/src/Shader/Vertex/VertexShaderSource.ts @@ -70,13 +70,13 @@ layout (location = 5) in vec4 a_mul; layout (location = 6) in vec4 a_add; out vec2 v_coord; -out vec4 mul; -out vec4 add; +out vec4 v_mul; +out vec4 v_add; void main() { v_coord = a_vertex * a_rect.zw + a_rect.xy; - mul = a_mul; - add = a_add; + v_mul = a_mul; + v_add = a_add; vec2 position = vec2(a_vertex.x, 1.0 - a_vertex.y); position = position * a_size.xy; diff --git a/packages/webgl/src/VertexArrayObject/usecase/VertexArrayObjectBindAttributeUseCase.ts b/packages/webgl/src/VertexArrayObject/usecase/VertexArrayObjectBindAttributeUseCase.ts index f87a0c63..17996071 100644 --- a/packages/webgl/src/VertexArrayObject/usecase/VertexArrayObjectBindAttributeUseCase.ts +++ b/packages/webgl/src/VertexArrayObject/usecase/VertexArrayObjectBindAttributeUseCase.ts @@ -1,6 +1,9 @@ import type { ShaderInstancedManager } from "../../Shader/ShaderInstancedManager"; import { execute as vertexArrayObjectBindService } from "../service/VertexArrayObjectBindService"; -import { $gl } from "../../WebGLUtil"; +import { + $gl, + $upperPowerOfTwo +} from "../../WebGLUtil"; import { $instancedVertexArrayObject, $getAttributeBuffer, @@ -27,7 +30,7 @@ export const execute = (shader_instanced_manager: ShaderInstancedManager): void if (shader_instanced_manager.attributes.length > attributeBuffer.length) { attributeBuffer = new Float32Array( - shader_instanced_manager.attributes.length + $upperPowerOfTwo(shader_instanced_manager.attributes.length) ); $setAttributeBuffer(attributeBuffer);