Compare commits
5 Commits
refactor-s
...
video3
| Author | SHA1 | Date | |
|---|---|---|---|
|
794812d4b7
|
|||
|
efe5e41fe2
|
|||
|
d9659b2701
|
|||
|
e39488d8f9
|
|||
|
f82d860822
|
@@ -6,7 +6,7 @@ pub struct Graphics{
|
||||
start_offset:glam::Vec3,
|
||||
}
|
||||
impl Graphics{
|
||||
pub fn new(device:&wgpu::Device,queue:&wgpu::Queue,size:glam::UVec2,view_format: wgpu::TextureFormat)->Self{
|
||||
pub fn new(device:&wgpu::Device,queue:&wgpu::Queue,size:glam::UVec2,view_format:wgpu::TextureFormat)->Self{
|
||||
let graphics=strafesnet_graphics::graphics::GraphicsState::new(device,queue,size,view_format);
|
||||
Self{
|
||||
graphics,
|
||||
|
||||
@@ -1,20 +1,25 @@
|
||||
struct VertexOutput {
|
||||
@builtin(position) position: vec4<f32>,
|
||||
@location(1) uv: vec2<f32>,
|
||||
}
|
||||
|
||||
@vertex
|
||||
fn vs_main(@builtin(vertex_index) vertex_index: u32) -> VertexOutput {
|
||||
// hacky way to draw a large triangle
|
||||
let tmp1 = i32(vertex_index) / 2;
|
||||
let tmp2 = i32(vertex_index) & 1;
|
||||
var result:VertexOutput;
|
||||
result.position=vec4<f32>(
|
||||
f32(tmp1) * 4.0 - 1.0,
|
||||
f32(tmp2) * 4.0 - 1.0,
|
||||
1.0,
|
||||
1.0
|
||||
);
|
||||
return result;
|
||||
// hacky way to draw a large triangle
|
||||
let tmp1 = i32(vertex_index) / 2;
|
||||
let tmp2 = i32(vertex_index) & 1;
|
||||
var result:VertexOutput;
|
||||
result.position=vec4<f32>(
|
||||
f32(tmp1) * 4.0 - 1.0,
|
||||
f32(tmp2) * 4.0 - 1.0,
|
||||
1.0,
|
||||
1.0
|
||||
);
|
||||
result.uv=vec2<f32>(
|
||||
f32(tmp1) * 2.0,
|
||||
1.0 - f32(tmp2) * 2.0
|
||||
);
|
||||
return result;
|
||||
}
|
||||
|
||||
@group(0)
|
||||
@@ -27,7 +32,7 @@ var texture_sampler: sampler;
|
||||
@fragment
|
||||
fn fs_main_y(input: VertexOutput) -> @location(0) f32 {
|
||||
let conversion_weights = vec3<f32>(0.2126, 0.7152, 0.0722);
|
||||
let color = textureSample(texture, texture_sampler, input.position.xy).rgb;
|
||||
let color = textureSample(texture, texture_sampler, input.uv).rgb;
|
||||
|
||||
return clamp(dot(color, conversion_weights), 0.0, 1.0);
|
||||
}
|
||||
@@ -40,7 +45,7 @@ fn fs_main_uv(input: VertexOutput) -> @location(0) vec2<f32> {
|
||||
0.5, -0.0458,
|
||||
);
|
||||
let conversion_bias = vec2<f32>(0.5, 0.5);
|
||||
let color = textureSample(texture, texture_sampler, input.position.xy).rgb;
|
||||
let color = textureSample(texture, texture_sampler, input.uv).rgb;
|
||||
|
||||
return clamp(conversion_weights * color + conversion_bias, vec2(0.0, 0.0), vec2(1.0, 1.0));
|
||||
}
|
||||
|
||||
@@ -302,7 +302,7 @@ impl PlaneRenderer {
|
||||
topology: wgpu::PrimitiveTopology::TriangleList,
|
||||
cull_mode: Some(wgpu::Face::Back),
|
||||
polygon_mode: wgpu::PolygonMode::Fill,
|
||||
front_face: wgpu::FrontFace::Ccw,
|
||||
front_face: wgpu::FrontFace::Cw,
|
||||
conservative: false,
|
||||
unclipped_depth: false,
|
||||
strip_index_format: None,
|
||||
|
||||
Reference in New Issue
Block a user