bevyengine / bevyengine/bevy

Render/Light layers data in shader example

Open
#15,433 0 comments 0 reactions 0 assignees View on GitHub
A-Rendering C-Examples D-Straightforward S-Ready-For-Implementation
Dominant language
Rust
Stars
48.2k
Forks
4.8k
Avg merge
3d 22h
Merged PRs (30d)
161

Description

## What problem does this solve or what need does it fill?
Add example of Render/Light layers data used in shader.

## What solution would you like?
Similarly to volumetric light:
`
#import bevy_pbr::mesh_view_types::DIRECTIONAL_LIGHT_FLAGS_VOLUMETRIC_BIT
....
if (((*light).flags & DIRECTIONAL_LIGHT_FLAGS_VOLUMETRIC_BIT) == 0)
{
......
}
.....
`
If specific post-fx (or shader in general) is requesting light data, only lights with particular u32 is used.

Close, but not exact example form existing games/media is
something that remotely resembles magic lamp from 2015 game _The Witcher 3_ by CDPR.

![Screenshot_18](https://github.com/user-attachments/assets/a6a71a73-2918-4360-b738-557cfdc58798)
Disclaimer:
1 I HAVE NO IDEA HOW IT IS IMPLEMENTED IN MENTIONED GAME
2 I HAVE NO RELATION TO CDPR
3 THIS MENTION OF GAME ISN'T SPONSORED OR PAID

Main idea is to have simple and reusable system.
It should work with all types of lights, not only directional.

## Proposed workflow
1. Set struct _light.shader_layer_ bits u32 in rust code
2. Use it in wgsl code _(*light).shader_layer_

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.