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

Refactor alpha_discard for reuse with different material types #9521

Closed
wants to merge 0 commits into from

Conversation

bonsairobo
Copy link
Contributor

Objective

I want to call the pbr_functions::alpha_discard shader function from my own material shader, but it only takes a StandardMaterial parameter.

Solution

This PR replaces the StandardMaterial parameter with less restrictive ones so my shader can call it.


Changelog

  • The signature of pbr_functions::alpha_discard changed by replacing StandardMaterial with only the flags and alpha_cutoff fields.

Migration Guide

Replace this:

pbr_functions::alpha_discard(material, ...);

with this:

pbr_functions::alpha_discard(material.flags, material.alpha_cutoff, ...);

@bonsairobo bonsairobo changed the title Refactor alpha_discard for ruse with different material types Refactor alpha_discard for reuse with different material types Aug 21, 2023
Copy link
Contributor

@superdump superdump left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could you rework prepass_alpha_discard() in the same kind of way?

@bonsairobo
Copy link
Contributor Author

@superdump

Could you rework prepass_alpha_discard() in the same kind of way?

Sure, if you don't mind that I extract a new function for only lines 47-60. The first part of that function does some sampling using global binding variables, and that defeats the point of making it reusable IMO.

@hymm hymm added the A-Rendering Drawing game state to the screen label Aug 28, 2023
@bonsairobo bonsairobo requested a review from superdump September 8, 2023 02:51
@bonsairobo
Copy link
Contributor Author

Merged with bevy 0.12, ready for review again.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-Rendering Drawing game state to the screen
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants