This commit is contained in:
griffi-gh 2023-01-17 21:35:45 +01:00
parent 27c55ed8c9
commit 717e219003
6 changed files with 14 additions and 4 deletions

View file

@ -12,3 +12,7 @@ strum = { version = "0.24", features = ["derive"] }
glam = { version = "0.22", features = ["debug-glam-assert", "mint", "fast-math"] }
hashbrown = "0.13"
simdnoise = "3.1"
[features]
default = []
polygon_rendering = []

View file

@ -5,7 +5,7 @@ pub struct GameOptions {
impl Default for GameOptions {
fn default() -> Self {
Self {
render_distance: 16,
render_distance: if cfg!(debug_assertions) { 8 } else { 16 },
}
}
}

View file

@ -38,7 +38,10 @@ pub const FRAGMENT_SHADER: &str = r#"
uniform sampler2D tex;
void main() {
// base color from texture
color = texture(tex, v_uv);
//basic lighting
color *= vec4(vec3(abs(v_normal.x) + .8 * abs(v_normal.y) + .6 * abs(v_normal.z)), 1.);
}
"#;

View file

@ -26,7 +26,7 @@ const NEGATIVE_X_NEIGHBOR: usize = 1;
const POSITIVE_Z_NEIGHBOR: usize = 2;
const NEGATIVE_Z_NEIGHBOR: usize = 3;
const MAX_TASKS: usize = 4;
const MAX_TASKS: usize = 6;
pub struct World {
pub chunks: HashMap<IVec2, Chunk>,
@ -58,8 +58,9 @@ impl World {
view: [[f32; 4]; 4]
) {
let sampler = SamplerBehavior {
minify_filter: MinifySamplerFilter::Nearest,
minify_filter: MinifySamplerFilter::Linear,
magnify_filter: MagnifySamplerFilter::Nearest,
max_anisotropy: 8,
..Default::default()
};
let draw_parameters = DrawParameters {
@ -68,6 +69,7 @@ impl World {
write: true,
..Default::default()
},
#[cfg(feature = "polygon_rendering")] polygon_mode: glium::PolygonMode::Line,
backface_culling: glium::draw_parameters::BackfaceCullingMode::CullCounterClockwise,
..Default::default()
};

View file

@ -123,6 +123,7 @@ pub fn generate_mesh(position: IVec2, chunk_data: ChunkData, neighbors: [ChunkDa
//TODO replace with a proper texture resolver (or calculate uvs in a shader!)
//this is temporary!
//also this can only resolve textures on the first row.
const TEX_WIDTH: f32 = 16. / 640.;
const TEX_HEIGHT: f32 = 16. / 404.;
let x1 = TEX_WIDTH * texture_id as f32;

View file

@ -13,7 +13,7 @@ pub fn generate_chunk(position: IVec2, seed: u32) -> ChunkData {
let mut chunk = Box::new([[[Block::Air; CHUNK_SIZE]; CHUNK_HEIGHT]; CHUNK_SIZE]);
//generate noises
let height_noise = NoiseBuilder::ridge_2d_offset(world_xz.x, CHUNK_SIZE, world_xz.y, CHUNK_SIZE)
let height_noise = NoiseBuilder::fbm_2d_offset(world_xz.x, CHUNK_SIZE, world_xz.y, CHUNK_SIZE)
.with_freq(0.01)
.with_octaves(4)
.with_seed(seed as i32)