From c488b7089c58c99371af25b7e27551e892df3dcf Mon Sep 17 00:00:00 2001
From: Nicola Papale <nicopap@users.noreply.github.com>
Date: Mon, 17 Apr 2023 08:22:34 +0200
Subject: [PATCH] Fix pbr shader breaking on missing UVs (#8412)

# Objective

Fix #8409

Since `in` doesn't have a `uv` field when `VERTEX_UVS` is not defined,
it shouldn't be accessed outside of related `#ifdef`s
---
 crates/bevy_pbr/src/render/pbr.wgsl | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/crates/bevy_pbr/src/render/pbr.wgsl b/crates/bevy_pbr/src/render/pbr.wgsl
index 6f36a1c59ebaf..f058a83ff8b53 100644
--- a/crates/bevy_pbr/src/render/pbr.wgsl
+++ b/crates/bevy_pbr/src/render/pbr.wgsl
@@ -23,8 +23,8 @@ struct FragmentInput {
 fn fragment(in: FragmentInput) -> @location(0) vec4<f32> {
     let is_orthographic = view.projection[3].w == 1.0;
     let V = calculate_view(in.world_position, is_orthographic);
-    var uv = in.uv;
 #ifdef VERTEX_UVS
+    var uv = in.uv;
 #ifdef VERTEX_TANGENTS
     if ((material.flags & STANDARD_MATERIAL_FLAGS_DEPTH_MAP_BIT) != 0u) {
         let N = in.world_normal;