stackgl / headless-gl

🎃 Windowless WebGL for node.js
1.76k stars 170 forks source link

Issue with transform matrix uniform #207

Open tomhog opened 3 years ago

tomhog commented 3 years ago

Hi

This may not be an issue but something I'm doing wrong. I have a WebGL app I run in the browser and electron. I want to add headless support to render on a server also. I've implemented headless-gl and on the whole it's been very straight forward.

Briefly my application renders floors in images. The floor mesh is rendered to texture and then combined with a photo. For some reason when using headless-gl the floor transform is incorrect.

Capture from browser webgl browser

Capture from node headless gl node

I've stepped through all my code and the uniform that sets the model view projection matrix is getting set to the exact same value in both instances.

What could be happening here? It almost seems as if it's using a different coord system but from my understanding chrome etc use Angle in the background and behaviour should be basically identical?

I'm using gl 4.8.0, node 14.3. Tested on Windows, macOS and Linux, all produce the same result.

Any help would be greatly appreciated. Tom

PS Very awesome project

dhritzkiv commented 3 years ago

Hi Tom. First off: cool photo/render! What is it for?

As for your question: I'm not entirely sure what's going on as I haven't experienced this myself, nor do I recall seeing any issues similar to yours.

Are there any extensions that you're relying on? Perhaps this library doesn't support it, causing unexpected results.

By the way, this library uses angle, which is also what Chrome uses, but headless-gl's version of angle is several years old at this point. It should work, but it doesn't receive new abilities such as webgl2

tomhog commented 3 years ago

Hi Daniel

Thanks for the reply and the comment. It's a flooring visualiser. It uses either photos we've setup with a tool like this one. Or alternatively users can upload their own photo and we use machine learning to create the mask of the floor area and calculate a pose. We'd like to use headless-gl to reach those devices that don't support webgl natively.

Yes I am using some extensions. I use VAO if available but I've tested the browser version with those off and it's ok. We also use standard derivatives and instanced rendering. I'll try a test with instanced rendering disabled and try a simpler shader.

I can probably put together a minimal example and see if it's still happening there.

Strangely last night I got it to look almost correct by flipping the view matrix upside down and flipping two of the components of the rotation quaternion.

I'll post back here what I discover.

Tom

dhritzkiv commented 3 years ago

Funny you mention VAO: it's currently not supported, but there's a PR open for adding it #204. I've still yet to review it and merge it.

That being said, I'm not sure if it would make a difference for your bug :(