biome mapping
This commit is contained in:
2
.vscode/launch.json
vendored
2
.vscode/launch.json
vendored
@@ -7,7 +7,7 @@
|
||||
{
|
||||
"type": "cppvsdbg",
|
||||
"stopAtEntry": false,
|
||||
"console": "externalTerminal",
|
||||
// "console": "externalTerminal",
|
||||
"request": "launch",
|
||||
"name": "Debug",
|
||||
"program": "${workspaceRoot}/target/debug/phos.exe",
|
||||
|
||||
@@ -32,12 +32,10 @@ pub fn generate_chunk(chunk_x: f64, chunk_z: f64, cfg: &GenerationConfig, seed:
|
||||
&noise,
|
||||
);
|
||||
result[x + z * Chunk::SIZE] = sample;
|
||||
moisture[x + z * Chunk::SIZE] = sample_simple(
|
||||
x as f64 + chunk_x * Chunk::SIZE as f64,
|
||||
z as f64 + chunk_z * Chunk::SIZE as f64,
|
||||
&cfg.layers[0],
|
||||
&noise,
|
||||
) as f32;
|
||||
moisture[x + z * Chunk::SIZE] = noise.get([
|
||||
(x as f64 + chunk_x * Chunk::SIZE as f64) / &cfg.noise_scale,
|
||||
(z as f64 + chunk_z * Chunk::SIZE as f64) / &cfg.noise_scale,
|
||||
]) as f32;
|
||||
temp[x + z * Chunk::SIZE] = sample_tempurature(
|
||||
z as f32 + chunk_z as f32 * Chunk::SIZE as f32,
|
||||
sample,
|
||||
@@ -57,10 +55,10 @@ pub fn generate_chunk(chunk_x: f64, chunk_z: f64, cfg: &GenerationConfig, seed:
|
||||
fn sample_tempurature(z: f32, height: f32, cfg: &GenerationConfig, equator: f32) -> f32 {
|
||||
let d = (equator - z).abs();
|
||||
let max_d = equator.max(cfg.get_total_height() as f32 - equator);
|
||||
let t_mod = d.remap(0., max_d, 0., 1.);
|
||||
let t_mod = d.remap(0., max_d, 0., 1.).clamp(0., 1.);
|
||||
|
||||
// let max_d = d.max()
|
||||
return height.remap(0., 100., 0., 1.).clamp(0., 1.) * t_mod;
|
||||
return (height.remap(0., 50., 0., 1.).clamp(0., 1.) + t_mod) / 2.;
|
||||
}
|
||||
|
||||
fn sample_point(x: f64, z: f64, cfg: &GenerationConfig, noise: &impl NoiseFn<f64, 2>) -> f32 {
|
||||
|
||||
@@ -25,8 +25,7 @@ impl Plugin for PhosCameraPlugin {
|
||||
}
|
||||
}
|
||||
|
||||
fn setup(mut commands: Commands, mut msaa: ResMut<Msaa>) {
|
||||
*msaa = Msaa::Off;
|
||||
fn setup(mut commands: Commands) {
|
||||
commands.spawn((
|
||||
Camera3dBundle {
|
||||
transform: Transform::from_xyz(0., 30., 0.)
|
||||
|
||||
Submodule game/main/assets updated: b5c3a166a0...256b49cc29
@@ -5,7 +5,7 @@ use bevy_inspector_egui::quick::WorldInspectorPlugin;
|
||||
|
||||
mod phos;
|
||||
mod prelude;
|
||||
|
||||
mod shader_extensions;
|
||||
use phos::PhosGamePlugin;
|
||||
|
||||
fn main() {
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
use crate::prelude::*;
|
||||
use crate::shader_extensions::chunk_material::ChunkMaterial;
|
||||
use bevy::asset::LoadState;
|
||||
use bevy::core_pipeline::experimental::taa::TemporalAntiAliasPlugin;
|
||||
use bevy::pbr::ExtendedMaterial;
|
||||
@@ -8,7 +9,7 @@ use bevy_rapier3d::render::RapierDebugRenderPlugin;
|
||||
use camera_system::PhosCameraPlugin;
|
||||
use iyes_perf_ui::prelude::*;
|
||||
use world_generation::biome_painter::{
|
||||
self, BiomePainterAsset, BiomePainterLoadState, BiomePainterPlugin,
|
||||
BiomePainterAsset, BiomePainterLoadState, BiomePainterPlugin,
|
||||
};
|
||||
use world_generation::hex_utils::offset_to_world;
|
||||
use world_generation::tile_manager::{TileAsset, TileAssetLoadState, TileAssetPlugin, TileManager};
|
||||
|
||||
@@ -1,9 +1,6 @@
|
||||
use bevy::asset::{Asset, Handle};
|
||||
use bevy::pbr::{MaterialExtension, MaterialExtensionKey, MaterialExtensionPipeline, MaterialPipeline, MaterialPipelineKey};
|
||||
use bevy::prelude::{Component, Image, Mesh, Resource, TypePath};
|
||||
use bevy::render::mesh::{Indices, MeshVertexBufferLayout};
|
||||
use bevy::render::render_resource::{AsBindGroup, RenderPipelineDescriptor, ShaderRef, SpecializedMeshPipelineError};
|
||||
use world_generation::prelude::ATTRIBUTE_TEXTURE_INDEX;
|
||||
use bevy::asset::Handle;
|
||||
|
||||
use bevy::prelude::{Component, Image, Resource};
|
||||
|
||||
#[derive(Resource)]
|
||||
pub struct ChunkAtlas {
|
||||
@@ -19,33 +16,3 @@ pub struct PhosMap {
|
||||
|
||||
#[derive(Component)]
|
||||
pub struct PhosChunk;
|
||||
|
||||
|
||||
#[derive(Asset, TypePath, AsBindGroup, Debug, Clone)]
|
||||
pub struct ChunkMaterial {
|
||||
#[texture(100, dimension = "2d_array")]
|
||||
#[sampler(101)]
|
||||
pub array_texture: Handle<Image>,
|
||||
}
|
||||
|
||||
impl MaterialExtension for ChunkMaterial {
|
||||
fn fragment_shader() -> ShaderRef {
|
||||
"shaders/world/chunk.wgsl".into()
|
||||
}
|
||||
|
||||
// fn specialize(
|
||||
// _pipeline: &MaterialExtensionPipeline,
|
||||
// descriptor: &mut RenderPipelineDescriptor,
|
||||
// layout: &MeshVertexBufferLayout,
|
||||
// _key: MaterialExtensionKey<Self>,
|
||||
// ) -> Result<(), SpecializedMeshPipelineError> {
|
||||
// let vertex_layout = layout.get_layout(&[
|
||||
// Mesh::ATTRIBUTE_POSITION.at_shader_location(0),
|
||||
// Mesh::ATTRIBUTE_UV_0.at_shader_location(1),
|
||||
// Mesh::ATTRIBUTE_NORMAL.at_shader_location(2),
|
||||
// ATTRIBUTE_TEXTURE_INDEX.at_shader_location(3),
|
||||
// ])?;
|
||||
// descriptor.vertex.buffers = vec![vertex_layout];
|
||||
// Ok(())
|
||||
// }
|
||||
}
|
||||
|
||||
18
game/main/src/shader_extensions/chunk_material.rs
Normal file
18
game/main/src/shader_extensions/chunk_material.rs
Normal file
@@ -0,0 +1,18 @@
|
||||
use bevy::asset::{Asset, Handle};
|
||||
use bevy::pbr::MaterialExtension;
|
||||
use bevy::reflect::TypePath;
|
||||
use bevy::render::render_resource::{AsBindGroup, ShaderRef};
|
||||
use bevy::render::texture::Image;
|
||||
|
||||
#[derive(Asset, TypePath, AsBindGroup, Debug, Clone)]
|
||||
pub struct ChunkMaterial {
|
||||
#[texture(100, dimension = "2d_array")]
|
||||
#[sampler(101)]
|
||||
pub array_texture: Handle<Image>,
|
||||
}
|
||||
|
||||
impl MaterialExtension for ChunkMaterial {
|
||||
fn fragment_shader() -> ShaderRef {
|
||||
"shaders/world/chunk.wgsl".into()
|
||||
}
|
||||
}
|
||||
1
game/main/src/shader_extensions/mod.rs
Normal file
1
game/main/src/shader_extensions/mod.rs
Normal file
@@ -0,0 +1 @@
|
||||
pub mod chunk_material;
|
||||
Reference in New Issue
Block a user