Make StandardMaterial bindless.#16644
Conversation
This commit makes `StandardMaterial` use bindless textures, as implemented in PR bevyengine#16368. Non-bindless mode, as used for example in Metal and WebGL 2, remains fully supported via a plethora of `#ifdef BINDLESS` preprocessor definitions. Unfortunately, this PR introduces quite a bit of unsightliness into the PBR shaders. This is a result of the fact that WGSL supports neither passing binding arrays to functions nor passing individual *elements* of binding arrays to functions, except directly to texture sample functions. Thus we're unable to use the `sample_texture` abstraction that helped abstract over the meshlet and non-meshlet paths. I don't think there's anything we can do to help this other than to suggest improvements to upstream Naga.
JMS55
left a comment
There was a problem hiding this comment.
Oh boy, absolutely terrible code 😅. We are unlikely to get any improvements to this in naga anytime soon afaik. I think we might want to look into writing a simple macro in naga_oil or bevy for texture sampling.
|
Yeah, I'd love a macro in |
kristoff3r
left a comment
There was a problem hiding this comment.
My eyes might have glazed over at some point, but looks correct and tested pbr example on linux+webgl2.
I agree we need macros or similar very soon, the pbr shaders weren't pretty before but they're getting borderline unreadable except for mechanical changes like this.
|
Testing this via an example run then merging. I'm not pleased with the reduced clarity of the shaders, but I agree that this is not the place to solve it (nor should this be blocked on that). |
|
Example run is green. |
This commit makes `StandardMaterial` use bindless textures, as implemented in PR #16368. Non-bindless mode, as used for example in Metal and WebGL 2, remains fully supported via a plethora of `#ifdef BINDLESS` preprocessor definitions. Unfortunately, this PR introduces quite a bit of unsightliness into the PBR shaders. This is a result of the fact that WGSL supports neither passing binding arrays to functions nor passing individual *elements* of binding arrays to functions, except directly to texture sample functions. Thus we're unable to use the `sample_texture` abstraction that helped abstract over the meshlet and non-meshlet paths. I don't think there's anything we can do to help this other than to suggest improvements to upstream Naga.
|
The example run completed successfully, but shows differences in https://pixel-eagle.com/project/B25A040A-A980-4602-B90C-D480AB84076D?filter=PR-16644 The volumetric fog stuff looks like it's just the branch being slightly stale + #16677 I don't know about |
This commit makes `StandardMaterial` use bindless textures, as implemented in PR bevyengine#16368. Non-bindless mode, as used for example in Metal and WebGL 2, remains fully supported via a plethora of `#ifdef BINDLESS` preprocessor definitions. Unfortunately, this PR introduces quite a bit of unsightliness into the PBR shaders. This is a result of the fact that WGSL supports neither passing binding arrays to functions nor passing individual *elements* of binding arrays to functions, except directly to texture sample functions. Thus we're unable to use the `sample_texture` abstraction that helped abstract over the meshlet and non-meshlet paths. I don't think there's anything we can do to help this other than to suggest improvements to upstream Naga.
This commit makes `StandardMaterial` use bindless textures, as implemented in PR bevyengine#16368. Non-bindless mode, as used for example in Metal and WebGL 2, remains fully supported via a plethora of `#ifdef BINDLESS` preprocessor definitions. Unfortunately, this PR introduces quite a bit of unsightliness into the PBR shaders. This is a result of the fact that WGSL supports neither passing binding arrays to functions nor passing individual *elements* of binding arrays to functions, except directly to texture sample functions. Thus we're unable to use the `sample_texture` abstraction that helped abstract over the meshlet and non-meshlet paths. I don't think there's anything we can do to help this other than to suggest improvements to upstream Naga.
This commit makes
StandardMaterialuse bindless textures, as implemented in PR #16368. Non-bindless mode, as used for example in Metal and WebGL 2, remains fully supported via a plethora of#ifdef BINDLESSpreprocessor definitions.Unfortunately, this PR introduces quite a bit of unsightliness into the PBR shaders. This is a result of the fact that WGSL supports neither passing binding arrays to functions nor passing individual elements of binding arrays to functions, except directly to texture sample functions. Thus we're unable to use the
sample_textureabstraction that helped abstract over the meshlet and non-meshlet paths. I don't think there's anything we can do to help this other than to suggest improvements to upstream Naga.