Skip to content
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

Add a more accurate fog implementation #1660

Draft
wants to merge 49 commits into
base: master
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
49 commits
Select commit Hold shift + click to select a range
2ce55fb
some experimentation
JustinTimeCuber Jul 15, 2023
a06fe8e
added some incorrect math
JustinTimeCuber Jul 15, 2023
af86166
fix math
JustinTimeCuber Jul 16, 2023
fcfbc59
add math for when |n.x| <= 0.1
JustinTimeCuber Jul 16, 2023
f435a53
first decently-working implementation
JustinTimeCuber Jul 17, 2023
7b69564
add to sun sampling strategy enum (and GUI dropdown)
JustinTimeCuber Jul 17, 2023
f64b971
Add more GUI controls
JustinTimeCuber Jul 17, 2023
c22644a
small code changes and added comments
JustinTimeCuber Jul 17, 2023
51cc441
New method for situations when the sun is at a shallow angle
JustinTimeCuber Jul 19, 2023
1ac7640
make the rectangle method more accurately predict where the top and b…
JustinTimeCuber Jul 19, 2023
2fa4870
maybe handle certain cases better
JustinTimeCuber Jul 19, 2023
6554525
Merge branch 'master' into sun-sampling
JustinTimeCuber Sep 4, 2023
bde089e
fix ray.color changing between subsequent branches
JustinTimeCuber Sep 4, 2023
06e8697
Merge branch 'master' into sun-sampling
JustinTimeCuber Sep 14, 2023
8ec2c5f
Merge branch 'master' into sun-sampling
JustinTimeCuber Sep 26, 2023
d02b7a9
unused import
JustinTimeCuber Sep 26, 2023
905d5df
initial testing
JustinTimeCuber Sep 27, 2023
62f6c6b
add to material list, better normals
JustinTimeCuber Sep 27, 2023
4e29353
Create abstract FogVolume class & add layer fog type
JustinTimeCuber Sep 29, 2023
b0455ae
rename scaleOffset to yOffset
JustinTimeCuber Sep 29, 2023
1342502
Cuboid fog
JustinTimeCuber Sep 29, 2023
3b5daf7
Add cuboid and spherical volumes
Peregrine05 Sep 29, 2023
d566809
rename scaleOffset to yOffset
Peregrine05 Sep 29, 2023
1930876
Merge pull request #15 from Peregrine05/fancy-fog
JustinTimeCuber Sep 30, 2023
40950f8
tweaks to fog code, add per-fog materials for emittance etc.
JustinTimeCuber Sep 30, 2023
f669b33
Implement JsonSerializable and add GUI
Peregrine05 Oct 2, 2023
25466c2
Merge pull request #16 from Peregrine05/fancy-fog
JustinTimeCuber Oct 3, 2023
420b119
Implement anisotropy for particle fog
Peregrine05 Oct 8, 2023
23739f7
Implement fog clouds
Peregrine05 Oct 12, 2023
5df8100
Set fog positions to camera / target controls
Peregrine05 Oct 12, 2023
b8b08a0
Do not create new Vector3's
Peregrine05 Oct 12, 2023
f120a9e
Set a random normal for volumetric clouds
Peregrine05 Oct 12, 2023
ba2ed0e
Remove unused import
Peregrine05 Oct 13, 2023
ad2391a
Move `Preview particle fog` to `Fog` tab
Peregrine05 Oct 14, 2023
c3a7721
Enable `Preview particle fog` by default
Peregrine05 Oct 14, 2023
913b798
Add volumetric cloud JSON
Peregrine05 Oct 14, 2023
217df7f
Add IntersectionConfig
Peregrine05 Oct 14, 2023
b7b1121
Implement multiple cloud layers
Peregrine05 Oct 17, 2023
e83219a
Remove `Anisotropy` from `Materials` tab
Peregrine05 Oct 22, 2023
ee52372
Merge pull request #17 from Peregrine05/fancy-fog
JustinTimeCuber Oct 23, 2023
331ba97
Merge pull request #18 from Peregrine05/fancy-fog
JustinTimeCuber Oct 30, 2023
3efe390
non-sun sampling
JustinTimeCuber Oct 30, 2023
3effb15
possibly working implementation
JustinTimeCuber Oct 31, 2023
f5e8c91
fix sun direction
JustinTimeCuber Oct 31, 2023
9c0ba23
Merge pull request #15 from JustinTimeCuber/fancy-fog
Peregrine05 Nov 6, 2023
e3b8a01
Revert "Diffuse sampling fog"
Peregrine05 Nov 6, 2023
63f6ea1
Merge pull request #16 from Peregrine05/revert-15-fancy-fog
Peregrine05 Nov 6, 2023
455bf99
fix coordinateSystem()
JustinTimeCuber Nov 21, 2023
beea8de
Merge pull request #18 from JustinTimeCuber/fancy-fog-fix
Peregrine05 Dec 17, 2023
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
28 changes: 18 additions & 10 deletions chunky/src/java/se/llbit/chunky/chunk/BlockPalette.java
Original file line number Diff line number Diff line change
Expand Up @@ -347,10 +347,10 @@ public static Map<String, Consumer<Block>> getDefaultMaterialProperties() {
}
});
materialProperties.put("minecraft:torch", block -> {
block.emittance = 50.0f;
block.emittance = 1.0f;
});
materialProperties.put("minecraft:wall_torch", block -> {
block.emittance = 50.0f;
block.emittance = 1.0f;
});
materialProperties.put("minecraft:fire", block -> {
block.emittance = 1.0f;
Expand Down Expand Up @@ -448,16 +448,16 @@ public static Map<String, Consumer<Block>> getDefaultMaterialProperties() {
block.emittance = 0.6f;
});
materialProperties.put("minecraft:soul_fire_torch", block -> { // MC 20w06a-20w16a
block.emittance = 35.0f;
block.emittance = 0.6f;
});
materialProperties.put("minecraft:soul_torch", block -> { // MC >= 20w17a
block.emittance = 35.0f;
block.emittance = 0.6f;
});
materialProperties.put("minecraft:soul_fire_wall_torch", block -> { // MC 20w06a-20w16a
block.emittance = 35.0f;
block.emittance = 0.6f;
});
materialProperties.put("minecraft:soul_wall_torch", block -> { // MC >= 20w17a
block.emittance = 35.0f;
block.emittance = 0.6f;
});
materialProperties.put("minecraft:soul_fire", block -> {
block.emittance = 0.6f;
Expand Down Expand Up @@ -523,16 +523,24 @@ public static Map<String, Consumer<Block>> getDefaultMaterialProperties() {
}
});
materialProperties.put("minecraft:small_amethyst_bud", block -> {
block.emittance = 1.0f / 15f;
if (block instanceof AmethystCluster && ((AmethystCluster) block).isLit()) {
block.emittance = 1.0f / 15f;
}
});
materialProperties.put("minecraft:medium_amethyst_bud", block -> {
block.emittance = 1.0f / 15f * 2;
if (block instanceof AmethystCluster && ((AmethystCluster) block).isLit()) {
block.emittance = 1.0f / 15f * 2;
}
});
materialProperties.put("minecraft:large_amethyst_bud", block -> {
block.emittance = 1.0f / 15f * 4;
if (block instanceof AmethystCluster && ((AmethystCluster) block).isLit()) {
block.emittance = 1.0f / 15f * 4;
}
});
materialProperties.put("minecraft:amethyst_cluster", block -> {
block.emittance = 1.0f / 15f * 5;
if (block instanceof AmethystCluster && ((AmethystCluster) block).isLit()) {
block.emittance = 1.0f / 15f * 5;
}
});
materialProperties.put("minecraft:tinted_glass", glassConfig);
materialProperties.put("minecraft:sculk_sensor", block -> {
Expand Down
15 changes: 10 additions & 5 deletions chunky/src/java/se/llbit/chunky/renderer/SunSamplingStrategy.java
Original file line number Diff line number Diff line change
Expand Up @@ -19,10 +19,11 @@
import se.llbit.util.Registerable;

public enum SunSamplingStrategy implements Registerable {
OFF("Off", "Sun is not sampled with next event estimation.", false, true, false, true),
NON_LUMINOUS("Non-Luminous", "Sun is drawn on the skybox but it does not contribute to the lighting of the scene.", false, false, false, false),
FAST("Fast", "Fast sun sampling algorithm. Lower noise but does not correctly model some visual effects.", true, false, false, false),
HIGH_QUALITY("High Quality", "High quality sun sampling. More noise but correctly models visual effects such as caustics.", true, true, true, true);
OFF("Off", "Sun is not sampled with next event estimation.", false, true, false, true, false),
NON_LUMINOUS("Non-Luminous", "Sun is drawn on the skybox but it does not contribute to the lighting of the scene.", false, false, false, false, false),
FAST("Fast", "Fast sun sampling algorithm. Lower noise but does not correctly model some visual effects.", true, false, false, false, false),
HIGH_QUALITY("High Quality", "High quality sun sampling. More noise but correctly models visual effects such as caustics.", true, true, true, true, false),
DIFFUSE("Diffuse", "Sun is sampled on a certain percentage of diffuse reflections. Correctly models visual effects while reducing noise for direct and diffuse illumination.", false, true, false, true, true);

private final String displayName;
private final String description;
Expand All @@ -31,15 +32,17 @@ public enum SunSamplingStrategy implements Registerable {
private final boolean diffuseSun;
private final boolean strictDirectLight;
private final boolean sunLuminosity;
private final boolean diffuseSampling;

SunSamplingStrategy(String displayName, String description, boolean sunSampling, boolean diffuseSun, boolean strictDirectLight, boolean sunLuminosity) {
SunSamplingStrategy(String displayName, String description, boolean sunSampling, boolean diffuseSun, boolean strictDirectLight, boolean sunLuminosity, boolean diffuseSampling) {
this.displayName = displayName;
this.description = description;

this.sunSampling = sunSampling;
this.diffuseSun = diffuseSun;
this.strictDirectLight = strictDirectLight;
this.sunLuminosity = sunLuminosity;
this.diffuseSampling = diffuseSampling;
}

@Override
Expand Down Expand Up @@ -72,4 +75,6 @@ public boolean isStrictDirectLight() {
public boolean isSunLuminosity() {
return sunLuminosity;
}

public boolean isDiffuseSampling() { return diffuseSampling; }
}
Loading