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

[Merged by Bors] - Add Distance and Atmospheric Fog support #6412

Closed
wants to merge 79 commits into from
Closed
Show file tree
Hide file tree
Changes from 69 commits
Commits
Show all changes
79 commits
Select commit Hold shift + click to select a range
014a9cb
Add fog support to bevy_pbr
coreh Oct 29, 2022
6458025
Add flag to `StandardMaterial` to disable fog
coreh Oct 29, 2022
dfbd7f6
Add fog documentation
coreh Oct 29, 2022
d7afc3e
Fix example code that's failing on CI
coreh Oct 29, 2022
fb588a5
Add additional fog documentation
coreh Oct 30, 2022
0d2afb9
Make `Fog` a `Component` instead of a `Resource`
coreh Nov 1, 2022
8855bdd
Consolidate fog-related setup into `FogPlugin`
coreh Nov 1, 2022
f7fb67e
Fix example code that's failing on CI
coreh Nov 1, 2022
8c8aa79
Remove `FogMode::Off`
coreh Nov 2, 2022
d999308
Add Fog example
coreh Nov 2, 2022
c446fcc
Fix clippy issues
coreh Nov 2, 2022
2138dfc
Apply feedback on example and fix mismatched variable names
coreh Nov 3, 2022
b7c478f
Add controls table to example module documentation
coreh Nov 3, 2022
db1eca0
Add semicolon
coreh Nov 3, 2022
1e7f6c3
Merge branch 'main' into fog
coreh Nov 3, 2022
6b8a196
Rename fog component and falloff enum, for consistency and reusability
coreh Nov 3, 2022
6d2a41a
Add initial implementation of atmospheric fog and directional light s…
coreh Nov 3, 2022
7de98fd
Fix documentation broken/missing links
coreh Nov 3, 2022
505a5a2
Fix example code now that there are more fog settings
coreh Nov 3, 2022
e13c5c3
Fix clippy issue
coreh Nov 3, 2022
5d8f708
Fix the spelling of the word ‘exponent’
coreh Nov 4, 2022
e7a4a98
Use `Time::elapsed_seconds()` and `Time::delta_seconds()`
coreh Nov 4, 2022
ddb4eb9
Improve documentation, in response to PR feedback
coreh Nov 4, 2022
48295a0
Improve `GpuFog` documentation comments
coreh Nov 4, 2022
7a88d0e
Optimize/cleanup shader code
coreh Nov 4, 2022
50f0f50
Take directional light colors into account for scattering
coreh Nov 4, 2022
00226a3
Rename `scattering_color` to `directional_light_color`
coreh Nov 4, 2022
e18f682
Merge branch 'main' into fog
coreh Nov 4, 2022
e4f01e2
Merge branch 'main' into fog
coreh Nov 4, 2022
e626862
Add atmospheric fog example
coreh Nov 4, 2022
270dcd9
Fix clippy issue
coreh Nov 4, 2022
8ecba3b
Add methods for more easily configuring atmospheric fog
coreh Nov 4, 2022
68447a2
Use new visibility helper method in atmospheric fog example
coreh Nov 4, 2022
a2a5b07
Improve documentation
coreh Nov 4, 2022
a4ee547
Use `Vec3` instead of `Color` for extinction and inscattering
coreh Nov 4, 2022
e0195d3
Improve documentation
coreh Nov 4, 2022
e830d93
Add convenience methods for `FogFalloff::ExponentialSquared`
coreh Nov 4, 2022
a998fa8
Tweaks to documentation formatting and punctuation
coreh Nov 4, 2022
c608a75
Improve documentation
coreh Nov 4, 2022
aeafcc7
Remove misleading note about exponential density values
coreh Nov 4, 2022
ecea533
Fix clippy issue
coreh Nov 4, 2022
73ad380
Remove now-unnecessary UI camera
coreh Nov 4, 2022
3323542
Add comments explaining values
coreh Nov 4, 2022
92dac89
Fix documentation tests
coreh Nov 4, 2022
256fce6
Update examples/README.md
coreh Nov 4, 2022
be50d07
Merge branch 'main' into fog
coreh Nov 4, 2022
50a41cd
Use positive `fog_enabled` flag (instead of `no_fog`)
coreh Nov 4, 2022
a35783a
Add minor clarification that this is the color obtained after extinction
coreh Nov 4, 2022
8261011
Rename `result` to `fog_color` in shader
coreh Nov 4, 2022
11f1bb5
Fix search and replace mishap
coreh Nov 4, 2022
cbb330c
Use names consistent with documentation
coreh Nov 4, 2022
bf668da
Move fog to outside of `pbr()`, so that it applies to unlit materials
coreh Nov 4, 2022
e3b65c8
Merge branch 'main' into fog
coreh Nov 6, 2022
036fbd3
Add controls table and move system to last
coreh Nov 6, 2022
9f3b0c4
Improve documentation
coreh Nov 6, 2022
49a3f1e
Use “glow” instead of “halo” in explanation
coreh Nov 6, 2022
f9056c0
Improve documentation
coreh Nov 6, 2022
3c9b359
Fix constants typo in documentation comments
coreh Nov 8, 2022
e123574
Fix additional constant typos
coreh Nov 9, 2022
2664ca1
Merge branch 'main' into fog
coreh Nov 12, 2022
d54dce2
Reduce sky size, fixing (floating point precision?) flicker in WASM /…
coreh Nov 20, 2022
ccfb0ce
Merge branch 'main' into fog
coreh Nov 24, 2022
6ab1188
Break up long lines in WGSL shaders for readability
coreh Jan 15, 2023
f44e381
Remove incorrect claim that extinction factor is ‘unitless’ from docu…
coreh Jan 15, 2023
aa3fef7
Improve documentation wording
coreh Jan 15, 2023
f1cebd2
Increase font size in fog examples
coreh Jan 15, 2023
f9ceb4c
Merge branch 'main' into fog
coreh Jan 15, 2023
820a6b1
Merge branch 'main' into fog
coreh Jan 21, 2023
cd11d43
Make sure `apply_fog()` function is not defined during normal prepass
coreh Jan 21, 2023
df77ce3
Merge branch 'main' into fog
coreh Jan 21, 2023
15afdfb
Fix code for creating exponential squared fog
coreh Jan 28, 2023
c4eb571
Remove unused `KOSCHMIEDER_CONTRAST_THRESHOLD` constant
coreh Jan 28, 2023
28f4fb0
Tweak wording, remove trailing whitespace
coreh Jan 28, 2023
8b99f6f
Reorder `GpuFog` fields for better struct packing
coreh Jan 28, 2023
1e3ab2c
Extract repeated scattering code into function
coreh Jan 28, 2023
5fd6a42
Merge branch 'main' into fog
coreh Jan 28, 2023
8c4d4e9
Properly configure cascade shadow map for scene
coreh Jan 28, 2023
4608dbd
Use multiplication instead of `pow()` with `2.0`
coreh Jan 28, 2023
fee838d
Pass fragment and view positions and calculate `view_to_world` in `ap…
coreh Jan 28, 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
21 changes: 21 additions & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -297,6 +297,27 @@ description = "A scene showcasing the built-in 3D shapes"
category = "3D Rendering"
wasm = true

[[example]]
name = "atmospheric_fog"
path = "examples/3d/atmospheric_fog.rs"

[package.metadata.example.atmospheric_fog]
name = "Atmospheric Fog"
description = "A scene showcasing the atmospheric fog effect"
category = "3D Rendering"
wasm = true

[[example]]
name = "fog"
path = "examples/3d/fog.rs"

[package.metadata.example.fog]
name = "Fog"
description = "A scene showcasing the distance fog effect"
category = "3D Rendering"
wasm = true


[[example]]
name = "lighting"
path = "examples/3d/lighting.rs"
Expand Down
Binary file added assets/models/terrain/Mountains.bin
Binary file not shown.
143 changes: 143 additions & 0 deletions assets/models/terrain/Mountains.gltf
Original file line number Diff line number Diff line change
@@ -0,0 +1,143 @@
{
"asset" : {
"generator" : "Khronos glTF Blender I/O v3.3.17",
"version" : "2.0"
},
"extensionsUsed" : [
"KHR_materials_specular",
"KHR_materials_ior"
],
"scene" : 0,
"scenes" : [
{
"name" : "Scene",
"nodes" : [
0,
1
]
}
],
"nodes" : [
{
"mesh" : 0,
"name" : "Grid"
},
{
"mesh" : 0,
"name" : "Grid.001",
"translation" : [
0.0018983177142217755,
-2.7217100068810396e-05,
0.0012765892315655947
]
}
],
"materials" : [
{
"doubleSided" : true,
"extensions" : {
"KHR_materials_specular" : {
"specularColorFactor" : [
0,
0,
0
]
},
"KHR_materials_ior" : {
"ior" : 1.4500000476837158
}
},
"name" : "Material.001",
"pbrMetallicRoughness" : {
"baseColorFactor" : [
0.12338346652686596,
0.35653680562973022,
0.065849664583802223,
1
],
"metallicFactor" : 0,
"roughnessFactor" : 0.9980237483978271
}
}
],
"meshes" : [
{
"name" : "Grid",
"primitives" : [
{
"attributes" : {
"POSITION" : 0,
"NORMAL" : 1,
"TEXCOORD_0" : 2
},
"indices" : 3,
"material" : 0
}
]
}
],
"accessors" : [
{
"bufferView" : 0,
"componentType" : 5126,
"count" : 6561,
"max" : [
1.0000003576278687,
0.2493455857038498,
1.0051095485687256
],
"min" : [
-1.0000003576278687,
-0.08555418252944946,
-1.0000003576278687
],
"type" : "VEC3"
},
{
"bufferView" : 1,
"componentType" : 5126,
"count" : 6561,
"type" : "VEC3"
},
{
"bufferView" : 2,
"componentType" : 5126,
"count" : 6561,
"type" : "VEC2"
},
{
"bufferView" : 3,
"componentType" : 5123,
"count" : 38400,
"type" : "SCALAR"
}
],
"bufferViews" : [
{
"buffer" : 0,
"byteLength" : 78732,
"byteOffset" : 0
},
{
"buffer" : 0,
"byteLength" : 78732,
"byteOffset" : 78732
},
{
"buffer" : 0,
"byteLength" : 52488,
"byteOffset" : 157464
},
{
"buffer" : 0,
"byteLength" : 76800,
"byteOffset" : 209952
}
],
"buffers" : [
{
"byteLength" : 286752,
"uri" : "Mountains.bin"
}
]
}
Loading