bevy/crates/bevy_pbr/src/render/mesh_view_bindings.wgsl

46 lines
1.3 KiB
WebGPU Shading Language
Raw Normal View History

2022-05-31 23:23:25 +00:00
#define_import_path bevy_pbr::mesh_view_bindings
#import bevy_pbr::mesh_view_types
@group(0) @binding(0)
2022-05-31 23:23:25 +00:00
var<uniform> view: View;
@group(0) @binding(1)
2022-05-31 23:23:25 +00:00
var<uniform> lights: Lights;
#ifdef NO_ARRAY_TEXTURES_SUPPORT
@group(0) @binding(2)
2022-05-31 23:23:25 +00:00
var point_shadow_textures: texture_depth_cube;
#else
@group(0) @binding(2)
2022-05-31 23:23:25 +00:00
var point_shadow_textures: texture_depth_cube_array;
#endif
@group(0) @binding(3)
2022-05-31 23:23:25 +00:00
var point_shadow_textures_sampler: sampler_comparison;
#ifdef NO_ARRAY_TEXTURES_SUPPORT
@group(0) @binding(4)
2022-05-31 23:23:25 +00:00
var directional_shadow_textures: texture_depth_2d;
#else
@group(0) @binding(4)
2022-05-31 23:23:25 +00:00
var directional_shadow_textures: texture_depth_2d_array;
#endif
@group(0) @binding(5)
2022-05-31 23:23:25 +00:00
var directional_shadow_textures_sampler: sampler_comparison;
#if AVAILABLE_STORAGE_BUFFER_BINDINGS >= 3
@group(0) @binding(6)
var<storage> point_lights: PointLights;
@group(0) @binding(7)
var<storage> cluster_light_index_lists: ClusterLightIndexLists;
@group(0) @binding(8)
var<storage> cluster_offsets_and_counts: ClusterOffsetsAndCounts;
2022-05-31 23:23:25 +00:00
#else
@group(0) @binding(6)
var<uniform> point_lights: PointLights;
@group(0) @binding(7)
var<uniform> cluster_light_index_lists: ClusterLightIndexLists;
@group(0) @binding(8)
var<uniform> cluster_offsets_and_counts: ClusterOffsetsAndCounts;
2022-05-31 23:23:25 +00:00
#endif
add globals to mesh view bind group (#5409) # Objective - It's often really useful to have access to the time when writing shaders. ## Solution - Add a UnifformBuffer in the mesh view bind group - This buffer contains the time, delta time and a wrapping frame count https://user-images.githubusercontent.com/8348954/180130314-97948c2a-2d11-423d-a9c4-fb5c9d1892c7.mp4 --- ## Changelog - Added a `GlobalsUniform` at position 9 of the mesh view bind group ## Notes The implementation is currently split between bevy_render and bevy_pbr because I was basing my implementation on the `ViewPlugin`. I'm not sure if that's the right way to structure it. I named this `globals` instead of just time because we could potentially add more things to it. ## References in other engines - Godot: <https://docs.godotengine.org/en/stable/tutorials/shaders/shader_reference/canvas_item_shader.html#global-built-ins> - Global time since startup, in seconds, by default resets to 0 after 3600 seconds - Doesn't seem to have anything else - Unreal: <https://docs.unrealengine.com/4.26/en-US/RenderingAndGraphics/Materials/ExpressionReference/Constant/> - Generic time value that updates every frame. Can be paused or scaled. - Frame count node, doesn't seem to be an equivalent for shaders: <https://docs.unrealengine.com/4.26/en-US/BlueprintAPI/Utilities/GetFrameCount/> - Unity: <https://docs.unity3d.com/Manual/SL-UnityShaderVariables.html> - time since startup in seconds. No mention of time wrapping. Stored as a `vec4(t/20, t, t*2, t*3)` where `t` is the value in seconds - Also has delta time, sin time and cos time - ShaderToy: <https://www.shadertoy.com/howto> - iTime is the time since startup in seconds. - iFrameRate - iTimeDelta - iFrame frame counter Co-authored-by: Charles <IceSentry@users.noreply.github.com>
2022-09-28 04:20:27 +00:00
@group(0) @binding(9)
var<uniform> globals: Globals;