Crates.io | bevy_mod_paramap |
lib.rs | bevy_mod_paramap |
version | 0.3.0 |
source | src |
created_at | 2022-09-12 15:54:53.782584 |
updated_at | 2023-03-06 18:22:56.91655 |
description | Parallax mapping shaders (relief and POM) for the bevy game engine |
homepage | |
repository | https://github.com/nicopap/bevy_mod_paramap |
max_upload_size | |
id | 663878 |
size | 133,461 |
parallax mapping is a graphical effect adding the impression of depth to simple 2d textures by moving the texture's pixel around according to the viewport's perspective.
This is NOT a "parallax" à la Super Mario World. This is intended for 3D rendering. This technic has been used with success in the Demon's Souls Bluepoint remake.
This crate adds a custom material that extends the default bevy PBR material
with parallax mapping. The ParallaxMaterial
asset is a straight copy
of bevy's PBR material with the addition of the height_map: Handle<Image>
filed (it's not Option
since you might as well use the default shader if
there is no height maps).
height_map
is a greyscale image representing the height of the object at the
specific pixel.
ParallaxMaterial
allows selecting the algorithm used for parallaxing. By
setting the algorithm
field to the ParallaxAlgo
of your choosing, you
may opt into using Relief Mapping. By default, ParallaxMaterial
uses the
Parallax Occlusion Mapping (POM) method. (see the shader source code for
explanation on what the algorithms do)
This repo contains two examples.
cargo run --example <example_name>
earth3d
: a spinning view of the earth. Takes advantage of height map,
but also of all the bevy PBR fields. This a good demonstration of bevy's
capabilities.
cube
: A spinning cube with a parallaxed material in a basic 3d scene,
mouse left click to switch point of view.The code is basically copied from the sunblackcat implementation linked on Wikipedia.
Optimization leads include:
Note that (1) says that (2) is slower than POM, while (3) is beyond out-of-scope for a small opensource crate (unless you want to pay me).
Reflect
)from_standard(StandardMaterial, height_map)
height_map
computation based on a normal_map
if possible
0.2.0
: Update bevy dependency to 0.9
0.3.0
: Update bevy dependency to 0.10
bevy | latest supporting version |
---|---|
0.10 | 0.3.0 |
0.9 | 0.2.0 |
0.8 | 0.1.0 |
Earth images in assets/earth
are public domain and taken from Wikimedia. I edited them myself, you
are free to re-use the edited version however you want without restrictions.
elevation_water.png
and elevation_surface.png
adjust the values to highlight
different topological features of earth, the normal_map.jpg
is also derived from it.metallic_roughness.png
and base_color.jpg
are derived
from that image.Copyright of code and assets go to their respective authors.
Original code is copyright © 2022 Nicola Papale
This software is licensed under Apache 2.0.