bevyengine / bevyengine/bevy

Split apply_pbr_lighting into many many small functions

Open
#17,541 7 comments 2 reactions 0 assignees View on GitHub
A-Rendering C-Feature D-Straightforward S-Needs-Design
Dominant language
Rust
Stars
48.2k
Forks
4.8k
Avg merge
4d 8m
Merged PRs (30d)
147

Description

## What problem does this solve or what need does it fill?

Please split apply_pbr_lighting into many many small functions. You can keep the function name the same and what it does the same. But please make it perform a bunch of small functions which can be called individually for when we are making Extension Material Shaders.

This is because I want to change the way shadows work (cel shading) but it seems VERY VERY horribly hard to do with the way that apply_pbr_lighting is so monolithic right now.

## What solution would you like?

for example I want each input of this line to have its own small function

```
// Total light
output_color = vec4(
(view_bindings::view.exposure * (transmitted_light + direct_light + indirect_light)) + emissive_light,
output_color.a
);

```

And i want to be able to effectively easily modify that specific line of code in my extension material shader . Right now, I have to completely re-write (re-implement) the entirety of apply_pbr_lighting just to change the way direct light affects my output color because this is too monolithic.

## What alternative(s) have you considered?

Offer a few preset different apply_pbr_lighting functions that work differently? Make some of them have different input props or a bit flag to be able to change the way inner parts of it work?

But overall i think the best soln here is to just take chunks of the innards of apply_pbr_lighting and put them into small functions which apply_pbr_lighting calls. That way, I can implement those small functions into my shader exactly how i wish and only have to rewrite perhaps a small part of apply_pbr_lighting to change the way my color reacts to point and dynamic lights. !

## Additional context

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.