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

Shader Error in Array Texture Example: Invalid Field Accessor clip_from_view #13751

Closed
altunenes opened this issue Jun 8, 2024 · 1 comment
Closed
Labels
C-Bug An unexpected or incorrect behavior S-User-Error This issue was caused by a mistake in the user's approach

Comments

@altunenes
Copy link

Bevy version

bevy = "0.13.2"

System information

win 11, rtx 3060m, ryzen 7 6800h, rust 1.78

What you did

I followed the official Bevy example for creating a texture for use with a texture_2d_array shader uniform variable.

https://github.com/bevyengine/bevy/blob/latest/examples/shader/array_texture.rs

shader:
https://github.com/bevyengine/bevy/blob/3bfc42766621d12749c09eca3bfd9911dc0dc3f5/assets/shaders/array_texture.wgsl

What went wrong

I encountered an error in the shader code:

error: invalid field accessor `clip_from_view`
   ┌─ shaders/array_texture.wgsl:39:10039 │     pbr_input.is_orthographic = bevy_pbr::mesh_view_bindings::view.clip_from_view[3].w == 1.0;
   │                                                                                                    ^^^^^^^^^^^^^^ invalid accessor
   │
   = invalid field accessor `clip_from_view`

My Solution

To resolve this, I changed the line:

pbr_input.is_orthographic = view.clip_from_view[3].w == 1.0;

with this:

pbr_input.is_orthographic = view.projection[3][3] == 1.0;

After making this change, the example worked as expected.

@altunenes altunenes added C-Bug An unexpected or incorrect behavior S-Needs-Triage This issue needs to be labelled labels Jun 8, 2024
@JMS55 JMS55 added S-User-Error This issue was caused by a mistake in the user's approach and removed S-Needs-Triage This issue needs to be labelled labels Jun 8, 2024
@JMS55
Copy link
Contributor

JMS55 commented Jun 8, 2024

You need to look at the 0.13.2 tag, not the main branch which contains unreleased changes

https://github.com/bevyengine/bevy/blob/release-0.13.2/assets/shaders/array_texture.wgsl

@JMS55 JMS55 closed this as completed Jun 8, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
C-Bug An unexpected or incorrect behavior S-User-Error This issue was caused by a mistake in the user's approach
Projects
None yet
Development

No branches or pull requests

2 participants