Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix distortion in p5 integration #101

Merged
merged 1 commit into from
Sep 5, 2023

Conversation

davepagurek
Copy link
Contributor

Currently, cubes rendered via the p5 integration show spherical distortion:
image

This is because the p5 integration was inverting the model view matrix before drawing the sphere that we render Shader Park onto. However, when drawing a sphere, p5 updates the model view matrix again to apply a scale. The camera information passed to Shader Park does not have this scale, which results in incorrect rays.

I've updated the code to no longer do the matrix inversion in Javascript. This eliminates the need to grab the model view matrix ahead of time, and instead only uses the correct uMVMatrix that p5 passes in.

Updated:

image Live: https://editor.p5js.org/davepagurek/sketches/HM9sUI8Qh

@PWhiddy
Copy link
Member

PWhiddy commented Sep 5, 2023

Perfect thank you!

@PWhiddy PWhiddy merged commit b906491 into shader-park:main Sep 5, 2023
1 check passed
@davepagurek davepagurek deleted the fix/p5-distortion branch September 5, 2023 15:49
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants