As of 0.6, the approach to importing the core PBR shader functionality is unclear but we want them to be reusable, whether due to people having PBR data that they need to obtain from different bindings, or if they want to customise the shading code. The story around how to do these kinds of things should be clear to enable flexible reuse and extension.
Split mesh view, mesh, and pbr shaders into types, bindings, and functions. The purpose of this is to allow reuse of types and functions without bindings, or types and bindings without functions, or all three, or whatever you like.
Move all normal and view vector calculation into separate functions to make them callable
Add mesh coordinate space transformation functions to support consistent calculation of world/clip positions and normals. Particularly clip positions are important due to using the equal depth comparison function for geometry with opaque or alpha mask materials in the main 3D passes.
Add PbrMaterial and PbrInput pbr types that contain all the material and fragment stage input information needed by the core pbr shaders
Add a pbr() shader function and pass all variables and bindings as arguments. Functions within the pbr() code path may no longer reference 'global' bindings directly. They must come through arguments. This is to remove the requirement for any bindings to have specific names which then cause unexpected problems.
Add back the array_texture example and leverage the imports, mesh position coordinate space transform functions. This could/should be extended to call into the pbr() function to demonstrate using the core pbr functionality with custom inputs.
Known Issues
On macOS on an M1 Max the branch currently seems to just hang and not render anything.
On Windows on a mobile RTX 3080 the branch shows black and white (probably garbage) for some seconds and eventually displays frames, but performance is awful.
The text was updated successfully, but these errors were encountered:
superdump
changed the title
Reusable PBR shader types/bindings/functions - https://github.com/superdump/bevy/tree/callable-pbr
Reusable PBR shader types/bindings/functions
Jan 9, 2022
Description
Solution
PbrMaterialandPbrInputpbr types that contain all the material and fragment stage input information needed by the core pbr shaderspbr()shader function and pass all variables and bindings as arguments. Functions within thepbr()code path may no longer reference 'global' bindings directly. They must come through arguments. This is to remove the requirement for any bindings to have specific names which then cause unexpected problems.array_textureexample and leverage the imports, mesh position coordinate space transform functions. This could/should be extended to call into thepbr()function to demonstrate using the core pbr functionality with custom inputs.Known Issues
The text was updated successfully, but these errors were encountered: