|
|
@@ -0,0 +1,53 @@
|
|
|
+// Vertex shader
|
|
|
+
|
|
|
+struct CameraUniform {
|
|
|
+ view_proj: mat4x4<f32>
|
|
|
+}
|
|
|
+
|
|
|
+@group(0) @binding(0)
|
|
|
+var<uniform> camera: CameraUniform;
|
|
|
+
|
|
|
+struct VertexInput {
|
|
|
+ @location(0) position: vec3<f32>,
|
|
|
+ @location(1) color: vec3<f32>,
|
|
|
+ @location(2) uv: vec2<f32>,
|
|
|
+};
|
|
|
+
|
|
|
+struct VertexOutput {
|
|
|
+ @builtin(position) clip_position: vec4<f32>,
|
|
|
+ @location(0) color: vec3<f32>,
|
|
|
+};
|
|
|
+
|
|
|
+@group(1) @binding(0)
|
|
|
+var t_diffuse: texture_2d<f32>;
|
|
|
+@group(1) @binding(1)
|
|
|
+var s_diffuse: sampler;
|
|
|
+
|
|
|
+@group(2) @binding(0)
|
|
|
+var h_diffuse: texture_2d<f32>;
|
|
|
+@group(2) @binding(1)
|
|
|
+var hs_diffuse: sampler;
|
|
|
+
|
|
|
+@vertex
|
|
|
+fn vs_main(
|
|
|
+ model: VertexInput,
|
|
|
+) -> VertexOutput {
|
|
|
+ //let normalized_uv_coordinates = model.uv * vec2<f32>(textureDimensions(t_diffuse));
|
|
|
+ let normalized_uv_coordinates = model.uv * vec2<f32>(textureDimensions(h_diffuse));
|
|
|
+
|
|
|
+ //let height_added = textureLoad(t_diffuse,vec2<u32>(normalized_uv_coordinates),0);
|
|
|
+ let height_added = textureLoad(h_diffuse,vec2<u32>(normalized_uv_coordinates),0);
|
|
|
+
|
|
|
+ let grayscale_height_added = height_added.x;
|
|
|
+ var out: VertexOutput;
|
|
|
+ out.color = model.color;
|
|
|
+ out.clip_position = camera.view_proj * vec4<f32>(model.position.x,model.position.y, model.position.z + ( grayscale_height_added), 1.0);
|
|
|
+ return out;
|
|
|
+}
|
|
|
+
|
|
|
+// Fragment shader
|
|
|
+
|
|
|
+@fragment
|
|
|
+fn fs_main(in: VertexOutput) -> @location(0) vec4<f32> {
|
|
|
+ return vec4<f32>(0.0,0.0,1.0, 1.0);
|
|
|
+}
|