-
-
Notifications
You must be signed in to change notification settings - Fork 198
Tweaks and clips to make things work on ThreeJS #231
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
Conversation
@patriciogonzalezvivo I would strongly object to having different default handedness for GLSL and HLSL. This is going to make porting code from one to the other much more difficult. You're right in saying that OpenGL is right-handed, but I think we should have unified handedness across Lygia. Did changing to right-handed by default break anything in the examples? Particularly in the raymarching examples. |
@shadielhajj examples from |
@shadielhajj I hear your concerns. I feel having a plug&play experience following the platform/driver conventions + define flags to overwrite those defaults, bring options and control while playing to the strengths of having a multi-language library (instead of trans-compiling from/to SPIR-V) |
@patriciogonzalezvivo Sadly the handedness issue is all over the place in the industry, as this graphic shows So I'm not sure sticking to platform conventions does help (because as you can see above, nobody seems to care). |
Haha, well spotted @mrdoob! Ricardo, while you're here, I'm really curious to hear about your experience with coordinate systems. As well as the rationale (if any) for preferring one over the other. |
Someone pointed to this one by @FreyaHolmer |
dang techarthub could've just asked to use my graphic rather than recreating it lol also, I think it's really really important to try and stick to the canonical ordering of axes to avoid confusion - we've very lucky in that the games industry has settled on always being 100% consistent on matching XYZ to the colors RGB (in that order), it'd be nice to stick to the thumb-index-middle order as well to avoid confusion or accidentally mixing up which finger is which axis |
Converting rotations and hierarchies from different coordinate systems is a pain. Nowadays, it's probably easy to ask the AI for the right conversion code though.
To me X right and Y up made sense as it follows the orientation of 2D images and made me think of the computer screen as a portal. Then it was a matter of deciding whether Z went towards the viewer or away from the viewer. Towards the viewer felt better to me. Hope that makes sense. |
hmm handedness is unrelated to look rotations in my view - generally handedness is "invisible" in math/code unless you're specifically converting between them. basically - a left handed coordinate system math library looks exactly the same as a right handed one, including a look rotation function. For example, if you say "Z+ is forward, Y+ is up", the math for that look rotation function is the same, regardless of whether your ambient space is left or right handed. Currently, looking at Also, I would recommend doing |
Makes a ton of sense, thank you. |
Agreed. In our case, the main impact will be on example code, which will have to be modified in case we decide to switch coordinate systems.
Good point. We should probably rename these defines to make it clearer.
Great point. Thanks. |
Thank you @FreyaHolmer those are great points! I will work on some corrections. |
I'm temporally undoing the default Originally my intention was to have an "ambient handedness" that change the behavior of all spatial matrices. I thought would be nice to have follow the framework/driver default so the experience is more seamless. But I hear the point so for the moment following mathematical correctness seams safer. Before settling down with the undoing of that change, did a super professional research to see what were users expectations. I'm adding it here in case we want to give another round of thoughts. Thank you everyone for your opinions. |
@shadielhajj do you mind reviewing? |
@patriciogonzalezvivo Sorry for the delay Patricio. I'm on vacation on an island and off-grid. But will review asap. Apologies again. |
@shadielhajj oh! that's fantastic! please enjoy and don't worry about this! enjoy! |
As far as I'm concerned, I think we're good to go on this one @patriciogonzalezvivo. Sorry again for the delay. |
Took some minor work to make this work correctly on ThreeJS. Mayor changes are:
ThreeJS inject a
float luminance(vec3)
function. Unfortunately they don't use any kind of define flag for it that we could use to single it out and prevent the collision. I should touch bases with @mrdoob and other ThreeJS maintainers to have a more robust solution for the future. For the moment I'm removing the dependency to that function just because is a one-liner.I'm making look-at matrices right handed by default in OpenGL (GLSL). In the same way we have
LOOK_AT_RIGHT_HANDED
now we haveLOOK_AT_LEFT_HANDED
to change the default behavior. This is mostly after a quick google that confirms that right handed view matrices are default on OpenGL. So, I could be totally wrong and misguided.fix the previous
tonemap()
additions to the SH sampling to make it active just for#ifdef GLSLVIEWER
. This is temporal, in the longer run I just need to fix the way I'm computing the SH. But now more correct, just like @shadielhajj.the rest are smaller things that were surface when trying to make the new PBR pipeline work on WebGL 2.0
Here running in this double ThreeJS/GlslViewer example:
2024-10-29.16-16-03.mp4