From c6e592c900651e1a6ec8782058aadb36d423dc30 Mon Sep 17 00:00:00 2001 From: tga Date: Thu, 16 Dec 2021 01:21:04 -0500 Subject: [PATCH 1/2] disable culling --- src/gfx.ts | 22 +++++++--------------- 1 file changed, 7 insertions(+), 15 deletions(-) diff --git a/src/gfx.ts b/src/gfx.ts index 512815c7c..b2afa943f 100644 --- a/src/gfx.ts +++ b/src/gfx.ts @@ -9,7 +9,6 @@ import { isVec3, isColor, isMat4, - testRectRect, } from "./math"; import { @@ -480,19 +479,19 @@ function gfxInit(gl: WebGLRenderingContext, gopt: GfxOpt): Gfx { flush(); } - const objBound = { p1: vec2(Number.MAX_VALUE), p2: vec2(-Number.MAX_VALUE)}; - const screenBound = { p1: vec2(-1), p2: vec2(1) }; +// const objBound = { p1: vec2(Number.MAX_VALUE), p2: vec2(-Number.MAX_VALUE)}; +// const screenBound = { p1: vec2(-1), p2: vec2(1) }; for (const v of verts) { - // WebGL screen space coordinate [-1.0 ~ 1.0] + // normalized world space coordinate [-1.0 ~ 1.0] const pt = toNDC(gfx.transform.multVec2(v.pos.xy())); // get the bounding rectangle for the polygon - objBound.p1.x = Math.min(objBound.p1.x, pt.x); - objBound.p2.x = Math.max(objBound.p2.x, pt.x); - objBound.p1.y = Math.min(objBound.p1.y, pt.y); - objBound.p2.y = Math.max(objBound.p2.y, pt.y); +// objBound.p1.x = Math.min(objBound.p1.x, pt.x); +// objBound.p2.x = Math.max(objBound.p2.x, pt.x); +// objBound.p1.y = Math.min(objBound.p1.y, pt.y); +// objBound.p2.y = Math.max(objBound.p2.y, pt.y); gfx.vqueue.push( pt.x, pt.y, v.pos.z, @@ -502,13 +501,6 @@ function gfxInit(gl: WebGLRenderingContext, gopt: GfxOpt): Gfx { } - // if the object bound is totally outside, we don't render - if (!testRectRect(objBound, screenBound)) { - const num = verts.length * STRIDE; - gfx.vqueue.splice(gfx.vqueue.length - num, num); - return; - } - for (const i of indices) { gfx.iqueue.push(i + gfx.vqueue.length / STRIDE - verts.length); } From d557b47731b696ba1eaefa7cfc07c2abd22c1b85 Mon Sep 17 00:00:00 2001 From: tga Date: Thu, 16 Dec 2021 01:28:43 -0500 Subject: [PATCH 2/2] remove unused code --- src/gfx.ts | 9 --------- 1 file changed, 9 deletions(-) diff --git a/src/gfx.ts b/src/gfx.ts index b2afa943f..770f0c795 100644 --- a/src/gfx.ts +++ b/src/gfx.ts @@ -479,20 +479,11 @@ function gfxInit(gl: WebGLRenderingContext, gopt: GfxOpt): Gfx { flush(); } -// const objBound = { p1: vec2(Number.MAX_VALUE), p2: vec2(-Number.MAX_VALUE)}; -// const screenBound = { p1: vec2(-1), p2: vec2(1) }; - for (const v of verts) { // normalized world space coordinate [-1.0 ~ 1.0] const pt = toNDC(gfx.transform.multVec2(v.pos.xy())); - // get the bounding rectangle for the polygon -// objBound.p1.x = Math.min(objBound.p1.x, pt.x); -// objBound.p2.x = Math.max(objBound.p2.x, pt.x); -// objBound.p1.y = Math.min(objBound.p1.y, pt.y); -// objBound.p2.y = Math.max(objBound.p2.y, pt.y); - gfx.vqueue.push( pt.x, pt.y, v.pos.z, v.uv.x, v.uv.y,