Skip to content

Commit

Permalink
Merge branch 'Uriopass:master' into master
Browse files Browse the repository at this point in the history
  • Loading branch information
reeceyang authored Dec 30, 2023
2 parents 39c6e81 + 6427ac1 commit 9480192
Show file tree
Hide file tree
Showing 95 changed files with 8,194 additions and 1,879 deletions.
871 changes: 664 additions & 207 deletions Cargo.lock

Large diffs are not rendered by default.

14 changes: 8 additions & 6 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ members = [
"engine",
"engine_demo",
"geom",
"goryak",
"headless",
"native_app",
"networking",
Expand All @@ -17,14 +18,12 @@ resolver = "2"
default-members = ["native_app"]

[workspace.dependencies]
egui = "0.24.1"
egui = { git = "https://github.com/emilk/egui" }
flat_spatial = "0.6"
egui_extras = "0.24.1"
egui-winit = { version = "0.24.1", default-features = false }
egui_plot = "0.24.1"
egui_extras = { git = "https://github.com/emilk/egui" }
egui_plot = { git = "https://github.com/emilk/egui" }
ordered-float = { version = "4.2.0", default-features = false }
winit = "0.28.7"
oddio = "0.6.2"
oddio = "0.7.4"
derive_more = "0.99.17"

# Set the settings for build scripts and proc-macros.
Expand All @@ -40,6 +39,9 @@ opt-level = 2
[profile.dev.package.geom]
opt-level = 2

[profile.dev.package.goryak]
opt-level = 1

[profile.dev.package.engine]
opt-level = 1

Expand Down
Binary file added assets/font_awesome_solid_900.otf
Binary file not shown.
1 change: 1 addition & 0 deletions assets/models_opt/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
*
2 changes: 1 addition & 1 deletion assets/shaders/pbr/render.wgsl
Original file line number Diff line number Diff line change
Expand Up @@ -166,7 +166,7 @@ fn render(sun: vec3<f32>,
color += atmo;
#endif

let autoexposure = 1.0 + smoothstep(0.0, 0.1, -sun.z) * 5.0;
let autoexposure = 1.0 + smoothstep(0.0, 0.1, -sun.z) * 10.0;

color = tonemap(autoexposure * color);

Expand Down
2 changes: 1 addition & 1 deletion assets/shaders/ssao.wgsl
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ var<private> sample_sphere: array<vec3<f32>,16u> = array<vec3<f32>,16u>(
const samples: i32 = 8;
const total_strength: f32 = 0.64;
const radius: f32 = 1.343;
const falloff: f32 = 0.0008;
const falloff: f32 = 0.0025;
const base: f32 = 0.01;

@fragment
Expand Down
38 changes: 24 additions & 14 deletions assets/shaders/terrain/terrain.frag.wgsl
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,9 @@ struct ChunkData {

@group(2) @binding(4) var t_grass: texture_2d<f32>;
@group(2) @binding(5) var s_grass: sampler;
@group(2) @binding(6) var<uniform> cdata: ChunkData;
@group(2) @binding(6) var t_cliff: texture_2d<f32>;
@group(2) @binding(7) var s_cliff: sampler;
@group(2) @binding(8) var<uniform> cdata: ChunkData;

@group(3) @binding(0) var t_ssao: texture_2d<f32>;
@group(3) @binding(1) var s_ssao: sampler;
Expand Down Expand Up @@ -83,8 +85,8 @@ fn textureNoTile(tex: texture_2d<f32>, samp: sampler, uv: vec2<f32>) -> vec4<f32
var ofc: vec4<f32> = hash4( iuv + vec2(0.0,1.0) );
var ofd: vec4<f32> = hash4( iuv + vec2(1.0,1.0) );

let ddx: vec2<f32> = dpdx(uv);
let ddy: vec2<f32> = dpdy(uv);
let ddx: vec2<f32> = dpdxCoarse(uv);
let ddy: vec2<f32> = dpdyCoarse(uv);

// transform per-tile uvs
ofa.z = sign(ofa.z - 0.5);
Expand Down Expand Up @@ -129,13 +131,24 @@ fn frag(@builtin(position) position: vec4<f32>,
shadow_v = sampleShadow(in_wpos);
}

var c: vec3<f32> = params.grass_col.rgb;
var c: vec3<f32> = vec3(0.0, 0.0, 0.0);
#ifdef TERRAIN_GRID
c.g += grid(in_wpos, fwidth(in_wpos.x)) * 0.015;
c.g += grid(in_wpos, fwidthCoarse(in_wpos.x)) * 0.015;
#endif

let grass = (textureNoTile(t_grass, s_grass, in_wpos.xy / 100.0).rgb * 0.3 - c) * 0.5;
c = c + grass;
// tri-planar mapping
let grass = textureNoTile(t_grass, s_grass, in_wpos.xy / 200.0).rgb;
let cliffE = textureSample(t_cliff, s_cliff, in_wpos.xz / 100.0).rgb;
let cliffN = textureSample(t_cliff, s_cliff, in_wpos.yz / 100.0).rgb;

let wcliffN = pow(abs(in_normal.x), 16.0);
let wcliffE = pow(abs(in_normal.y), 16.0);
let wgrass = pow(abs(in_normal.z)*0.8, 16.0);

let sum = wgrass + wcliffE + wcliffN;

c = c + (grass * wgrass + cliffE * wcliffE + cliffN * wcliffN) / sum;

c = mix(params.sand_col.rgb, c, smoothstep(-5.0, 0.0, in_wpos.z));
c = mix(params.sea_col.rgb, c, smoothstep(-25.0, -20.0, in_wpos.z));

Expand All @@ -154,16 +167,13 @@ fn frag(@builtin(position) position: vec4<f32>,

if (params.terraforming_mode_radius > 0.0) {
let dist = length(params.unproj_pos - in_wpos.xy);
let alpha = smoothstep(params.terraforming_mode_radius, 0.0, dist) * 0.1;
let alpha2 = smoothstep(params.terraforming_mode_radius * 0.5, 0.0, dist) * 0.3;
let alpha3 = smoothstep(params.terraforming_mode_radius * 0.25, 0.0, dist) * 0.3;
var fw = fwidth(in_wpos.z) * 2.5;
var fw = fwidthCoarse(in_wpos.z) * 2.5;

let alpha = smoothstep(params.terraforming_mode_radius, params.terraforming_mode_radius*0.4, dist);
let alpha4 = smoothstep(fw, 0.0, abs((in_wpos.z % 10.0) - 5.0)) * 0.1;
let alpha5 = smoothstep(fw, 0.0, abs((in_wpos.z % 50.0) - 25.0)) * 0.1;

c = mix(c, vec3(1.0, 0.5, 0.5), alpha);
c = mix(c, vec3(0.5, 1.0, 0.5), alpha2);
c = mix(c, vec3(0.5, 0.5, 1.0), alpha3);
c = mix(c, vec3(0.7, 0.4, 0.2), alpha * 0.15);
c = mix(c, vec3(0.0, 0.0, 0.0), alpha4 + alpha5);
}

Expand Down
12 changes: 6 additions & 6 deletions assets/shaders/terrain/terrain.vert.wgsl
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ struct ChunkData {
@group(2) @binding(1) var s_terrain: sampler;
@group(2) @binding(2) var t_normals: texture_2d<u32>;
@group(2) @binding(3) var s_normals: sampler;
@group(2) @binding(6) var<uniform> cdata: ChunkData;
@group(2) @binding(8) var<uniform> cdata: ChunkData;

/*
normal: vec3(self.cell_size * scale as f32, 0.0, hx - height)
Expand Down Expand Up @@ -75,23 +75,23 @@ fn vert(@builtin(vertex_index) vid: u32,

var world_pos: vec3<f32> = vec3(vec2<f32>(in_position * i32(cdata.lod_pow2)) * cdata.cell_size + in_off, height_normal.x);

let height_normal_next: vec4<f32> = sampleHeightDxDy(tpos / 2, i32(cdata.lod) + 1);

#ifdef DEBUG
var debug = 1.0;
#endif

if (cdata.lod < 4u) {
let dist_to_cam: f32 = length(params.cam_pos.xyz - vec3(world_pos.xy, 0.0));
let transition_alpha: f32 = smoothstep(cdata.distance_lod_cutoff * 0.8, cdata.distance_lod_cutoff, dist_to_cam);
let dist_to_cam: f32 = length(params.cam_pos.xyz - vec3(world_pos.xy, 0.0));
let transition_alpha: f32 = smoothstep(cdata.distance_lod_cutoff * 0.8, cdata.distance_lod_cutoff, dist_to_cam);

if (cdata.lod < 4u && transition_alpha > 0.0) {
#ifdef DEBUG
// debug = (f32(cdata.lod) + transition_alpha + 1.0) / 5.0;
debug = f32(cdata.lod);
#endif
let height_normal_next: vec4<f32> = sampleHeightDxDy(tpos / 2, i32(cdata.lod) + 1);

var world_pos_next: vec3<f32> = vec3(vec2<f32>(in_position / 2 * i32(cdata.lod_pow2)) * cdata.cell_size * 2.0 + in_off, height_normal_next.x);


normal = normalize(mix(normal, height_normal_next.yzw, transition_alpha));
world_pos = mix(world_pos, world_pos_next, transition_alpha);
}
Expand Down
2 changes: 1 addition & 1 deletion assets/shaders/terrain/unpack.wgsl
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ fn unpack_height(h: u32) -> f32 {
fn unpack_normal(v: u32) -> vec3<f32> {
let x = f32(v >> 8u) / 128.0 - 1.0;
let y = f32(v & 0xFFu) / 128.0 - 1.0;
let z = sqrt(1.0 - x * x - y * y);
let z = sqrt(max(0.0, 1.0 - x * x - y * y));

return vec3<f32>(x, y, z);
}
3 changes: 3 additions & 0 deletions assets/sprites/cliff.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
4 changes: 2 additions & 2 deletions assets/sprites/grass.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
6 changes: 4 additions & 2 deletions assets_gui/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,11 @@ edition = "2021"
[dependencies]
common = { path = "../common" }
geom = { path = "../geom" }
engine = { path = "../engine" }
engine = { path = "../engine", features=["yakui"] }
egui-inspect = { path = "../egui-inspect" }
log = { version = "0.4.11", features=["max_level_info", "release_max_level_info"] }
inline_tweak = "1.0.8"
egui_dock = "0.9.0"
egui = { workspace = true }
yakui = { git = "https://github.com/SecondHalfGames/yakui" }
goryak = { path = "../goryak" }
meshopt2 = "0.2.0"
1 change: 1 addition & 0 deletions assets_gui/src/companies.rs
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ impl Companies {
})
}

#[allow(dead_code)]
pub fn save(&self) {
common::saveload::JSONPretty::save(&self.companies, "companies");
}
Expand Down
Loading

0 comments on commit 9480192

Please sign in to comment.