This example is running in WebGL2 and should work in most browsers. You can check the WebGPU examples here.
//! This example illustrates how to create a texture for use with a `texture_2d_array<f32>` shader
//! uniform variable.
use ;
/// This example uses a shader source file from the assets subdirectory
const SHADER_ASSET_PATH: &str = "shaders/array_texture.wgsl";
#import bevy_pbr::{
forward_io::VertexOutput,
mesh_view_bindings::view,
pbr_types::{STANDARD_MATERIAL_FLAGS_DOUBLE_SIDED_BIT, PbrInput, pbr_input_new},
pbr_functions as fns,
pbr_bindings,
}
#import bevy_core_pipeline::tonemapping::tone_mapping
(2) (0) var my_array_texture: texture_2d_array<f32>;
(2) (1) var my_array_texture_sampler: sampler;
fn is_front: bool,
mesh: VertexOutput,
) -> (0) vec4<f32> {
let layer = & 0x3;
// Prepare a 'processed' StandardMaterial by sampling all textures to resolve
// the material members
var pbr_input: PbrInput = ;
pbr_input.material.base_color = ;
#ifdef VERTEX_COLORS
pbr_input.material.base_color = pbr_input.material.base_color * mesh.color;
#endif
let double_sided = (pbr_input.material.flags & STANDARD_MATERIAL_FLAGS_DOUBLE_SIDED_BIT) != 0u;
pbr_input.frag_coord = mesh.position;
pbr_input.world_position = mesh.world_position;
pbr_input.world_normal = fns::;
pbr_input.is_orthographic = view.clip_from_view[3].w == 1.0;
pbr_input.N = ;
#ifdef VERTEX_TANGENTS
let Nt = .rgb;
let TBN = fns::;
pbr_input.N = fns::;
#endif
pbr_input.V = fns::;
return ;
}