From f62f44b5a77fa2cbefad4608538aa07449d149b3 Mon Sep 17 00:00:00 2001 From: Aaron Fenyes Date: Tue, 27 Aug 2024 00:00:48 -0700 Subject: [PATCH] Optimization: decouple internal and uniform SPHERE_MAX --- app-proto/inversive-display/src/inversive.frag | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/app-proto/inversive-display/src/inversive.frag b/app-proto/inversive-display/src/inversive.frag index 51bc0ff..ce6deae 100644 --- a/app-proto/inversive-display/src/inversive.frag +++ b/app-proto/inversive-display/src/inversive.frag @@ -25,10 +25,10 @@ vecInv sphere(vec3 center, float radius) { // construction. the SPHERE_MAX array size seems to affect frame rate a lot, // even though we should only be using the first few elements of each array -const int SPHERE_MAX = 12; +const int SPHERE_MAX_UNIFORM = 12; uniform int sphere_cnt; -uniform vecInv sphere_list[SPHERE_MAX]; -uniform vec3 color_list[SPHERE_MAX]; +uniform vecInv sphere_list[SPHERE_MAX_UNIFORM]; +uniform vec3 color_list[SPHERE_MAX_UNIFORM]; // view uniform vec2 resolution; @@ -135,8 +135,9 @@ void main() { vec3 dir = vec3(focal_slope * scr, -1.); // cast rays through the spheres - vec2 depth_pairs [SPHERE_MAX]; - taggedFrag frags [2*SPHERE_MAX]; + const int SPHERE_MAX_INTERNAL = 6; + vec2 depth_pairs [SPHERE_MAX_INTERNAL]; + taggedFrag frags [2*SPHERE_MAX_INTERNAL]; int frag_cnt = 0; for (int i = 0; i < sphere_cnt; ++i) { vec2 hit_depths = sphere_cast(sphere_list[i], dir);