Search across packages, versions, files, declarations, and comments. Use multiple terms to narrow results (AND), and add @vertex, @fragment, or @compute to filter by shader stage.
1#import bevy_pbr::{
2 mesh_functions,
3 skinning,
4 view_transformations::position_world_to_clip,
5}
7#import bevy_water::water_functions as water_fn
9#import bevy_water::water_bindings
10#ifdef PREPASS_PIPELINE
11#import bevy_pbr::prepass_io::{Vertex, VertexOutput}
12#else
13#import bevy_pbr::forward_io::{Vertex, VertexOutput}
14#endif
16@vertex
17fn vertex(vertex: Vertex) -> VertexOutput {
18 var out: VertexOutput;
20#ifdef SKINNED
21 var model = skinning::skin_model(vertex.joint_indices, vertex.joint_weights);
22#else
23 var model = mesh_functions::get_world_from_local(vertex.instance_index);
24#endif
26#ifdef VERTEX_UVS
27#ifdef SKINNED
28 out.world_normal = skinning::skin_normals(model, vertex.normal);
29#else
30 out.world_normal = mesh_functions::mesh_normal_local_to_world(
31 vertex.normal,
32 vertex.instance_index
33 );
34#endif
35#endif
37 let world_position = mesh_functions::mesh_position_local_to_world(model, vec4<f32>(vertex.position, 1.0));
39 // Add the wave height to the world position.
40 var height = -0.5;
41#if QUALITY > 2
42 let w_pos = water_fn::uv_to_coord(vertex.uv);
43 height = water_fn::get_wave_height(w_pos);
44#endif
46 out.world_position = world_position + vec4<f32>((out.world_normal * height), 0.);
47 out.position = position_world_to_clip(out.world_position.xyz);
49#ifdef VERTEX_UVS
50 out.uv = vertex.uv;
51#endif
53#ifdef VERTEX_TANGENTS
54 out.world_tangent = mesh_functions::mesh_tangent_local_to_world(
55 model,
56 vertex.tangent,
57 vertex.instance_index
58 );
59#endif
61#ifdef VERTEX_COLORS
62 out.color = vertex.color;
63#endif
65#ifdef VERTEX_OUTPUT_INSTANCE_INDEX
66 out.instance_index = vertex.instance_index;
67#endif
69 return out;
Contents