Skip to content

Conversation

@Peregrine05
Copy link
Member

@Peregrine05 Peregrine05 commented Aug 27, 2025

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 Vector3 origin, a Vector3 direction, 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 ToggleSwitch control, which is a better design choice than a CheckBox when the effects of the control are realized immediately, rather than later.

  • The Lighting tab was removed. Its contents pertaining to the sky and to the sun were relocated to the new Environment tab. The contents pertaining to emitters were relocated to the new Emitters tab.

  • The Sky & Fog tab was removed. Its contents pertaining to the sky were relocated to the Environment tab. Its contents pertaining to fog and clouds were relocated to the new Fog & Clouds tab.

  • 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 Materials tab.

  • 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 Materials tab 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 opacity does what Chunky's current FAST does. Sample only stops when it hits certain interactions (like glass). Diffuse treats the sun as part of the skymap. Mix allows diffuse sun intersections after hitting those certain interactions that Sample only does not handle, but prevents diffuse sun intersections when sampling the sun directly is possible. Overall, the results should be the same as with Diffuse.

  • Draw sun enables 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 texture overrides 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 color tints the sun texture when Use flat texture is disabled, and controls the sun color directly when it is enabled.

  • The Nishita sky model now has many more customization options available.

There may still be plenty of bugs, so this PR could use some testing.

@Peregrine05
Copy link
Member Author

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 controlsfx in the .chunky folder. Add the ControlsFX Jar to the folder.

Build Chunky with ./gradlew buildReleaseJar. (The update site doesn't seem to work for this PR.) Run the build (which will be in build/installer/).

In the Java options field in the Launcher, move the cursor to the end of the value of the --module-path argument. Enter a semicolon ;, and then add the path to the folder containing the ControlsFX Jar. Then move the cursor to the end of the value of the --add-modules argument. Enter a comma ,, and then enter: org.controlsfx.controls.

Your Java options should look something like:

--module-path /home/user/.chunky/javafx/javafx-sdk-17.0.2/lib;/home/user/.chunky/controlsfx --add-modules javafx.controls,javafx.fxml,org.controlsfx.controls

Glass panes are not water-tight, and have quads in strange
places, leading to broken intersections and refractions.
For the moment, disabling refration in glass panes is the
simpler and easier option. Glass panes are too thin for
the refraction to be noticeable in most cases, anyway.
@Peregrine05 Peregrine05 marked this pull request as ready for review September 13, 2025 07:03
@Peregrine05
Copy link
Member Author

Conflicts have been resolved.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment