Skip to content

Commit

Permalink
mips
Browse files Browse the repository at this point in the history
todo:
- fix transitions
- make setting for generate/gen speed
- make server executable
- fix tiling seams for large mips?
- add mip hash checks
  • Loading branch information
robtfm committed Nov 21, 2024
1 parent c8078c5 commit 5ce5dca
Show file tree
Hide file tree
Showing 19 changed files with 1,295 additions and 677 deletions.
16 changes: 9 additions & 7 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -191,5 +191,5 @@ deno_websocket = { git = "https://github.com/robtfm/deno", branch = "1_46_hotfix
# [patch."https://github.com/robtfm/bevy_simple_text_input"]
# bevy_simple_text_input = { path = "../bevy_simple_text_input" }

[patch."https://github.com/robtfm/boimp"]
boimp = { path = "../boimp" }
# [patch."https://github.com/robtfm/boimp"]
# boimp = { path = "../boimp" }
2 changes: 1 addition & 1 deletion assets/shaders/bound_material_baker.wgsl
Original file line number Diff line number Diff line change
Expand Up @@ -126,7 +126,7 @@ fn fragment(
outside_amt = 0.0;
}

if outside_amt > 0.00 {
if outside_amt > bounds.distance {
discard;
}

Expand Down
22 changes: 22 additions & 0 deletions assets/shaders/floor_bake.wgsl
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
#import boimp::shared::{ImposterVertexOut, unpack_pbrinput, pack_pbrinput};
#import boimp::bindings::sample_tile_material;

@group(2) @binding(100)
var<uniform> offset: f32;

@fragment
fn fragment(in: ImposterVertexOut) -> @location(0) vec2<u32> {
let inv_rot = mat3x3(
in.inverse_rotation_0c,
in.inverse_rotation_1c,
in.inverse_rotation_2c,
);

var props = sample_tile_material(clamp(in.uv_c, vec2(0.0001), vec2(17.0/18.0 - 0.0001)), vec2(0u,0u), vec2(offset, offset));
var pbr_input = unpack_pbrinput(props, in.position);
pbr_input.N = inv_rot * normalize(pbr_input.N);
pbr_input.world_normal = pbr_input.N;

// write the imposter gbuffer
return pack_pbrinput(pbr_input);
}
8 changes: 6 additions & 2 deletions assets/shaders/floor_fragment.wgsl
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,9 @@
#import boimp::shared::{ImposterVertexOut, unpack_pbrinput};
#import boimp::bindings::sample_tile_material;

@group(2) @binding(100)
var<uniform> offset: f32;

@fragment
fn fragment(in: ImposterVertexOut) -> FragmentOutput {
var out: FragmentOutput;
Expand All @@ -17,11 +20,12 @@ fn fragment(in: ImposterVertexOut) -> FragmentOutput {
in.inverse_rotation_2c,
);

var props = sample_tile_material(in.uv_c, vec2(0u,0u), vec2(-0.5));
var props = sample_tile_material(clamp(in.uv_c, vec2(0.0001), vec2(17.0/18.0 - 0.0001)), vec2(0u,0u), vec2(offset, offset));

if props.rgba.a < 0.5 {
if props.rgba.a == 0.0 {
discard;
}

props.rgba.a = 1.0;

var pbr_input = unpack_pbrinput(props, in.position);
Expand Down
7 changes: 6 additions & 1 deletion assets/shaders/floor_vertex.wgsl
Original file line number Diff line number Diff line change
@@ -1,9 +1,14 @@
#import bevy_pbr::{
mesh_functions,
forward_io::Vertex,
view_transformations::{position_world_to_clip, position_view_to_world},
}

#ifdef PREPASS_PIPELINE
#import bevy_pbr::prepass_io::Vertex;
#else
#import bevy_pbr::forward_io::Vertex;
#endif

#import boimp::shared::ImposterVertexOut;
#import boimp::bindings::{imposter_data, sample_uvs_unbounded, grid_weights, sample_positions_from_camera_dir};

Expand Down
1 change: 1 addition & 0 deletions crates/imposters/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ boimp = { workspace = true }
serde = { workspace = true }
serde_json = { workspace = true }
anyhow = { workspace = true }
urlencoding = { workspace = true }
async-fs = "2.0"

[lints]
Expand Down
Loading

0 comments on commit 5ce5dca

Please sign in to comment.