gkjohnson / three-gpu-pathtracer

Path tracing renderer and utilities for three.js built on top of three-mesh-bvh.
https://gkjohnson.github.io/three-gpu-pathtracer/example/bundle/index.html
MIT License
1.28k stars 125 forks source link

iOS modifications #466

Closed robertoranon closed 7 months ago

robertoranon commented 7 months ago

This PR modifies the library so that it can render on iPadOS / iOS. More specifically:

important: these modifications, at present, require also to disable Multiple Importance Sampling (MIS), otherwise the browser crashes, or there are shader compilation errors. This is also needed for the library to work on macOS, but has not been done in this PR, to avoid disabling MIS for other systems. If you are on a Mac or iOS device, you can disable MIS globally by adding the following line:

this.setDefine('FEATURE_MIS', 0);

in the onBeforeRender function in src/materials/pathtracing/PhysicalPathTracingMaterial.js.

With these modifications, all examples work, except for:

Tested with iPad Pro M1 (iPadOS 17.0.3) and MacBook Pro M1 Max 32 giga (Sonoma 14.1)

gkjohnson commented 7 months ago

Thanks for bearing with the linting changes 😅 You can check for them locally by running npm run lint, as well.

Otherwise this looks good!

gkjohnson commented 7 months ago

Amazing! Thank you!

If you'd like to help understand why any of the remaining issues aren't working, either, that would be very helpful:

With these modifications, all examples work, except for:

  • depthOfField (black screen, also on macOS)
  • blur (black screen, also on macOS)
  • materialBall (webgl error, also on macOS)
  • spotLights.js (black screen, also on macOS)