-
-
Notifications
You must be signed in to change notification settings - Fork 3.4k
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
Separate the Model and View Matrices #5287
Comments
I agree with this. I found it painful to work on AR for p5.xr without separated model and view matrices. As a side note, I think that this would set us up to allow for more of an object-based approach to manipulating 3D objects. I have longed for the day that we could just do Anyways, I am a bit off-topic here but separated model and view matrices would open up the door to thinking about differently scoped model matrices as well. |
Unfortunately I don't think I have the technical knowledge to implement this, nor the familiarity with the P5 code base, but I'd just like to throw my support behind this feature as well. It would be really useful to get the world-space position of vertices inside the vertex shader for certain effects. |
Hello! I am trying to work on this. These are the changes made so far. I'd be grateful for any tips or suggestions to make things work. Thanks! I request @davepagurek to please take a look.. Thank you! |
Thanks for taking this on, it's looking good! I noticed a few little things to update:
Feel free to open a PR for easier reviewing/conversation! |
Sure, thank you! |
I've implemented a temporary hack for this using bindMatrices (source code available here). Check out the visualization of perspective transformation to NDC for an example. I'm also looking for advice on applying the shader there to scene lines in addition to just polygons? |
Most appropriate sub-area of p5.js?
Feature enhancement details:
Currently in the source code, the model and view matrices are combined into one (
uMVMatrix
). Typically, these two matrices are kept distinct from each other. The model matrix used only for translating / rotating / scaling the model. The view matrix used only for translating / rotating the camera.One consequence of this, is that the model matrix is not available for use in shader programs. Currently, the view matrix and modelView matrix are passed to shaders as follows:
If the two are kept separate in the code, then providing the model matrix to shader programs becomes trivial.
The separation of concerns will also make maintaining and/or expanding functionality in the source code simpler.
How would this new feature help increase access to p5.js?
Exposing the model matrix as a uniform available for users to use in their shader programs can make p5 a better platform for people looking to learn about 3D graphics and shaders. It will make it possible to use p5 to follow along with the wider ecosystem of tutorials, books, and other educational material on computer graphics.
---
This issue is an extension of the conversation here.
The text was updated successfully, but these errors were encountered: