-
Notifications
You must be signed in to change notification settings - Fork 960
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
[glsl-out] fix usage of gsamplerCubeArrayShadow #4455
Comments
This is literally impossible -- the GLSL spec doesn't define any of those functions for gsamplerCubeArrayShadow. https://www.khronos.org/registry/OpenGL/specs/gl/GLSLangSpec.4.60.pdf#page=183 Neither does WGSL: https://gpuweb.github.io/gpuweb/wgsl/#texturesamplecompare What does the input shader look like? |
We have a workaround that uses textureGrad instead of textureLod on cubemaps. It's probably involved: |
That's after the code that's outputting that error. |
@kvark as magicus pointed out this is impossible, this workaround doesn't work on |
If we can't do this, we should return an error from the backend (instead of generating bad code). |
We're not generating bad code -- we're returning an error (admittedly a confusing one). What is the WGSL that's generating this error? |
Damn, you are right. |
The code in question is https://github.com/bevyengine/bevy/blob/963e2f08a2f762d896eb28ef4a80ba2ec124655b/crates/bevy_pbr/src/render/pbr.wgsl#L387. Minimal example: [[group(0), binding(2)]]
var point_shadow_textures: texture_depth_cube_array;
[[group(0), binding(3)]]
var point_shadow_textures_sampler: sampler_comparison;
[[stage(fragment)]]
fn main() {
let frag_ls = vec3<f32>(0.0);
let depth: f32 = 0.0;
let value = textureSampleCompareLevel(point_shadow_textures, point_shadow_textures_sampler, frag_ls, i32(0), depth);
} > naga repro.wgsl out.frag
gsamplerCubeArrayShadow isn't supported in textureGrad, textureLod or texture with bias |
This could be supported if with this OpenGL extension: https://www.khronos.org/registry/OpenGL/extensions/EXT/EXT_texture_shadow_lod.txt Obviously not going to work with WebGL, though. If you only have a single mipmap in your cube (not sure why you'd have more?), consider using textureSampleCompare instead. Another workaround would be to pack them into a depth texture array and do the 3D -> 2D array coordinate conversion in the shader. |
I believe the reason for using the
|
boo... I understand the WGSL compiler can't possibly know that the texture has no mipmaps, but this sure is unfortunate. As a hack, Naga might be able to generate texture() in this case and pray it has no mipmaps? All options are unfortunate. |
This comment was marked as off-topic.
This comment was marked as off-topic.
I realize immediately below the code that errors out is code that checks for TEXTURE_SHADOW_LOD. Assuming the user has support for TEXTURE_SHADOW_LOD, this shouldn't be impossible to fix. |
#5171 should have resolved this, closing. |
from bevyengine/bevy#841 (comment)
The text was updated successfully, but these errors were encountered: