Skip to content

Commit

Permalink
wip update to main
Browse files Browse the repository at this point in the history
  • Loading branch information
IceSentry committed Jan 13, 2024
1 parent e248130 commit 9061a40
Show file tree
Hide file tree
Showing 2 changed files with 131 additions and 102 deletions.
21 changes: 10 additions & 11 deletions assets/shaders/custom_draw.wgsl
Original file line number Diff line number Diff line change
@@ -1,20 +1,18 @@
#import bevy_pbr::mesh_functions as mesh_functions
#import bevy_render::view View
#import bevy_pbr::mesh_types Mesh
#import bevy_pbr::{mesh_types::Mesh, view_transformations}
#import bevy_render::view::View

@group(0) @binding(0)
var<uniform> view: View;
@group(0) @binding(0) var<uniform> view: View;

struct CustomMaterial {
color: vec4<f32>,
};
@group(1) @binding(0)
var<uniform> material: CustomMaterial;
@group(1) @binding(0) var<uniform> material: CustomMaterial;

@group(2) @binding(0)
var<uniform> mesh: Mesh;
@group(2) @binding(0) var<uniform> mesh: Mesh;

struct Vertex {
@builtin(instance_index) instance_index: u32,
@location(0) position: vec3<f32>,
};

Expand All @@ -25,12 +23,13 @@ struct VertexOutput {
@vertex
fn vertex(vertex: Vertex) -> VertexOutput {
var out: VertexOutput;
let world_position = mesh_functions::mesh_position_local_to_world(mesh.model, vec4(vertex.position, 1.0));
out.position = mesh_functions::mesh_position_world_to_clip(world_position);
var model = mesh_functions::get_model_matrix(vertex.instance_index);
let world_position = mesh_functions::mesh_position_local_to_world(model, vec4<f32>(vertex.position, 1.0));
out.position = view_transformations::position_world_to_clip(world_position.xyz);
return out;
}

@fragment
fn fragment() -> @location(0) vec4<f32> {
return material.color;
return vec4(1.0, 0.0, 0.0, 1.0);
}
Loading

0 comments on commit 9061a40

Please sign in to comment.