Skip to content

Commit

Permalink
Fix distortion in p5 integration
Browse files Browse the repository at this point in the history
  • Loading branch information
davepagurek authored and PWhiddy committed Sep 5, 2023
1 parent cbe386a commit b906491
Showing 1 changed file with 2 additions and 9 deletions.
11 changes: 2 additions & 9 deletions targets/p5.js
Original file line number Diff line number Diff line change
Expand Up @@ -21,19 +21,18 @@ export function toGLSL(source) {
precision highp float;
in vec3 aPosition;
uniform mat4 uModelViewMatrix;
uniform mat4 uInverseModelViewMatrix;
uniform mat4 uProjectionMatrix;
out vec4 worldPos;
out vec3 sculptureCenter;
out vec3 cameraPosition;
void main() {
vec4 mvPosition = uModelViewMatrix * vec4(aPosition, 1.0);
mat4 modelMatrix = uModelViewMatrix;
mat4 inverseModelViewMatrix = inverse(uModelViewMatrix);
worldPos = vec4(aPosition, 1.);
sculptureCenter = vec3(0.);
cameraPosition = (uInverseModelViewMatrix * vec4(0., 0., 0., 1.0)).xyz;
cameraPosition = (inverseModelViewMatrix * vec4(0., 0., 0., 1.0)).xyz;
gl_Position = uProjectionMatrix * mvPosition;
}
Expand Down Expand Up @@ -97,8 +96,6 @@ function createRenderer(target, {
);
}

const inverseModelViewMatrix =
new p5.Matrix().invert(_renderer.uMVMatrix)
const gl = window._renderer.GL;
const faceCullingEnabled = gl.isEnabled(gl.CULL_FACE);
const cullFaceMode = gl.getParameter(gl.CULL_FACE_MODE);
Expand All @@ -108,10 +105,6 @@ function createRenderer(target, {
target.push();
target.noStroke();
target.shader(output.shader);
output.shader.setUniform(
'uInverseModelViewMatrix',
inverseModelViewMatrix.mat4
);
output.shader.setUniform('time', millis() / 1000);
output.shader.setUniform('opacity', 1);
output.shader.setUniform(
Expand Down

0 comments on commit b906491

Please sign in to comment.