veloren_voxygen/render/renderer/
binding.rs1use crate::render::pipelines::rain_occlusion;
2
3use super::{
4 super::{
5 pipelines::{
6 AtlasTextures, FigureSpriteAtlasData, GlobalModel, GlobalsBindGroup, TerrainAtlasData,
7 debug, figure, lod_terrain, rope, shadow, sprite, terrain, ui,
8 },
9 texture::Texture,
10 },
11 Renderer,
12};
13
14impl Renderer {
15 pub fn bind_globals(
16 &self,
17 global_model: &GlobalModel,
18 lod_data: &lod_terrain::LodData,
19 ) -> GlobalsBindGroup {
20 self.layouts
21 .global
22 .bind(&self.device, global_model, lod_data, &self.noise_tex)
23 }
24
25 pub fn bind_sprite_globals(
26 &self,
27 global_model: &GlobalModel,
28 lod_data: &lod_terrain::LodData,
29 sprite_verts: &sprite::SpriteVerts,
30 ) -> sprite::SpriteGlobalsBindGroup {
31 self.layouts.sprite.bind_globals(
32 &self.device,
33 global_model,
34 lod_data,
35 &self.noise_tex,
36 sprite_verts,
37 )
38 }
39
40 pub fn create_debug_bound_locals(&mut self, vals: &[debug::Locals]) -> debug::BoundLocals {
41 let locals = self.create_consts(vals);
42 self.layouts.debug.bind_locals(&self.device, locals)
43 }
44
45 pub fn create_ui_bound_locals(&mut self, vals: &[ui::Locals]) -> ui::BoundLocals {
46 let locals = self.create_consts(vals);
47 self.layouts.ui.bind_locals(&self.device, locals)
48 }
49
50 pub fn ui_bind_texture(&mut self, texture: &Texture) -> ui::TextureBindGroup {
51 let tex_locals = ui::TexLocals::from(texture.get_dimensions().xy());
52 let tex_locals_consts = self.create_consts(&[tex_locals]);
53 self.layouts
54 .ui
55 .bind_texture(&self.device, texture, tex_locals_consts)
56 }
57
58 pub fn create_figure_bound_locals(
59 &mut self,
60 locals: &[figure::Locals],
61 bone_data: &[figure::BoneData],
62 ) -> figure::BoundLocals {
63 let locals = self.create_consts(locals);
64 let bone_data = self.create_consts(bone_data);
65 self.layouts
66 .figure
67 .bind_locals(&self.device, locals, bone_data)
68 }
69
70 pub fn create_rope_bound_locals(&mut self, locals: &[rope::Locals]) -> rope::BoundLocals {
71 let locals = self.create_consts(locals);
72 self.layouts.rope.bind_locals(&self.device, locals)
73 }
74
75 pub fn create_terrain_bound_locals(
76 &mut self,
77 locals: &[terrain::Locals],
78 ) -> terrain::BoundLocals {
79 let locals = self.create_consts(locals);
80 self.layouts.terrain.bind_locals(&self.device, locals)
81 }
82
83 pub fn create_shadow_bound_locals(&mut self, locals: &[shadow::Locals]) -> shadow::BoundLocals {
84 let locals = self.create_consts(locals);
85 self.layouts.shadow.bind_locals(&self.device, locals)
86 }
87
88 pub fn create_rain_occlusion_bound_locals(
89 &mut self,
90 locals: &[rain_occlusion::Locals],
91 ) -> rain_occlusion::BoundLocals {
92 let locals = self.create_consts(locals);
93 self.layouts
94 .rain_occlusion
95 .bind_locals(&self.device, locals)
96 }
97
98 pub fn figure_bind_atlas_textures(
99 &self,
100 col_light: Texture,
101 ) -> AtlasTextures<figure::Locals, FigureSpriteAtlasData> {
102 self.layouts.global.bind_atlas_textures(
103 &self.device,
104 &self.layouts.global.figure_sprite_atlas_layout,
105 [col_light],
106 )
107 }
108
109 pub fn terrain_bind_atlas_textures(
110 &self,
111 col_light: Texture,
112 kinds: Texture,
113 ) -> AtlasTextures<terrain::Locals, TerrainAtlasData> {
114 self.layouts.global.bind_atlas_textures(
115 &self.device,
116 &self.layouts.global.terrain_atlas_layout,
117 [col_light, kinds],
118 )
119 }
120
121 pub fn sprite_bind_atlas_textures(
122 &self,
123 col_light: Texture,
124 ) -> AtlasTextures<sprite::Locals, FigureSpriteAtlasData> {
125 self.layouts.global.bind_atlas_textures(
126 &self.device,
127 &self.layouts.global.figure_sprite_atlas_layout,
128 [col_light],
129 )
130 }
131}