Skip to content

Commit 44f0236

Browse files
committed
Add terraintessellation rust shaders
1 parent d32e247 commit 44f0236

File tree

12 files changed

+292
-0
lines changed

12 files changed

+292
-0
lines changed

shaders/rust/Cargo.lock

Lines changed: 14 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

shaders/rust/Cargo.toml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -141,6 +141,8 @@ members = [
141141
"shadowmappingcascade/scene",
142142
"pipelinestatistics/scene",
143143
"meshshader/meshshader",
144+
"terraintessellation/terrain",
145+
"terraintessellation/skysphere",
144146
]
145147

146148
[workspace.package]
680 Bytes
Binary file not shown.
Binary file not shown.
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
[package]
2+
name = "terraintessellation-skysphere"
3+
version = "0.1.0"
4+
edition.workspace = true
5+
6+
[lib]
7+
crate-type = ["dylib"]
8+
9+
[dependencies]
10+
spirv-std = { workspace = true }
Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
#![no_std]
2+
3+
use spirv_std::glam::{Mat4, Vec2, Vec3, Vec4, Vec4Swizzles};
4+
use spirv_std::spirv;
5+
use spirv_std::{Image, Sampler};
6+
7+
#[repr(C)]
8+
#[derive(Copy, Clone)]
9+
pub struct UBO {
10+
pub mvp: Mat4,
11+
}
12+
13+
#[spirv(vertex)]
14+
pub fn main_vs(
15+
in_pos: Vec3,
16+
_in_normal: Vec3,
17+
in_uv: Vec2,
18+
#[spirv(uniform, descriptor_set = 0, binding = 0)] ubo: &UBO,
19+
#[spirv(position)] out_position: &mut Vec4,
20+
out_uv: &mut Vec2,
21+
) {
22+
*out_position = ubo.mvp * Vec4::from((in_pos, 1.0));
23+
*out_uv = in_uv;
24+
}
25+
26+
#[spirv(fragment)]
27+
pub fn main_fs(
28+
in_uv: Vec2,
29+
#[spirv(descriptor_set = 0, binding = 1)] sampler_color_map: &Image!(2D, type=f32, sampled),
30+
#[spirv(descriptor_set = 0, binding = 1)] sampler: &Sampler,
31+
out_frag_color: &mut Vec4,
32+
) {
33+
let color = sampler_color_map.sample(*sampler, in_uv);
34+
*out_frag_color = Vec4::from((color.xyz(), 1.0));
35+
}
Binary file not shown.
Binary file not shown.
Binary file not shown.
684 Bytes
Binary file not shown.

0 commit comments

Comments
 (0)