remove texture transform lol
This commit is contained in:
parent
8fc87a59ce
commit
f0d9c219b6
@ -148,7 +148,6 @@ pub fn generate_modeldatas_roblox(dom:rbx_dom_weak::WeakDom) -> Result<(Vec<Mode
|
|||||||
}
|
}
|
||||||
let model_instance=ModelInstance {
|
let model_instance=ModelInstance {
|
||||||
model_transform,
|
model_transform,
|
||||||
texture_transform,
|
|
||||||
color: glam::vec4(color3.r as f32/255f32, color3.g as f32/255f32, color3.b as f32/255f32, 1.0-*transparency),
|
color: glam::vec4(color3.r as f32/255f32, color3.g as f32/255f32, color3.b as f32/255f32, 1.0-*transparency),
|
||||||
};
|
};
|
||||||
match i_can_only_load_one_texture_per_model{
|
match i_can_only_load_one_texture_per_model{
|
||||||
|
14
src/main.rs
14
src/main.rs
@ -285,7 +285,7 @@ impl GraphicsData {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
const MODEL_BUFFER_SIZE:usize=4*4 + 2*2 + 2+2 + 4;//let size=std::mem::size_of::<ModelInstance>();
|
const MODEL_BUFFER_SIZE:usize=4*4 + 4;//let size=std::mem::size_of::<ModelInstance>();
|
||||||
const MODEL_BUFFER_SIZE_BYTES:usize=MODEL_BUFFER_SIZE*4;
|
const MODEL_BUFFER_SIZE_BYTES:usize=MODEL_BUFFER_SIZE*4;
|
||||||
fn get_instances_buffer_data(instances:&[ModelInstance]) -> Vec<f32> {
|
fn get_instances_buffer_data(instances:&[ModelInstance]) -> Vec<f32> {
|
||||||
let mut raw = Vec::with_capacity(MODEL_BUFFER_SIZE*instances.len());
|
let mut raw = Vec::with_capacity(MODEL_BUFFER_SIZE*instances.len());
|
||||||
@ -293,11 +293,6 @@ fn get_instances_buffer_data(instances:&[ModelInstance]) -> Vec<f32> {
|
|||||||
let mut v = raw.split_off(MODEL_BUFFER_SIZE*i);
|
let mut v = raw.split_off(MODEL_BUFFER_SIZE*i);
|
||||||
//model_transform
|
//model_transform
|
||||||
raw.extend_from_slice(&AsRef::<[f32; 4*4]>::as_ref(&glam::Mat4::from(mi.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
|
//color
|
||||||
raw.extend_from_slice(AsRef::<[f32; 4]>::as_ref(&mi.color));
|
raw.extend_from_slice(AsRef::<[f32; 4]>::as_ref(&mi.color));
|
||||||
raw.append(&mut v);
|
raw.append(&mut v);
|
||||||
@ -329,40 +324,33 @@ impl framework::Example for GraphicsData {
|
|||||||
println!("models.len = {:?}", modeldatas.len());
|
println!("models.len = {:?}", modeldatas.len());
|
||||||
modeldatas[0].instances.push(ModelInstance{
|
modeldatas[0].instances.push(ModelInstance{
|
||||||
model_transform:glam::Affine3A::from_translation(glam::vec3(10.,0.,-10.)),
|
model_transform:glam::Affine3A::from_translation(glam::vec3(10.,0.,-10.)),
|
||||||
texture_transform:glam::Affine2::IDENTITY,
|
|
||||||
color:ModelData::COLOR_VEC4_WHITE,
|
color:ModelData::COLOR_VEC4_WHITE,
|
||||||
});
|
});
|
||||||
//quad monkeys
|
//quad monkeys
|
||||||
modeldatas[1].instances.push(ModelInstance{
|
modeldatas[1].instances.push(ModelInstance{
|
||||||
model_transform:glam::Affine3A::from_translation(glam::vec3(10.,5.,10.)),
|
model_transform:glam::Affine3A::from_translation(glam::vec3(10.,5.,10.)),
|
||||||
texture_transform:glam::Affine2::IDENTITY,
|
|
||||||
color:ModelData::COLOR_VEC4_WHITE,
|
color:ModelData::COLOR_VEC4_WHITE,
|
||||||
});
|
});
|
||||||
modeldatas[1].instances.push(ModelInstance{
|
modeldatas[1].instances.push(ModelInstance{
|
||||||
model_transform:glam::Affine3A::from_translation(glam::vec3(20.,5.,10.)),
|
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),
|
color:glam::vec4(1.0,0.0,0.0,1.0),
|
||||||
});
|
});
|
||||||
modeldatas[1].instances.push(ModelInstance{
|
modeldatas[1].instances.push(ModelInstance{
|
||||||
model_transform:glam::Affine3A::from_translation(glam::vec3(10.,5.,20.)),
|
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),
|
color:glam::vec4(0.0,1.0,0.0,1.0),
|
||||||
});
|
});
|
||||||
modeldatas[1].instances.push(ModelInstance{
|
modeldatas[1].instances.push(ModelInstance{
|
||||||
model_transform:glam::Affine3A::from_translation(glam::vec3(20.,5.,20.)),
|
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),
|
color:glam::vec4(0.0,0.0,1.0,1.0),
|
||||||
});
|
});
|
||||||
//teapot
|
//teapot
|
||||||
modeldatas[2].instances.push(ModelInstance{
|
modeldatas[2].instances.push(ModelInstance{
|
||||||
model_transform:glam::Affine3A::from_translation(glam::vec3(-10.,5.,10.)),
|
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,
|
color:ModelData::COLOR_VEC4_WHITE,
|
||||||
});
|
});
|
||||||
//ground
|
//ground
|
||||||
modeldatas[3].instances.push(ModelInstance{
|
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)),
|
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,
|
color:ModelData::COLOR_VEC4_WHITE,
|
||||||
});
|
});
|
||||||
|
|
||||||
|
@ -10,7 +10,6 @@ pub struct Vertex {
|
|||||||
#[derive(Clone)]
|
#[derive(Clone)]
|
||||||
pub struct ModelInstance {
|
pub struct ModelInstance {
|
||||||
pub model_transform: glam::Affine3A,
|
pub model_transform: glam::Affine3A,
|
||||||
pub texture_transform: glam::Affine2,
|
|
||||||
pub color: glam::Vec4,
|
pub color: glam::Vec4,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -43,9 +43,6 @@ fn vs_sky(@builtin(vertex_index) vertex_index: u32) -> SkyOutput {
|
|||||||
|
|
||||||
struct ModelInstance{
|
struct ModelInstance{
|
||||||
model_transform:mat4x4<f32>,
|
model_transform:mat4x4<f32>,
|
||||||
//simple to save 4 bytes, so do it. above would need to be spit out into components.
|
|
||||||
texture_matrix:mat2x2<f32>,
|
|
||||||
texture_offset:vec2<f32>,
|
|
||||||
color:vec4<f32>,
|
color:vec4<f32>,
|
||||||
}
|
}
|
||||||
//my fancy idea is to create a megatexture for each model that includes all the textures each intance will need
|
//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<f32> = model_instances[instance].model_transform * vec4<f32>(pos, 1.0);
|
var position: vec4<f32> = model_instances[instance].model_transform * vec4<f32>(pos, 1.0);
|
||||||
var result: EntityOutputTexture;
|
var result: EntityOutputTexture;
|
||||||
result.normal = (model_instances[instance].model_transform * vec4<f32>(normal, 0.0)).xyz;
|
result.normal = (model_instances[instance].model_transform * vec4<f32>(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.color = model_instances[instance].color * color;
|
||||||
result.view = position.xyz - camera.cam_pos.xyz;
|
result.view = position.xyz - camera.cam_pos.xyz;
|
||||||
result.position = camera.proj * camera.view * position;
|
result.position = camera.proj * camera.view * position;
|
||||||
|
Loading…
Reference in New Issue
Block a user