@dcl-regenesislabs/bevy-explorer-web 0.1.0-18229784557.commit-ef374b9
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/asset_loader.js +31 -0
- package/assets/animations/Dance_Female.glb +0 -0
- package/assets/animations/Dance_Male.glb +0 -0
- package/assets/animations/F_FistPump.glb +0 -0
- package/assets/animations/F_RobotDance.glb +0 -0
- package/assets/animations/Hands_Air.glb +0 -0
- package/assets/animations/M_FistPump.glb +0 -0
- package/assets/animations/M_RobotDance.glb +0 -0
- package/assets/animations/Raise_Hand.glb +0 -0
- package/assets/animations/Throw Money-Emote.glb +0 -0
- package/assets/animations/Wave_Female.glb +0 -0
- package/assets/animations/Wave_Male.glb +0 -0
- package/assets/animations/clap.glb +0 -0
- package/assets/animations/disco_dance.glb +0 -0
- package/assets/animations/dont_wanna_see.glb +0 -0
- package/assets/animations/f_head_explode.glb +0 -0
- package/assets/animations/idle.glb +0 -0
- package/assets/animations/jump2.glb +0 -0
- package/assets/animations/kiss.glb +0 -0
- package/assets/animations/m_head_explode.glb +0 -0
- package/assets/animations/mchammer-dance.glb +0 -0
- package/assets/animations/run.glb +0 -0
- package/assets/animations/shrug.glb +0 -0
- package/assets/animations/tektonik-dance.glb +0 -0
- package/assets/animations/thumbnails/clap.png +0 -0
- package/assets/animations/thumbnails/dance.png +0 -0
- package/assets/animations/thumbnails/disco.png +0 -0
- package/assets/animations/thumbnails/dontsee.png +0 -0
- package/assets/animations/thumbnails/fistpump.png +0 -0
- package/assets/animations/thumbnails/hammer.png +0 -0
- package/assets/animations/thumbnails/handsair.png +0 -0
- package/assets/animations/thumbnails/headexplode.png +0 -0
- package/assets/animations/thumbnails/kiss.png +0 -0
- package/assets/animations/thumbnails/money.png +0 -0
- package/assets/animations/thumbnails/raisehand.png +0 -0
- package/assets/animations/thumbnails/robot.png +0 -0
- package/assets/animations/thumbnails/shrug.png +0 -0
- package/assets/animations/thumbnails/tektonik.png +0 -0
- package/assets/animations/thumbnails/tik.png +0 -0
- package/assets/animations/thumbnails/wave.png +0 -0
- package/assets/animations/tik-tok-dance.glb +0 -0
- package/assets/animations/walk.glb +0 -0
- package/assets/fonts/NotoSans-Bold.ttf +0 -0
- package/assets/fonts/NotoSans-BoldItalic.ttf +0 -0
- package/assets/fonts/NotoSans-Italic.ttf +0 -0
- package/assets/fonts/NotoSans-Regular.ttf +0 -0
- package/assets/fonts/NotoSansMono-Bold.ttf +0 -0
- package/assets/fonts/NotoSansMono-Regular.ttf +0 -0
- package/assets/fonts/NotoSerif-Bold.ttf +0 -0
- package/assets/fonts/NotoSerif-BoldItalic.ttf +0 -0
- package/assets/fonts/NotoSerif-Italic.ttf +0 -0
- package/assets/fonts/NotoSerif-Regular.ttf +0 -0
- package/assets/fonts/OFL.txt +93 -0
- package/assets/images/FriendsIcon.png +0 -0
- package/assets/images/ask.png +0 -0
- package/assets/images/backpack/Background.jpeg +0 -0
- package/assets/images/backpack/empty.png +0 -0
- package/assets/images/backpack/item_bg.png +0 -0
- package/assets/images/backpack/wearable_categories/body_shape.png +0 -0
- package/assets/images/backpack/wearable_categories/earring.png +0 -0
- package/assets/images/backpack/wearable_categories/eyebrows.png +0 -0
- package/assets/images/backpack/wearable_categories/eyes.png +0 -0
- package/assets/images/backpack/wearable_categories/eyewear.png +0 -0
- package/assets/images/backpack/wearable_categories/facial_hair.png +0 -0
- package/assets/images/backpack/wearable_categories/feet.png +0 -0
- package/assets/images/backpack/wearable_categories/hair.png +0 -0
- package/assets/images/backpack/wearable_categories/hands_wear.png +0 -0
- package/assets/images/backpack/wearable_categories/hat.png +0 -0
- package/assets/images/backpack/wearable_categories/helmet.png +0 -0
- package/assets/images/backpack/wearable_categories/lower_body.png +0 -0
- package/assets/images/backpack/wearable_categories/mask.png +0 -0
- package/assets/images/backpack/wearable_categories/mouth.png +0 -0
- package/assets/images/backpack/wearable_categories/skin.png +0 -0
- package/assets/images/backpack/wearable_categories/tiara.png +0 -0
- package/assets/images/backpack/wearable_categories/top_head.png +0 -0
- package/assets/images/backpack/wearable_categories/upper_body.png +0 -0
- package/assets/images/button copy.png +0 -0
- package/assets/images/button.png +0 -0
- package/assets/images/button_base.png +0 -0
- package/assets/images/chat_button.png +0 -0
- package/assets/images/copy.png +0 -0
- package/assets/images/crosshair.png +0 -0
- package/assets/images/cursor.png +0 -0
- package/assets/images/dao_small.png +0 -0
- package/assets/images/dcl-godot-bevy.png +0 -0
- package/assets/images/discover/art.png +0 -0
- package/assets/images/discover/business.png +0 -0
- package/assets/images/discover/casino.png +0 -0
- package/assets/images/discover/crypto.png +0 -0
- package/assets/images/discover/education.png +0 -0
- package/assets/images/discover/eye.png +0 -0
- package/assets/images/discover/fashion.png +0 -0
- package/assets/images/discover/featured.png +0 -0
- package/assets/images/discover/game.png +0 -0
- package/assets/images/discover/icons.png +0 -0
- package/assets/images/discover/music.png +0 -0
- package/assets/images/discover/point of interest.png +0 -0
- package/assets/images/discover/shop.png +0 -0
- package/assets/images/discover/social.png +0 -0
- package/assets/images/discover/sports.png +0 -0
- package/assets/images/discover/thumbsup.png +0 -0
- package/assets/images/emote-button-background.png +0 -0
- package/assets/images/emote_button.png +0 -0
- package/assets/images/genesis_tx.png +0 -0
- package/assets/images/grid.png +0 -0
- package/assets/images/grip.png +0 -0
- package/assets/images/left-arrow.png +0 -0
- package/assets/images/line.png +0 -0
- package/assets/images/mic_button_inactive.png +0 -0
- package/assets/images/mic_button_off.png +0 -0
- package/assets/images/mic_button_on.png +0 -0
- package/assets/images/next.png +0 -0
- package/assets/images/person.png +0 -0
- package/assets/images/person_button.png +0 -0
- package/assets/images/profile_button.png +0 -0
- package/assets/images/redx.png +0 -0
- package/assets/images/right-arrow.png +0 -0
- package/assets/images/screenshots/montage.png +0 -0
- package/assets/images/screenshots/screenshot%2Fbevy_snapshot_avatar_attach_1.png.png +0 -0
- package/assets/images/screenshots/screenshot%2Fbevy_snapshot_avatar_attach_2.png.png +0 -0
- package/assets/images/screenshots/screenshot%2Fbevy_snapshot_avatar_attach_3.png.png +0 -0
- package/assets/images/screenshots/screenshot%2Fbevy_snapshot_avatar_attach_4.png.png +0 -0
- package/assets/images/screenshots/screenshot%2Fbevy_snapshot_gltfcontainer_avocado.png.png +0 -0
- package/assets/images/screenshots/screenshot%2Fbevy_snapshot_gltfcontainer_hev.png.png +0 -0
- package/assets/images/screenshots/screenshot%2Fbevy_snapshot_material_01.png.png +0 -0
- package/assets/images/screenshots/screenshot%2Fbevy_snapshot_material_02.png.png +0 -0
- package/assets/images/screenshots/screenshot%2Fbevy_snapshot_material_03.png.png +0 -0
- package/assets/images/screenshots/screenshot%2Fbevy_snapshot_material_04.png.png +0 -0
- package/assets/images/screenshots/screenshot%2Fbevy_snapshot_material_05.png.png +0 -0
- package/assets/images/screenshots/screenshot%2Fbevy_snapshot_material_06.png.png +0 -0
- package/assets/images/screenshots/screenshot%2Fbevy_snapshot_material_07.png.png +0 -0
- package/assets/images/screenshots/screenshot%2Fbevy_snapshot_material_08.png.png +0 -0
- package/assets/images/screenshots/screenshot%2Fbevy_snapshot_material_09.png.png +0 -0
- package/assets/images/screenshots/screenshot%2Fbevy_snapshot_material_10.png.png +0 -0
- package/assets/images/screenshots/screenshot%2Fbevy_snapshot_material_11.png.png +0 -0
- package/assets/images/screenshots/screenshot%2Fbevy_snapshot_material_12.png.png +0 -0
- package/assets/images/screenshots/screenshot%2Fbevy_snapshot_material_13.png.png +0 -0
- package/assets/images/screenshots/screenshot%2Fbevy_snapshot_material_14.png.png +0 -0
- package/assets/images/screenshots/screenshot%2Fbevy_snapshot_mesh_renderer_box.png.png +0 -0
- package/assets/images/screenshots/screenshot%2Fbevy_snapshot_mesh_renderer_cylinder.png.png +0 -0
- package/assets/images/screenshots/screenshot%2Fbevy_snapshot_mesh_renderer_plane.png.png +0 -0
- package/assets/images/screenshots/screenshot%2Fbevy_snapshot_mesh_renderer_sphere.png.png +0 -0
- package/assets/images/screenshots/screenshot%2Fbevy_snapshot_text_shape_1.png.png +0 -0
- package/assets/images/screenshots/screenshot%2Fbevy_snapshot_text_shape_2.png.png +0 -0
- package/assets/images/screenshots/screenshot%2Fbevy_snapshot_text_shape_3.png.png +0 -0
- package/assets/images/screenshots/screenshot%2Fbevy_snapshot_text_shape_4.png.png +0 -0
- package/assets/images/screenshots/screenshot%2Fbevy_snapshot_text_shape_5.png.png +0 -0
- package/assets/images/screenshots/screenshot%2Fbevy_snapshot_text_shape_6.png.png +0 -0
- package/assets/images/screenshots/screenshot%2Fbevy_snapshot_ui_background_all_screen_green.png.png +0 -0
- package/assets/images/screenshots/screenshot%2Fbevy_snapshot_ui_background_all_screen_red.png.png +0 -0
- package/assets/images/screenshots/screenshot%2Fbevy_snapshot_ui_background_all_screen_rocks.png.png +0 -0
- package/assets/images/screenshots/screenshot%2Fbevy_snapshot_ui_text_1.png.png +0 -0
- package/assets/images/screenshots/screenshot%2Fbevy_snapshot_ui_text_2.png.png +0 -0
- package/assets/images/screenshots/screenshot%2Fbevy_snapshot_video_player_1.png.png +0 -0
- package/assets/images/screenshots/screenshot%2Fbevy_snapshot_video_player_2.png.png +0 -0
- package/assets/images/screenshots/screenshot%2Fbevy_snapshot_video_player_3.png.png +0 -0
- package/assets/images/screenshots/screenshot%2Fbevy_snapshot_video_player_4.png.png +0 -0
- package/assets/images/screenshots/screenshot%2Fbevy_snapshot_visibility_false.png.png +0 -0
- package/assets/images/screenshots/screenshot%2Fbevy_snapshot_visibility_true.png.png +0 -0
- package/assets/images/skybox/skybox_cubemap.png +0 -0
- package/assets/images/skybox/skybox_cubemap_original.png +0 -0
- package/assets/images/spinner.png +0 -0
- package/assets/images/spinner_atlas.png +0 -0
- package/assets/images/tick.png +0 -0
- package/assets/images/toggle-off.png +0 -0
- package/assets/images/toggle-on.png +0 -0
- package/assets/images/unknown_person.png +0 -0
- package/assets/images/you_are_here.png +0 -0
- package/assets/nft_shapes/Baroque_Ornament.glb +0 -0
- package/assets/nft_shapes/Blocky.glb +0 -0
- package/assets/nft_shapes/Canvas.glb +0 -0
- package/assets/nft_shapes/Classic.glb +0 -0
- package/assets/nft_shapes/Diamond_Ornament.glb +0 -0
- package/assets/nft_shapes/Floor_Wood01.png +0 -0
- package/assets/nft_shapes/Genesis_TX.png +0 -0
- package/assets/nft_shapes/Gold_Carved.glb +0 -0
- package/assets/nft_shapes/Gold_Edges.glb +0 -0
- package/assets/nft_shapes/Gold_Rounded.glb +0 -0
- package/assets/nft_shapes/Gold_Wide.glb +0 -0
- package/assets/nft_shapes/Metal_Medium.glb +0 -0
- package/assets/nft_shapes/Metal_Rounded.glb +0 -0
- package/assets/nft_shapes/Metal_Slim.glb +0 -0
- package/assets/nft_shapes/Metal_Wide.glb +0 -0
- package/assets/nft_shapes/Minimal_Black.glb +0 -0
- package/assets/nft_shapes/Minimal_Grey.glb +0 -0
- package/assets/nft_shapes/Minimal_White.glb +0 -0
- package/assets/nft_shapes/Minimal_Wide.glb +0 -0
- package/assets/nft_shapes/MulticolorDotsLoading.png +0 -0
- package/assets/nft_shapes/NFTIcon.png +0 -0
- package/assets/nft_shapes/NoneIcon.png +0 -0
- package/assets/nft_shapes/Pins.glb +0 -0
- package/assets/nft_shapes/Tape.glb +0 -0
- package/assets/nft_shapes/Wood_Slim.glb +0 -0
- package/assets/nft_shapes/Wood_Twigs.glb +0 -0
- package/assets/nft_shapes/Wood_Wide.glb +0 -0
- package/assets/shaders/bound_material.wgsl +183 -0
- package/assets/shaders/bound_material_baker.wgsl +145 -0
- package/assets/shaders/bound_node.wgsl +57 -0
- package/assets/shaders/bound_prepass.wgsl +160 -0
- package/assets/shaders/floor_bake.wgsl +30 -0
- package/assets/shaders/floor_fragment.wgsl +74 -0
- package/assets/shaders/floor_vertex.wgsl +47 -0
- package/assets/shaders/loading.wgsl +35 -0
- package/assets/shaders/mask_material.wgsl +117 -0
- package/assets/shaders/nineslice_material.wgsl +47 -0
- package/assets/shaders/nishita_cloud.wgsl +378 -0
- package/assets/shaders/outline.wgsl +69 -0
- package/assets/shaders/simplex.wgsl +77 -0
- package/assets/shaders/stretch_uv_material.wgsl +79 -0
- package/assets/shaders/text_quad_vertex.wgsl +78 -0
- package/assets/sounds/avatar/avatar_footstep_jump01.wav +0 -0
- package/assets/sounds/avatar/avatar_footstep_jump02.wav +0 -0
- package/assets/sounds/avatar/avatar_footstep_jump03.wav +0 -0
- package/assets/sounds/avatar/avatar_footstep_land01.wav +0 -0
- package/assets/sounds/avatar/avatar_footstep_land02.wav +0 -0
- package/assets/sounds/avatar/avatar_footstep_run01.wav +0 -0
- package/assets/sounds/avatar/avatar_footstep_run02.wav +0 -0
- package/assets/sounds/avatar/avatar_footstep_run03.wav +0 -0
- package/assets/sounds/avatar/avatar_footstep_run04.wav +0 -0
- package/assets/sounds/avatar/avatar_footstep_run05.wav +0 -0
- package/assets/sounds/avatar/avatar_footstep_run06.wav +0 -0
- package/assets/sounds/avatar/avatar_footstep_run07.wav +0 -0
- package/assets/sounds/avatar/avatar_footstep_run08.wav +0 -0
- package/assets/sounds/avatar/avatar_footstep_walk01.wav +0 -0
- package/assets/sounds/avatar/avatar_footstep_walk02.wav +0 -0
- package/assets/sounds/avatar/avatar_footstep_walk03.wav +0 -0
- package/assets/sounds/avatar/avatar_footstep_walk04.wav +0 -0
- package/assets/sounds/avatar/avatar_footstep_walk05.wav +0 -0
- package/assets/sounds/avatar/avatar_footstep_walk06.wav +0 -0
- package/assets/sounds/avatar/avatar_footstep_walk07.wav +0 -0
- package/assets/sounds/avatar/avatar_footstep_walk08.wav +0 -0
- package/assets/sounds/ui/generic_button_hover.wav +0 -0
- package/assets/sounds/ui/generic_button_press.wav +0 -0
- package/assets/sounds/ui/mainmenu_widget_open.wav +0 -0
- package/assets/sounds/ui/toggle_disable.wav +0 -0
- package/assets/sounds/ui/toggle_enable.wav +0 -0
- package/assets/sounds/ui/voice_chat_mic_off.wav +0 -0
- package/assets/sounds/ui/voice_chat_mic_on.wav +0 -0
- package/assets/sounds/ui/widget_chat_message_private_send.wav +0 -0
- package/assets/sounds/ui/widget_emotes_close.wav +0 -0
- package/assets/sounds/ui/widget_emotes_highlight.wav +0 -0
- package/assets/sounds/ui/widget_emotes_open.wav +0 -0
- package/assets/ui/app_settings.dui +91 -0
- package/assets/ui/avatar.dui +18 -0
- package/assets/ui/button.dui +78 -0
- package/assets/ui/change-realm.dui +46 -0
- package/assets/ui/chat.dui +182 -0
- package/assets/ui/combo.dui +23 -0
- package/assets/ui/dialog.dui +46 -0
- package/assets/ui/discover.dui +139 -0
- package/assets/ui/emote-select.dui +45 -0
- package/assets/ui/emote.dui +116 -0
- package/assets/ui/foreign-profile-dialog.dui +18 -0
- package/assets/ui/fullscreen-block.dui +12 -0
- package/assets/ui/login.dui +72 -0
- package/assets/ui/map.dui +8 -0
- package/assets/ui/minimap.dui +16 -0
- package/assets/ui/motd.dui +25 -0
- package/assets/ui/nft-dialog.dui +29 -0
- package/assets/ui/oow.dui +41 -0
- package/assets/ui/permissions-dialog.dui +39 -0
- package/assets/ui/permissions.dui +54 -0
- package/assets/ui/profile-detail.dui +24 -0
- package/assets/ui/profile.dui +29 -0
- package/assets/ui/spinner.dui +3 -0
- package/assets/ui/toast.dui +27 -0
- package/assets/ui/tracker.dui +21 -0
- package/assets/ui/update.dui +16 -0
- package/assets/ui/utils.dui +40 -0
- package/assets/ui/wearables.dui +134 -0
- package/gpu_cache.js +302 -0
- package/index.html +134 -0
- package/main.js +284 -0
- package/package.json +9 -0
- package/sandbox_worker.js +394 -0
- package/serve.json +21 -0
- package/service_worker.js +93 -0
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
@@ -0,0 +1,183 @@
|
|
|
1
|
+
#import bevy_pbr::{
|
|
2
|
+
forward_io::{VertexOutput, FragmentOutput},
|
|
3
|
+
pbr_fragment::pbr_input_from_standard_material,
|
|
4
|
+
pbr_functions::{SampleBias, alpha_discard, apply_pbr_lighting, main_pass_post_lighting_processing},
|
|
5
|
+
pbr_bindings::{material, emissive_texture, emissive_sampler},
|
|
6
|
+
pbr_types::STANDARD_MATERIAL_FLAGS_EMISSIVE_TEXTURE_BIT,
|
|
7
|
+
mesh_view_bindings::{globals, view},
|
|
8
|
+
pbr_types,
|
|
9
|
+
}
|
|
10
|
+
#import "shaders/simplex.wgsl"::simplex_noise_3d
|
|
11
|
+
#import "shaders/outline.wgsl"::apply_outline
|
|
12
|
+
|
|
13
|
+
struct Bounds {
|
|
14
|
+
min: u32,
|
|
15
|
+
max: u32,
|
|
16
|
+
height: f32,
|
|
17
|
+
_padding0: u32,
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
struct SceneBounds {
|
|
21
|
+
bounds: array<Bounds,8>,
|
|
22
|
+
distance: f32,
|
|
23
|
+
flags: u32,
|
|
24
|
+
num_bounds: u32,
|
|
25
|
+
_pad: u32,
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
fn unpack_bounds(packed: u32) -> vec2<f32> {
|
|
29
|
+
let x = i32((packed >> 16) & 0xFFFF);
|
|
30
|
+
let x_signed = select(x, x - 0x10000, (x & 0x8000) != 0);
|
|
31
|
+
let y = i32(packed & 0xFFFF);
|
|
32
|
+
let y_signed = select(y, y - 0x10000, (y & 0x8000) != 0);
|
|
33
|
+
return vec2<f32>(f32((x_signed) * 16), f32((y_signed) * 16));
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
const SHOW_OUTSIDE: u32 = 1u;
|
|
37
|
+
//const OUTLINE: u32 = 2u; // replaced by OUTLINE shader def
|
|
38
|
+
const OUTLINE_RED: u32 = 4u;
|
|
39
|
+
const OUTLINE_FORCE: u32 = 8u;
|
|
40
|
+
|
|
41
|
+
@group(2) @binding(100)
|
|
42
|
+
var<uniform> bounds: SceneBounds;
|
|
43
|
+
|
|
44
|
+
@fragment
|
|
45
|
+
fn fragment(
|
|
46
|
+
in: VertexOutput,
|
|
47
|
+
@builtin(front_facing) is_front: bool,
|
|
48
|
+
#ifdef OUTLINE
|
|
49
|
+
#ifdef MULTISAMPLED
|
|
50
|
+
@builtin(sample_index) sample_index: u32,
|
|
51
|
+
#endif
|
|
52
|
+
#endif
|
|
53
|
+
) -> FragmentOutput {
|
|
54
|
+
// generate a PbrInput struct from the StandardMaterial bindings
|
|
55
|
+
var pbr_input = pbr_input_from_standard_material(in, is_front);
|
|
56
|
+
var out: FragmentOutput;
|
|
57
|
+
|
|
58
|
+
#ifdef OUTLINE
|
|
59
|
+
#ifndef MULTISAMPLED
|
|
60
|
+
let sample_index = 0u;
|
|
61
|
+
#endif
|
|
62
|
+
#endif
|
|
63
|
+
|
|
64
|
+
// apply emmissive multiplier
|
|
65
|
+
// dcl uses default 2.0 intensity. we also override bevy_pbr base emissive rules so that
|
|
66
|
+
// - if emissive texture is supplied but color is not, we use the texture (bevy by default multiplies emissive color and emissive texture, so color must be white to pass the texture through)
|
|
67
|
+
// - if emissive color (== gltf emissive_intensity == dcl pbr emissive_color * emissive_intensity) is supplied but emissive texture is not, we use emissive color * base color
|
|
68
|
+
// emissive color | emissive texture | result
|
|
69
|
+
// 0 no 0
|
|
70
|
+
// x no x * base color
|
|
71
|
+
// 0 t 2 * t
|
|
72
|
+
// x != 0 t x * t
|
|
73
|
+
var emissive: vec4<f32> = material.emissive;
|
|
74
|
+
#ifdef VERTEX_UVS
|
|
75
|
+
if ((material.flags & STANDARD_MATERIAL_FLAGS_EMISSIVE_TEXTURE_BIT) != 0u) {
|
|
76
|
+
if dot(emissive, emissive) == 0.0 {
|
|
77
|
+
emissive = vec4(2.0);
|
|
78
|
+
}
|
|
79
|
+
var bias: SampleBias;
|
|
80
|
+
bias.mip_bias = view.mip_bias;
|
|
81
|
+
emissive = vec4<f32>(emissive.rgb * textureSampleBias(
|
|
82
|
+
emissive_texture,
|
|
83
|
+
emissive_sampler,
|
|
84
|
+
#ifdef STANDARD_MATERIAL_EMISSIVE_UV_B
|
|
85
|
+
#ifdef VERTEX_UVS_B
|
|
86
|
+
(material.uv_transform * vec3(in.uv_b, 1.0)).xy,
|
|
87
|
+
#else
|
|
88
|
+
(material.uv_transform * vec3(in.uv, 1.0)).xy,
|
|
89
|
+
#endif
|
|
90
|
+
#else
|
|
91
|
+
(material.uv_transform * vec3(in.uv, 1.0)).xy,
|
|
92
|
+
#endif
|
|
93
|
+
bias.mip_bias,
|
|
94
|
+
).rgb, emissive.a);
|
|
95
|
+
} else {
|
|
96
|
+
if dot(emissive, emissive) != 0.0 {
|
|
97
|
+
// emissive is set, no emissive texture, use base color texture as emissive texture
|
|
98
|
+
emissive = emissive * pbr_input.material.base_color;
|
|
99
|
+
}
|
|
100
|
+
}
|
|
101
|
+
#endif
|
|
102
|
+
// scale up for lumens
|
|
103
|
+
pbr_input.material.emissive = emissive * 10.0;
|
|
104
|
+
pbr_input.material.emissive.a = min(pbr_input.material.emissive.a, 1.0);
|
|
105
|
+
|
|
106
|
+
let world_position = pbr_input.world_position.xyz;
|
|
107
|
+
// check bounds
|
|
108
|
+
var outside_amt: f32 = 9999.0;
|
|
109
|
+
var nearest_region_distance: f32 = 9999.0;
|
|
110
|
+
var nearest_region_height: f32 = 9999.0;
|
|
111
|
+
if bounds.num_bounds > 0 {
|
|
112
|
+
for (var ix = 0u; ix < bounds.num_bounds; ix += 1u) {
|
|
113
|
+
let min_wp = unpack_bounds(bounds.bounds[ix].min);
|
|
114
|
+
let max_wp = unpack_bounds(bounds.bounds[ix].max);
|
|
115
|
+
|
|
116
|
+
let outside_xy = abs(clamp(world_position.xz, min_wp, max_wp) - world_position.xz);
|
|
117
|
+
let distance = max(outside_xy.x, outside_xy.y);
|
|
118
|
+
if distance < nearest_region_distance {
|
|
119
|
+
nearest_region_distance = distance;
|
|
120
|
+
nearest_region_height = bounds.bounds[ix].height;
|
|
121
|
+
}
|
|
122
|
+
outside_amt = min(outside_amt, distance);
|
|
123
|
+
}
|
|
124
|
+
let outside_height = max(world_position.y - nearest_region_height, 0.0);
|
|
125
|
+
outside_amt = max(outside_amt, outside_height);
|
|
126
|
+
} else {
|
|
127
|
+
outside_amt = 0.0;
|
|
128
|
+
}
|
|
129
|
+
|
|
130
|
+
var noise = 0.05;
|
|
131
|
+
var should_discard = false;
|
|
132
|
+
if outside_amt > 0.00 {
|
|
133
|
+
if outside_amt < bounds.distance {
|
|
134
|
+
noise = simplex_noise_3d(world_position * 2.0 + globals.time * vec3(0.2, 0.16, 0.24)) * 0.5 + 0.55;
|
|
135
|
+
if noise < (outside_amt - 0.125) / 2.0 {
|
|
136
|
+
should_discard = true;
|
|
137
|
+
}
|
|
138
|
+
} else if outside_amt > 0.05 {
|
|
139
|
+
should_discard = true;
|
|
140
|
+
}
|
|
141
|
+
}
|
|
142
|
+
|
|
143
|
+
if should_discard && ((bounds.flags & SHOW_OUTSIDE) == 0) {
|
|
144
|
+
discard;
|
|
145
|
+
}
|
|
146
|
+
|
|
147
|
+
// alpha discard
|
|
148
|
+
pbr_input.material.base_color = alpha_discard(pbr_input.material, pbr_input.material.base_color);
|
|
149
|
+
|
|
150
|
+
// apply lighting
|
|
151
|
+
if (pbr_input.material.flags & bevy_pbr::pbr_types::STANDARD_MATERIAL_FLAGS_UNLIT_BIT) == 0u {
|
|
152
|
+
out.color = apply_pbr_lighting(pbr_input);
|
|
153
|
+
} else {
|
|
154
|
+
out.color = pbr_input.material.base_color;
|
|
155
|
+
}
|
|
156
|
+
|
|
157
|
+
if should_discard {
|
|
158
|
+
out.color.a = out.color.a * 0.5;
|
|
159
|
+
out.color.r = 4.0;
|
|
160
|
+
} else {
|
|
161
|
+
if noise < outside_amt / 2.0 {
|
|
162
|
+
out.color = mix(out.color, vec4(10.0, 1.0, 0.0, 1.0), (outside_amt / 2.0 - noise) / 0.125);
|
|
163
|
+
}
|
|
164
|
+
}
|
|
165
|
+
|
|
166
|
+
#ifdef OUTLINE
|
|
167
|
+
let alpha_mode = material.flags & pbr_types::STANDARD_MATERIAL_FLAGS_ALPHA_MODE_RESERVED_BITS;
|
|
168
|
+
if (alpha_mode == pbr_types::STANDARD_MATERIAL_FLAGS_ALPHA_MODE_OPAQUE) || ((bounds.flags & OUTLINE_FORCE) != 0u) {
|
|
169
|
+
out.color = apply_outline(
|
|
170
|
+
in.position,
|
|
171
|
+
out.color,
|
|
172
|
+
(bounds.flags & OUTLINE_RED) != 0u,
|
|
173
|
+
sample_index,
|
|
174
|
+
);
|
|
175
|
+
}
|
|
176
|
+
#endif
|
|
177
|
+
|
|
178
|
+
// apply in-shader post processing (fog, alpha-premultiply, and also tonemapping, debanding if the camera is non-hdr)
|
|
179
|
+
// note this does not include fullscreen postprocessing effects like bloom.
|
|
180
|
+
out.color = main_pass_post_lighting_processing(pbr_input, out.color);
|
|
181
|
+
|
|
182
|
+
return out;
|
|
183
|
+
}
|
|
@@ -0,0 +1,145 @@
|
|
|
1
|
+
#import bevy_pbr::{
|
|
2
|
+
prepass_io::{VertexOutput, FragmentOutput},
|
|
3
|
+
pbr_fragment::pbr_input_from_standard_material,
|
|
4
|
+
pbr_functions::{SampleBias, alpha_discard, apply_pbr_lighting, main_pass_post_lighting_processing},
|
|
5
|
+
pbr_bindings::{material, emissive_texture, emissive_sampler},
|
|
6
|
+
pbr_types::STANDARD_MATERIAL_FLAGS_EMISSIVE_TEXTURE_BIT,
|
|
7
|
+
mesh_view_bindings::{globals, view},
|
|
8
|
+
pbr_types,
|
|
9
|
+
}
|
|
10
|
+
#import boimp::shared::pack_pbrinput;
|
|
11
|
+
|
|
12
|
+
struct Bounds {
|
|
13
|
+
min: u32,
|
|
14
|
+
max: u32,
|
|
15
|
+
height: f32,
|
|
16
|
+
_padding0: u32,
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
struct SceneBounds {
|
|
20
|
+
bounds: array<Bounds,8>,
|
|
21
|
+
distance: f32,
|
|
22
|
+
flags: u32,
|
|
23
|
+
num_bounds: u32,
|
|
24
|
+
_pad: u32,
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
fn unpack_bounds(packed: u32) -> vec2<f32> {
|
|
28
|
+
let x = i32((packed >> 16) & 0xFFFF);
|
|
29
|
+
let x_signed = select(x, x - 0x10000, (x & 0x8000) != 0);
|
|
30
|
+
let y = i32(packed & 0xFFFF);
|
|
31
|
+
let y_signed = select(y, y - 0x10000, (y & 0x8000) != 0);
|
|
32
|
+
return vec2<f32>(f32((x_signed) * 16), f32((y_signed) * 16));
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
const SHOW_OUTSIDE: u32 = 1u;
|
|
36
|
+
//const OUTLINE: u32 = 2u; // replaced by OUTLINE shader def
|
|
37
|
+
const OUTLINE_RED: u32 = 4u;
|
|
38
|
+
const OUTLINE_FORCE: u32 = 8u;
|
|
39
|
+
|
|
40
|
+
@group(2) @binding(100)
|
|
41
|
+
var<uniform> bounds: SceneBounds;
|
|
42
|
+
|
|
43
|
+
@fragment
|
|
44
|
+
fn fragment(
|
|
45
|
+
in: VertexOutput,
|
|
46
|
+
@builtin(front_facing) is_front: bool,
|
|
47
|
+
#ifdef OUTLINE
|
|
48
|
+
#ifdef MULTISAMPLED
|
|
49
|
+
@builtin(sample_index) sample_index: u32,
|
|
50
|
+
#endif
|
|
51
|
+
#endif
|
|
52
|
+
) -> @location(0) vec2<u32> {
|
|
53
|
+
// generate a PbrInput struct from the StandardMaterial bindings
|
|
54
|
+
var pbr_input = pbr_input_from_standard_material(in, is_front);
|
|
55
|
+
var out: FragmentOutput;
|
|
56
|
+
|
|
57
|
+
#ifdef OUTLINE
|
|
58
|
+
#ifndef MULTISAMPLED
|
|
59
|
+
let sample_index = 0u;
|
|
60
|
+
#endif
|
|
61
|
+
#endif
|
|
62
|
+
|
|
63
|
+
// apply emmissive multiplier
|
|
64
|
+
// dcl uses default 2.0 intensity. we also override bevy_pbr base emissive rules so that
|
|
65
|
+
// - if emissive texture is supplied but color is not, we use the texture (bevy by default multiplies emissive color and emissive texture, so color must be white to pass the texture through)
|
|
66
|
+
// - if emissive color (== gltf emissive_intensity == dcl pbr emissive_color * emissive_intensity) is supplied but emissive texture is not, we use emissive color * base color
|
|
67
|
+
// emissive color | emissive texture | result
|
|
68
|
+
// 0 no 0
|
|
69
|
+
// x no x * base color
|
|
70
|
+
// 0 t 2 * t
|
|
71
|
+
// x != 0 t x * t
|
|
72
|
+
var emissive: vec4<f32> = material.emissive;
|
|
73
|
+
#ifdef VERTEX_UVS
|
|
74
|
+
if ((material.flags & STANDARD_MATERIAL_FLAGS_EMISSIVE_TEXTURE_BIT) != 0u) {
|
|
75
|
+
if dot(emissive, emissive) == 0.0 {
|
|
76
|
+
emissive = vec4(2.0);
|
|
77
|
+
}
|
|
78
|
+
var bias: SampleBias;
|
|
79
|
+
bias.mip_bias = view.mip_bias;
|
|
80
|
+
emissive = vec4<f32>(emissive.rgb * textureSampleBias(
|
|
81
|
+
emissive_texture,
|
|
82
|
+
emissive_sampler,
|
|
83
|
+
#ifdef STANDARD_MATERIAL_EMISSIVE_UV_B
|
|
84
|
+
#ifdef VERTEX_UVS_B
|
|
85
|
+
(material.uv_transform * vec3(in.uv_b, 1.0)).xy,
|
|
86
|
+
#else
|
|
87
|
+
(material.uv_transform * vec3(in.uv, 1.0)).xy,
|
|
88
|
+
#endif
|
|
89
|
+
#else
|
|
90
|
+
(material.uv_transform * vec3(in.uv, 1.0)).xy,
|
|
91
|
+
#endif
|
|
92
|
+
bias.mip_bias,
|
|
93
|
+
).rgb, emissive.a);
|
|
94
|
+
} else {
|
|
95
|
+
if dot(emissive, emissive) != 0.0 {
|
|
96
|
+
// emissive is set, no emissive texture, use base color texture as emissive texture
|
|
97
|
+
emissive = emissive * pbr_input.material.base_color;
|
|
98
|
+
}
|
|
99
|
+
}
|
|
100
|
+
#endif
|
|
101
|
+
// scale up for lumens
|
|
102
|
+
pbr_input.material.emissive = emissive * 10.0;
|
|
103
|
+
pbr_input.material.emissive.a = min(pbr_input.material.emissive.a, 1.0);
|
|
104
|
+
|
|
105
|
+
let world_position = pbr_input.world_position.xyz;
|
|
106
|
+
|
|
107
|
+
// check bounds
|
|
108
|
+
var outside_amt: f32 = 9999.0;
|
|
109
|
+
var nearest_region_distance: f32 = 9999.0;
|
|
110
|
+
var nearest_region_height: f32 = 9999.0;
|
|
111
|
+
if bounds.num_bounds > 0 {
|
|
112
|
+
for (var ix = 0u; ix < bounds.num_bounds; ix += 1u) {
|
|
113
|
+
let min_wp = unpack_bounds(bounds.bounds[ix].min);
|
|
114
|
+
let max_wp = unpack_bounds(bounds.bounds[ix].max);
|
|
115
|
+
|
|
116
|
+
let outside_xy = abs(clamp(world_position.xz, min_wp, max_wp) - world_position.xz);
|
|
117
|
+
let distance = max(outside_xy.x, outside_xy.y);
|
|
118
|
+
if distance < nearest_region_distance {
|
|
119
|
+
nearest_region_distance = distance;
|
|
120
|
+
nearest_region_height = bounds.bounds[ix].height;
|
|
121
|
+
}
|
|
122
|
+
outside_amt = min(outside_amt, distance);
|
|
123
|
+
}
|
|
124
|
+
let outside_height = max(world_position.y - nearest_region_height, 0.0);
|
|
125
|
+
outside_amt = max(outside_amt, outside_height);
|
|
126
|
+
} else {
|
|
127
|
+
outside_amt = 0.0;
|
|
128
|
+
}
|
|
129
|
+
|
|
130
|
+
if outside_amt > bounds.distance {
|
|
131
|
+
discard;
|
|
132
|
+
}
|
|
133
|
+
|
|
134
|
+
// alpha discard
|
|
135
|
+
pbr_input.material.base_color = alpha_discard(pbr_input.material, pbr_input.material.base_color);
|
|
136
|
+
|
|
137
|
+
if pbr_input.material.base_color.a < 0.5 {
|
|
138
|
+
discard;
|
|
139
|
+
}
|
|
140
|
+
|
|
141
|
+
// use max of emissive and color (imposters only take albedo)
|
|
142
|
+
// pbr_input.material.base_color = max(pbr_input.material.base_color, pbr_input.material.emissive);
|
|
143
|
+
|
|
144
|
+
return pack_pbrinput(pbr_input);
|
|
145
|
+
}
|
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
#import bevy_ui::ui_vertex_output::UiVertexOutput
|
|
2
|
+
#import bevy_render::view::View
|
|
3
|
+
|
|
4
|
+
@group(0) @binding(0) var<uniform> view: View;
|
|
5
|
+
|
|
6
|
+
struct Bounds {
|
|
7
|
+
bounds: vec4<f32>,
|
|
8
|
+
border_color: vec4<f32>,
|
|
9
|
+
edge_scale: vec4<f32>,
|
|
10
|
+
corner_size: f32,
|
|
11
|
+
corner_blend_size: f32,
|
|
12
|
+
border_size: f32,
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
@group(1) @binding(0) var image_texture: texture_2d<f32>;
|
|
16
|
+
@group(1) @binding(1) var image_sampler: sampler;
|
|
17
|
+
@group(1) @binding(2) var<uniform> bounds_data: Bounds;
|
|
18
|
+
@group(1) @binding(3) var<uniform> bg_color: vec4<f32>;
|
|
19
|
+
|
|
20
|
+
fn edge_color(uv: vec2<f32>, position: vec4<f32>, in_color: vec4<f32>) -> vec4<f32> {
|
|
21
|
+
let corner_size = bounds_data.corner_size;
|
|
22
|
+
let bounds = bounds_data.bounds;
|
|
23
|
+
let edges = bounds_data.edge_scale;
|
|
24
|
+
|
|
25
|
+
let left = max(0.0, (bounds.x + corner_size) - position.x) * edges.x;
|
|
26
|
+
let right = max(0.0, position.x - (bounds.z - corner_size)) * edges.y;
|
|
27
|
+
let top = max(0.0, (bounds.y + corner_size) - position.y) * edges.z;
|
|
28
|
+
let bottom = max(0.0, position.y - (bounds.w - corner_size)) * edges.w;
|
|
29
|
+
let corner_dist_sq = max(left * left, right * right) + max(top * top, bottom * bottom);
|
|
30
|
+
let corner_end_size_sq = corner_size * corner_size;
|
|
31
|
+
|
|
32
|
+
if corner_dist_sq > corner_end_size_sq {
|
|
33
|
+
discard;
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
let edge_sq = max(corner_dist_sq, max(max(left * left, right * right), max(top * top, bottom * bottom)));
|
|
37
|
+
var out_color = in_color;
|
|
38
|
+
if bounds_data.border_size > 0.0 {
|
|
39
|
+
let border_start_size_sq = (corner_size - bounds_data.border_size) * (corner_size - bounds_data.border_size);
|
|
40
|
+
let border = 1.0 - clamp((edge_sq - border_start_size_sq) / (corner_end_size_sq - border_start_size_sq), 0.0, 1.0);
|
|
41
|
+
out_color = mix(bounds_data.border_color, out_color, border);
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
if bounds_data.corner_blend_size > 0.0 {
|
|
45
|
+
let corner_start_size_sq = (corner_size - bounds_data.corner_blend_size) * (corner_size - bounds_data.corner_blend_size);
|
|
46
|
+
let alpha = 1.0 - clamp((edge_sq - corner_start_size_sq) / (corner_end_size_sq - corner_start_size_sq), 0.0, 1.0);
|
|
47
|
+
out_color.a *= alpha;
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
return out_color;
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
@fragment
|
|
54
|
+
fn fragment(in: UiVertexOutput) -> @location(0) vec4<f32> {
|
|
55
|
+
var color = textureSample(image_texture, image_sampler, in.uv) * bg_color;
|
|
56
|
+
return edge_color(in.uv, in.position, color);
|
|
57
|
+
}
|
|
@@ -0,0 +1,160 @@
|
|
|
1
|
+
#import bevy_pbr::{
|
|
2
|
+
prepass_bindings,
|
|
3
|
+
prepass_io::{Vertex, VertexOutput, FragmentOutput},
|
|
4
|
+
mesh_view_bindings::{view, previous_view_proj},
|
|
5
|
+
pbr_fragment::pbr_input_from_standard_material,
|
|
6
|
+
pbr_prepass_functions::prepass_alpha_discard,
|
|
7
|
+
}
|
|
8
|
+
#import bevy_render::globals::Globals;
|
|
9
|
+
|
|
10
|
+
#import "shaders/simplex.wgsl"::simplex_noise_3d
|
|
11
|
+
|
|
12
|
+
@group(0) @binding(1) var<uniform> globals: Globals;
|
|
13
|
+
|
|
14
|
+
struct Bounds {
|
|
15
|
+
min: u32,
|
|
16
|
+
max: u32,
|
|
17
|
+
height: f32,
|
|
18
|
+
_padding0: u32,
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
struct SceneBounds {
|
|
22
|
+
bounds: array<Bounds,8>,
|
|
23
|
+
distance: f32,
|
|
24
|
+
flags: u32,
|
|
25
|
+
num_bounds: u32,
|
|
26
|
+
_pad: u32,
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
fn unpack_bounds(packed: u32) -> vec2<f32> {
|
|
30
|
+
let x = i32((packed >> 16) & 0xFFFF);
|
|
31
|
+
let x_signed = select(x, x - 0x10000, (x & 0x8000) != 0);
|
|
32
|
+
let y = i32(packed & 0xFFFF);
|
|
33
|
+
let y_signed = select(y, y - 0x10000, (y & 0x8000) != 0);
|
|
34
|
+
return vec2<f32>(f32((x_signed) * 16), f32((y_signed) * 16));
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
@group(2) @binding(100)
|
|
38
|
+
var<uniform> bounds: SceneBounds;
|
|
39
|
+
|
|
40
|
+
|
|
41
|
+
#ifdef PREPASS_FRAGMENT
|
|
42
|
+
@fragment
|
|
43
|
+
fn fragment(
|
|
44
|
+
in: VertexOutput,
|
|
45
|
+
@builtin(front_facing) is_front: bool
|
|
46
|
+
) -> FragmentOutput {
|
|
47
|
+
var out: FragmentOutput;
|
|
48
|
+
|
|
49
|
+
#ifdef NORMAL_PREPASS
|
|
50
|
+
out.normal = vec4(in.world_normal * 0.5 + vec3(0.5), 1.0);
|
|
51
|
+
#endif
|
|
52
|
+
|
|
53
|
+
#ifdef UNCLIPPED_DEPTH_ORTHO_EMULATION
|
|
54
|
+
out.frag_depth = in.unclipped_depth;
|
|
55
|
+
#endif // UNCLIPPED_DEPTH_ORTHO_EMULATION
|
|
56
|
+
|
|
57
|
+
#ifdef MOTION_VECTOR_PREPASS
|
|
58
|
+
let clip_position_t = view.unjittered_view_proj * in.world_position;
|
|
59
|
+
let clip_position = clip_position_t.xy / clip_position_t.w;
|
|
60
|
+
let previous_clip_position_t = prepass_bindings::previous_view_proj * in.previous_world_position;
|
|
61
|
+
let previous_clip_position = previous_clip_position_t.xy / previous_clip_position_t.w;
|
|
62
|
+
// These motion vectors are used as offsets to UV positions and are stored
|
|
63
|
+
// in the range -1,1 to allow offsetting from the one corner to the
|
|
64
|
+
// diagonally-opposite corner in UV coordinates, in either direction.
|
|
65
|
+
// A difference between diagonally-opposite corners of clip space is in the
|
|
66
|
+
// range -2,2, so this needs to be scaled by 0.5. And the V direction goes
|
|
67
|
+
// down where clip space y goes up, so y needs to be flipped.
|
|
68
|
+
out.motion_vector = (clip_position - previous_clip_position) * vec2(0.5, -0.5);
|
|
69
|
+
#endif // MOTION_VECTOR_PREPASS
|
|
70
|
+
|
|
71
|
+
#ifdef DEFERRED_PREPASS
|
|
72
|
+
// There isn't any material info available for this default prepass shader so we are just writing
|
|
73
|
+
// emissive magenta out to the deferred gbuffer to be rendered by the first deferred lighting pass layer.
|
|
74
|
+
// The is here so if the default prepass fragment is used for deferred magenta will be rendered, and also
|
|
75
|
+
// as an example to show that a user could write to the deferred gbuffer if they were to start from this shader.
|
|
76
|
+
out.deferred = vec4(0u, bevy_pbr::rgb9e5::vec3_to_rgb9e5_(vec3(1.0, 0.0, 1.0)), 0u, 0u);
|
|
77
|
+
out.deferred_lighting_pass_id = 1u;
|
|
78
|
+
#endif
|
|
79
|
+
|
|
80
|
+
let world_position = in.world_position.xyz;
|
|
81
|
+
// check bounds
|
|
82
|
+
var outside_amt: f32 = 9999.0;
|
|
83
|
+
var nearest_region_distance: f32 = 9999.0;
|
|
84
|
+
var nearest_region_height: f32 = 9999.0;
|
|
85
|
+
if bounds.num_bounds > 0 {
|
|
86
|
+
for (var ix = 0u; ix < bounds.num_bounds; ix += 1u) {
|
|
87
|
+
let min_wp = unpack_bounds(bounds.bounds[ix].min);
|
|
88
|
+
let max_wp = unpack_bounds(bounds.bounds[ix].max);
|
|
89
|
+
|
|
90
|
+
let outside_xy = abs(clamp(world_position.xz, min_wp, max_wp) - world_position.xz);
|
|
91
|
+
let distance = max(outside_xy.x, outside_xy.y);
|
|
92
|
+
if distance < nearest_region_distance {
|
|
93
|
+
nearest_region_distance = distance;
|
|
94
|
+
nearest_region_height = bounds.bounds[ix].height;
|
|
95
|
+
}
|
|
96
|
+
outside_amt = min(outside_amt, distance);
|
|
97
|
+
}
|
|
98
|
+
let outside_height = max(world_position.y - nearest_region_height, 0.0);
|
|
99
|
+
outside_amt = max(outside_amt, outside_height);
|
|
100
|
+
} else {
|
|
101
|
+
outside_amt = 0.0;
|
|
102
|
+
}
|
|
103
|
+
|
|
104
|
+
var noise = 0.0;
|
|
105
|
+
if outside_amt > 0.0 {
|
|
106
|
+
if outside_amt < bounds.distance {
|
|
107
|
+
noise = simplex_noise_3d(world_position * 2.0 + globals.time * vec3(0.2, 0.16, 0.24)) * 0.5 + 0.55;
|
|
108
|
+
if noise < (outside_amt - 0.125) / 2.0 {
|
|
109
|
+
discard;
|
|
110
|
+
}
|
|
111
|
+
} else if outside_amt > 0.05 {
|
|
112
|
+
discard;
|
|
113
|
+
}
|
|
114
|
+
}
|
|
115
|
+
|
|
116
|
+
prepass_alpha_discard(in);
|
|
117
|
+
|
|
118
|
+
return out;
|
|
119
|
+
}
|
|
120
|
+
#else // !PREPASS_FRAGMENT (?)
|
|
121
|
+
@fragment
|
|
122
|
+
fn fragment(in: VertexOutput) {
|
|
123
|
+
let world_position = in.world_position.xyz;
|
|
124
|
+
var outside_amt: f32 = 9999.0;
|
|
125
|
+
var nearest_region_distance: f32 = 9999.0;
|
|
126
|
+
var nearest_region_height: f32 = 9999.0;
|
|
127
|
+
if bounds.num_bounds > 0 {
|
|
128
|
+
for (var ix = 0u; ix < bounds.num_bounds; ix += 1u) {
|
|
129
|
+
let min_wp = unpack_bounds(bounds.bounds[ix].min);
|
|
130
|
+
let max_wp = unpack_bounds(bounds.bounds[ix].max);
|
|
131
|
+
|
|
132
|
+
let outside_xy = abs(clamp(world_position.xz, min_wp, max_wp) - world_position.xz);
|
|
133
|
+
let distance = max(outside_xy.x, outside_xy.y);
|
|
134
|
+
if distance < nearest_region_distance {
|
|
135
|
+
nearest_region_distance = distance;
|
|
136
|
+
nearest_region_height = bounds.bounds[ix].height;
|
|
137
|
+
}
|
|
138
|
+
outside_amt = min(outside_amt, distance);
|
|
139
|
+
}
|
|
140
|
+
let outside_height = max(world_position.y - nearest_region_height, 0.0);
|
|
141
|
+
outside_amt = max(outside_amt, outside_height);
|
|
142
|
+
} else {
|
|
143
|
+
outside_amt = 0.0;
|
|
144
|
+
}
|
|
145
|
+
|
|
146
|
+
var noise = 0.0;
|
|
147
|
+
if outside_amt > 0.0 {
|
|
148
|
+
if outside_amt < bounds.distance {
|
|
149
|
+
noise = simplex_noise_3d(world_position * 2.0 + globals.time * vec3(0.2, 0.16, 0.24)) * 0.5 + 0.55;
|
|
150
|
+
if noise < (outside_amt - 0.125) / 2.0 {
|
|
151
|
+
discard;
|
|
152
|
+
}
|
|
153
|
+
} else if outside_amt > 0.05 {
|
|
154
|
+
discard;
|
|
155
|
+
}
|
|
156
|
+
}
|
|
157
|
+
|
|
158
|
+
prepass_alpha_discard(in);
|
|
159
|
+
}
|
|
160
|
+
#endif // PREPASS_FRAGMENT
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
#import boimp::shared::{ImposterVertexOut, unpack_pbrinput, pack_pbrinput};
|
|
2
|
+
#import boimp::bindings::sample_tile_material;
|
|
3
|
+
|
|
4
|
+
@group(2) @binding(100)
|
|
5
|
+
var<uniform> offset: f32;
|
|
6
|
+
|
|
7
|
+
struct VertexOut {
|
|
8
|
+
@builtin(position) position: vec4<f32>,
|
|
9
|
+
@location(0) inverse_rotation_0c: vec3<f32>,
|
|
10
|
+
@location(1) inverse_rotation_1c: vec3<f32>,
|
|
11
|
+
@location(2) inverse_rotation_2c: vec3<f32>,
|
|
12
|
+
@location(3) uv: vec2<f32>,
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
@fragment
|
|
16
|
+
fn fragment(in: VertexOut) -> @location(0) vec2<u32> {
|
|
17
|
+
let inv_rot = mat3x3(
|
|
18
|
+
in.inverse_rotation_0c,
|
|
19
|
+
in.inverse_rotation_1c,
|
|
20
|
+
in.inverse_rotation_2c,
|
|
21
|
+
);
|
|
22
|
+
|
|
23
|
+
var props = sample_tile_material(vec4<f32>(clamp(in.uv, vec2(0.0001), vec2(17.0/18.0 - 0.0001)), vec2<f32>(0.0)), vec2(0u,0u), vec2(offset, offset));
|
|
24
|
+
var pbr_input = unpack_pbrinput(props, in.position);
|
|
25
|
+
pbr_input.N = inv_rot * normalize(pbr_input.N);
|
|
26
|
+
pbr_input.world_normal = pbr_input.N;
|
|
27
|
+
|
|
28
|
+
// write the imposter gbuffer
|
|
29
|
+
return pack_pbrinput(pbr_input);
|
|
30
|
+
}
|
|
@@ -0,0 +1,74 @@
|
|
|
1
|
+
#import bevy_pbr::{
|
|
2
|
+
pbr_functions::{apply_pbr_lighting, main_pass_post_lighting_processing},
|
|
3
|
+
pbr_types::{STANDARD_MATERIAL_FLAGS_ALPHA_MODE_ADD, STANDARD_MATERIAL_FLAGS_FOG_ENABLED_BIT},
|
|
4
|
+
}
|
|
5
|
+
|
|
6
|
+
#ifdef PREPASS_PIPELINE
|
|
7
|
+
#import bevy_pbr::prepass_io::FragmentOutput;
|
|
8
|
+
#else
|
|
9
|
+
#import bevy_pbr::forward_io::FragmentOutput;
|
|
10
|
+
#endif
|
|
11
|
+
|
|
12
|
+
#import boimp::shared::unpack_pbrinput;
|
|
13
|
+
#import boimp::bindings::sample_tile_material;
|
|
14
|
+
|
|
15
|
+
@group(2) @binding(100)
|
|
16
|
+
var<uniform> offset: f32;
|
|
17
|
+
|
|
18
|
+
struct VertexOut {
|
|
19
|
+
@builtin(position) position: vec4<f32>,
|
|
20
|
+
@location(0) inverse_rotation_0c: vec3<f32>,
|
|
21
|
+
@location(1) inverse_rotation_1c: vec3<f32>,
|
|
22
|
+
@location(2) inverse_rotation_2c: vec3<f32>,
|
|
23
|
+
@location(3) uv: vec2<f32>,
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
@fragment
|
|
27
|
+
fn fragment(in: VertexOut) -> FragmentOutput {
|
|
28
|
+
var out: FragmentOutput;
|
|
29
|
+
|
|
30
|
+
#ifdef PREPASS_PIPELINE
|
|
31
|
+
|
|
32
|
+
#ifdef NORMAL_PREPASS
|
|
33
|
+
out.normal = vec4<f32>(0.0, 1.0, 0.0, 0.0);
|
|
34
|
+
#endif
|
|
35
|
+
// we don't support MOTION_VECTOR or DEFERRED
|
|
36
|
+
#ifdef UNCLIPPED_DEPTH_ORTHO_EMULATION
|
|
37
|
+
out.frag_depth = in.position.z;
|
|
38
|
+
#endif
|
|
39
|
+
|
|
40
|
+
#else
|
|
41
|
+
|
|
42
|
+
let inv_rot = mat3x3(
|
|
43
|
+
in.inverse_rotation_0c,
|
|
44
|
+
in.inverse_rotation_1c,
|
|
45
|
+
in.inverse_rotation_2c,
|
|
46
|
+
);
|
|
47
|
+
|
|
48
|
+
var props = sample_tile_material(vec4<f32>(clamp(in.uv, vec2(0.0001), vec2(17.0/18.0 - 0.0001)), vec2<f32>(0.0)), vec2(0u,0u), vec2(offset, offset));
|
|
49
|
+
|
|
50
|
+
if props.rgba.a == 0.0 {
|
|
51
|
+
// hacky - we are using opaque to ensure imposters render above the floor
|
|
52
|
+
// so we have to put the ground color here
|
|
53
|
+
// todo use some nice
|
|
54
|
+
props.rgba = vec4<f32>(0.07323897, 0.17064494, 0.033104762, 1.0);
|
|
55
|
+
props.roughness = 1.0;
|
|
56
|
+
props.metallic = 0.0;
|
|
57
|
+
props.normal = vec3<f32>(0.0, 1.0, 0.0);
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
props.rgba.a = 1.0;
|
|
61
|
+
|
|
62
|
+
var pbr_input = unpack_pbrinput(props, in.position);
|
|
63
|
+
pbr_input.N = inv_rot * normalize(pbr_input.N);
|
|
64
|
+
pbr_input.world_normal = pbr_input.N;
|
|
65
|
+
pbr_input.material.flags |= STANDARD_MATERIAL_FLAGS_ALPHA_MODE_ADD;
|
|
66
|
+
out.color = apply_pbr_lighting(pbr_input);
|
|
67
|
+
|
|
68
|
+
pbr_input.material.flags |= STANDARD_MATERIAL_FLAGS_FOG_ENABLED_BIT;
|
|
69
|
+
out.color = main_pass_post_lighting_processing(pbr_input, out.color);
|
|
70
|
+
|
|
71
|
+
#endif
|
|
72
|
+
|
|
73
|
+
return out;
|
|
74
|
+
}
|