threepipe
Вы не можете выбрать более 25 тем Темы должны начинаться с буквы или цифры, могут содержать дефисы(-) и должны содержать не более 35 символов.

plugin-path-tracing.md 2.5KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768
  1. ---
  2. prev:
  3. text: '@threepipe/plugin-assimpjs'
  4. link: './plugin-assimpjs'
  5. next: false
  6. ---
  7. # @threepipe/plugin-path-tracing
  8. Provides plugin(s) for [path-tracing](https://en.wikipedia.org/wiki/Path_tracing).
  9. Exports
  10. - [ThreeGpuPathTracer](https://threepipe.org/plugins/path-tracing/docs/classes/ThreeGpuPathTracer.html) - adds support for full scene path tracing with GPU acceleration using [three-gpu-pathtracer](https://github.com/gkjohnson/three-gpu-pathtracer)
  11. It provides options to configure the path tracing parameters such as bounces, samples per frame, and more.
  12. It also integrates with the Three.js scene and camera, updating materials and lights as needed.
  13. Serialization and deserialization are supported for plugin state management.
  14. It listens to scene updates, camera changes, and material updates to refresh the path tracing setup.
  15. It can be enabled or disabled, and it automatically handles rendering to the screen or to a texture.
  16. It supports progressive rendering, allowing for a smooth transition of rendered frames.
  17. [Example](https://threepipe.org/examples/#three-gpu-pathtracer/) —
  18. [Source Code](https://github.com/repalash/threepipe/blob/master/plugins/path-tracing/src/index.ts) —
  19. [API Reference](https://threepipe.org/plugins/path-tracing/docs)
  20. [![NPM Package](https://img.shields.io/npm/v/@threepipe/plugin-path-tracing.svg)](https://www.npmjs.com/package/@threepipe/plugin-path-tracing)
  21. ```bash
  22. npm install @threepipe/plugin-path-tracing
  23. ```
  24. ::: warning Note
  25. This is still a WIP.
  26. :::
  27. :::tip Editor
  28. Path tracing rendering can be done directly in the tweakpane editor. Simply enable the plugin from the UI.
  29. :::
  30. ## Sample Usage
  31. To use the plugin, simply add it to the viewer.
  32. The plugin automatically interfaces with the `ProgressivePlugin` to render upto `maxFrameCount`.
  33. The samples are rendered whenever the plugin is enabled and the camera is not moving.
  34. The `WebGLPathTracer` instance in the plugin can be accessed via `viewer.getPlugin(ThreeGpuPathTracer).tracer` property or edited in the UI.
  35. ```typescript
  36. import {ThreeViewer} from 'threepipe'
  37. import {ThreeGpuPathTracer} from '@threepipe/plugin-path-tracing'
  38. const viewer = new ThreeViewer({...})
  39. const pathTracer = viewer.addPluginSync(new ThreeGpuPathTracer(false)) // add the plugin disabled
  40. console.log(pathTracer.tracer) // access the path tracer instance
  41. // load files and environment
  42. pathTracer.enabled = true // enable the plugin to start rendering
  43. ```
  44. Check the [three-gpu-pathtracer](https://threepipe.org/examples/#three-gpu-pathtracer/) example for a live demo.