chunky-dev / chunky

A path tracer to create realistic images of your Minecraft worlds.
https://chunky-dev.github.io/docs
GNU General Public License v3.0
643 stars 76 forks source link

Color-based, per-material emittance mapping #1627

Open JustinTimeCuber opened 12 months ago

JustinTimeCuber commented 12 months ago

NOTE: this PR depends on/includes the changes from #1621, so it is currently marked as a draft. One useful feature Chunky is currently missing is the ability to differentiate between the parts of blocks that should emit light and the parts that shouldn't. Here is an example with furnaces: image As can be seen, the entirety of the blocks are emitting light despite the fact that physically, only the "flame" portions should be providing light. Ideally this could be done with PBR maps, but besides the fact that we don't have those yet, that basically requires either us to provide them for every emitter (potentially a lot of work) or users to provide them (not really an ideal solution in my opinion). This PR provides 3 methods for determining how much light should be emitted from each pixel as a function of pixel color rather than an emittance map texture. One of these is REFERENCE_COLORS, which allows for specific color range(s) to be specified which should emit light while all other colors will not do so. In this mode, the strength of the emitted light is also dependent on the HSV Value of the pixel color raised to some exponent (default: 1.5). This mode is well-suited to furnaces, as well as some other blocks like lanterns, torches, glow berries, and end rods. There is currently no GUI for adjusting the reference colors, but they can be specified in JSON format and defaults are included for the aforementioned emitters. image For certain other emitters like magma blocks, sea lanterns, and redstone lamps, the darker pixels should emit less light, but not none. In this case, a simpler method (BRIGHTEST_CHANNEL) is used, which simply takes the HSV value raised to the same exponent and uses that as the relative emittance of that pixel: image There is also one more method included called (INDEPENDENT_CHANNELS) which raises each individual RGB component to the provided exponent. This isn't the default because it tends to increase the saturation of emitted light at higher powers making it a bit less realistic, but it is still included as an option for more artistic freedom. image

The current version of this PR doesn't include a GUI option for setting REFERENCE_COLORS which can only be customized by editing the scene JSON, but everything else is customizable through the GUI. I'll look into adding a GUI option (let me know if this is needed before merging) based on the layered fog GUI in #1618.

leMaik commented 11 months ago

We can add a GUI in a future PR.

Peregrine05 commented 10 months ago

How easily is this extended to other material properties?

JustinTimeCuber commented 10 months ago

Should be pretty easy I think

On Thu, Oct 26, 2023, 03:42 Peregrine05 @.***> wrote:

How easily is this extended to other material properties?

— Reply to this email directly, view it on GitHub https://github.com/chunky-dev/chunky/pull/1627#issuecomment-1780580067, or unsubscribe https://github.com/notifications/unsubscribe-auth/ALCOLJDBRT5RZWULGM6FK7TYBIH4RAVCNFSM6AAAAAA4WYOKU2VHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMYTOOBQGU4DAMBWG4 . You are receiving this because you authored the thread.Message ID: @.***>

leMaik commented 10 months ago

Rebased against latest master. Mapping for copper bulbs would be great. :bulb:

leMaik commented 5 months ago

@JustinTimeCuber Given that #1621 is merged now, is this one ready for merge?

JustinTimeCuber commented 5 months ago

I think so, as long as there isn't another new light source I haven't heard about