-
Notifications
You must be signed in to change notification settings - Fork 77
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Color-based, per-material emittance mapping #1627
Open
JustinTimeCuber
wants to merge
16
commits into
chunky-dev:master
Choose a base branch
from
JustinTimeCuber:emittance-mapping
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
16 commits
Select commit
Hold shift + click to select a range
31ce4bf
Configurable exponent for emitter mapping
JustinTimeCuber 95c78a0
add emitter mapping type option
JustinTimeCuber 91c8366
make it work with emitter sampling
JustinTimeCuber 757ada5
per-material customization
JustinTimeCuber 3fe2548
assign some defaults and fix all emittances
JustinTimeCuber 1a34520
tweaks
JustinTimeCuber db8e089
add REFERENCE_COLORS mode
JustinTimeCuber d48dc3f
colors for torches and lanterns
JustinTimeCuber 90164ad
end rods and glow berries
JustinTimeCuber b517294
JSON parsing for reference colors
JustinTimeCuber 8fb22d5
Hide extra settings behind "Advanced" checkbox in materials & "Enable…
JustinTimeCuber eba5b5f
add redstone ore reference colors
JustinTimeCuber 38dc155
copper bulb emitter maps
JustinTimeCuber 863237c
some small fixes
JustinTimeCuber 43d1326
Merge branch 'master' into emittance-mapping
JustinTimeCuber bf900cb
Remove debug output
JustinTimeCuber File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
224 changes: 144 additions & 80 deletions
224
chunky/src/java/se/llbit/chunky/chunk/BlockPalette.java
Large diffs are not rendered by default.
Oops, something went wrong.
30 changes: 30 additions & 0 deletions
30
chunky/src/java/se/llbit/chunky/renderer/EmitterMappingType.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
package se.llbit.chunky.renderer; | ||
|
||
import se.llbit.util.Registerable; | ||
|
||
public enum EmitterMappingType implements Registerable { | ||
NONE("None", "Fallback to default option - should only be used for materials (not global default)"), | ||
BRIGHTEST_CHANNEL("Brightest Channel", "Emitted light (R', G', B') = (R*M^P, G*M^P, B*M^P) where M = max(R, G, B) and P is the specified power. Emitted light will always match pixel color."), | ||
REFERENCE_COLORS("Reference Colors", "Like BRIGHTEST_CHANNEL, but only for colors near enough to a reference color; rest of pixels won't emit at all."), | ||
INDEPENDENT_CHANNELS("Independent Channels", "Emitted light (R', G', B') = (R^P, G^P, B^P) where P is the specified power. Saturation of emitted light increases with P - possibly less realistic in some situations."); | ||
private final String displayName; | ||
private final String description; | ||
EmitterMappingType(String displayName, String description) { | ||
this.displayName = displayName; | ||
this.description = description; | ||
} | ||
@Override | ||
public String getName() { | ||
return this.displayName; | ||
} | ||
|
||
@Override | ||
public String getDescription() { | ||
return this.description; | ||
} | ||
|
||
@Override | ||
public String getId() { | ||
return this.name(); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -25,7 +25,9 @@ | |
import javafx.scene.control.*; | ||
import javafx.scene.control.Alert.AlertType; | ||
import javafx.scene.control.ButtonBar.ButtonData; | ||
import javafx.scene.layout.VBox; | ||
import javafx.scene.paint.Color; | ||
import se.llbit.chunky.renderer.EmitterMappingType; | ||
import se.llbit.chunky.renderer.EmitterSamplingStrategy; | ||
import se.llbit.chunky.renderer.SunSamplingStrategy; | ||
import se.llbit.chunky.renderer.scene.Scene; | ||
|
@@ -52,6 +54,9 @@ public class LightingTab extends ScrollPane implements RenderControlsTab, Initia | |
@FXML private DoubleAdjuster skyIntensity; | ||
@FXML private DoubleAdjuster apparentSkyBrightness; | ||
@FXML private DoubleAdjuster emitterIntensity; | ||
@FXML private VBox emitterSettings; | ||
@FXML private ComboBox<EmitterMappingType> emitterMappingType; | ||
@FXML private DoubleAdjuster emitterMappingExponent; | ||
@FXML private DoubleAdjuster sunIntensity; | ||
@FXML private CheckBox drawSun; | ||
@FXML private ComboBox<SunSamplingStrategy> sunSamplingStrategy; | ||
|
@@ -101,7 +106,21 @@ public LightingTab() throws IOException { | |
|
||
enableEmitters.setTooltip(new Tooltip("Allow blocks to emit light based on their material settings.")); | ||
enableEmitters.selectedProperty().addListener( | ||
(observable, oldValue, newValue) -> scene.setEmittersEnabled(newValue)); | ||
(observable, oldValue, newValue) -> { | ||
scene.setEmittersEnabled(newValue); | ||
emitterSettings.setVisible(newValue); | ||
emitterSettings.setManaged(newValue); | ||
}); | ||
boolean showEmitterSettings = scene != null && scene.getEmittersEnabled(); | ||
emitterSettings.setVisible(showEmitterSettings); | ||
emitterSettings.setManaged(showEmitterSettings); | ||
|
||
// fancierTranslucency.selectedProperty() | ||
// .addListener((observable, oldValue, newValue) -> { | ||
// scene.setFancierTranslucency(newValue); | ||
// transmissivityCap.setVisible(newValue); | ||
// transmissivityCap.setManaged(newValue); | ||
// }); | ||
Comment on lines
+118
to
+123
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This seems unrelated? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Huh I wonder how that got there, I'll remove it |
||
|
||
emitterIntensity.setName("Emitter intensity"); | ||
emitterIntensity.setTooltip("Modifies the intensity of emitter light."); | ||
|
@@ -110,6 +129,18 @@ public LightingTab() throws IOException { | |
emitterIntensity.clampMin(); | ||
emitterIntensity.onValueChange(value -> scene.setEmitterIntensity(value)); | ||
|
||
emitterMappingType.getItems().addAll(EmitterMappingType.values()); | ||
emitterMappingType.getItems().remove(EmitterMappingType.NONE); | ||
emitterMappingType.getSelectionModel().selectedItemProperty().addListener( | ||
(observable, oldValue, newValue) -> scene.setEmitterMappingType(newValue)); | ||
emitterMappingType.setTooltip(new Tooltip("Determines how per-pixel light emission is computed.")); | ||
|
||
emitterMappingExponent.setName("Emitter mapping exponent"); | ||
emitterMappingExponent.setTooltip("Determines how much light is emitted from darker or lighter pixels.\nHigher values will result in darker pixels emitting less light."); | ||
emitterMappingExponent.setRange(Scene.MIN_EMITTER_MAPPING_EXPONENT, Scene.MAX_EMITTER_MAPPING_EXPONENT); | ||
emitterMappingExponent.clampMin(); | ||
emitterMappingExponent.onValueChange(value -> scene.setEmitterMappingExponent(value)); | ||
|
||
emitterSamplingStrategy.getItems().addAll(EmitterSamplingStrategy.values()); | ||
emitterSamplingStrategy.getSelectionModel().selectedItemProperty() | ||
.addListener((observable, oldvalue, newvalue) -> { | ||
|
@@ -194,6 +225,8 @@ public void setController(RenderControlsFxController controller) { | |
skyIntensity.set(scene.sky().getSkyLight()); | ||
apparentSkyBrightness.set(scene.sky().getApparentSkyLight()); | ||
emitterIntensity.set(scene.getEmitterIntensity()); | ||
emitterMappingExponent.set(scene.getEmitterMappingExponent()); | ||
emitterMappingType.getSelectionModel().select(scene.getEmitterMappingType()); | ||
sunIntensity.set(scene.sun().getIntensity()); | ||
sunLuminosity.set(scene.sun().getLuminosity()); | ||
apparentSunBrightness.set(scene.sun().getApparentBrightness()); | ||
|
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can we do this without allocating
Vector3
andVector4
?There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think the
Vector3 emiitance
is definitely useful because otherwise we'd need adoEmittanceMappingR
etc. but theVector4
could be removed