Hi all,
This is a bit of a two-part question:
I’m working on a sketch of falling 3D cubes that uses cannon.js and shaders. I currently have a shader applied that creates a gradient on each face based on the vertex positions. https://editor.p5js.org/bdooley7/sketches/HpqxdO62r. However, this gradient is tied to the camera position - I believe due to uModelViewMatrix being used to calculate both the model and view matrices. I would like to remove the effect of the camera, replacing it with a fixed reference point, so the camera can orbit without affecting the box gradients.
Camera zoomed far away vs close up:
Is the only way to accomplish this by defining a model matrix manually? I have attempted to do this, using the cannon.js position and quaternion of each box, and successfully got the boxes to change color based on position, but now they appear as solid colors (https://editor.p5js.org/bdooley7/sketches/J1U0ipv47), rather than the gradient effect I would like to achieve.
I would greatly appreciate any help!