diff --git a/src/load_roblox.rs b/src/load_roblox.rs index 7d2ddc9e..0142f099 100644 --- a/src/load_roblox.rs +++ b/src/load_roblox.rs @@ -148,7 +148,6 @@ pub fn generate_modeldatas_roblox(dom:rbx_dom_weak::WeakDom) -> Result<(Vec(); +const MODEL_BUFFER_SIZE:usize=4*4 + 4;//let size=std::mem::size_of::(); const MODEL_BUFFER_SIZE_BYTES:usize=MODEL_BUFFER_SIZE*4; fn get_instances_buffer_data(instances:&[ModelInstance]) -> Vec { let mut raw = Vec::with_capacity(MODEL_BUFFER_SIZE*instances.len()); @@ -293,11 +293,6 @@ fn get_instances_buffer_data(instances:&[ModelInstance]) -> Vec { let mut v = raw.split_off(MODEL_BUFFER_SIZE*i); //model_transform raw.extend_from_slice(&AsRef::<[f32; 4*4]>::as_ref(&glam::Mat4::from(mi.model_transform))[..]); - //texture_matrix - raw.extend_from_slice(&AsRef::<[f32; 2*2]>::as_ref(&mi.texture_transform.matrix2)[..]); - //texture_offset - raw.extend_from_slice(AsRef::<[f32; 2]>::as_ref(&mi.texture_transform.translation)); - raw.extend_from_slice(&[0.0,0.0]); //color raw.extend_from_slice(AsRef::<[f32; 4]>::as_ref(&mi.color)); raw.append(&mut v); @@ -329,40 +324,33 @@ impl framework::Example for GraphicsData { println!("models.len = {:?}", modeldatas.len()); modeldatas[0].instances.push(ModelInstance{ model_transform:glam::Affine3A::from_translation(glam::vec3(10.,0.,-10.)), - texture_transform:glam::Affine2::IDENTITY, color:ModelData::COLOR_VEC4_WHITE, }); //quad monkeys modeldatas[1].instances.push(ModelInstance{ model_transform:glam::Affine3A::from_translation(glam::vec3(10.,5.,10.)), - texture_transform:glam::Affine2::IDENTITY, color:ModelData::COLOR_VEC4_WHITE, }); modeldatas[1].instances.push(ModelInstance{ model_transform:glam::Affine3A::from_translation(glam::vec3(20.,5.,10.)), - texture_transform:glam::Affine2::IDENTITY, color:glam::vec4(1.0,0.0,0.0,1.0), }); modeldatas[1].instances.push(ModelInstance{ model_transform:glam::Affine3A::from_translation(glam::vec3(10.,5.,20.)), - texture_transform:glam::Affine2::IDENTITY, color:glam::vec4(0.0,1.0,0.0,1.0), }); modeldatas[1].instances.push(ModelInstance{ model_transform:glam::Affine3A::from_translation(glam::vec3(20.,5.,20.)), - texture_transform:glam::Affine2::IDENTITY, color:glam::vec4(0.0,0.0,1.0,1.0), }); //teapot modeldatas[2].instances.push(ModelInstance{ model_transform:glam::Affine3A::from_translation(glam::vec3(-10.,5.,10.)), - texture_transform:glam::Affine2::from_scale(glam::vec2(2.0,2.0)), color:ModelData::COLOR_VEC4_WHITE, }); //ground modeldatas[3].instances.push(ModelInstance{ model_transform:glam::Affine3A::from_translation(glam::vec3(0.,0.,0.))*glam::Affine3A::from_scale(glam::vec3(160.0, 1.0, 160.0)), - texture_transform:glam::Affine2::IDENTITY, color:ModelData::COLOR_VEC4_WHITE, }); diff --git a/src/model.rs b/src/model.rs index 5fcac1df..5c8b26e4 100644 --- a/src/model.rs +++ b/src/model.rs @@ -10,7 +10,6 @@ pub struct Vertex { #[derive(Clone)] pub struct ModelInstance { pub model_transform: glam::Affine3A, - pub texture_transform: glam::Affine2, pub color: glam::Vec4, } diff --git a/src/shader.wgsl b/src/shader.wgsl index d2a31656..69774fbe 100644 --- a/src/shader.wgsl +++ b/src/shader.wgsl @@ -43,9 +43,6 @@ fn vs_sky(@builtin(vertex_index) vertex_index: u32) -> SkyOutput { struct ModelInstance{ model_transform:mat4x4, - //simple to save 4 bytes, so do it. above would need to be spit out into components. - texture_matrix:mat2x2, - texture_offset:vec2, color:vec4, } //my fancy idea is to create a megatexture for each model that includes all the textures each intance will need @@ -80,7 +77,7 @@ fn vs_entity_texture( var position: vec4 = model_instances[instance].model_transform * vec4(pos, 1.0); var result: EntityOutputTexture; result.normal = (model_instances[instance].model_transform * vec4(normal, 0.0)).xyz; - result.texture = model_instances[instance].texture_matrix * texture + model_instances[instance].texture_offset; + result.texture = texture; result.color = model_instances[instance].color * color; result.view = position.xyz - camera.cam_pos.xyz; result.position = camera.proj * camera.view * position;