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

SDF generation demo not work on windows #497

Open
MaksimMirR opened this issue Nov 30, 2022 · 17 comments
Open

SDF generation demo not work on windows #497

MaksimMirR opened this issue Nov 30, 2022 · 17 comments
Labels
bug Something isn't working
Milestone

Comments

@MaksimMirR
Copy link

Screenshots

bugReport

Platform:

Any windows machine is the same result

@MaksimMirR MaksimMirR added the bug Something isn't working label Nov 30, 2022
@gkjohnson
Copy link
Owner

Yes I think @DennisSmolek mentioned the same thing. I don't have access to a windows machine at the moment so any help or investigation into this would be great.

@gkjohnson gkjohnson added this to the v0.x.x milestone Nov 30, 2022
@DennisSmolek
Copy link

I've actually been trying to get the example working on my local machine or a sandbox,
unfortunately I'm running into the import.meta issue with the worker and can't see a quick fix or how to get it to work in code sandbox...

If someone has the fix for that I'll get back on this grey box sdf thing..

@gkjohnson
Copy link
Owner

I've actually been trying to get the example working on my local machine or a sandbox,
unfortunately I'm running into the import.meta issue

How are you running the examples? It should be better documented / cleaned up but you'll want to run npm start then visit localhost:9080/example/dev-bundle/sdfGeneration.html.

I'd like the get rid of the static-server component and just use parcel in the future, tho.

@CodyJasonBennett
Copy link

CodyJasonBennett commented Dec 1, 2022

I put this together for #491 which works on my Windows machines after disabling GPU generation (populating a Data3DTexture on the CPU instead of rendering into a WebGL3DRenderTarget).

@DennisSmolek
Copy link

@CodyJasonBennett haha I was going to post my fork of that too!
https://codesandbox.io/s/three-mesh-bvh-sdf-generation-fbo-forked-fb7r86?file=/src/index.js:8488-8497

If you flip the "surface" value positive you'll see that it goes dark immediately at the cube boundary, which is where the march approximation starts in the GPU version:

I fiddled with things initially the other day and the render pass is still working correctly, but was having a hard time doing a comparison of GPU vs CPU as it has a pretty different setup/flow and not just because it's on the GPU...

On the GPU it calls ThreeJS methods to add some lights.. Which the CPU version skips.

// compute some basic lighting effects
vec3 lightDirection = normalize( vec3( 1.0 ) );
float lightIntensity =
    saturate( dot( normal, lightDirection ) ) +
    saturate( dot( normal, - lightDirection ) ) * 0.05 +0.1;

So my newb brain cant workout if it's say a bad sample or the light is weird etc.

It makes sense, the GPU would be faster/more powerful so add stuff, but on top of the Worker blocking a unbundled build I wasn't able to track down yet.

I'm going to refactor a version of that sandbox and try to make the marching passes as basic and 1:1 so I can better follow where it might be breaking..

@DennisSmolek
Copy link

Screenshot_20221202_154013
GPU pass

Screenshot_20221202_154536
CPU pass and tweaking the surface value in realtime

@DennisSmolek
Copy link

I stumbled onto this UnityLabs package and it seems we're all following the same guides..
https://github.com/Unity-Technologies/com.unity.demoteam.mesh-to-sdf/blob/main/Runtime/MeshToSDF.compute#L128
Which they cited as being based on a AMD OpenGPU lib. They actually included it: https://github.com/Unity-Technologies/com.unity.demoteam.mesh-to-sdf/blob/main/_External/TressFXSDF.hlsl#L123

Someone might swoop and and see the bug, but I'm confident I'll be able to work it out eventually!

@CodyJasonBennett
Copy link

CodyJasonBennett commented Dec 7, 2022

Here's a minimal recreation toggling between THREE.WebGL3DRenderTarget and THREE.Data3DTexture via the gpuGeneration boolean. https://jsfiddle.net/cbenn/h3cL7tjw/ The page should display green at all times, but is black when gpuGeneration is disabled on Windows/D3D12.

This is clearly an issue between my device and three.js so I'll do a little investigation and forward this over there.

@DennisSmolek
Copy link

This is clearly an issue between my device and three.js so I'll do a little investigation and forward this over there.
Small addendum I wanted to add is it's not just your device but seems like all windows machines.

Admittedly our sample size is small, but the OP also a Windows user. as is the 2 others I talked with

@N8python would be interesting to ask too, as they seems to be using the same boilerplate/logic for GPU Generate things and may have a work around..

@gkjohnson
Copy link
Owner

@N8python would be interesting to ask too, as they seems to be using the same boilerplate/logic for GPU Generate things and may have a work around..

As far as I understand N8 was not rendering directly into a 3d render target.

This sounds like a platform issue, though. Does this happen on all browsers on windows? Or just Chrome?

@CodyJasonBennett
Copy link

I can reproduce this on all browsers on Windows. Is there a way to have ANGLE choose Vulcan or some other backend?

@gkjohnson
Copy link
Owner

I can reproduce this on all browsers on Windows. Is there a way to have ANGLE choose Vulcan or some other backend?

I'm not sure. Maybe it's worth opening a three.js issue with the minimal repro and the consider reporting to Chrome Bugzilla and maybe they can provide some more insight into where this is failing.

@DennisSmolek
Copy link

@CodyJasonBennett you have the specifics, but we isolated the issue to problems with the renderTarget / 3D Texture.

Seems it may be a higher up bug.

There are work arounds but they are hacks.

Problem on Chrome/Mac still exists (Onioning)

@CodyJasonBennett
Copy link

CodyJasonBennett commented Dec 15, 2022

A work-around would be to render each layer into a 2D render target and iteratively pipe it into a 3D data texture on the CPU. You can see the diff here: https://gist.github.com/CodyJasonBennett/b6172655dd8bcf5a4d11c556394c7210. This is used in practice with https://codesandbox.io/s/simondev-youtube-clouds-rn9kfx.

I'm a bit burnt out right now, but I'll see if I can find time to report this downstream.

@gkjohnson
Copy link
Owner

gkjohnson commented Jan 28, 2023

In toggling the chrome://flags#use-angle setting for gkjohnson/three-gpu-pathtracer#325 (comment) I've noticed that the rendering with the OpenGL backend rather than the D3D11 backend fixes this issue. So this seems to definitely be a platform issue specifically with D3D11 ANGLE.

I'm going to try to take some steps to understand where this breaks, though, between the SDF example and working 2d array three.js example.

@makc
Copy link

makc commented Jun 27, 2023

same issue here. Idk if relevant, but did you see this comment at SO:
Screenshot 2023-06-27 at 10-38-22 Render to 3D texture webgl2

@gkjohnson
Copy link
Owner

This has been submitted to and acknowledged as a bug by Chrome:

https://bugs.chromium.org/p/chromium/issues/detail?id=1411048

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

5 participants