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

NodeMaterials support #479

Open hybridherbst opened 5 months ago

hybridherbst commented 5 months ago

Is your feature request related to a problem? Please describe.

I have no idea if this is feasible! As three.js is moving (slowly but surely) to node materials for a lot of things, we're looking into support for MaterialX inside glTF and all kinds of fun other things that, in essence, mean: using node-based shaders instead of single Uber shaders like MeshPhysicalMaterial.

My understanding is that currently three-gpu-pathtracer works by mashing every shader in the scene into one big mega shader that is used for the actual pathtracing. For supporting node materials, that would likely mean scenes become even more complex – any of the well-defined slots of MeshPhysicalMaterial could have a node graph behind them that outputs that single channel.

I believe in theory the approach stays the same, but the resulting shader becomes even more complex (for complex scenes), as it now would have to contain all node graphs used in the scene as somehow separately accessible functions.

Describe the solution outcome you'd like

Being able to pathtrace scenes like this: