remove proj
This commit is contained in:
parent
664223d199
commit
6b68aedc2a
170
Cargo.lock
generated
170
Cargo.lock
generated
@ -354,29 +354,6 @@ version = "1.6.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "8c3c1a368f70d6cf7302d78f8f7093da241fb8e8807c05cc9e51a125895a6d5b"
|
||||
|
||||
[[package]]
|
||||
name = "bindgen"
|
||||
version = "0.66.1"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "f2b84e06fc203107bfbad243f4aba2af864eb7db3b1cf46ea0a023b0b433d2a7"
|
||||
dependencies = [
|
||||
"bitflags 2.6.0",
|
||||
"cexpr",
|
||||
"clang-sys",
|
||||
"lazy_static",
|
||||
"lazycell",
|
||||
"log",
|
||||
"peeking_take_while",
|
||||
"prettyplease",
|
||||
"proc-macro2 1.0.86",
|
||||
"quote 1.0.37",
|
||||
"regex",
|
||||
"rustc-hash",
|
||||
"shlex",
|
||||
"syn 2.0.75",
|
||||
"which",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "bit_field"
|
||||
version = "0.10.2"
|
||||
@ -662,15 +639,6 @@ version = "1.1.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "6d43a04d8753f35258c91f8ec639f792891f748a1edbd759cf1dcea3382ad83c"
|
||||
|
||||
[[package]]
|
||||
name = "cexpr"
|
||||
version = "0.6.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "6fac387a98bb7c37292057cffc56d62ecb629900026402633ae9160df93a8766"
|
||||
dependencies = [
|
||||
"nom",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "cfg-expr"
|
||||
version = "0.15.8"
|
||||
@ -816,17 +784,6 @@ dependencies = [
|
||||
"inout",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "clang-sys"
|
||||
version = "1.8.1"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "0b023947811758c97c59bf9d1c188fd619ad4718dcaa767947df1cadb14f39f4"
|
||||
dependencies = [
|
||||
"glob",
|
||||
"libc",
|
||||
"libloading 0.8.5",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "clipboard-win"
|
||||
version = "3.1.1"
|
||||
@ -837,15 +794,6 @@ dependencies = [
|
||||
"winapi",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "cmake"
|
||||
version = "0.1.51"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "fb1e43aa7fd152b1f968787f7dbcdeb306d1867ff373c69955211876c053f91a"
|
||||
dependencies = [
|
||||
"cc",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "cocoa"
|
||||
version = "0.24.1"
|
||||
@ -1392,18 +1340,6 @@ dependencies = [
|
||||
"rustc_version",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "filetime"
|
||||
version = "0.2.24"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "bf401df4a4e3872c4fe8151134cf483738e74b67fc934d6532c882b3d24a4550"
|
||||
dependencies = [
|
||||
"cfg-if",
|
||||
"libc",
|
||||
"libredox 0.1.3",
|
||||
"windows-sys 0.59.0",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "flate2"
|
||||
version = "1.0.32"
|
||||
@ -2054,12 +1990,6 @@ dependencies = [
|
||||
"system-deps 7.0.2",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "glob"
|
||||
version = "0.3.1"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "d2fabcfbdc87f4758337ca535fb41a6d701b65693ce38287d856d1674551ec9b"
|
||||
|
||||
[[package]]
|
||||
name = "glow"
|
||||
version = "0.13.1"
|
||||
@ -2425,15 +2355,6 @@ dependencies = [
|
||||
"digest",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "home"
|
||||
version = "0.5.9"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "e3d1354bf6b7235cb4a0576c2619fd4ed18183f689b12b006a0ee7329eeff9a5"
|
||||
dependencies = [
|
||||
"windows-sys 0.52.0",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "http"
|
||||
version = "0.2.12"
|
||||
@ -2788,12 +2709,6 @@ version = "1.5.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "bbd2bcb4c963f2ddae06a2efc7e9f3591312473c50c6685e1f298068316e66fe"
|
||||
|
||||
[[package]]
|
||||
name = "lazycell"
|
||||
version = "1.3.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "830d08ce1d1d941e6b30645f1a0eb5643013d835ce3779a5fc208261dbe10f55"
|
||||
|
||||
[[package]]
|
||||
name = "leak"
|
||||
version = "0.1.2"
|
||||
@ -2908,7 +2823,6 @@ checksum = "c0ff37bd590ca25063e35af745c343cb7a0271906fb7b37e4813e8f79f00268d"
|
||||
dependencies = [
|
||||
"bitflags 2.6.0",
|
||||
"libc",
|
||||
"redox_syscall 0.5.3",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
@ -3829,12 +3743,6 @@ dependencies = [
|
||||
"sha2",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "peeking_take_while"
|
||||
version = "0.1.2"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "19b17cddbe7ec3f8bc800887bab5e717348c95ea2ca0b1bf0837fb964dc67099"
|
||||
|
||||
[[package]]
|
||||
name = "percent-encoding"
|
||||
version = "2.3.1"
|
||||
@ -3962,16 +3870,6 @@ dependencies = [
|
||||
"zerocopy",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "prettyplease"
|
||||
version = "0.2.20"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "5f12335488a2f3b0a83b14edad48dca9879ce89b2edd10e80237e4e852dd645e"
|
||||
dependencies = [
|
||||
"proc-macro2 1.0.86",
|
||||
"syn 2.0.75",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "proc-macro-crate"
|
||||
version = "1.3.1"
|
||||
@ -4064,32 +3962,6 @@ dependencies = [
|
||||
"syn 2.0.75",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "proj"
|
||||
version = "0.27.2"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "7ad1830ad8966eba22c76e78440458f07bd812bef5c3efdf335dec55cd1085ab"
|
||||
dependencies = [
|
||||
"geo-types",
|
||||
"libc",
|
||||
"num-traits",
|
||||
"proj-sys",
|
||||
"thiserror",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "proj-sys"
|
||||
version = "0.23.2"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "601bf4fa1e17fde1a56d303f7bed5c65969cf1822c6baf5d6c2c12c593638fec"
|
||||
dependencies = [
|
||||
"bindgen",
|
||||
"cmake",
|
||||
"flate2",
|
||||
"pkg-config",
|
||||
"tar",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "py_literal"
|
||||
version = "0.4.0"
|
||||
@ -4199,8 +4071,6 @@ dependencies = [
|
||||
"dirs",
|
||||
"ndarray 0.16.1",
|
||||
"num-traits",
|
||||
"proj",
|
||||
"proj-sys",
|
||||
"quick_cache 0.6.5",
|
||||
"radarg_plugin_interface",
|
||||
"relm4",
|
||||
@ -4579,12 +4449,6 @@ version = "0.1.24"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "719b953e2095829ee67db738b3bfa9fa368c94900df327b3f07fe6e794d2fe1f"
|
||||
|
||||
[[package]]
|
||||
name = "rustc-hash"
|
||||
version = "1.1.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "08d43f7aa6b08d49f382cde6a7982047c3426db949b1424bc4b7ec9ae12c6ce2"
|
||||
|
||||
[[package]]
|
||||
name = "rustc_version"
|
||||
version = "0.4.0"
|
||||
@ -5216,17 +5080,6 @@ dependencies = [
|
||||
"version-compare",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "tar"
|
||||
version = "0.4.41"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "cb797dad5fb5b76fcf519e702f4a589483b5ef06567f160c392832c1f5e44909"
|
||||
dependencies = [
|
||||
"filetime",
|
||||
"libc",
|
||||
"xattr",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "target-lexicon"
|
||||
version = "0.12.16"
|
||||
@ -6071,18 +5924,6 @@ version = "0.1.8"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "53a85b86a771b1c87058196170769dd264f66c0782acf1ae6cc51bfd64b39082"
|
||||
|
||||
[[package]]
|
||||
name = "which"
|
||||
version = "4.4.2"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "87ba24419a2078cd2b0f2ede2691b6c66d8e47836da3b6db8265ebad47afbfc7"
|
||||
dependencies = [
|
||||
"either",
|
||||
"home",
|
||||
"once_cell",
|
||||
"rustix",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "wide"
|
||||
version = "0.7.28"
|
||||
@ -6508,17 +6349,6 @@ version = "0.13.1"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "ec107c4503ea0b4a98ef47356329af139c0a4f7750e621cf2973cd3385ebcb3d"
|
||||
|
||||
[[package]]
|
||||
name = "xattr"
|
||||
version = "1.3.1"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "8da84f1a25939b27f6820d92aed108f83ff920fdf11a7b19366c27c4cda81d4f"
|
||||
dependencies = [
|
||||
"libc",
|
||||
"linux-raw-sys",
|
||||
"rustix",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "xcursor"
|
||||
version = "0.3.8"
|
||||
|
||||
@ -1,3 +1,7 @@
|
||||
[common]
|
||||
background = "Terrain"
|
||||
path = "/Users/tsuki/projects/radar-gb/resources/alts.png"
|
||||
|
||||
[[cmap]]
|
||||
type = "DBZ"
|
||||
levels = [0, 5, 10, 15, 20, 25, 30, 35, 40, 45, 50, 55, 60, 65, 70, 75]
|
||||
|
||||
@ -1,6 +1,6 @@
|
||||
use cgmath::Euler;
|
||||
use glow::NativeProgram;
|
||||
use nalgebra_glm::{look_at, Mat4x4, Vec3};
|
||||
use nalgebra_glm::{look_at, Mat3, Mat3x3, Mat4x4, Vec3};
|
||||
use std::num::NonZeroU32;
|
||||
|
||||
#[derive(Clone)]
|
||||
@ -46,12 +46,20 @@ impl Camera {
|
||||
}
|
||||
|
||||
pub fn get_view_matrix(&self) -> Mat4x4 {
|
||||
let l = self.center;
|
||||
look_at(&self.pos, &l, &self.upward)
|
||||
look_at(&self.pos, &self.center, &self.upward)
|
||||
}
|
||||
|
||||
// Left-handed coordinate system, for ray tracing
|
||||
pub fn ca(&self) -> Mat3x3 {
|
||||
let front = (-self.front()).normalize();
|
||||
let right = front.cross(&self.upward).normalize();
|
||||
let up = self.upward;
|
||||
let result = Mat3x3::from_columns(&[right, up, front]);
|
||||
result
|
||||
}
|
||||
|
||||
pub fn front(&self) -> Vec3 {
|
||||
self.center - self.pos
|
||||
self.pos - self.center
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@ -24,4 +24,10 @@ pub enum Error {
|
||||
|
||||
#[error("Invalid Setting {0}")]
|
||||
SettingError(String),
|
||||
|
||||
#[error("IO Error")]
|
||||
IO {
|
||||
#[from]
|
||||
source: std::io::Error,
|
||||
},
|
||||
}
|
||||
|
||||
@ -31,7 +31,7 @@ impl Earth {
|
||||
})
|
||||
}
|
||||
|
||||
fn set_conf(&mut self, gl: &GL, config: &EarthConfig) -> Result<()> {
|
||||
fn set_conf(&mut self, gl: &glow::Context, config: &EarthConfig) -> Result<()> {
|
||||
unsafe {
|
||||
let sun_loc = self.program.get_uniform_location(gl, "sun_location");
|
||||
gl.uniform_3_f32_slice(sun_loc.as_ref(), &config.sun_location);
|
||||
@ -72,72 +72,12 @@ impl EarthConfig {
|
||||
}
|
||||
|
||||
fn generate_cube(&self) -> (Vec<f32>, Vec<u32>) {
|
||||
let mut vertices = vec![];
|
||||
let mut indices = vec![];
|
||||
|
||||
let mut add_vertex = |x: f32, y: f32, z: f32| {
|
||||
vertices.push(x);
|
||||
vertices.push(y);
|
||||
vertices.push(z);
|
||||
};
|
||||
|
||||
let mut add_indices = |a: u32, b: u32, c: u32| {
|
||||
indices.push(a);
|
||||
indices.push(b);
|
||||
indices.push(c);
|
||||
};
|
||||
|
||||
let mut add_face = |a: u32, b: u32, c: u32, d: u32| {
|
||||
add_indices(a, b, c);
|
||||
add_indices(a, c, d);
|
||||
};
|
||||
|
||||
let r = self.earth_radius;
|
||||
|
||||
// Front
|
||||
add_vertex(-r, -r, r);
|
||||
add_vertex(r, -r, r);
|
||||
add_vertex(r, r, r);
|
||||
add_vertex(-r, r, r);
|
||||
add_face(0, 1, 2, 3);
|
||||
|
||||
// Back
|
||||
add_vertex(-r, -r, -r);
|
||||
add_vertex(-r, r, -r);
|
||||
add_vertex(r, r, -r);
|
||||
add_vertex(r, -r, -r);
|
||||
add_face(4, 5, 6, 7);
|
||||
|
||||
// Top
|
||||
add_vertex(-r, r, -r);
|
||||
add_vertex(-r, r, r);
|
||||
add_vertex(r, r, r);
|
||||
add_vertex(r, r, -r);
|
||||
add_face(8, 9, 10, 11);
|
||||
|
||||
// Bottom
|
||||
add_vertex(-r, -r, -r);
|
||||
add_vertex(r, -r, -r);
|
||||
add_vertex(r, -r, r);
|
||||
add_vertex(-r, -r, r);
|
||||
add_face(12, 13, 14, 15);
|
||||
|
||||
// Right
|
||||
|
||||
add_vertex(r, -r, -r);
|
||||
add_vertex(r, r, -r);
|
||||
add_vertex(r, r, r);
|
||||
add_vertex(r, -r, r);
|
||||
add_face(16, 17, 18, 19);
|
||||
|
||||
// Left
|
||||
|
||||
add_vertex(-r, -r, -r);
|
||||
add_vertex(-r, -r, r);
|
||||
add_vertex(-r, r, r);
|
||||
add_vertex(-r, r, -r);
|
||||
add_face(20, 21, 22, 23);
|
||||
let vertices = vec![
|
||||
// positions
|
||||
-1.0, -1.0, 0.0, -1.0, 1.0, 0.0, 1.0, -1.0, 0.0, 1.0, 1.0, 0.0,
|
||||
];
|
||||
|
||||
let indices = vec![0, 1, 2, 1, 3, 2];
|
||||
(vertices, indices)
|
||||
}
|
||||
}
|
||||
@ -167,7 +107,6 @@ impl Graphics for Earth {
|
||||
fn draw(&self, gl: &glow::Context, count: i32) -> Result<()> {
|
||||
self.attach.bind_self(gl, &self.program);
|
||||
unsafe {
|
||||
// gl.draw_arrays(glow::POINTS, 0, count);
|
||||
gl.draw_elements(glow::TRIANGLES, self.attach.len, glow::UNSIGNED_INT, 0);
|
||||
}
|
||||
Ok(())
|
||||
@ -198,6 +137,7 @@ impl Graphics for Earth {
|
||||
}
|
||||
|
||||
fn set_config(&mut self, gl: &glow::Context, config: &Self::Config) -> Result<()> {
|
||||
self.set_conf(gl, config);
|
||||
Ok(())
|
||||
}
|
||||
}
|
||||
|
||||
@ -1 +1,2 @@
|
||||
pub mod earth;
|
||||
pub mod terrain;
|
||||
|
||||
199
gi/src/graphics/planet/terrain.rs
Normal file
199
gi/src/graphics/planet/terrain.rs
Normal file
@ -0,0 +1,199 @@
|
||||
use glow::HasContext;
|
||||
|
||||
use crate::components::Program;
|
||||
use crate::errors::Result;
|
||||
use crate::graphics::collections::agg_fast_path::Path;
|
||||
use crate::graphics::{AttaWithBuffer, Graphics};
|
||||
use crate::pg::Attach;
|
||||
use crate::resources::RcGlRcResource;
|
||||
use crate::shaders::terrain::{TerrainFragment, TerrainVertex};
|
||||
use crate::GL;
|
||||
use crate::{components::Shader, shaders::earth::EarthVertex};
|
||||
|
||||
pub struct Terrain {
|
||||
program: Program,
|
||||
// Buffers
|
||||
attach: Attach,
|
||||
}
|
||||
|
||||
impl Terrain {
|
||||
pub fn new(gl: &GL) -> Result<Self> {
|
||||
let vertex = Shader::new(glow::VERTEX_SHADER, TerrainVertex::new())?;
|
||||
// let geometry = Shader::new(glow::GEOMETRY_SHADER, EarthGeometry::new())?;
|
||||
let fragment = Shader::new(glow::FRAGMENT_SHADER, TerrainFragment::new())?;
|
||||
|
||||
let config = TerrainConfig::default();
|
||||
let default_attach = config.create_attach(gl);
|
||||
|
||||
let program = Program::new(vertex, fragment, None, "330 core");
|
||||
Ok(Self {
|
||||
program,
|
||||
attach: default_attach,
|
||||
})
|
||||
}
|
||||
|
||||
fn set_conf(&mut self, gl: &glow::Context, config: &TerrainConfig) -> Result<()> {
|
||||
unsafe {
|
||||
let sun_loc = self.program.get_uniform_location(gl, "sun_location");
|
||||
gl.uniform_3_f32_slice(sun_loc.as_ref(), &config.sun_location);
|
||||
|
||||
let er = self.program.get_uniform_location(gl, "ER");
|
||||
gl.uniform_1_f32(er.as_ref(), config.earth_radius);
|
||||
|
||||
let ts = self.program.get_uniform_location(gl, "terrain_scale");
|
||||
gl.uniform_1_f32(ts.as_ref(), config.terrain_scale);
|
||||
|
||||
let tt = self.program.get_uniform_location(gl, "terrain_texture");
|
||||
if let Some(texture) = &config.terrain_texture {
|
||||
gl.uniform_1_i32(tt.as_ref(), 0);
|
||||
gl.active_texture(glow::TEXTURE0);
|
||||
gl.bind_texture(glow::TEXTURE_2D, Some(texture.native()));
|
||||
}
|
||||
}
|
||||
Ok(())
|
||||
}
|
||||
}
|
||||
|
||||
pub struct TerrainConfig {
|
||||
pub earth_radius: f32,
|
||||
pub sun_location: [f32; 3],
|
||||
pub terrain_scale: f32,
|
||||
max_height: f32,
|
||||
tex_range: [f32; 4],
|
||||
terrain_texture: Option<RcGlRcResource<glow::NativeTexture>>,
|
||||
}
|
||||
|
||||
impl TerrainConfig {
|
||||
fn create_attach(&self, gl: &GL) -> Attach {
|
||||
unsafe {
|
||||
let vao = gl.create_vertex_array().unwrap();
|
||||
gl.bind_vertex_array(Some(vao));
|
||||
|
||||
let vbo = gl.create_buffer().unwrap();
|
||||
gl.bind_buffer(glow::ARRAY_BUFFER, Some(vbo));
|
||||
|
||||
gl.enable_vertex_attrib_array(0);
|
||||
gl.vertex_attrib_pointer_f32(0, 3, glow::FLOAT, false, 12, 0);
|
||||
|
||||
let ebo = gl.create_buffer().unwrap();
|
||||
gl.bind_buffer(glow::ELEMENT_ARRAY_BUFFER, Some(ebo));
|
||||
|
||||
let mut attach = Attach::new(gl.clone(), vao, vbo, Some(ebo), None, Some(1));
|
||||
|
||||
let (vbo, ebo) = self.generate_cube();
|
||||
attach.bind_data(gl, &vbo, Some(&ebo), ebo.len() as i32, glow::STATIC_DRAW);
|
||||
attach
|
||||
}
|
||||
}
|
||||
|
||||
fn generate_cube(&self) -> (Vec<f32>, Vec<u32>) {
|
||||
let vertices = vec![
|
||||
// positions
|
||||
-1.0, -1.0, 0.0, -1.0, 1.0, 0.0, 1.0, -1.0, 0.0, 1.0, 1.0, 0.0,
|
||||
];
|
||||
|
||||
let indices = vec![0, 1, 2, 1, 3, 2];
|
||||
(vertices, indices)
|
||||
}
|
||||
}
|
||||
|
||||
impl Default for TerrainConfig {
|
||||
fn default() -> Self {
|
||||
Self {
|
||||
earth_radius: 3.0,
|
||||
sun_location: [10.0, 0.0, 0.0],
|
||||
terrain_scale: 1.0,
|
||||
tex_range: [0.0, 0.0, 0.0, 0.0],
|
||||
max_height: 1.0,
|
||||
terrain_texture: None,
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
impl TerrainConfig {
|
||||
pub fn set_alt_texture(
|
||||
&mut self,
|
||||
gl: &GL,
|
||||
path: impl AsRef<std::path::Path>,
|
||||
) -> crate::errors::Result<()> {
|
||||
let img = image::open(path).unwrap();
|
||||
let img = img.flipv();
|
||||
let img = img.to_rgba8();
|
||||
let (width, height) = img.dimensions();
|
||||
let data = img.into_raw();
|
||||
|
||||
let texture = unsafe {
|
||||
let texture = gl.create_texture().unwrap();
|
||||
gl.bind_texture(glow::TEXTURE_2D, Some(texture));
|
||||
gl.tex_image_2d(
|
||||
glow::TEXTURE_2D,
|
||||
0,
|
||||
glow::RGBA as i32,
|
||||
width as i32,
|
||||
height as i32,
|
||||
0,
|
||||
glow::RGBA,
|
||||
glow::UNSIGNED_BYTE,
|
||||
Some(&data),
|
||||
);
|
||||
gl.generate_mipmap(glow::TEXTURE_2D);
|
||||
texture
|
||||
};
|
||||
|
||||
let result = gl.create_resource_rc_with(texture);
|
||||
self.terrain_texture = Some(result);
|
||||
|
||||
Ok(())
|
||||
}
|
||||
}
|
||||
|
||||
impl Graphics for Terrain {
|
||||
const id: &'static str = "Terrain";
|
||||
type Config = TerrainConfig;
|
||||
|
||||
fn compile(&mut self, gl: &glow::Context) -> Result<()> {
|
||||
self.program.compile(gl)
|
||||
}
|
||||
|
||||
fn destroy(&mut self, gl: &glow::Context) -> Result<()> {
|
||||
self.program.destroy(gl);
|
||||
Ok(())
|
||||
}
|
||||
|
||||
fn draw(&self, gl: &glow::Context, count: i32) -> Result<()> {
|
||||
self.attach.bind_self(gl, &self.program);
|
||||
unsafe {
|
||||
gl.draw_elements(glow::TRIANGLES, self.attach.len, glow::UNSIGNED_INT, 0);
|
||||
}
|
||||
Ok(())
|
||||
}
|
||||
|
||||
fn mount(&self, gl: &glow::Context) -> Result<()> {
|
||||
unsafe {
|
||||
gl.use_program(self.program.native_program);
|
||||
}
|
||||
|
||||
Ok(())
|
||||
}
|
||||
|
||||
fn unmount(&self, gl: &glow::Context) -> Result<()> {
|
||||
unsafe {
|
||||
gl.use_program(None);
|
||||
}
|
||||
|
||||
Ok(())
|
||||
}
|
||||
|
||||
fn program_ref(&self) -> &Program {
|
||||
&self.program
|
||||
}
|
||||
|
||||
fn program_mut(&mut self) -> &mut Program {
|
||||
&mut self.program
|
||||
}
|
||||
|
||||
fn set_config(&mut self, gl: &glow::Context, config: &Self::Config) -> Result<()> {
|
||||
self.set_conf(gl, config);
|
||||
Ok(())
|
||||
}
|
||||
}
|
||||
@ -48,12 +48,13 @@ impl App {
|
||||
if let Err(e) = self.context.programs.prepare() {
|
||||
error!("prepare failed: {:?}", e);
|
||||
}
|
||||
|
||||
let init_modules = self.init_modules(setting)?;
|
||||
self.init_modules = Some(init_modules);
|
||||
Ok(())
|
||||
}
|
||||
|
||||
pub fn set_init_modules(&mut self, modules: ModulePackage) {
|
||||
self.init_modules = Some(modules);
|
||||
}
|
||||
|
||||
pub fn render<'a>(
|
||||
&'a mut self,
|
||||
modules: &mut Vec<Rc<RefCell<ModulePackage>>>,
|
||||
@ -79,11 +80,6 @@ impl App {
|
||||
&mut self.context.programs
|
||||
}
|
||||
|
||||
fn init_modules(&mut self, setting: &radarg_core::config::Setting) -> Result<ModulePackage> {
|
||||
let earth_module = self.program().earth();
|
||||
earth_module.load_data(&(), setting).map(|v| v.into())
|
||||
}
|
||||
|
||||
pub fn supported_modules<'a>(
|
||||
&mut self,
|
||||
data: &'a Value<Data>,
|
||||
|
||||
@ -25,7 +25,10 @@ use crate::{
|
||||
collections::agg_fast_path::AggFastPath,
|
||||
font::Text,
|
||||
geoquadmesh::GeoQuadMesh,
|
||||
planet::earth::{self, Earth},
|
||||
planet::{
|
||||
earth::{self, Earth},
|
||||
terrain::Terrain,
|
||||
},
|
||||
ppi::PPI,
|
||||
transforms::plane::PlaneTrans,
|
||||
AttaWithProgram, AttachWithIO, Graphics,
|
||||
@ -77,12 +80,15 @@ pub struct Programs {
|
||||
_line: AggFastPath,
|
||||
_geo_quad_mesh: GeoQuadMesh,
|
||||
_earth: Earth,
|
||||
_terrain: Terrain,
|
||||
}
|
||||
|
||||
impl Programs {
|
||||
fn new(gl: GL) -> Result<Self> {
|
||||
let font_manager = FontManager::new()?;
|
||||
let earth = Earth::new(&gl)?;
|
||||
let _terrain = Terrain::new(&gl)?;
|
||||
|
||||
Ok(Self {
|
||||
gl: gl.clone(),
|
||||
_ppi: PPI::new()?,
|
||||
@ -90,6 +96,7 @@ impl Programs {
|
||||
_line: AggFastPath::new()?,
|
||||
_geo_quad_mesh: GeoQuadMesh::new()?,
|
||||
_earth: earth,
|
||||
_terrain,
|
||||
})
|
||||
}
|
||||
|
||||
@ -99,6 +106,7 @@ impl Programs {
|
||||
self._text.program_mut().compile(&self.gl)?;
|
||||
self._geo_quad_mesh.program().compile(&self.gl)?;
|
||||
self._earth.program_mut().compile(&self.gl)?;
|
||||
self._terrain.program_mut().compile(&self.gl)?;
|
||||
Ok(())
|
||||
}
|
||||
|
||||
@ -108,6 +116,7 @@ impl Programs {
|
||||
self._line.destroy(&self.gl)?;
|
||||
self._geo_quad_mesh.destroy(&self.gl)?;
|
||||
self._earth.destroy(&self.gl)?;
|
||||
self._terrain.destroy(&self.gl)?;
|
||||
Ok(())
|
||||
}
|
||||
}
|
||||
@ -290,13 +299,15 @@ macro_rules! impl_module_package {
|
||||
program_impl!(
|
||||
{ppi | ppi_ref, PPIModule | PPIModuleRef, (_ppi, _text, _line)},
|
||||
{geo_quad_mesh | geo_quad_mesh_ref, GeoQuadMeshModule | GeoQuadMeshModuleRef, (_geo_quad_mesh,_text, _line)},
|
||||
{earth | earth_ref, EarthModule | EarthModuleRef, (_earth)}
|
||||
{earth | earth_ref, EarthModule | EarthModuleRef, (_earth)},
|
||||
{terrain | terrain_ref, TerrainModule | TerrainModuleRef, (_terrain)}
|
||||
);
|
||||
|
||||
impl_module_package!(
|
||||
{ppi|ppi_ref,PPIPackage => PPI | PPIModule | PPIModuleRef | PPIModuleConfigComponent},
|
||||
{geo_quad_mesh|geo_quad_mesh_ref,GeoQuadMeshPackage => GeoQuadMesh | GeoQuadMeshModule | GeoQuadMeshModuleRef | GeoQuadMeshModuleConfigComponent},
|
||||
{earth|earth_ref, EarthModulePackage => Earth| EarthModule | EarthModuleRef | EarthModuleConfigComponent}
|
||||
{earth|earth_ref, EarthModulePackage => Earth| EarthModule | EarthModuleRef | EarthModuleConfigComponent},
|
||||
{terrain|terrain_ref, TerrainModulePackage => Terrain | TerrainModule | TerrainModuleRef | TerrainModuleConfigComponent}
|
||||
);
|
||||
|
||||
impl ModulePackage {
|
||||
|
||||
@ -81,10 +81,11 @@ impl<'b, 'gl: 'b> Module for EarthModule<'b, 'gl> {
|
||||
) -> super::Result<()> {
|
||||
self.earth.mount(&self.gl)?;
|
||||
self.earth.set_config(&self.gl, &EarthConfig::default())?;
|
||||
operation.attach_with_program(&self.gl, self.earth.program_mut());
|
||||
// operation.attach_with_program(&self.gl, self.earth.program_mut());
|
||||
|
||||
// Camera Info
|
||||
let camera_loc = operation.camera().get_position();
|
||||
|
||||
// focal length
|
||||
let focal_length = operation.projection().fov();
|
||||
let focal_length = 1.0 / ((focal_length / 2.0).to_radians().tan());
|
||||
@ -104,12 +105,20 @@ impl<'b, 'gl: 'b> Module for EarthModule<'b, 'gl> {
|
||||
let projection_params =
|
||||
earth_program.get_uniform_location(&self.gl, "projection_params");
|
||||
|
||||
let ca = earth_program.get_uniform_location(&self.gl, "ca");
|
||||
|
||||
self.gl
|
||||
.uniform_3_f32(cloc.as_ref(), camera_loc.x, camera_loc.y, camera_loc.z);
|
||||
self.gl.uniform_1_f32(foc.as_ref(), focal_length);
|
||||
self.gl.uniform_2_f32_slice(res.as_ref(), &resolution);
|
||||
self.gl
|
||||
.uniform_2_f32(projection_params.as_ref(), znear, zfar);
|
||||
|
||||
self.gl.uniform_matrix_3_f32_slice(
|
||||
ca.as_ref(),
|
||||
false,
|
||||
operation.camera().ca().as_slice(),
|
||||
);
|
||||
}
|
||||
|
||||
self.earth.draw(&self.gl, 1);
|
||||
|
||||
@ -17,6 +17,7 @@ use std::{cell::RefCell, path::Component, rc::Rc, sync::Arc};
|
||||
mod earth;
|
||||
mod geoquadmesh;
|
||||
mod ppi;
|
||||
mod terrain;
|
||||
use crate::errors::*;
|
||||
pub use geoquadmesh::{
|
||||
GeoQuadMeshModule, GeoQuadMeshModuleConfig, GeoQuadMeshModuleConfigComponent,
|
||||
@ -31,6 +32,10 @@ pub use earth::{
|
||||
EarthModuleRef,
|
||||
};
|
||||
|
||||
pub use terrain::{
|
||||
TerrainModule, TerrainModuleConfigComponent, TerrainModulePackage, TerrainModuleRef,
|
||||
};
|
||||
|
||||
use relm4::Component as RComponent;
|
||||
|
||||
use super::{layout_type::ViewPort, SideBarInputMsg};
|
||||
|
||||
@ -611,11 +611,11 @@ impl SimpleComponent for PPIModuleConfigComponent {
|
||||
adw::PreferencesGroup {
|
||||
set_title:"Show Config",
|
||||
set_hexpand:true,
|
||||
adw::PreferencesRow {
|
||||
set_title:"Color Line",
|
||||
#[wrap(Some)]
|
||||
set_child=>k::Box{
|
||||
gtk::ColorDialogButton {
|
||||
adw::ActionRow {
|
||||
set_title: "Color Line",
|
||||
add_suffix=>k::ColorDialogButton {
|
||||
set_vexpand:false,
|
||||
set_height_request: 10,
|
||||
set_dialog=>k::ColorDialog {},
|
||||
set_rgba: >k::gdk::RGBA::new(init_config.line_color[0], init_config.line_color[1],init_config.line_color[2],init_config.line_color[3]),
|
||||
connect_rgba_notify[sender, config_ref] => move |this| {
|
||||
@ -625,10 +625,7 @@ impl SimpleComponent for PPIModuleConfigComponent {
|
||||
sender.output(OutputMsg::Refresh);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
},
|
||||
|
||||
adw::SpinRow {
|
||||
set_title: "Line Width",
|
||||
set_digits: 1,
|
||||
|
||||
168
gi/src/pg/modules/terrain.rs
Normal file
168
gi/src/pg/modules/terrain.rs
Normal file
@ -0,0 +1,168 @@
|
||||
use geo_macros::{module_ref_impl, ModuleRef};
|
||||
use glow::HasContext;
|
||||
use relm4::{
|
||||
adw::{self, prelude::*},
|
||||
gtk::{self, prelude::*},
|
||||
view, ComponentParts, SimpleComponent,
|
||||
};
|
||||
use std::{cell::RefCell, rc::Rc, sync::Arc};
|
||||
|
||||
use crate::{
|
||||
graphics::{
|
||||
planet::terrain::{Terrain, TerrainConfig},
|
||||
transforms::plane::PlaneTrans,
|
||||
Graphics,
|
||||
},
|
||||
GL,
|
||||
};
|
||||
|
||||
use super::{Module, ModuleCursor};
|
||||
|
||||
#[derive(ModuleRef)]
|
||||
pub struct TerrainModule<'b, 'gl: 'b> {
|
||||
gl: &'gl GL,
|
||||
terrain: &'b mut Terrain,
|
||||
}
|
||||
|
||||
impl<'b, 'gl: 'b> TerrainModule<'b, 'gl> {
|
||||
pub fn name(&self) -> &'static str {
|
||||
"Terrain"
|
||||
}
|
||||
|
||||
pub fn supported(&self, data: &Arc<radarg_core::Data>) -> bool {
|
||||
false
|
||||
}
|
||||
}
|
||||
|
||||
impl<'b, 'gl: 'b> TerrainModuleRef<'b, 'gl> {
|
||||
pub fn name(&self) -> &'static str {
|
||||
"Terrain"
|
||||
}
|
||||
|
||||
pub fn supported(&self, data: &Arc<radarg_core::Data>) -> bool {
|
||||
false
|
||||
}
|
||||
}
|
||||
|
||||
impl<'b, 'gl: 'b> TerrainModule<'b, 'gl> {
|
||||
pub fn new(gl: &'gl GL, terrain: &'b mut Terrain) -> Self {
|
||||
Self { gl, terrain }
|
||||
}
|
||||
}
|
||||
|
||||
impl<'b, 'gl: 'b> TerrainModuleRef<'b, 'gl> {
|
||||
pub fn new(gl: &'gl GL, terrain: &'b Terrain) -> Self {
|
||||
Self { gl, terrain }
|
||||
}
|
||||
}
|
||||
|
||||
pub struct TerrainModulePackage {
|
||||
conf: TerrainModulePackageConfig,
|
||||
}
|
||||
|
||||
impl<'b, 'gl: 'b> Module for TerrainModule<'b, 'gl> {
|
||||
type Cursor = TerrainModulePackage;
|
||||
type Data = ();
|
||||
type Operation = PlaneTrans;
|
||||
|
||||
const NAME: &'static str = "Terrain";
|
||||
|
||||
fn load_data<'dt>(
|
||||
&self,
|
||||
data: &Self::Data,
|
||||
setting: &radarg_core::config::Setting,
|
||||
) -> super::Result<Self::Cursor> {
|
||||
let mut conf = TerrainModulePackageConfig::default();
|
||||
let texture_path = &setting.common.path;
|
||||
conf.terrain_conf.set_alt_texture(&self.gl, texture_path)?;
|
||||
Ok(TerrainModulePackage { conf })
|
||||
}
|
||||
|
||||
fn render(
|
||||
&mut self,
|
||||
cursor: &mut Self::Cursor,
|
||||
operation: &crate::ui::operation::Operation<Self::Operation>,
|
||||
viewport: &crate::pg::layout_type::ViewPort,
|
||||
) -> super::Result<()> {
|
||||
self.terrain.mount(&self.gl)?;
|
||||
|
||||
let conf = &cursor.conf.terrain_conf;
|
||||
|
||||
self.terrain.set_config(&self.gl, conf)?;
|
||||
// operation.attach_with_program(&self.gl, self.earth.program_mut());
|
||||
// Camera Info
|
||||
let camera_loc = operation.camera().get_position();
|
||||
|
||||
// focal length
|
||||
let focal_length = operation.projection().fov();
|
||||
let focal_length = 1.0 / ((focal_length / 2.0).to_radians().tan());
|
||||
|
||||
// Viewport Info
|
||||
let resolution = viewport.size();
|
||||
|
||||
let znear = operation.projection().z_near();
|
||||
let zfar = operation.projection().z_far();
|
||||
Ok(())
|
||||
}
|
||||
|
||||
fn supported(&self, data: &radarg_core::Data) -> bool {
|
||||
false
|
||||
}
|
||||
}
|
||||
|
||||
#[derive(Default)]
|
||||
pub struct TerrainModulePackageConfig {
|
||||
terrain_conf: TerrainConfig,
|
||||
}
|
||||
|
||||
impl ModuleCursor for TerrainModulePackage {
|
||||
type Module<'rf, 'gl: 'rf> = TerrainModule<'rf, 'gl>;
|
||||
type Config = TerrainModulePackageConfig;
|
||||
type Data = ();
|
||||
type Component = TerrainModuleConfigComponent;
|
||||
type ComponentOutput = ();
|
||||
|
||||
fn set_config<F>(&mut self, f: F)
|
||||
where
|
||||
F: FnOnce(&mut Self::Config),
|
||||
{
|
||||
}
|
||||
|
||||
fn component_config(&self) -> () {
|
||||
()
|
||||
}
|
||||
|
||||
fn component_sender(&self) -> Box<dyn Fn(Self::ComponentOutput) -> crate::pg::SideBarInputMsg> {
|
||||
todo!()
|
||||
}
|
||||
}
|
||||
|
||||
pub struct TerrainModuleConfigComponent {}
|
||||
|
||||
#[relm4::component(pub)]
|
||||
impl SimpleComponent for TerrainModuleConfigComponent {
|
||||
type Widgets = EarthModuleConfigComponentWidgets;
|
||||
type Init = ();
|
||||
|
||||
type Input = ();
|
||||
type Output = ();
|
||||
|
||||
view! {
|
||||
adw::PreferencesPage {
|
||||
}
|
||||
}
|
||||
|
||||
fn init(
|
||||
init: Self::Init,
|
||||
root: Self::Root,
|
||||
sender: relm4::ComponentSender<Self>,
|
||||
) -> relm4::ComponentParts<Self> {
|
||||
let model = TerrainModuleConfigComponent {};
|
||||
|
||||
let widgets = view_output!();
|
||||
|
||||
ComponentParts { model, widgets }
|
||||
}
|
||||
|
||||
fn update(&mut self, message: Self::Input, sender: relm4::ComponentSender<Self>) {}
|
||||
}
|
||||
@ -11,18 +11,15 @@ pub struct EarthFragment(pub ShaderStage);
|
||||
|
||||
impl EarthVertex {
|
||||
pub fn new() -> Self {
|
||||
let mut trackball = Trackball::new().0;
|
||||
let raw = glsl! {
|
||||
layout(location = 0) in vec3 in_position;
|
||||
void main() {
|
||||
gl_Position = transform(vec4(in_position, 1.0));
|
||||
gl_Position = vec4(in_position, 1.0);
|
||||
}
|
||||
|
||||
};
|
||||
|
||||
trackball.extend(raw);
|
||||
|
||||
Self(trackball)
|
||||
Self(raw)
|
||||
}
|
||||
}
|
||||
|
||||
@ -34,10 +31,9 @@ impl EarthFragment {
|
||||
uniform float focal_length;
|
||||
uniform vec2 resolution;
|
||||
uniform mat4 trackball_view;
|
||||
|
||||
uniform vec2 projection_params;
|
||||
|
||||
uniform vec3 sun_location;
|
||||
uniform mat3 ca;
|
||||
|
||||
uniform float ER;
|
||||
|
||||
@ -56,89 +52,93 @@ impl EarthFragment {
|
||||
return vec2( max( max( t1.x, t1.y ), t1.z ),min( min( t2.x, t2.y ), t2.z ) );
|
||||
}
|
||||
|
||||
vec3 calcNormal( in vec3 pos ) {
|
||||
vec2 e = vec2(1.0,-1.0)*0.5773*0.0005;
|
||||
return normalize( e.xyy*sdSphere( pos + e.xyy, ER ) +
|
||||
e.yyx*sdSphere( pos + e.yyx ,ER) +
|
||||
e.yxy*sdSphere( pos + e.yxy ,ER) +
|
||||
e.xxx*sdSphere( pos + e.xxx ,ER) );
|
||||
}
|
||||
vec2 raycast(vec3 ro, vec3 rd )
|
||||
{
|
||||
vec2 res = vec2(-1.0,-1.0);
|
||||
|
||||
float raycast(in vec3 ro, in vec3 rd) {
|
||||
|
||||
float res = -1.0;
|
||||
|
||||
vec2 tb = iBox(ro, rd, vec3(ER, ER, ER));
|
||||
float tmin = projection_params.x;
|
||||
float tmax = projection_params.y;
|
||||
|
||||
if(tb.x < tb.y && tb.y > 0.0 && tb.x < tmax) {
|
||||
|
||||
tmin = max(tb.x, tmin);
|
||||
tmax = min(tb.y, tmax);
|
||||
// raymarch primitives
|
||||
vec2 tb = iBox( ro, rd, vec3(ER) );
|
||||
if( tb.x<tb.y && tb.y>0.0 && tb.x<tmax)
|
||||
{
|
||||
//return vec2(tb.x,2.0);
|
||||
tmin = max(tb.x,tmin);
|
||||
tmax = min(tb.y,tmax);
|
||||
|
||||
float t = tmin;
|
||||
int i = 0;
|
||||
|
||||
while ( i < 70 && t < tmax) {
|
||||
|
||||
float h = sdSphere(ro + rd * t, ER);
|
||||
|
||||
if(abs(h) < (0.0001 * t)) {
|
||||
res = t;
|
||||
break;
|
||||
}
|
||||
|
||||
t += h;
|
||||
i += 1;
|
||||
while (i < 70 && t < tmax) {
|
||||
vec2 h = vec2(sdSphere( ro+rd*t, ER ), 30.0);
|
||||
if( abs(h.x)<(0.0001*t) )
|
||||
{
|
||||
res = vec2(t,h.y);
|
||||
break;
|
||||
}
|
||||
t += h.x;
|
||||
i += 1;
|
||||
}
|
||||
}
|
||||
|
||||
return res;
|
||||
}
|
||||
|
||||
vec3 calcNormal( in vec3 pos )
|
||||
{
|
||||
vec2 e = vec2(1.0,-1.0)*0.5773*0.0005;
|
||||
return normalize( e.xyy*sdSphere( pos + e.xyy, ER ) +
|
||||
e.yyx*sdSphere( pos + e.yyx,ER) +
|
||||
e.yxy*sdSphere( pos + e.yxy,ER) +
|
||||
e.xxx*sdSphere( pos + e.xxx,ER) );
|
||||
}
|
||||
|
||||
|
||||
void main() {
|
||||
|
||||
vec2 p = (2.0 * gl_FragCoord.xy - resolution) / resolution.y;
|
||||
|
||||
vec3 ro = camera_location;
|
||||
|
||||
mat3 ca = transpose(mat3(trackball_view));
|
||||
|
||||
vec3 rd = ca * normalize(vec3(p, focal_length));
|
||||
|
||||
float t = raycast(ro, rd);
|
||||
vec2 res = raycast(camera_location, rd);
|
||||
|
||||
float ks = 1.0;
|
||||
float t = res.x;
|
||||
float m = res.y;
|
||||
|
||||
vec3 lin = vec3(0.0);
|
||||
|
||||
if (t < 0.0) {
|
||||
if( t <0.0 )
|
||||
{
|
||||
discard;
|
||||
}
|
||||
|
||||
vec3 col = vec3(1.0, 1.0, 1.0);
|
||||
vec3 col = vec3(0.7, 0.7, 0.9) - max(rd.y,0.0)*0.3;
|
||||
|
||||
col = 0.2 + 0.2*sin( m*2.0 + vec3(0.0,1.0,2.0) );
|
||||
|
||||
vec3 pos = camera_location + rd*t;
|
||||
|
||||
vec3 lin = vec3(0.0);
|
||||
|
||||
vec3 pos = ro + t * rd;
|
||||
vec3 nor = calcNormal(pos);
|
||||
// vec3 ref = reflect(rd, nor);
|
||||
|
||||
float ks = 1.0;
|
||||
|
||||
{
|
||||
// lighting
|
||||
vec3 lig = normalize( vec3(-0.5, 0.4, -0.6) );
|
||||
vec3 hal = normalize( lig-rd );
|
||||
float dif = clamp( dot( nor, lig ), 0.0, 1.0 );
|
||||
float spe = pow( clamp( dot( nor, hal ), 0.0, 1.0 ),16.0);
|
||||
spe *= dif;
|
||||
spe *= 0.04+0.96*pow(clamp(1.0-dot(hal,lig),0.0,1.0),5.0);
|
||||
lin += col*2.20*dif*vec3(1.30,1.00,0.70);
|
||||
lin += 5.00*spe*vec3(1.30,1.00,0.70)*ks;
|
||||
}
|
||||
|
||||
col = lin;
|
||||
|
||||
col = clamp(mix( col, vec3(0.7,0.7,0.9), 1.0-exp( -0.0001*t*t*t ) ), 0.0, 1.0);
|
||||
|
||||
|
||||
|
||||
// If we hit the sphere
|
||||
vec3 lig = normalize(sun_location);
|
||||
vec3 hal = normalize(lig - rd);
|
||||
float dif = clamp( dot( nor, lig ), 0.0, 1.0 );
|
||||
|
||||
float spe = pow( clamp( dot( nor, hal ), 0.0, 1.0 ),16.0);
|
||||
spe *= dif;
|
||||
spe *= 0.04+0.96*pow(clamp(1.0-dot(hal,lig),0.0,1.0),5.0);
|
||||
|
||||
lin += col*2.20*dif*vec3(1.30,1.00,0.70);
|
||||
lin += 5.00*spe*vec3(1.30,1.00,0.70)*ks;
|
||||
|
||||
col = mix( col, vec3(0.7,0.7,0.9), 1.0-exp( -0.0001*t*t*t ) );
|
||||
FragColor = vec4(clamp( col, 0.0, 1.0 ),1.0);
|
||||
FragColor = vec4(col, 1.0);
|
||||
}
|
||||
|
||||
};
|
||||
|
||||
@ -7,6 +7,7 @@ pub mod math;
|
||||
pub mod polar;
|
||||
pub mod ppi;
|
||||
pub mod proj;
|
||||
pub mod terrain;
|
||||
pub mod trackball;
|
||||
|
||||
use glsl::{
|
||||
|
||||
141
gi/src/shaders/terrain.rs
Normal file
141
gi/src/shaders/terrain.rs
Normal file
@ -0,0 +1,141 @@
|
||||
use super::trackball::Trackball;
|
||||
use super::CodePiece;
|
||||
use crate::impl_code_piece;
|
||||
use glsl::syntax::ShaderStage;
|
||||
use glsl::syntax::TranslationUnit;
|
||||
use glsl::transpiler::glsl::show_translation_unit;
|
||||
use glsl_quasiquote::glsl;
|
||||
|
||||
pub struct TerrainVertex(pub ShaderStage);
|
||||
pub struct TerrainFragment(pub ShaderStage);
|
||||
|
||||
impl TerrainVertex {
|
||||
pub fn new() -> Self {
|
||||
let raw = glsl! {
|
||||
layout(location = 0) in vec4 in_position;
|
||||
void main() {
|
||||
gl_Position = in_position;
|
||||
}
|
||||
};
|
||||
|
||||
Self(raw)
|
||||
}
|
||||
}
|
||||
|
||||
impl TerrainFragment {
|
||||
pub fn new() -> Self {
|
||||
use super::polar::PolarTransform;
|
||||
let mut include = PolarTransform::new().raw;
|
||||
let mut colormap = super::colormap::ColorMap::new().0;
|
||||
let raw = glsl! {
|
||||
|
||||
// Perspective Camera
|
||||
uniform vec2 projection_params;
|
||||
uniform vec3 camera_location;
|
||||
uniform float focal_length;
|
||||
uniform vec2 resolution;
|
||||
|
||||
// Earth Radius, alpha, beta
|
||||
uniform vec3 earth;
|
||||
|
||||
uniform float maxHeight;
|
||||
|
||||
// Left Hand Coordinate System
|
||||
uniform mat3 ca;
|
||||
// Terrain
|
||||
uniform float terrain_scale;
|
||||
// Terrain SDF
|
||||
uniform sampler2D terrain_texture;
|
||||
// longitude, latitude
|
||||
uniform vec4 tex_range;
|
||||
|
||||
const int NUM_SAMPLES = 16;
|
||||
const float PI = 3.14159265359;
|
||||
const float SAMPLE_STEP = 0.1;
|
||||
|
||||
out vec4 FragColor;
|
||||
|
||||
|
||||
vec2 iBox(in vec3 ro, in vec3 rd, in vec3 rad ){
|
||||
vec3 m = 1.0/rd;
|
||||
vec3 n = m*ro;
|
||||
vec3 k = abs(m)*rad;
|
||||
vec3 t1 = -n - k;
|
||||
vec3 t2 = -n + k;
|
||||
return vec2( max( max( t1.x, t1.y ), t1.z ),min( min( t2.x, t2.y ), t2.z ) );
|
||||
}
|
||||
|
||||
vec2 sdf(vec3 p) {
|
||||
|
||||
float ER = earth.x;
|
||||
float alpha = earth.y;
|
||||
float beta = earth.z;
|
||||
|
||||
float longitude = atan(p.z, p.x) + alpha;
|
||||
float latitude = atan(p.y, length(p.xz)) + beta;
|
||||
|
||||
// 从高度图获取地形高度
|
||||
vec2 uv = vec2((longitude + PI) / (2.0 * PI), (latitude + PI / 2.0) / PI);
|
||||
float height = texture(terrain_texture, uv).r * maxHeight;
|
||||
|
||||
// 计算点到地球表面的最近距离
|
||||
float baseDist = length(p) - ER - height;
|
||||
return vec2(baseDist, height);
|
||||
}
|
||||
|
||||
vec2 raycast(vec3 ro, vec3 rd) {
|
||||
|
||||
float ER = earth.x;
|
||||
float tmin = projection_params.x;
|
||||
float tmax = projection_params.y;
|
||||
|
||||
// raymarch primitives
|
||||
vec2 tb = iBox(ro, rd, vec3(ER));
|
||||
|
||||
vec2 res = vec2(-1.0, -1.0);
|
||||
|
||||
if (tb.x < tb.y && tb.y > 0.0 && tb.x < tmax) {
|
||||
tmin = max(tb.x, tmin);
|
||||
tmax = min(tb.y, tmax);
|
||||
|
||||
float t = tmin;
|
||||
int i = 0;
|
||||
|
||||
while (i < 70 && t < tmax) {
|
||||
vec2 h = sdf(ro + rd * t);
|
||||
if (abs(h.x) < (0.0001 * t)) {
|
||||
res = vec2(t, h.y);
|
||||
}
|
||||
t += h.x;
|
||||
i += 1;
|
||||
}
|
||||
}
|
||||
return res;
|
||||
}
|
||||
|
||||
void main() {
|
||||
vec2 p = (2.0 * gl_FragCoord.xy - resolution) / resolution.y;
|
||||
vec3 rd = normalize(ca * vec3(p, focal_length));
|
||||
|
||||
vec2 res = raycast(camera_location, rd);
|
||||
|
||||
float t = res.x;
|
||||
float m = res.y;
|
||||
|
||||
if (m < 0.0) {
|
||||
discard;
|
||||
}
|
||||
FragColor = vec4(1.0, 0.0, 0.0, 1.0);
|
||||
}
|
||||
|
||||
};
|
||||
|
||||
include.extend(colormap);
|
||||
include.extend(raw);
|
||||
|
||||
Self(include)
|
||||
}
|
||||
}
|
||||
|
||||
impl_code_piece!(TerrainVertex, 0);
|
||||
impl_code_piece!(TerrainFragment, 0);
|
||||
407
loaders/Cargo.lock
generated
407
loaders/Cargo.lock
generated
@ -157,6 +157,19 @@ dependencies = [
|
||||
"generic-array",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "blosc-src"
|
||||
version = "0.3.4"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "31e5a7dc1b763e125322b8935ca19d712299f0ee1a8eed5474a45bd6ad9e592c"
|
||||
dependencies = [
|
||||
"cc",
|
||||
"libz-sys",
|
||||
"lz4-sys",
|
||||
"snappy_src",
|
||||
"zstd-sys",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "bumpalo"
|
||||
version = "3.16.0"
|
||||
@ -168,6 +181,20 @@ name = "bytemuck"
|
||||
version = "1.17.1"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "773d90827bc3feecfb67fab12e24de0749aad83c74b9504ecde46237b5cd24e2"
|
||||
dependencies = [
|
||||
"bytemuck_derive",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "bytemuck_derive"
|
||||
version = "1.7.1"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "0cc8b54b395f2fcfbb3d90c47b01c7f444d94d05bdeb775811dec868ac3bbc26"
|
||||
dependencies = [
|
||||
"proc-macro2",
|
||||
"quote",
|
||||
"syn 2.0.76",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "byteorder"
|
||||
@ -175,6 +202,12 @@ version = "1.5.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "1fd0f2584146f6f2ef48085050886acf353beff7305ebd1ae69500e27c67f64b"
|
||||
|
||||
[[package]]
|
||||
name = "bytes"
|
||||
version = "1.7.2"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "428d9aa8fbc0670b7b8d6030a7fadd0f86151cae55e4dbbece15f3780a3dfaf3"
|
||||
|
||||
[[package]]
|
||||
name = "bzip2"
|
||||
version = "0.4.4"
|
||||
@ -295,6 +328,15 @@ version = "2.4.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "19d374276b40fb8bbdee95aef7c7fa6b5316ec764510eb64b8dd0e2ed0d7e7f5"
|
||||
|
||||
[[package]]
|
||||
name = "crc32c"
|
||||
version = "0.6.8"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "3a47af21622d091a8f0fb295b88bc886ac74efcc613efc19f5d0b21de5c89e47"
|
||||
dependencies = [
|
||||
"rustc_version",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "crc32fast"
|
||||
version = "1.4.2"
|
||||
@ -313,12 +355,37 @@ dependencies = [
|
||||
"crossbeam-utils",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "crossbeam-deque"
|
||||
version = "0.8.5"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "613f8cc01fe9cf1a3eb3d7f488fd2fa8388403e97039e2f73692932e291a770d"
|
||||
dependencies = [
|
||||
"crossbeam-epoch",
|
||||
"crossbeam-utils",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "crossbeam-epoch"
|
||||
version = "0.9.18"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "5b82ac4a3c2ca9c3460964f020e1402edd5753411d7737aa39c3714ad1b5420e"
|
||||
dependencies = [
|
||||
"crossbeam-utils",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "crossbeam-utils"
|
||||
version = "0.8.20"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "22ec99545bb0ed0ea7bb9b8e1e9122ea386ff8a48c0922e43f36d45ab09e0e80"
|
||||
|
||||
[[package]]
|
||||
name = "crunchy"
|
||||
version = "0.2.2"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "7a81dae078cea95a014a339291cec439d2f232ebe854a9d672b796c6afafa9b7"
|
||||
|
||||
[[package]]
|
||||
name = "crypto-common"
|
||||
version = "0.1.6"
|
||||
@ -355,6 +422,27 @@ dependencies = [
|
||||
"syn 2.0.76",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "derive_more"
|
||||
version = "1.0.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "4a9b99b9cbbe49445b21764dc0625032a89b145a2642e67603e1c936f5458d05"
|
||||
dependencies = [
|
||||
"derive_more-impl",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "derive_more-impl"
|
||||
version = "1.0.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "cb7330aeadfbe296029522e6c40f315320aba36fc43a5b3632f3795348f3bd22"
|
||||
dependencies = [
|
||||
"proc-macro2",
|
||||
"quote",
|
||||
"syn 2.0.76",
|
||||
"unicode-xid",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "digest"
|
||||
version = "0.10.7"
|
||||
@ -377,13 +465,19 @@ dependencies = [
|
||||
"syn 2.0.76",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "dyn-clone"
|
||||
version = "1.0.17"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "0d6ef0072f8a535281e4876be788938b528e9a1d43900b82c2569af7da799125"
|
||||
|
||||
[[package]]
|
||||
name = "earcutr"
|
||||
version = "0.4.3"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "79127ed59a85d7687c409e9978547cffb7dc79675355ed22da6b66fd5f6ead01"
|
||||
dependencies = [
|
||||
"itertools",
|
||||
"itertools 0.11.0",
|
||||
"num-traits",
|
||||
]
|
||||
|
||||
@ -417,6 +511,7 @@ dependencies = [
|
||||
"serde",
|
||||
"serde_json",
|
||||
"thiserror",
|
||||
"zarrs",
|
||||
"zip",
|
||||
]
|
||||
|
||||
@ -504,6 +599,17 @@ dependencies = [
|
||||
"wasi",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "half"
|
||||
version = "2.4.1"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "6dd08c532ae367adf81c312a4580bc67f1d0fe8bc9c460520283f4c0ff277888"
|
||||
dependencies = [
|
||||
"bytemuck",
|
||||
"cfg-if",
|
||||
"crunchy",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "hash32"
|
||||
version = "0.3.1"
|
||||
@ -584,6 +690,12 @@ dependencies = [
|
||||
"generic-array",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "inventory"
|
||||
version = "0.3.15"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "f958d3d68f4167080a18141e10381e7634563984a537f2a49a30fd8e53ac5767"
|
||||
|
||||
[[package]]
|
||||
name = "itertools"
|
||||
version = "0.11.0"
|
||||
@ -593,6 +705,15 @@ dependencies = [
|
||||
"either",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "itertools"
|
||||
version = "0.13.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "413ee7dfc52ee1a4949ceeb7dbc8a33f2d6c088194d9f922fb8318faf1f01186"
|
||||
dependencies = [
|
||||
"either",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "itoa"
|
||||
version = "1.0.11"
|
||||
@ -639,6 +760,27 @@ version = "0.2.8"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "4ec2a862134d2a7d32d7983ddcdd1c4923530833c9f2ea1a44fc5fa473989058"
|
||||
|
||||
[[package]]
|
||||
name = "libz-sys"
|
||||
version = "1.1.20"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "d2d16453e800a8cf6dd2fc3eb4bc99b786a9b90c663b8559a5b1a041bf89e472"
|
||||
dependencies = [
|
||||
"cc",
|
||||
"libc",
|
||||
"pkg-config",
|
||||
"vcpkg",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "link-cplusplus"
|
||||
version = "1.0.9"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "9d240c6f7e1ba3a28b0249f774e6a9dd0175054b52dfbb61b16eb8505c3785c9"
|
||||
dependencies = [
|
||||
"cc",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "lock_api"
|
||||
version = "0.4.12"
|
||||
@ -661,6 +803,16 @@ version = "0.4.22"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "a7a70ba024b9dc04c27ea2f0c0548feb474ec5c54bba33a7f72f873a39d07b24"
|
||||
|
||||
[[package]]
|
||||
name = "lz4-sys"
|
||||
version = "1.11.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "fcb44a01837a858d47e5a630d2ccf304c8efcc4b83b8f9f75b7a9ee4fcc6e57d"
|
||||
dependencies = [
|
||||
"cc",
|
||||
"libc",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "lzma-rs"
|
||||
version = "0.3.0"
|
||||
@ -671,6 +823,16 @@ dependencies = [
|
||||
"crc",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "matrixmultiply"
|
||||
version = "0.3.9"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "9380b911e3e96d10c1f415da0876389aaf1b56759054eeb0de7df940c456ba1a"
|
||||
dependencies = [
|
||||
"autocfg",
|
||||
"rawpointer",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "memchr"
|
||||
version = "2.7.4"
|
||||
@ -692,6 +854,40 @@ dependencies = [
|
||||
"adler2",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "monostate"
|
||||
version = "0.1.13"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "0d208407d7552cd041d8cdb69a1bc3303e029c598738177a3d87082004dc0e1e"
|
||||
dependencies = [
|
||||
"monostate-impl",
|
||||
"serde",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "monostate-impl"
|
||||
version = "0.1.13"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "a7ce64b975ed4f123575d11afd9491f2e37bbd5813fbfbc0f09ae1fbddea74e0"
|
||||
dependencies = [
|
||||
"proc-macro2",
|
||||
"quote",
|
||||
"syn 2.0.76",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "ndarray"
|
||||
version = "0.15.6"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "adb12d4e967ec485a5f71c6311fe28158e9d6f4bc4a447b474184d0f91a8fa32"
|
||||
dependencies = [
|
||||
"matrixmultiply",
|
||||
"num-complex",
|
||||
"num-integer",
|
||||
"num-traits",
|
||||
"rawpointer",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "nom"
|
||||
version = "7.1.3"
|
||||
@ -724,12 +920,77 @@ dependencies = [
|
||||
"syn 1.0.109",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "num"
|
||||
version = "0.4.3"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "35bd024e8b2ff75562e5f34e7f4905839deb4b22955ef5e73d2fea1b9813cb23"
|
||||
dependencies = [
|
||||
"num-bigint",
|
||||
"num-complex",
|
||||
"num-integer",
|
||||
"num-iter",
|
||||
"num-rational",
|
||||
"num-traits",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "num-bigint"
|
||||
version = "0.4.6"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "a5e44f723f1133c9deac646763579fdb3ac745e418f2a7af9cd0c431da1f20b9"
|
||||
dependencies = [
|
||||
"num-integer",
|
||||
"num-traits",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "num-complex"
|
||||
version = "0.4.6"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "73f88a1307638156682bada9d7604135552957b7818057dcef22705b4d509495"
|
||||
dependencies = [
|
||||
"bytemuck",
|
||||
"num-traits",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "num-conv"
|
||||
version = "0.1.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "51d515d32fb182ee37cda2ccdcb92950d6a3c2893aa280e540671c2cd0f3b1d9"
|
||||
|
||||
[[package]]
|
||||
name = "num-integer"
|
||||
version = "0.1.46"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "7969661fd2958a5cb096e56c8e1ad0444ac2bbcd0061bd28660485a44879858f"
|
||||
dependencies = [
|
||||
"num-traits",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "num-iter"
|
||||
version = "0.1.45"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "1429034a0490724d0075ebb2bc9e875d6503c3cf69e235a8941aa757d83ef5bf"
|
||||
dependencies = [
|
||||
"autocfg",
|
||||
"num-integer",
|
||||
"num-traits",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "num-rational"
|
||||
version = "0.4.2"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "f83d14da390562dca69fc84082e73e548e1ad308d24accdedd2720017cb37824"
|
||||
dependencies = [
|
||||
"num-bigint",
|
||||
"num-integer",
|
||||
"num-traits",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "num-traits"
|
||||
version = "0.2.19"
|
||||
@ -775,6 +1036,12 @@ version = "1.0.15"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "57c0d7b74b563b49d38dae00a0c37d4d6de9b432382b2892f0574ddcae73fd0a"
|
||||
|
||||
[[package]]
|
||||
name = "pathdiff"
|
||||
version = "0.2.1"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "8835116a5c179084a830efb3adc117ab007512b535bc1a21c991d3b32a6b44dd"
|
||||
|
||||
[[package]]
|
||||
name = "pbkdf2"
|
||||
version = "0.12.2"
|
||||
@ -861,6 +1128,41 @@ dependencies = [
|
||||
"getrandom",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "rawpointer"
|
||||
version = "0.2.1"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "60a357793950651c4ed0f3f52338f53b2f809f32d83a07f72909fa13e4c6c1e3"
|
||||
|
||||
[[package]]
|
||||
name = "rayon"
|
||||
version = "1.10.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "b418a60154510ca1a002a752ca9714984e21e4241e804d32555251faf8b78ffa"
|
||||
dependencies = [
|
||||
"either",
|
||||
"rayon-core",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "rayon-core"
|
||||
version = "1.12.1"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "1465873a3dfdaa8ae7cb14b4383657caab0b3e8a0aa9ae8e04b044854c8dfce2"
|
||||
dependencies = [
|
||||
"crossbeam-deque",
|
||||
"crossbeam-utils",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "rayon_iter_concurrent_limit"
|
||||
version = "0.2.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "d09ee01023de07fa073ce14c37cbe0a9e099c6b0b60a29cf4af6d04d9553fed7"
|
||||
dependencies = [
|
||||
"rayon",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "redox_syscall"
|
||||
version = "0.5.3"
|
||||
@ -917,6 +1219,15 @@ version = "1.0.18"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "f3cb5ba0dc43242ce17de99c180e96db90b235b8a9fdc9543c96d2209116bd9f"
|
||||
|
||||
[[package]]
|
||||
name = "same-file"
|
||||
version = "1.0.6"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "93fc1dc3aaa9bfed95e02e6eadabb4baf7e3078b0bd1b4d7b6b0b68378900502"
|
||||
dependencies = [
|
||||
"winapi-util",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "scopeguard"
|
||||
version = "1.2.0"
|
||||
@ -955,12 +1266,24 @@ version = "1.0.127"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "8043c06d9f82bd7271361ed64f415fe5e12a77fdb52e573e7f06a516dea329ad"
|
||||
dependencies = [
|
||||
"indexmap",
|
||||
"itoa",
|
||||
"memchr",
|
||||
"ryu",
|
||||
"serde",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "serde_repr"
|
||||
version = "0.1.19"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "6c64451ba24fc7a6a2d60fc75dd9c83c90903b19028d4eff35e88fc1e86564e9"
|
||||
dependencies = [
|
||||
"proc-macro2",
|
||||
"quote",
|
||||
"syn 2.0.76",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "sha1"
|
||||
version = "0.10.6"
|
||||
@ -990,6 +1313,16 @@ version = "1.13.2"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "3c5e1a9a646d36c3599cd173a41282daf47c44583ad367b8e6837255952e5c67"
|
||||
|
||||
[[package]]
|
||||
name = "snappy_src"
|
||||
version = "0.2.3+snappy.1.2.1"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "fc78d0b5fea71fda96c2e67f99ff3cfb34757307dd088a9abed3a4ba0a7f7465"
|
||||
dependencies = [
|
||||
"cc",
|
||||
"link-cplusplus",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "spade"
|
||||
version = "2.12.0"
|
||||
@ -1108,12 +1441,34 @@ version = "1.0.12"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "3354b9ac3fae1ff6755cb6db53683adb661634f67557942dea4facebec0fee4b"
|
||||
|
||||
[[package]]
|
||||
name = "unicode-xid"
|
||||
version = "0.2.5"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "229730647fbc343e3a80e463c1db7f78f3855d3f3739bee0dda773c9a037c90a"
|
||||
|
||||
[[package]]
|
||||
name = "vcpkg"
|
||||
version = "0.2.15"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "accd4ea62f7bb7a82fe23066fb0957d48ef677f6eeb8215f372f52e48bb32426"
|
||||
|
||||
[[package]]
|
||||
name = "version_check"
|
||||
version = "0.9.5"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "0b928f33d975fc6ad9f86c8f283853ad26bdd5b10b7f1542aa2fa15e2289105a"
|
||||
|
||||
[[package]]
|
||||
name = "walkdir"
|
||||
version = "2.5.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "29790946404f91d9c5d06f9874efddea1dc06c5efe94541a7d6863108e3a5e4b"
|
||||
dependencies = [
|
||||
"same-file",
|
||||
"winapi-util",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "wasi"
|
||||
version = "0.11.0+wasi-snapshot-preview1"
|
||||
@ -1191,6 +1546,15 @@ version = "0.4.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "ac3b87c63620426dd9b991e5ce0329eff545bccbbb34f3be09ff6fb6ab51b7b6"
|
||||
|
||||
[[package]]
|
||||
name = "winapi-util"
|
||||
version = "0.1.9"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "cf221c93e13a30d793f7645a0e7762c55d169dbb0a49671918a2319d289b10bb"
|
||||
dependencies = [
|
||||
"windows-sys",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "winapi-x86_64-pc-windows-gnu"
|
||||
version = "0.4.0"
|
||||
@ -1206,6 +1570,15 @@ dependencies = [
|
||||
"windows-targets",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "windows-sys"
|
||||
version = "0.59.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "1e38bc4d79ed67fd075bcc251a1c39b32a1776bbe92e5bef1f0bf1f8c531853b"
|
||||
dependencies = [
|
||||
"windows-targets",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "windows-targets"
|
||||
version = "0.52.6"
|
||||
@ -1270,6 +1643,38 @@ version = "0.52.6"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "589f6da84c646204747d1270a2a5661ea66ed1cced2631d546fdfb155959f9ec"
|
||||
|
||||
[[package]]
|
||||
name = "zarrs"
|
||||
version = "0.16.4"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "5fa44a5936d9bfbfe5e57d1e397ede1d821415b8f7f4060b4f33a5335e75f835"
|
||||
dependencies = [
|
||||
"blosc-src",
|
||||
"bytemuck",
|
||||
"bytes",
|
||||
"crc32c",
|
||||
"derive_more",
|
||||
"dyn-clone",
|
||||
"flate2",
|
||||
"half",
|
||||
"inventory",
|
||||
"itertools 0.13.0",
|
||||
"monostate",
|
||||
"ndarray",
|
||||
"num",
|
||||
"num-complex",
|
||||
"parking_lot",
|
||||
"pathdiff",
|
||||
"rayon",
|
||||
"rayon_iter_concurrent_limit",
|
||||
"serde",
|
||||
"serde_json",
|
||||
"serde_repr",
|
||||
"thiserror",
|
||||
"walkdir",
|
||||
"zstd",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "zerocopy"
|
||||
version = "0.7.35"
|
||||
|
||||
@ -18,6 +18,7 @@ num-traits = "0.2.17"
|
||||
serde = { version = "1.0.196", features = ["derive"] }
|
||||
serde_json = "1.0.112"
|
||||
thiserror = "1.0.56"
|
||||
zarrs = "0.16.4"
|
||||
zip = "2.2.0"
|
||||
|
||||
[dependencies.radarg_plugin_interface]
|
||||
|
||||
@ -6,7 +6,7 @@ use super::{Layer, WindowCoord};
|
||||
use femtovg::{Canvas, Color, FontId, Paint, Renderer};
|
||||
use gi::graphics::transforms::plane::PlaneTrans;
|
||||
use gi::pg::layout_type::ViewPort;
|
||||
use gi::pg::ModulePackage;
|
||||
use gi::pg::{Module, ModulePackage};
|
||||
use gi::ui::io::IO;
|
||||
use gi::ui::operation::Operation;
|
||||
use gi::{App as GI, Helper, GL};
|
||||
@ -245,6 +245,13 @@ impl Render {
|
||||
};
|
||||
|
||||
gi.prepare(&SETTING).expect("Cannot prepare GI");
|
||||
|
||||
// Terrain
|
||||
let terrain_module = gi.program().terrain().load_data(&(), &SETTING).unwrap();
|
||||
// Init Modules
|
||||
gi.set_init_modules(terrain_module.into());
|
||||
// Set Modules
|
||||
|
||||
self.viewport.replace(Some(viewport));
|
||||
self.gi.replace(Some(gi));
|
||||
}
|
||||
|
||||
@ -9,8 +9,6 @@ ndarray = "0.16.1"
|
||||
thiserror = "1.0.56"
|
||||
rust-embed = "8.5.0"
|
||||
toml = "0.8.19"
|
||||
proj-sys = "0.23.1"
|
||||
proj = "0.27.2"
|
||||
dirs = "5.0.1"
|
||||
num-traits = "0.2.19"
|
||||
serde = { version = "1.0.209", features = ["derive"] }
|
||||
|
||||
@ -5,7 +5,7 @@ use crate::Asset;
|
||||
use dirs;
|
||||
use num_traits::{AsPrimitive, FromPrimitive};
|
||||
use serde::{Deserialize, Serialize};
|
||||
use std::env;
|
||||
use std::{env, path::PathBuf};
|
||||
use toml;
|
||||
|
||||
macro_rules! find_cmap {
|
||||
@ -32,6 +32,7 @@ macro_rules! find_cmap {
|
||||
#[derive(Deserialize, Serialize)]
|
||||
|
||||
pub struct Setting {
|
||||
pub common: Common,
|
||||
pub cmap: Vec<CB>,
|
||||
}
|
||||
|
||||
@ -122,3 +123,15 @@ impl CB {
|
||||
Ok(result)
|
||||
}
|
||||
}
|
||||
|
||||
#[derive(Deserialize, Serialize)]
|
||||
pub struct Common {
|
||||
pub background: BackgroundType,
|
||||
pub path: PathBuf,
|
||||
}
|
||||
|
||||
#[derive(Deserialize, Serialize, Debug)]
|
||||
pub enum BackgroundType {
|
||||
Terrain,
|
||||
Earth,
|
||||
}
|
||||
|
||||
@ -1,4 +1,3 @@
|
||||
use proj::ProjError;
|
||||
use radarg_plugin_interface::Error as PluginError;
|
||||
use thiserror::Error;
|
||||
|
||||
@ -14,11 +13,6 @@ pub enum DataError {
|
||||
|
||||
#[derive(Debug, Error)]
|
||||
pub enum PipelineError {
|
||||
#[error("proj error")]
|
||||
ProjError {
|
||||
#[from]
|
||||
source: ProjError,
|
||||
},
|
||||
#[error("data error")]
|
||||
DataError(String),
|
||||
}
|
||||
|
||||
BIN
resources/alts.png
Normal file
BIN
resources/alts.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 10 MiB |
Loading…
Reference in New Issue
Block a user