Repository navigation
Refactor the path tracer - #1830
Peregrine05 wants to merge 173 commits into
Conversation
Current bugs: - Water is invisible - Entities are visible through blocks (probably due to intersection order and not testing against distance to previous intersection test) - Sky / sunlight is visible through blocks
(they didn't fix clouds)
This prevents total internal reflection on most underwater surfaces where its presence doesn't make sense.
Fix file permissions
|
To build and run the PR, follow the instructions below. Download ControlsFX from here: https://repo1.maven.org/maven2/org/controlsfx/controlsfx/11.2.1/controlsfx-11.2.1.jar Create a new folder somewhere, such as Build Chunky with In the Your Java options should look something like:
|
(cherry picked from commit 9af7774)
(cherry picked from commit be0b00c)
(cherry picked from commit 5192f64)
(cherry picked from commit c3b4bb3)
* Add sulfur spikes. * Add the new bed models and refactor loading bed textures to map old textures to the new format. * Fix hard-coded legacy bed texture scale. (cherry picked from commit 4676936)
* Add an adapter to convert old sign textures to 26.2 sign textures. * Update the sign model. * Update the wall sign model. * Add an adapter to convert old hanging sign textures to 26.2 sign textures. * Update the hanging sign model. * Update the wall hanging sign model. (cherry picked from commit 59ed6de)
…ky-dev#1896) (cherry picked from commit 14daf1c)
…ected by the biome. (chunky-dev#1901) (cherry picked from commit 27f874b)
Related to chunky-dev#1408 (cherry picked from commit 02d2676)
…nd EmptyDimension. (chunky-dev#1905) * Resolve cyclic dependency between static initializers of EmptyWorld and EmptyDimension. * Ensure that EmptyWorld cannot change dimension. (cherry picked from commit 156e2bb)
…hunky-dev#1376) * Allow Blocks and Entities to return multiple Entities Lecterns are no longer poseable Lecterns now return both the lectern and its book. * Use Collections.singleton instead of Collections.singletonList. * Throw UnsupportedOperationException instead of Error when trying to create entities or block entities from blocks that don't support this. * Rename some entity-related block methods and add more documentation to clarify how entities and block entities work. * Make Entities#fromJson return a single entity, legacy entities now handled by caller --------- Co-authored-by: Maik Marschner <leMaik@leMaik.de> (cherry picked from commit b1bd7fa)
chunky-dev#1910) (cherry picked from commit 4f1dc9c)
…er time. (chunky-dev#1911) * Calculate samples per second from time per pass instead of total render time. * Apply batched suggestions from code review Fix ns to ms conversion. Co-authored-by: Maik Marschner <m.marschner@wertarbyte.com> (cherry picked from commit f2f7ab8)
(cherry picked from commit 527cb4a)
… match Minecraft (chunky-dev#1915) * Add support for new chunk format * Update default block states to match Minecraft * Remove unused import * Update BlockPaletteTest.java * Actually add support for the 26.3 chunk format (cherry picked from commit 65db8a6)
* Add blocks from 26.3 snapshot 1 * Remove unused import * Fix copy error * Add age to shelf mushroom description. * Move shelf mushroom texture selection into the model code. --------- Co-authored-by: Maik Marschner <m.marschner@wertarbyte.com> (cherry picked from commit 73497cd)
(cherry picked from commit 62525ec)
chunky-dev#1895) * Create a single place for all chunky thread/executors to be registered Closes chunky-dev#1893 - Allows chunky to close them on shutdown without a System.exit() - Additionally provides an api to wait on all chunky threads to be joined. * Fix race between joinAll and extremely lately added threads/executors * Make joinAll not synchronized * Return whether all threads were joined from joinAll methods * Add Chunky's ForkJoinPool to ChunkyThread * Change ExecutorService thread factory * Add PluginApi to relevant ChunkyThread methods * Add shutdown hook to handle early System.exit() * Put interruptAndJoinAll in a finally block * Switch back to ConsoleReceiver on UI stop * Move the shutdown hook out of ChunkyThread, now managed by Chunky itself * Remove PluginApi from joinAll * Refactor ChunkyThread joinAll to give stronger guarantees And hopefully be more readable (cherry picked from commit a52b9bc)
* Remove jank in PluginManager * Remove unnecessary chunky.plugins.maxLoadCycles jvm arg. The comment already explains that the worst case cannot take more cycles than the number of plugins to load, so we use that. * Implement plugin shutdown (cherry picked from commit f10ef3f)
…ounds straw. (cherry picked from commit ff3e8b1)
(cherry picked from commit fa85002)
…ng visible. (cherry picked from commit 98c7653)
(cherry picked from commit 5c3ffc6)
(cherry picked from commit 053bf04)
…to remove implicit format dependencies. (cherry picked from commit 891d6ad)
# Conflicts: # chunky/src/java/se/llbit/chunky/block/BlockSpec.java # chunky/src/java/se/llbit/chunky/block/MinecraftBlockProvider.java # chunky/src/java/se/llbit/chunky/block/minecraft/CopperGolemStatue.java # chunky/src/java/se/llbit/chunky/block/minecraft/CoralFan.java # chunky/src/java/se/llbit/chunky/block/minecraft/Head.java # chunky/src/java/se/llbit/chunky/block/minecraft/Lava.java # chunky/src/java/se/llbit/chunky/block/minecraft/Lectern.java # chunky/src/java/se/llbit/chunky/block/minecraft/LilyPad.java # chunky/src/java/se/llbit/chunky/block/minecraft/SporeBlossom.java # chunky/src/java/se/llbit/chunky/block/minecraft/WallCoralFan.java # chunky/src/java/se/llbit/chunky/block/minecraft/WallHead.java # chunky/src/java/se/llbit/chunky/block/minecraft/Water.java # chunky/src/java/se/llbit/chunky/chunk/BlockPalette.java # chunky/src/java/se/llbit/chunky/entity/ChickenEntity.java # chunky/src/java/se/llbit/chunky/entity/Entity.java # chunky/src/java/se/llbit/chunky/entity/MooshroomEntity.java # chunky/src/java/se/llbit/chunky/entity/PlayerEntity.java # chunky/src/java/se/llbit/chunky/model/AABBModel.java # chunky/src/java/se/llbit/chunky/model/minecraft/GlassPaneModel.java # chunky/src/java/se/llbit/chunky/model/minecraft/ObserverModel.java # chunky/src/java/se/llbit/chunky/model/minecraft/PressurePlateModel.java # chunky/src/java/se/llbit/chunky/renderer/scene/OctreeFinalizer.java # chunky/src/java/se/llbit/chunky/renderer/scene/Scene.java # chunky/src/java/se/llbit/chunky/renderer/scene/SceneEntities.java # chunky/src/java/se/llbit/chunky/renderer/scene/sky/Sky.java # chunky/src/java/se/llbit/chunky/renderer/scene/sky/Sun.java # chunky/src/java/se/llbit/chunky/renderer/scene/watershading/WaterShader.java # chunky/src/java/se/llbit/chunky/resources/SignTexture.java # chunky/src/java/se/llbit/chunky/ui/controller/ChunkyFxController.java # chunky/src/java/se/llbit/chunky/ui/render/tabs/EntitiesTab.java # chunky/src/java/se/llbit/chunky/world/ExtraMaterials.java # chunky/src/java/se/llbit/math/Octree.java # chunky/src/java/se/llbit/math/Vector3.java # chunky/src/res/se/llbit/chunky/ui/render/tabs/GeneralTab.fxml
Closes #26
Closes #361
Closes #502
Closes #612
Closes #636
Closes #665
Closes #893
Closes #980
Closes #1162
Closes #1230
Closes #1258
Closes #1409
Closes #1476
Closes #1477
Closes #1482
Closes #1515
Closes #1591
Possibly closes #1617
Possibly closes #1642
Closes #1669
Closes #1671
Closes #1494 in favor of this
Closes #1577 in favor of this
Closes #1601 in favor of this
Includes the changes from #1627, and adds a GUI for the reference color system.
Closes #1660 in favor of this
Closes #1668 in favor of this
Closes #1673 in favor of this
Includes the changes from #1809
The primary purpose of this PR is to refactor the path tracer to use a simple ray, and intersection records. The new ray stores a
Vector3origin, aVector3direction, the material it is traversing, and a flags integer. The IntersectionRecord stores distance, geometry normal, shading normal, uv coordinates, material, color, and a flags integer.I fixed a few other problems, but unfortunately did not think to change branches while doing so.
Notably:
I made use of the ControlsFX library for the
ToggleSwitchcontrol, which is a better design choice than aCheckBoxwhen the effects of the control are realized immediately, rather than later.The
Lightingtab was removed. Its contents pertaining to the sky and to the sun were relocated to the newEnvironmenttab. The contents pertaining to emitters were relocated to the newEmitterstab.The
Sky & Fogtab was removed. Its contents pertaining to the sky were relocated to theEnvironmenttab. Its contents pertaining to fog and clouds were relocated to the newFog & Cloudstab.The
Water visibility,Water opacity, and water color controls were removed, in favor of using material properties to control these properties. Notably, biome-tinted water is no longer possible, but it doesn't look realistic to begin with.More material properties were added to the
Materialstab.Materials can be right-clicked in the render preview to be edited through a dialog box. The advantages of this approach are that individual blockstates can be edited, which is something that the
Materialstab does not support. While changes to octree materials are saved to the blockPalette, allowing them to persist through scene saves and restarts, they are not saved to the scene.json, making external editing difficult. Also, individual materials in the BVH can be edited; however, since individual BVH materials are not saved to the scene.json, these changes will not persist through scene saves and restarts.These material properties are:
Emittance color: Changes the tint of the color of emitted light.Emitter mapping offset: See Color-based, per-material emittance mapping #1627 for details.Emitter mapping type: See Color-based, per-material emittance mapping #1627 for details.Use reference colors: Extracted this option to its own control, so that it can be used in conjunction with the other emitter mapping types.Alpha: Changes the opacity of the texture.Subsurface scattering: Changes the percentage of rays that have their normal inverted, so that they scatter to the other side of the texture.Diffuse color: Changes the tint of diffuse reflections.Specular: Changes the percentage of rays that are specularly reflected with no texture tinting.Transmission smoothness: Changes the smoothness for transmitted and refracted rays.Opaque: This option requires a chunk reload for its effects to be realized.Hidden: Prevents intersections with this material entirely.Volume density: When the current ray medium is the selected material, this sets the density of the volume scatter medium.Absorption: Rays travelling through the medium will be attenuated if the value is greater than 0.Metalness: Changes the percentage of specularly-reflected rays that are texture-tinted.Transmission metalness: Changes the percentage of specularly-transmitted or refracted rays that are texture tinted.The reference color GUI should be self-explanatory.
Other things of note are:
Branched path tracing is not functional at the moment. The infrastructure is still present in the renderer, but it is not implemented in the path tracer. As such, branch count is hard-coded to 1, and the control is hidden.
Fancier translucency is removed, because the new path tracer should handle transparent colors correctly* (At least it seems to do so.)
The sun sampling options have been changed.
Sample through opacitydoes what Chunky's currentFASTdoes.Sample onlystops when it hits certain interactions (like glass).Diffusetreats the sun as part of the skymap.Mixallows diffuse sun intersections after hitting those certain interactions thatSample onlydoes not handle, but prevents diffuse sun intersections when sampling the sun directly is possible. Overall, the results should be the same as withDiffuse.Draw sunenables or disables sunlight entirely, through adding or removing the sun texture from the skymap. It does not stop "sun sampling", however, as Chunky will still sample the sky where the sun is. This can be used to sample an HDRi, for example.Use flat textureoverrides the sun texture provided by the resource pack with a simple solid color square. It is enabled by default, and should be used when you want a specific sun color.Sunlight colortints the sun texture whenUse flat textureis disabled, and controls the sun color directly when it is enabled.The
Nishitasky model now has many more customization options available.There may still be plenty of bugs, so this PR could use some testing.