Compare commits
4 Commits
e8c6dd61f9
...
62bb5c620c
Author | SHA1 | Date |
---|---|---|
mars | 62bb5c620c | |
mars | 398064aef0 | |
mars | 30024a7e79 | |
mars | 2387e60c0f |
|
@ -204,7 +204,7 @@ impl RenderState {
|
|||
let render_schedule = render_schedule.build();
|
||||
|
||||
// make debug draw grid
|
||||
let grid_size = 10;
|
||||
let grid_size = 100;
|
||||
let grid_color = [0.0, 1.0, 0.0];
|
||||
let mut grid_vertices = Vec::new();
|
||||
|
||||
|
|
|
@ -15,7 +15,10 @@ pub struct ScriptData {
|
|||
|
||||
#[derive(Copy, Clone, Debug, Deserialize, Serialize)]
|
||||
pub struct Transform {
|
||||
#[serde(default)]
|
||||
pub position: glam::Vec3,
|
||||
|
||||
#[serde(default)]
|
||||
pub orientation: glam::Quat,
|
||||
}
|
||||
|
||||
|
|
|
@ -11,11 +11,16 @@ struct VertexInput {
|
|||
struct VertexOutput {
|
||||
[[builtin(position)]] clip_position: vec4<f32>;
|
||||
[[location(0)]] position: vec3<f32>;
|
||||
[[location(1)]] color: vec3<f32>;
|
||||
};
|
||||
|
||||
[[group(0), binding(0)]]
|
||||
var<uniform> camera: CameraUniform;
|
||||
|
||||
fn random(seed: u32, salt: f32) -> f32 {
|
||||
return abs(sin((f32(seed & u32(0x11111)) * 0.7071 + salt) * 78.233));
|
||||
}
|
||||
|
||||
[[stage(vertex)]]
|
||||
fn vs_main(
|
||||
[[builtin(instance_index)]] mesh_idx: u32,
|
||||
|
@ -27,6 +32,9 @@ fn vs_main(
|
|||
var out: VertexOutput;
|
||||
out.clip_position = camera.vp * vec4<f32>(world_pos, 1.0);
|
||||
out.position = world_pos;
|
||||
out.color.r = random(vertex_idx, f32(1.0) + world_pos.x);
|
||||
out.color.g = random(vertex_idx, f32(2.0) + world_pos.y);
|
||||
out.color.b = random(vertex_idx, f32(3.0) + world_pos.z);
|
||||
return out;
|
||||
}
|
||||
|
||||
|
@ -34,5 +42,5 @@ fn vs_main(
|
|||
fn fs_main(
|
||||
frag: VertexOutput,
|
||||
) -> [[location(0)]] vec4<f32> {
|
||||
return vec4<f32>(sin(frag.position) * vec3<f32>(0.5) + vec3<f32>(0.5), 1.0);
|
||||
return vec4<f32>(frag.color, 1.0);
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue