threepipe
Nelze vybrat více než 25 témat Téma musí začínat písmenem nebo číslem, může obsahovat pomlčky („-“) a může být dlouhé až 35 znaků.

ParallaxMappingPlugin.md 2.1KB

před 1 rokem
123456789101112131415161718192021222324252627282930313233343536373839404142434445
  1. ---
  2. prev:
  3. text: 'FragmentClippingExtensionPlugin'
  4. link: './FragmentClippingExtensionPlugin'
  5. next:
  6. text: 'HDRiGroundPlugin'
  7. link: './HDRiGroundPlugin'
  8. ---
  9. # ParallaxMappingPlugin
  10. [//]: # (todo: image)
  11. [Example](https://threepipe.org/examples/#parallax-mapping-plugin/) —
  12. [Source Code](https://github.com/repalash/threepipe/blob/master/src/plugins/material/ParallaxMappingPlugin.ts) —
  13. [API Reference](https://threepipe.org/docs/classes/ParallaxMappingPlugin.html)
  14. `ParallaxMappingPlugin` adds a material extension to PhysicalMaterial to add support for [parallax relief mapping](https://en.wikipedia.org/wiki/Relief_mapping_(computer_graphics)). The idea is to walk along a ray that has entered the bumpmap's volume, finding the intersection point of the ray with the bumpmap. [Steep parallax mapping](https://en.wikipedia.org/wiki/Parallax_mapping) and [parallax occlusion mapping](https://en.wikipedia.org/wiki/Parallax_occlusion_mapping) are other common names for these techniques.
  15. To use the plugin, add the plugin to the viewer and use the `bumpMap` in `PhysicalMaterial` normally. The max height is determined by the `bumpScale` in the material. This is assumed to be in world scale.
  16. ```typescript
  17. import {ThreeViewer, ParallaxMappingPlugin} from 'threepipe'
  18. const viewer = new ThreeViewer({...})
  19. const parallaxMapping = viewer.addPluginSync(ParallaxMappingPlugin)
  20. // load or create an object
  21. // set the bump map
  22. object.material.bumpMap = await viewer.load<ITexture>(bumps[0]) || null
  23. // set the bump scale
  24. object.material.bumpScale = 0.1
  25. // setDirty to notify the viewer to update.
  26. object.material.setDirty()
  27. ```
  28. ## References and related links:
  29. - WebGL implementation by Rabbid76 - [github.com/Rabbid76/graphics-snippets](https://github.com/Rabbid76/graphics-snippets/blob/master/html/technique/parallax_005_parallax_relief_mapping_derivative_tbn.html)
  30. - Lesson on Parallax Occlusion Mapping in GLSL - [http://sunandblackcat.com/tipFullView.php?topicid=28](https://web.archive.org/web/20190128023901/http://sunandblackcat.com/tipFullView.php?topicid=28)
  31. - Learn OpenGL - https://learnopengl.com/Advanced-Lighting/Parallax-Mapping