diff options
author | metamuffin <metamuffin@disroot.org> | 2025-01-10 03:23:57 +0100 |
---|---|---|
committer | metamuffin <metamuffin@disroot.org> | 2025-01-10 03:23:57 +0100 |
commit | 9446cda10e1a1b82e08d94c9c43a3e024e55c655 (patch) | |
tree | d4dfa9b03feb2dc659e81274ad3b1ad3e603fbb6 | |
parent | 5d935c26589c014e6dc2941481988abf50e51fdf (diff) | |
download | weareserver-9446cda10e1a1b82e08d94c9c43a3e024e55c655.tar weareserver-9446cda10e1a1b82e08d94c9c43a3e024e55c655.tar.bz2 weareserver-9446cda10e1a1b82e08d94c9c43a3e024e55c655.tar.zst |
ui still no work
-rw-r--r-- | client/src/ui.rs | 15 | ||||
-rw-r--r-- | client/src/ui.wgsl | 24 |
2 files changed, 23 insertions, 16 deletions
diff --git a/client/src/ui.rs b/client/src/ui.rs index 3687276..69f1081 100644 --- a/client/src/ui.rs +++ b/client/src/ui.rs @@ -24,13 +24,12 @@ use std::{collections::HashMap, num::NonZeroU64}; use wgpu::{ BindGroup, BindGroupDescriptor, BindGroupEntry, BindGroupLayout, BindGroupLayoutDescriptor, BindGroupLayoutEntry, BindingResource, BindingType, BlendState, Buffer, BufferDescriptor, - BufferUsages, Color, ColorTargetState, ColorWrites, CommandEncoder, CompareFunction, - DepthBiasState, DepthStencilState, Device, Extent3d, FragmentState, FrontFace, IndexFormat, - LoadOp, MultisampleState, Operations, PipelineCompilationOptions, PipelineLayoutDescriptor, - PolygonMode, PrimitiveState, PrimitiveTopology, PushConstantRange, Queue, - RenderPassColorAttachment, RenderPassDescriptor, RenderPipeline, RenderPipelineDescriptor, - SamplerBindingType, SamplerDescriptor, ShaderStages, StencilState, StoreOp, Texture, - TextureDescriptor, TextureDimension, TextureFormat, TextureSampleType, TextureUsages, + BufferUsages, ColorTargetState, ColorWrites, CommandEncoder, Device, Extent3d, FragmentState, + FrontFace, IndexFormat, LoadOp, MultisampleState, Operations, PipelineCompilationOptions, + PipelineLayoutDescriptor, PolygonMode, PrimitiveState, PrimitiveTopology, PushConstantRange, + Queue, RenderPassColorAttachment, RenderPassDescriptor, RenderPipeline, + RenderPipelineDescriptor, SamplerBindingType, SamplerDescriptor, ShaderStages, StoreOp, + Texture, TextureDescriptor, TextureDimension, TextureFormat, TextureSampleType, TextureUsages, TextureView, TextureViewDescriptor, TextureViewDimension, VertexAttribute, VertexBufferLayout, VertexFormat, VertexState, VertexStepMode, include_wgsl, util::{DeviceExt, TextureDataOrder}, @@ -122,7 +121,7 @@ impl UiRenderer { shader_location: 1, }, VertexAttribute { - format: VertexFormat::Float32x3, + format: VertexFormat::Uint32, offset: size_of::<f32>() as u64 * 4, shader_location: 2, }, diff --git a/client/src/ui.wgsl b/client/src/ui.wgsl index 174f20c..3dd9b62 100644 --- a/client/src/ui.wgsl +++ b/client/src/ui.wgsl @@ -16,28 +16,36 @@ struct VertexIn { @location(0) pos: vec2<f32>, @location(1) uv: vec2<f32>, - @location(2) color: vec3<f32>, + @location(2) color: u32, } struct VertexOut { @builtin(position) clip: vec4<f32>, @location(0) uv: vec2<f32>, - @location(1) color: vec3<f32>, + @location(1) color: vec4<f32>, } @group(0) @binding(0) var texture: texture_2d<f32>; @group(0) @binding(1) var texture_sampler: sampler; var<push_constant> project: mat4x4<f32>; +fn unpack_color(color: u32) -> vec4<f32> { + return vec4<f32>( + f32(color & 255u), + f32((color >> 8u) & 255u), + f32((color >> 16u) & 255u), + f32((color >> 24u) & 255u), + ) / 255.0; +} + @vertex fn vs_main(vi: VertexIn) -> VertexOut { - var clip = project * vec4(vi.pos, 0., -1.); - clip /= clip.w; - clip.x *= -1.; - clip.y *= -1.; - let vo = VertexOut(clip, vi.uv, vi.color); + // var clip = project * vec4(vi.pos, 0., 1.); + var clip = vec4(vi.pos / 200., 0., 1.); + let vo = VertexOut(clip, vi.uv, unpack_color(vi.color)); return vo; } @fragment fn fs_main(vo: VertexOut) -> @location(0) vec4<f32> { - return textureSample(texture, texture_sampler, vo.uv) * vec4(vo.color, 1.); + return vec4(1., 0., 1., 1.); + // return textureSample(texture, texture_sampler, vo.uv) * vec4(vo.color, 1.); } |