Skip to content

naasblod/bevy_contact_projective_decals

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

37 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Contact Projective Decals

Based on Alexander Sannikovs talk on the rendering techniques of Path of Exile 2

Image of a bunch of decals being projected on top of a bunch of boxes and stuff

!WARNING!

  • This is a work in progress
  • Due to the nature of this technique looking at the decal from very steep angles will cause distortion, this can be mitigated by creating textures that are bigger than the effect, maybe the actual thing you want to display is 16x16px then you could pad your image with pixels with an alpha value of 0 to 32x32px or something like that. Basically: don't put stuff on the edges of your image or you will have distortions.

Open for any and all issues and pull requests

Description

This uses a standard material extension shader and a Quad (now Rectangle) mesh to render decals on top of geometry. It smoothly fades instead of clips when the quad intersects with geometry. It uses information from the depth buffer to create a depth texture which it uses to distort the uvs of the mesh to make it look like the mesh conforms to intersecting geometry.

The depth test is disabled so that decals that intersect with other geometry can be smoothly faded instead of culled.

Bevy Compatibility

This is not up on crates.io right now. Use bevy_contact_projective_decals = { git = "https://github.com/naasblod/bevy_contact_projective_decals.git", branch = "main" }

Bevy Version Crate Version
0.13 None.None.None

Example

Setup:

use bevy_contact_projective_decals::{DecalPlugin};
fn main() {
    App::new()
        .add_plugins((DefaultPlugins, DecalPlugin))
        .run();
}

Spawning:

commands.spawn(DecalBundle {
    transform: Transform::from_xyz(x, y, z),
    decal_material: decal_materials.add(ExtendedMaterial::<
        StandardMaterial,
        DecalMaterial,
    > {
        base: StandardMaterial {
            base_color_texture: Some(asset_server.load("my_decal.png"))),
            base_color: color,
            alpha_mode: AlphaMode::Blend,
            ..default()
        },
        extension: DecalMaterial {
            depth_fade_factor: 8.0,
        },
    }),
    mesh: meshes.add(decal_mesh_quad(Vec2::splat(scale))),
    ..default()
});

Super big thanks to NiseVoid and Griffin

uv checker map from https://github.com/Arahnoid/UVChecker-map

About

No description, website, or topics provided.

Resources

License

Apache-2.0, MIT licenses found

Licenses found

Apache-2.0
LICENCE-APACHE
MIT
LICENCE-MIT

Stars

Watchers

Forks

Releases

No releases published

Packages