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.27k stars 125 forks source link

Line2 object render error, just show as a plane #643

Closed Milesssssss closed 4 weeks ago

Milesssssss commented 4 weeks ago
image

Code demo

const l = new Bezier({
      x: -3, y: 0, z: 0
    }, { x: 2, y: 0, z: 0 }, { x: 3, y: 0, z: 0 })
    const lineGeometry = new LineGeometry()
    const ps = l.getLUT(10).flatMap(r => {
      return [r.x, r.y, r.z]
    })
    lineGeometry.setPositions(ps)
    const test = new Line2(lineGeometry, new LineMaterial({
      color: 0xff0000,
      linewidth: 0.005,
      dashed: false,
    }))
    test.computeLineDistances()
gkjohnson commented 4 weeks ago

The path tracer only supports Mesh geometry and does not support instancing or custom shaders - both of which Line2 uses. If you'd like to render the line on top of the path traced model you'll have to render it in a separate pass or convert it to a 3d mesh like a tube before path tracing.

Milesssssss commented 4 weeks ago

Get it.