@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.
Files changed (277) hide show
  1. package/asset_loader.js +31 -0
  2. package/assets/animations/Dance_Female.glb +0 -0
  3. package/assets/animations/Dance_Male.glb +0 -0
  4. package/assets/animations/F_FistPump.glb +0 -0
  5. package/assets/animations/F_RobotDance.glb +0 -0
  6. package/assets/animations/Hands_Air.glb +0 -0
  7. package/assets/animations/M_FistPump.glb +0 -0
  8. package/assets/animations/M_RobotDance.glb +0 -0
  9. package/assets/animations/Raise_Hand.glb +0 -0
  10. package/assets/animations/Throw Money-Emote.glb +0 -0
  11. package/assets/animations/Wave_Female.glb +0 -0
  12. package/assets/animations/Wave_Male.glb +0 -0
  13. package/assets/animations/clap.glb +0 -0
  14. package/assets/animations/disco_dance.glb +0 -0
  15. package/assets/animations/dont_wanna_see.glb +0 -0
  16. package/assets/animations/f_head_explode.glb +0 -0
  17. package/assets/animations/idle.glb +0 -0
  18. package/assets/animations/jump2.glb +0 -0
  19. package/assets/animations/kiss.glb +0 -0
  20. package/assets/animations/m_head_explode.glb +0 -0
  21. package/assets/animations/mchammer-dance.glb +0 -0
  22. package/assets/animations/run.glb +0 -0
  23. package/assets/animations/shrug.glb +0 -0
  24. package/assets/animations/tektonik-dance.glb +0 -0
  25. package/assets/animations/thumbnails/clap.png +0 -0
  26. package/assets/animations/thumbnails/dance.png +0 -0
  27. package/assets/animations/thumbnails/disco.png +0 -0
  28. package/assets/animations/thumbnails/dontsee.png +0 -0
  29. package/assets/animations/thumbnails/fistpump.png +0 -0
  30. package/assets/animations/thumbnails/hammer.png +0 -0
  31. package/assets/animations/thumbnails/handsair.png +0 -0
  32. package/assets/animations/thumbnails/headexplode.png +0 -0
  33. package/assets/animations/thumbnails/kiss.png +0 -0
  34. package/assets/animations/thumbnails/money.png +0 -0
  35. package/assets/animations/thumbnails/raisehand.png +0 -0
  36. package/assets/animations/thumbnails/robot.png +0 -0
  37. package/assets/animations/thumbnails/shrug.png +0 -0
  38. package/assets/animations/thumbnails/tektonik.png +0 -0
  39. package/assets/animations/thumbnails/tik.png +0 -0
  40. package/assets/animations/thumbnails/wave.png +0 -0
  41. package/assets/animations/tik-tok-dance.glb +0 -0
  42. package/assets/animations/walk.glb +0 -0
  43. package/assets/fonts/NotoSans-Bold.ttf +0 -0
  44. package/assets/fonts/NotoSans-BoldItalic.ttf +0 -0
  45. package/assets/fonts/NotoSans-Italic.ttf +0 -0
  46. package/assets/fonts/NotoSans-Regular.ttf +0 -0
  47. package/assets/fonts/NotoSansMono-Bold.ttf +0 -0
  48. package/assets/fonts/NotoSansMono-Regular.ttf +0 -0
  49. package/assets/fonts/NotoSerif-Bold.ttf +0 -0
  50. package/assets/fonts/NotoSerif-BoldItalic.ttf +0 -0
  51. package/assets/fonts/NotoSerif-Italic.ttf +0 -0
  52. package/assets/fonts/NotoSerif-Regular.ttf +0 -0
  53. package/assets/fonts/OFL.txt +93 -0
  54. package/assets/images/FriendsIcon.png +0 -0
  55. package/assets/images/ask.png +0 -0
  56. package/assets/images/backpack/Background.jpeg +0 -0
  57. package/assets/images/backpack/empty.png +0 -0
  58. package/assets/images/backpack/item_bg.png +0 -0
  59. package/assets/images/backpack/wearable_categories/body_shape.png +0 -0
  60. package/assets/images/backpack/wearable_categories/earring.png +0 -0
  61. package/assets/images/backpack/wearable_categories/eyebrows.png +0 -0
  62. package/assets/images/backpack/wearable_categories/eyes.png +0 -0
  63. package/assets/images/backpack/wearable_categories/eyewear.png +0 -0
  64. package/assets/images/backpack/wearable_categories/facial_hair.png +0 -0
  65. package/assets/images/backpack/wearable_categories/feet.png +0 -0
  66. package/assets/images/backpack/wearable_categories/hair.png +0 -0
  67. package/assets/images/backpack/wearable_categories/hands_wear.png +0 -0
  68. package/assets/images/backpack/wearable_categories/hat.png +0 -0
  69. package/assets/images/backpack/wearable_categories/helmet.png +0 -0
  70. package/assets/images/backpack/wearable_categories/lower_body.png +0 -0
  71. package/assets/images/backpack/wearable_categories/mask.png +0 -0
  72. package/assets/images/backpack/wearable_categories/mouth.png +0 -0
  73. package/assets/images/backpack/wearable_categories/skin.png +0 -0
  74. package/assets/images/backpack/wearable_categories/tiara.png +0 -0
  75. package/assets/images/backpack/wearable_categories/top_head.png +0 -0
  76. package/assets/images/backpack/wearable_categories/upper_body.png +0 -0
  77. package/assets/images/button copy.png +0 -0
  78. package/assets/images/button.png +0 -0
  79. package/assets/images/button_base.png +0 -0
  80. package/assets/images/chat_button.png +0 -0
  81. package/assets/images/copy.png +0 -0
  82. package/assets/images/crosshair.png +0 -0
  83. package/assets/images/cursor.png +0 -0
  84. package/assets/images/dao_small.png +0 -0
  85. package/assets/images/dcl-godot-bevy.png +0 -0
  86. package/assets/images/discover/art.png +0 -0
  87. package/assets/images/discover/business.png +0 -0
  88. package/assets/images/discover/casino.png +0 -0
  89. package/assets/images/discover/crypto.png +0 -0
  90. package/assets/images/discover/education.png +0 -0
  91. package/assets/images/discover/eye.png +0 -0
  92. package/assets/images/discover/fashion.png +0 -0
  93. package/assets/images/discover/featured.png +0 -0
  94. package/assets/images/discover/game.png +0 -0
  95. package/assets/images/discover/icons.png +0 -0
  96. package/assets/images/discover/music.png +0 -0
  97. package/assets/images/discover/point of interest.png +0 -0
  98. package/assets/images/discover/shop.png +0 -0
  99. package/assets/images/discover/social.png +0 -0
  100. package/assets/images/discover/sports.png +0 -0
  101. package/assets/images/discover/thumbsup.png +0 -0
  102. package/assets/images/emote-button-background.png +0 -0
  103. package/assets/images/emote_button.png +0 -0
  104. package/assets/images/genesis_tx.png +0 -0
  105. package/assets/images/grid.png +0 -0
  106. package/assets/images/grip.png +0 -0
  107. package/assets/images/left-arrow.png +0 -0
  108. package/assets/images/line.png +0 -0
  109. package/assets/images/mic_button_inactive.png +0 -0
  110. package/assets/images/mic_button_off.png +0 -0
  111. package/assets/images/mic_button_on.png +0 -0
  112. package/assets/images/next.png +0 -0
  113. package/assets/images/person.png +0 -0
  114. package/assets/images/person_button.png +0 -0
  115. package/assets/images/profile_button.png +0 -0
  116. package/assets/images/redx.png +0 -0
  117. package/assets/images/right-arrow.png +0 -0
  118. package/assets/images/screenshots/montage.png +0 -0
  119. package/assets/images/screenshots/screenshot%2Fbevy_snapshot_avatar_attach_1.png.png +0 -0
  120. package/assets/images/screenshots/screenshot%2Fbevy_snapshot_avatar_attach_2.png.png +0 -0
  121. package/assets/images/screenshots/screenshot%2Fbevy_snapshot_avatar_attach_3.png.png +0 -0
  122. package/assets/images/screenshots/screenshot%2Fbevy_snapshot_avatar_attach_4.png.png +0 -0
  123. package/assets/images/screenshots/screenshot%2Fbevy_snapshot_gltfcontainer_avocado.png.png +0 -0
  124. package/assets/images/screenshots/screenshot%2Fbevy_snapshot_gltfcontainer_hev.png.png +0 -0
  125. package/assets/images/screenshots/screenshot%2Fbevy_snapshot_material_01.png.png +0 -0
  126. package/assets/images/screenshots/screenshot%2Fbevy_snapshot_material_02.png.png +0 -0
  127. package/assets/images/screenshots/screenshot%2Fbevy_snapshot_material_03.png.png +0 -0
  128. package/assets/images/screenshots/screenshot%2Fbevy_snapshot_material_04.png.png +0 -0
  129. package/assets/images/screenshots/screenshot%2Fbevy_snapshot_material_05.png.png +0 -0
  130. package/assets/images/screenshots/screenshot%2Fbevy_snapshot_material_06.png.png +0 -0
  131. package/assets/images/screenshots/screenshot%2Fbevy_snapshot_material_07.png.png +0 -0
  132. package/assets/images/screenshots/screenshot%2Fbevy_snapshot_material_08.png.png +0 -0
  133. package/assets/images/screenshots/screenshot%2Fbevy_snapshot_material_09.png.png +0 -0
  134. package/assets/images/screenshots/screenshot%2Fbevy_snapshot_material_10.png.png +0 -0
  135. package/assets/images/screenshots/screenshot%2Fbevy_snapshot_material_11.png.png +0 -0
  136. package/assets/images/screenshots/screenshot%2Fbevy_snapshot_material_12.png.png +0 -0
  137. package/assets/images/screenshots/screenshot%2Fbevy_snapshot_material_13.png.png +0 -0
  138. package/assets/images/screenshots/screenshot%2Fbevy_snapshot_material_14.png.png +0 -0
  139. package/assets/images/screenshots/screenshot%2Fbevy_snapshot_mesh_renderer_box.png.png +0 -0
  140. package/assets/images/screenshots/screenshot%2Fbevy_snapshot_mesh_renderer_cylinder.png.png +0 -0
  141. package/assets/images/screenshots/screenshot%2Fbevy_snapshot_mesh_renderer_plane.png.png +0 -0
  142. package/assets/images/screenshots/screenshot%2Fbevy_snapshot_mesh_renderer_sphere.png.png +0 -0
  143. package/assets/images/screenshots/screenshot%2Fbevy_snapshot_text_shape_1.png.png +0 -0
  144. package/assets/images/screenshots/screenshot%2Fbevy_snapshot_text_shape_2.png.png +0 -0
  145. package/assets/images/screenshots/screenshot%2Fbevy_snapshot_text_shape_3.png.png +0 -0
  146. package/assets/images/screenshots/screenshot%2Fbevy_snapshot_text_shape_4.png.png +0 -0
  147. package/assets/images/screenshots/screenshot%2Fbevy_snapshot_text_shape_5.png.png +0 -0
  148. package/assets/images/screenshots/screenshot%2Fbevy_snapshot_text_shape_6.png.png +0 -0
  149. package/assets/images/screenshots/screenshot%2Fbevy_snapshot_ui_background_all_screen_green.png.png +0 -0
  150. package/assets/images/screenshots/screenshot%2Fbevy_snapshot_ui_background_all_screen_red.png.png +0 -0
  151. package/assets/images/screenshots/screenshot%2Fbevy_snapshot_ui_background_all_screen_rocks.png.png +0 -0
  152. package/assets/images/screenshots/screenshot%2Fbevy_snapshot_ui_text_1.png.png +0 -0
  153. package/assets/images/screenshots/screenshot%2Fbevy_snapshot_ui_text_2.png.png +0 -0
  154. package/assets/images/screenshots/screenshot%2Fbevy_snapshot_video_player_1.png.png +0 -0
  155. package/assets/images/screenshots/screenshot%2Fbevy_snapshot_video_player_2.png.png +0 -0
  156. package/assets/images/screenshots/screenshot%2Fbevy_snapshot_video_player_3.png.png +0 -0
  157. package/assets/images/screenshots/screenshot%2Fbevy_snapshot_video_player_4.png.png +0 -0
  158. package/assets/images/screenshots/screenshot%2Fbevy_snapshot_visibility_false.png.png +0 -0
  159. package/assets/images/screenshots/screenshot%2Fbevy_snapshot_visibility_true.png.png +0 -0
  160. package/assets/images/skybox/skybox_cubemap.png +0 -0
  161. package/assets/images/skybox/skybox_cubemap_original.png +0 -0
  162. package/assets/images/spinner.png +0 -0
  163. package/assets/images/spinner_atlas.png +0 -0
  164. package/assets/images/tick.png +0 -0
  165. package/assets/images/toggle-off.png +0 -0
  166. package/assets/images/toggle-on.png +0 -0
  167. package/assets/images/unknown_person.png +0 -0
  168. package/assets/images/you_are_here.png +0 -0
  169. package/assets/nft_shapes/Baroque_Ornament.glb +0 -0
  170. package/assets/nft_shapes/Blocky.glb +0 -0
  171. package/assets/nft_shapes/Canvas.glb +0 -0
  172. package/assets/nft_shapes/Classic.glb +0 -0
  173. package/assets/nft_shapes/Diamond_Ornament.glb +0 -0
  174. package/assets/nft_shapes/Floor_Wood01.png +0 -0
  175. package/assets/nft_shapes/Genesis_TX.png +0 -0
  176. package/assets/nft_shapes/Gold_Carved.glb +0 -0
  177. package/assets/nft_shapes/Gold_Edges.glb +0 -0
  178. package/assets/nft_shapes/Gold_Rounded.glb +0 -0
  179. package/assets/nft_shapes/Gold_Wide.glb +0 -0
  180. package/assets/nft_shapes/Metal_Medium.glb +0 -0
  181. package/assets/nft_shapes/Metal_Rounded.glb +0 -0
  182. package/assets/nft_shapes/Metal_Slim.glb +0 -0
  183. package/assets/nft_shapes/Metal_Wide.glb +0 -0
  184. package/assets/nft_shapes/Minimal_Black.glb +0 -0
  185. package/assets/nft_shapes/Minimal_Grey.glb +0 -0
  186. package/assets/nft_shapes/Minimal_White.glb +0 -0
  187. package/assets/nft_shapes/Minimal_Wide.glb +0 -0
  188. package/assets/nft_shapes/MulticolorDotsLoading.png +0 -0
  189. package/assets/nft_shapes/NFTIcon.png +0 -0
  190. package/assets/nft_shapes/NoneIcon.png +0 -0
  191. package/assets/nft_shapes/Pins.glb +0 -0
  192. package/assets/nft_shapes/Tape.glb +0 -0
  193. package/assets/nft_shapes/Wood_Slim.glb +0 -0
  194. package/assets/nft_shapes/Wood_Twigs.glb +0 -0
  195. package/assets/nft_shapes/Wood_Wide.glb +0 -0
  196. package/assets/shaders/bound_material.wgsl +183 -0
  197. package/assets/shaders/bound_material_baker.wgsl +145 -0
  198. package/assets/shaders/bound_node.wgsl +57 -0
  199. package/assets/shaders/bound_prepass.wgsl +160 -0
  200. package/assets/shaders/floor_bake.wgsl +30 -0
  201. package/assets/shaders/floor_fragment.wgsl +74 -0
  202. package/assets/shaders/floor_vertex.wgsl +47 -0
  203. package/assets/shaders/loading.wgsl +35 -0
  204. package/assets/shaders/mask_material.wgsl +117 -0
  205. package/assets/shaders/nineslice_material.wgsl +47 -0
  206. package/assets/shaders/nishita_cloud.wgsl +378 -0
  207. package/assets/shaders/outline.wgsl +69 -0
  208. package/assets/shaders/simplex.wgsl +77 -0
  209. package/assets/shaders/stretch_uv_material.wgsl +79 -0
  210. package/assets/shaders/text_quad_vertex.wgsl +78 -0
  211. package/assets/sounds/avatar/avatar_footstep_jump01.wav +0 -0
  212. package/assets/sounds/avatar/avatar_footstep_jump02.wav +0 -0
  213. package/assets/sounds/avatar/avatar_footstep_jump03.wav +0 -0
  214. package/assets/sounds/avatar/avatar_footstep_land01.wav +0 -0
  215. package/assets/sounds/avatar/avatar_footstep_land02.wav +0 -0
  216. package/assets/sounds/avatar/avatar_footstep_run01.wav +0 -0
  217. package/assets/sounds/avatar/avatar_footstep_run02.wav +0 -0
  218. package/assets/sounds/avatar/avatar_footstep_run03.wav +0 -0
  219. package/assets/sounds/avatar/avatar_footstep_run04.wav +0 -0
  220. package/assets/sounds/avatar/avatar_footstep_run05.wav +0 -0
  221. package/assets/sounds/avatar/avatar_footstep_run06.wav +0 -0
  222. package/assets/sounds/avatar/avatar_footstep_run07.wav +0 -0
  223. package/assets/sounds/avatar/avatar_footstep_run08.wav +0 -0
  224. package/assets/sounds/avatar/avatar_footstep_walk01.wav +0 -0
  225. package/assets/sounds/avatar/avatar_footstep_walk02.wav +0 -0
  226. package/assets/sounds/avatar/avatar_footstep_walk03.wav +0 -0
  227. package/assets/sounds/avatar/avatar_footstep_walk04.wav +0 -0
  228. package/assets/sounds/avatar/avatar_footstep_walk05.wav +0 -0
  229. package/assets/sounds/avatar/avatar_footstep_walk06.wav +0 -0
  230. package/assets/sounds/avatar/avatar_footstep_walk07.wav +0 -0
  231. package/assets/sounds/avatar/avatar_footstep_walk08.wav +0 -0
  232. package/assets/sounds/ui/generic_button_hover.wav +0 -0
  233. package/assets/sounds/ui/generic_button_press.wav +0 -0
  234. package/assets/sounds/ui/mainmenu_widget_open.wav +0 -0
  235. package/assets/sounds/ui/toggle_disable.wav +0 -0
  236. package/assets/sounds/ui/toggle_enable.wav +0 -0
  237. package/assets/sounds/ui/voice_chat_mic_off.wav +0 -0
  238. package/assets/sounds/ui/voice_chat_mic_on.wav +0 -0
  239. package/assets/sounds/ui/widget_chat_message_private_send.wav +0 -0
  240. package/assets/sounds/ui/widget_emotes_close.wav +0 -0
  241. package/assets/sounds/ui/widget_emotes_highlight.wav +0 -0
  242. package/assets/sounds/ui/widget_emotes_open.wav +0 -0
  243. package/assets/ui/app_settings.dui +91 -0
  244. package/assets/ui/avatar.dui +18 -0
  245. package/assets/ui/button.dui +78 -0
  246. package/assets/ui/change-realm.dui +46 -0
  247. package/assets/ui/chat.dui +182 -0
  248. package/assets/ui/combo.dui +23 -0
  249. package/assets/ui/dialog.dui +46 -0
  250. package/assets/ui/discover.dui +139 -0
  251. package/assets/ui/emote-select.dui +45 -0
  252. package/assets/ui/emote.dui +116 -0
  253. package/assets/ui/foreign-profile-dialog.dui +18 -0
  254. package/assets/ui/fullscreen-block.dui +12 -0
  255. package/assets/ui/login.dui +72 -0
  256. package/assets/ui/map.dui +8 -0
  257. package/assets/ui/minimap.dui +16 -0
  258. package/assets/ui/motd.dui +25 -0
  259. package/assets/ui/nft-dialog.dui +29 -0
  260. package/assets/ui/oow.dui +41 -0
  261. package/assets/ui/permissions-dialog.dui +39 -0
  262. package/assets/ui/permissions.dui +54 -0
  263. package/assets/ui/profile-detail.dui +24 -0
  264. package/assets/ui/profile.dui +29 -0
  265. package/assets/ui/spinner.dui +3 -0
  266. package/assets/ui/toast.dui +27 -0
  267. package/assets/ui/tracker.dui +21 -0
  268. package/assets/ui/update.dui +16 -0
  269. package/assets/ui/utils.dui +40 -0
  270. package/assets/ui/wearables.dui +134 -0
  271. package/gpu_cache.js +302 -0
  272. package/index.html +134 -0
  273. package/main.js +284 -0
  274. package/package.json +9 -0
  275. package/sandbox_worker.js +394 -0
  276. package/serve.json +21 -0
  277. package/service_worker.js +93 -0
@@ -0,0 +1,47 @@
1
+ #import bevy_pbr::{
2
+ mesh_functions,
3
+ view_transformations::{position_world_to_clip, position_view_to_world},
4
+ }
5
+
6
+ #ifdef PREPASS_PIPELINE
7
+ #import bevy_pbr::prepass_io::Vertex;
8
+ #else
9
+ #import bevy_pbr::forward_io::Vertex;
10
+ #endif
11
+
12
+ #import boimp::shared::ImposterVertexOut;
13
+ #import boimp::bindings::{imposter_data, sample_uvs_unbounded, grid_weights, sample_positions_from_camera_dir};
14
+
15
+ struct VertexOut {
16
+ @builtin(position) position: vec4<f32>,
17
+ @location(0) inverse_rotation_0c: vec3<f32>,
18
+ @location(1) inverse_rotation_1c: vec3<f32>,
19
+ @location(2) inverse_rotation_2c: vec3<f32>,
20
+ @location(3) uv: vec2<f32>,
21
+ }
22
+
23
+ @vertex
24
+ fn vertex(vertex: Vertex) -> VertexOut {
25
+ var out: VertexOut;
26
+
27
+ var model = mesh_functions::get_world_from_local(vertex.instance_index);
28
+
29
+ let imposter_world_position = mesh_functions::mesh_position_local_to_world(model, vec4<f32>(0.0, 0.0, 0.0, 1.0)).xyz;
30
+
31
+ // extract inverse rotation
32
+ let inv_rot = transpose(mat3x3<f32>(
33
+ normalize(model[0].xyz),
34
+ normalize(model[1].xyz),
35
+ normalize(model[2].xyz)
36
+ ));
37
+
38
+ out.inverse_rotation_0c = inv_rot[0];
39
+ out.inverse_rotation_1c = inv_rot[1];
40
+ out.inverse_rotation_2c = inv_rot[2];
41
+
42
+ let world_position = mesh_functions::mesh_position_local_to_world(model, vec4<f32>(vertex.position, 1.0)).xyz;
43
+ out.position = position_world_to_clip(world_position);
44
+ out.uv = vertex.uv;
45
+
46
+ return out;
47
+ }
@@ -0,0 +1,35 @@
1
+ #import bevy_pbr::{
2
+ forward_io::{VertexOutput, FragmentOutput},
3
+ mesh_view_bindings::globals,
4
+ }
5
+ #import "shaders/simplex.wgsl"::simplex_noise_3d
6
+
7
+ struct LoadingData {
8
+ player_pos_and_render: vec4<f32>,
9
+ }
10
+
11
+ @group(2) @binding(0)
12
+ var<uniform> material: LoadingData;
13
+
14
+ @fragment
15
+ fn fragment(
16
+ in: VertexOutput,
17
+ @builtin(front_facing) is_front: bool,
18
+ ) -> FragmentOutput {
19
+ if material.player_pos_and_render.a == 0.0 {
20
+ discard;
21
+ }
22
+
23
+ let world_position = in.world_position.xyz;
24
+ let offset = world_position - material.player_pos_and_render.xyz;
25
+
26
+ let noise = simplex_noise_3d(world_position * 2.0 + globals.time * vec3(0.2, 0.16, 0.24)) * 0.5 + 0.5;
27
+
28
+ if noise > 0.5 {
29
+ discard;
30
+ }
31
+
32
+ var out: FragmentOutput;
33
+ out.color = vec4<f32>(noise, noise * 10.0, noise, pow((1.0 - clamp(dot(offset, offset) * 0.03, 0.0, 1.0)), 2.0));
34
+ return out;
35
+ }
@@ -0,0 +1,117 @@
1
+ #import bevy_pbr::{
2
+ forward_io::{VertexOutput, FragmentOutput},
3
+ pbr_fragment::pbr_input_from_vertex_output,
4
+ pbr_functions::{apply_pbr_lighting, main_pass_post_lighting_processing},
5
+ mesh_view_bindings::globals,
6
+ }
7
+ #import "shaders/simplex.wgsl"::simplex_noise_3d
8
+ #import "shaders/outline.wgsl"::apply_outline
9
+
10
+ struct Bounds {
11
+ min: u32,
12
+ max: u32,
13
+ height: f32,
14
+ _padding0: u32,
15
+ }
16
+
17
+ fn unpack_bounds(packed: u32) -> vec2<f32> {
18
+ let x = i32((packed >> 16) & 0xFFFF);
19
+ let x_signed = select(x, x - 0x10000, (x & 0x8000) != 0);
20
+ let y = i32(packed & 0xFFFF);
21
+ let y_signed = select(y, y - 0x10000, (y & 0x8000) != 0);
22
+ return vec2<f32>(f32((x_signed) * 16), f32((y_signed) * 16));
23
+ }
24
+
25
+ struct MaskMaterial {
26
+ bounds: array<Bounds,8>,
27
+ color: vec4<f32>,
28
+ distance: f32,
29
+ num_bounds: u32,
30
+ };
31
+
32
+ @group(2) @binding(0)
33
+ var<uniform> material: MaskMaterial;
34
+ @group(2) @binding(1)
35
+ var base_texture: texture_2d<f32>;
36
+ @group(2) @binding(2)
37
+ var base_sampler: sampler;
38
+ @group(2) @binding(3)
39
+ var mask_texture: texture_2d<f32>;
40
+ @group(2) @binding(4)
41
+ var mask_sampler: sampler;
42
+
43
+ @fragment
44
+ fn fragment(
45
+ in: VertexOutput,
46
+ @builtin(front_facing) is_front: bool,
47
+ #ifdef MULTISAMPLED
48
+ @builtin(sample_index) sample_index: u32,
49
+ #endif
50
+ ) -> FragmentOutput {
51
+ #ifndef MULTISAMPLED
52
+ let sample_index = 0u;
53
+ #endif
54
+
55
+ var pbr_input = pbr_input_from_vertex_output(in, is_front, false);
56
+
57
+ let world_position = pbr_input.world_position.xyz;
58
+ // check bounds
59
+ var outside_amt: f32 = 9999.0;
60
+ var nearest_region_distance: f32 = 9999.0;
61
+ var nearest_region_height: f32 = 9999.0;
62
+ if material.num_bounds > 0 {
63
+ for (var ix = 0u; ix < material.num_bounds; ix += 1u) {
64
+ let min_wp = unpack_bounds(material.bounds[ix].min);
65
+ let max_wp = unpack_bounds(material.bounds[ix].max);
66
+
67
+ let outside_xy = abs(clamp(world_position.xz, min_wp, max_wp) - world_position.xz);
68
+ let distance = max(outside_xy.x, outside_xy.y);
69
+ if distance < nearest_region_distance {
70
+ nearest_region_distance = distance;
71
+ nearest_region_height = material.bounds[ix].height;
72
+ }
73
+ outside_amt = min(outside_amt, distance);
74
+ }
75
+ let outside_height = max(world_position.y - nearest_region_height, 0.0);
76
+ outside_amt = max(outside_amt, outside_height);
77
+ } else {
78
+ outside_amt = 0.0;
79
+ }
80
+
81
+ var noise = 0.05;
82
+ if outside_amt > 0.00 {
83
+ if outside_amt < material.distance {
84
+ noise = simplex_noise_3d(world_position * 2.0 + globals.time * vec3(0.2, 0.16, 0.24)) * 0.5 + 0.55;
85
+ if noise < (outside_amt - 0.125) / 2.0 {
86
+ discard;
87
+ }
88
+ } else if outside_amt > 0.05 {
89
+ discard;
90
+ }
91
+ }
92
+
93
+ let mask = textureSample(mask_texture, mask_sampler, in.uv);
94
+ let base = textureSample(base_texture, base_sampler, in.uv);
95
+ let color_amt = mask.r * mask.a;
96
+
97
+ let color = mix(material.color, vec4<f32>(1.0), color_amt) * base;
98
+
99
+ pbr_input.material.base_color = color;
100
+
101
+ var out: FragmentOutput;
102
+ // apply lighting
103
+ out.color = apply_pbr_lighting(pbr_input);
104
+
105
+ out.color = apply_outline(
106
+ in.position,
107
+ out.color,
108
+ false,
109
+ sample_index,
110
+ );
111
+
112
+ // apply in-shader post processing (fog, alpha-premultiply, and also tonemapping, debanding if the camera is non-hdr)
113
+ // note this does not include fullscreen postprocessing effects like bloom.
114
+ out.color = main_pass_post_lighting_processing(pbr_input, out.color);
115
+
116
+ return out;
117
+ }
@@ -0,0 +1,47 @@
1
+ #import bevy_ui::ui_vertex_output::UiVertexOutput
2
+
3
+ struct SliceData {
4
+ bounds: vec4<f32>,
5
+ surface: vec4<f32>,
6
+ }
7
+
8
+ @group(1) @binding(0) var image_texture: texture_2d<f32>;
9
+ @group(1) @binding(1) var image_sampler: sampler;
10
+ @group(1) @binding(2) var<uniform> slice_data: SliceData;
11
+ @group(1) @binding(3) var<uniform> bg_color: vec4<f32>;
12
+
13
+ @fragment
14
+ fn fragment(in: UiVertexOutput) -> @location(0) vec4<f32> {
15
+ var uv = in.uv;
16
+ let image_size = vec2<f32>(textureDimensions(image_texture));
17
+ let border_size = vec2<f32>(slice_data.bounds.x + slice_data.bounds.z, slice_data.bounds.y + slice_data.bounds.z);
18
+ let position = in.uv * slice_data.surface.xy;
19
+
20
+ if slice_data.surface.x > image_size.x {
21
+ let left = slice_data.bounds.x - position.x;
22
+ let right = position.x - (slice_data.surface.x - slice_data.bounds.z);
23
+
24
+ if left > 0.0 && left > right {
25
+ uv.x = position.x / image_size.x;
26
+ } else if right > 0.0 {
27
+ uv.x = 1.0 - (slice_data.surface.x - position.x) / image_size.x;
28
+ } else {
29
+ uv.x = ((position.x - slice_data.bounds.x) / (slice_data.surface.x - border_size.x) * (image_size.x - border_size.x) + slice_data.bounds.x) / image_size.x;
30
+ }
31
+ }
32
+
33
+ if slice_data.surface.y > image_size.y {
34
+ let top = slice_data.bounds.y - position.y;
35
+ let bottom = position.y - (slice_data.surface.y - slice_data.bounds.w);
36
+
37
+ if top > 0.0 && top > bottom {
38
+ uv.y = position.y / image_size.y;
39
+ } else if bottom > 0.0 {
40
+ uv.y = 1.0 - (slice_data.surface.y - position.y) / image_size.y;
41
+ } else {
42
+ uv.y = ((position.y - slice_data.bounds.y) / (slice_data.surface.y - border_size.y) * (image_size.y - border_size.y) + slice_data.bounds.y) / image_size.y;
43
+ }
44
+ }
45
+
46
+ return textureSample(image_texture, image_sampler, uv) * bg_color;
47
+ }
@@ -0,0 +1,378 @@
1
+ // cloud sampling:
2
+
3
+ // find cloud_floor intersection
4
+ // step through
5
+ // at each point
6
+ // sample once based on xy only -> take as density at lo + 0.25 * (hi-lo)
7
+ // sample again based on xy only -> take as density at lo + 0.75 * (hi-lo)
8
+ // smooth step to get actual density at point
9
+
10
+ struct Nishita {
11
+ ray_origin: vec3<f32>,
12
+ sun_position: vec3<f32>,
13
+ sun_intensity: f32,
14
+ planet_radius: f32,
15
+ atmosphere_radius: f32,
16
+ rayleigh_coefficient: vec3<f32>,
17
+ rayleigh_scale_height: f32,
18
+ mie_coefficient: f32,
19
+ mie_scale_height: f32,
20
+ mie_direction: f32,
21
+ time: f32,
22
+ cloudy: f32,
23
+ tick: u32,
24
+ sun_color: vec3<f32>,
25
+ dir_light_intensity: f32,
26
+ }
27
+
28
+ const PI: f32 = 3.141592653589793;
29
+ const ISTEPS: u32 = 16u;
30
+ const JSTEPS: u32 = 8u;
31
+
32
+ fn rsi(rd: vec3<f32>, r0: vec3<f32>, sr: f32) -> vec2<f32> {
33
+ // ray-sphere intersection that assumes
34
+ // the sphere is centered at the origin.
35
+ // No intersection when result.x > result.y
36
+ let a = dot(rd, rd);
37
+ let b = 2.0 * dot(rd, r0);
38
+ let c = dot(r0, r0) - (sr * sr);
39
+ let d = (b * b) - (4.0 * a * c);
40
+
41
+ if d < 0.0 {
42
+ return vec2<f32>(1e5, -1e5);
43
+ } else {
44
+ return vec2<f32>(
45
+ (-b - sqrt(d)) / (2.0 * a),
46
+ (-b + sqrt(d)) / (2.0 * a)
47
+ );
48
+ }
49
+ }
50
+
51
+ fn render_nishita(r_full: vec3<f32>, r0: vec3<f32>, p_sun_full: vec3<f32>, i_sun: f32, r_planet: f32, r_atmos: f32, k_rlh: vec3<f32>, k_mie: f32, sh_rlh: f32, sh_mie: f32, g: f32) -> vec3<f32> {
52
+ // Normalize the ray direction and sun position.
53
+ let r = normalize(r_full);
54
+ let p_sun = normalize(p_sun_full);
55
+
56
+ // Calculate the step size of the primary ray.
57
+ var p = rsi(r, r0, r_atmos);
58
+ if p.x > p.y { return vec3<f32>(0f); }
59
+ p.y = min(p.y, rsi(r, r0, r_planet).x);
60
+ let i_step_size = (p.y - p.x) / f32(ISTEPS);
61
+
62
+ // Initialize the primary ray depth.
63
+ var i_depth = 0.0;
64
+
65
+ // Initialize accumulators for Rayleigh and Mie scattering.
66
+ var total_rlh = vec3<f32>(0f);
67
+ var total_mie = vec3<f32>(0f);
68
+
69
+ // Initialize optical depth accumulators for the primary ray.
70
+ var i_od_rlh = 0f;
71
+ var i_od_mie = 0f;
72
+
73
+ // Calculate the Rayleigh and Mie phases.
74
+ let mu = dot(r, p_sun);
75
+ let mumu = mu * mu;
76
+ let gg = g * g;
77
+ let p_rlh = 3.0 / (16.0 * PI) * (1.0 + mumu);
78
+ let p_mie = 3.0 / (8.0 * PI) * ((1.0 - gg) * (mumu + 1.0)) / (pow(1.0 + gg - 2.0 * mu * g, 1.5) * (2.0 + gg));
79
+
80
+ // Sample the primary ray.
81
+ for (var i = 0u; i < ISTEPS; i++) {
82
+ // Calculate the primary ray sample position.
83
+ let i_pos = r0 + r * (i_depth + i_step_size * 0.5);
84
+
85
+ // Calculate the height of the sample.
86
+ let i_height = length(i_pos) - r_planet;
87
+
88
+ // Calculate the optical depth of the Rayleigh and Mie scattering for this step.
89
+ let od_step_rlh = exp(-i_height / sh_rlh) * i_step_size;
90
+ let od_step_mie = exp(-i_height / sh_mie) * i_step_size;
91
+
92
+ // Accumulate optical depth.
93
+ i_od_rlh += od_step_rlh;
94
+ i_od_mie += od_step_mie;
95
+
96
+ // Calculate the step size of the secondary ray.
97
+ let j_step_size = rsi(p_sun, i_pos, r_atmos).y / f32(JSTEPS);
98
+
99
+ // Initialize the secondary ray depth.
100
+ var j_depth = 0f;
101
+
102
+ // Initialize optical depth accumulators for the secondary ray.
103
+ var j_od_rlh = 0f;
104
+ var j_od_mie = 0f;
105
+
106
+ // Sample the secondary ray.
107
+ for (var j = 0u; j < JSTEPS; j++) {
108
+
109
+ // Calculate the secondary ray sample position.
110
+ let j_pos = i_pos + p_sun * (j_depth + j_step_size * 0.5);
111
+
112
+ // Calculate the height of the sample.
113
+ let j_height = length(j_pos) - r_planet;
114
+
115
+ // Accumulate the optical depth.
116
+ j_od_rlh += exp(-j_height / sh_rlh) * j_step_size;
117
+ j_od_mie += exp(-j_height / sh_mie) * j_step_size;
118
+
119
+ // Increment the secondary ray depth.
120
+ j_depth += j_step_size;
121
+ }
122
+
123
+ // Calculate attenuation.
124
+ let attn = exp(-(k_mie * (i_od_mie + j_od_mie) + k_rlh * (i_od_rlh + j_od_rlh)));
125
+
126
+ // Accumulate scattering.
127
+ total_rlh += od_step_rlh * attn;
128
+ total_mie += od_step_mie * attn;
129
+
130
+ // Increment the primary ray depth.
131
+ i_depth += i_step_size;
132
+ }
133
+
134
+ // Calculate and return the final color.
135
+ return i_sun * (p_rlh * k_rlh * total_rlh + p_mie * k_mie * total_mie);
136
+ }
137
+
138
+ @group(0) @binding(0) var<uniform> nishita: Nishita;
139
+ @group(0) @binding(1) var noise_texture: texture_2d<f32>;
140
+ @group(0) @binding(2) var noise_sampler: sampler;
141
+
142
+ const CLOUD_LOWER: f32 = 3300.0;
143
+ const CLOUD_UPPER: f32 = 4800.0;
144
+
145
+ fn noise(x: vec2<f32>) -> f32 {
146
+ return textureSampleLevel(noise_texture, noise_sampler, x / 65536.0, 0.0).r;
147
+ }
148
+
149
+ const m: mat3x3<f32> = mat3x3<f32>( 0.00, 0.80, 0.60,
150
+ -0.80, 0.36, -0.48,
151
+ -0.60, -0.48, 0.64 ) * 2.345;
152
+
153
+ fn FBM(p0: vec3<f32>) -> f32 {
154
+ var p = p0;
155
+
156
+ let speed = 2.0;
157
+
158
+ p.x += nishita.time * 3.0 * speed;
159
+
160
+ var f = 0.3750 * noise(p.xz); p = m*p; p.y -= nishita.time * 20.0 * speed;
161
+ f += 0.3750 * noise(p.xz); p = m*p; p.y += nishita.time * 10.0 * speed;
162
+ f += 0.1250 * noise(p.xz); p = m*p; p.x -= nishita.time * 10.0 * speed;
163
+ f += 0.0625 * noise(p.xz); p = m*p;
164
+ f += 0.03125 * noise(p.xz); p = m*p;
165
+ f += 0.015625 * noise(p.xz);
166
+ return f;
167
+ }
168
+
169
+ fn cloudy() -> f32 {
170
+ return (nishita.cloudy - 0.5) * 0.666;
171
+ }
172
+
173
+ fn density(p: vec3<f32>) -> f32 {
174
+ let density = clamp(FBM(p) * 0.5 + cloudy(), 0.0, 1.0);
175
+ let cloud_range = CLOUD_UPPER - CLOUD_LOWER;
176
+ let outside = clamp(abs(clamp(p.y, CLOUD_LOWER + 0.1 * cloud_range, CLOUD_UPPER - 0.1 * cloud_range) - p.y) / (0.1 * cloud_range), 0.0, 1.0);
177
+ return mix(density, 0.0, outside);
178
+ }
179
+
180
+ fn lighting(p: vec3<f32>, dir: vec3<f32>, sun: vec3<f32>) -> f32 {
181
+ let l = density(p + sun * 400.0);
182
+ return clamp(pow(l, 0.25), 0.0, 1.0);
183
+ }
184
+
185
+ const STEPS: u32 = 20u;
186
+
187
+ fn render_cloud(sky: vec3<f32>, pos: vec3<f32>, dir: vec3<f32>) -> vec3<f32> {
188
+ let p_sun = normalize(nishita.sun_position);
189
+ let sun_amount: f32 = max(dot(dir, p_sun), 0.0);
190
+
191
+ var low = ((CLOUD_LOWER-pos.y) / dir.y);
192
+ let high = ((CLOUD_UPPER-pos.y) / dir.y);
193
+
194
+ var p = pos + dir * low;
195
+
196
+ var d = 0.0;
197
+ let add = dir * ((high - low) / f32(STEPS));
198
+ var shade_sum: vec2<f32> = vec2<f32>(0.0);
199
+
200
+ let step_length = length(add);
201
+
202
+ let density_cap = 0.8;
203
+ for (var i = 0u; i < STEPS; i += 1u) {
204
+ if shade_sum.y >= density_cap {
205
+ break;
206
+ }
207
+
208
+ let base_density = clamp(cloudy(), 0.0, 1.0);
209
+ let base_light = pow(base_density, 0.25) * base_density;
210
+
211
+ let sample_density = density(p);
212
+ let sample_light = lighting(p, dir, p_sun) * sample_density;
213
+
214
+ let density = mix(sample_density, base_density, clamp(length(p.xz) / 100000.0, 0.0, 1.0));
215
+ let light = mix(sample_light, base_light, clamp(length(p.xz) / 100000.0, 0.0, 1.0));
216
+
217
+ shade_sum += vec2<f32>(light, density) * (vec2<f32>(1.0) - shade_sum.y);
218
+ p += add;
219
+ }
220
+
221
+ shade_sum /= max(shade_sum.y, density_cap);
222
+
223
+ let light_cloud_color_indirect = max(vec3(0.05), saturate(nishita.sun_color * 1.5) * min(1.0, nishita.dir_light_intensity / 5000.0));
224
+ let light_cloud_color_direct = max(vec3(0.05), saturate(nishita.sun_color * 1.5) * min(nishita.dir_light_intensity / 1000.0, 4.0));
225
+ let light_cloud_color = mix(light_cloud_color_indirect, light_cloud_color_direct, pow(smoothstep(0.8 + (0.1 * shade_sum.y), 1.0, sun_amount), 5.0));
226
+ shade_sum.y = mix(shade_sum.y, sqrt(shade_sum.y), smoothstep(0.9, 1.0, sun_amount));
227
+
228
+ let clouds = mix(light_cloud_color, vec3(0.05), pow(shade_sum.x, 3.0));
229
+ let result = mix(sky, min(clouds, vec3<f32>(1.0)), shade_sum.y);
230
+ return clamp(result, vec3<f32>(0.0), vec3<f32>(1.0));
231
+ }
232
+
233
+ @group(1) @binding(0)
234
+ var image: texture_storage_2d_array<rgba16float, write>;
235
+
236
+ fn hash13(p: vec3<f32>) -> f32 {
237
+ // A common simple hash function
238
+ var p3 = fract(p * vec3<f32>(0.1031, 0.1030, 0.0973));
239
+ p3 = p3 + dot(p3, p3.yzx + 19.19);
240
+ return fract((p3.x + p3.y) * p3.z);
241
+ }
242
+
243
+ @compute @workgroup_size(8, 8, 1)
244
+ fn main(@builtin(global_invocation_id) original_invocation_id: vec3<u32>, @builtin(num_workgroups) num_workgroups: vec3<u32>) {
245
+ let size = textureDimensions(image).x;
246
+ let scale = f32(size) / 2f;
247
+
248
+ // dither pattern for updates
249
+ let tick = nishita.tick & 63;
250
+
251
+ var UPDATE_OFFSETS_X: array<u32,64> = array<u32,64>(
252
+ 0u, 4u, 4u, 0u, 2u, 6u, 6u, 2u, 2u, 6u, 6u, 2u, 0u, 4u, 4u, 0u,
253
+ 1u, 5u, 5u, 1u, 3u, 7u, 7u, 3u, 3u, 7u, 7u, 3u, 1u, 5u, 5u, 1u,
254
+ 1u, 5u, 5u, 1u, 3u, 7u, 7u, 3u, 3u, 7u, 7u, 3u, 1u, 5u, 5u, 1u,
255
+ 0u, 4u, 4u, 0u, 2u, 6u, 6u, 2u, 2u, 6u, 6u, 2u, 0u, 4u, 4u, 0u
256
+ );
257
+
258
+ var UPDATE_OFFSETS_Y: array<u32,64> = array<u32,64>(
259
+ 0u, 4u, 0u, 4u, 2u, 6u, 2u, 6u, 0u, 4u, 0u, 4u, 2u, 6u, 2u, 6u,
260
+ 1u, 5u, 1u, 5u, 3u, 7u, 3u, 7u, 1u, 5u, 1u, 5u, 3u, 7u, 3u, 7u,
261
+ 4u, 0u, 4u, 0u, 6u, 2u, 6u, 2u, 4u, 0u, 4u, 0u, 6u, 2u, 6u, 2u,
262
+ 5u, 1u, 5u, 1u, 7u, 3u, 7u, 3u, 5u, 1u, 5u, 1u, 7u, 3u, 7u, 3u
263
+ );
264
+
265
+ let invocation_id = original_invocation_id * vec3(8, 8, 1) + vec3(UPDATE_OFFSETS_X[tick], UPDATE_OFFSETS_Y[tick], 0);
266
+
267
+ let dir = vec2<f32>((f32(invocation_id.x) / scale) - 1f, (f32(invocation_id.y) / scale) - 1f);
268
+
269
+ var ray: vec3<f32>;
270
+
271
+ switch invocation_id.z {
272
+ case 0u {
273
+ ray = vec3<f32>(1f, -dir.y, -dir.x); // +X
274
+ }
275
+ case 1u {
276
+ ray = vec3<f32>(-1f, -dir.y, dir.x);// -X
277
+ }
278
+ case 2u {
279
+ ray = vec3<f32>(dir.x, 1f, dir.y); // +Y
280
+ }
281
+ case 3u {
282
+ ray = vec3<f32>(dir.x, -1f, -dir.y);// -Y
283
+ }
284
+ case 4u {
285
+ ray = vec3<f32>(dir.x, -dir.y, 1f); // +Z
286
+ }
287
+ default: {
288
+ ray = vec3<f32>(-dir.x, -dir.y, -1f);// -Z
289
+ }
290
+ }
291
+
292
+ var initial_y = normalize(ray).y;
293
+ if ray.y < 0.0 {
294
+ ray.y = 0.0;
295
+ }
296
+ ray = normalize(ray);
297
+
298
+
299
+ var render_base = vec3<f32>(0.0);
300
+
301
+ let fwd = normalize(nishita.sun_position);
302
+ let basis_u = vec3<f32>(0.0, sign(nishita.sun_position.z), 0.0);
303
+ let right = normalize(cross(basis_u, fwd));
304
+ let up = normalize(cross(fwd, right));
305
+ let sun_transform = mat3x3(right, up, fwd);
306
+
307
+ let multiplier = 1.0 + saturate(nishita.dir_light_intensity / 11000.0);
308
+
309
+ if nishita.dir_light_intensity > 0.0 {
310
+ render_base = render_nishita(
311
+ ray,
312
+ nishita.ray_origin,
313
+ nishita.sun_position,
314
+ nishita.sun_intensity * multiplier,
315
+ nishita.planet_radius,
316
+ nishita.atmosphere_radius,
317
+ nishita.rayleigh_coefficient,
318
+ nishita.mie_coefficient,
319
+ nishita.rayleigh_scale_height,
320
+ nishita.mie_scale_height,
321
+ nishita.mie_direction,
322
+ );
323
+
324
+
325
+ // // add sun
326
+ let sun_weight = dot(ray, normalize(nishita.sun_position));
327
+ if sun_weight >= 0.997 {
328
+ render_base = max(render_base, mix(render_base, nishita.sun_color, smoothstep(0.997, 0.999, sun_weight)));
329
+ }
330
+ // sun 2 ..
331
+ let angle = 0.3;
332
+ let cosa = cos(angle);
333
+ let sina = sin(angle);
334
+ let sun_weight_2 = dot(ray, normalize(nishita.sun_position - vec3(0.3, 0.3, 0.3)));
335
+ if sun_weight_2 >= 0.998 {
336
+ render_base = max(render_base, mix(render_base, nishita.sun_color, smoothstep(0.999, 1.0, sun_weight_2)));
337
+ }
338
+ }
339
+
340
+ // stars
341
+ if nishita.dir_light_intensity < 1000.0 {
342
+ for (var i=0u; i<1000u; i++) {
343
+ let star_world_dir = normalize(
344
+ vec3<f32>(
345
+ hash13(vec3::<f32>(17.5, 19.2, -888.2) * f32(i)),
346
+ hash13(vec3::<f32>(117.5, 19.2, -888.2) * f32(i)),
347
+ abs(hash13(vec3::<f32>(217.5, 19.2, -888.2) * f32(i)))
348
+ ) * 2.0 - 1.0
349
+ );
350
+ let star_dir = sun_transform * star_world_dir;
351
+ let stardirdot = dot(normalize(star_dir), ray);
352
+ let hash = hash13(star_world_dir);
353
+ // size range should vary based on resolution of the cubemap
354
+ let size = 0.99995 + 0.000025 * pow(fract(hash * 100000.0), 0.25);
355
+ if stardirdot > size {
356
+ let color = vec3<f32>(0.25 + 0.75 * fract(hash * 1000.0), 0.625 + 0.375 * fract(hash * 1000.0), 1.0);
357
+ let brightness = smoothstep(0.99995 + 0.000025, 0.99995, size);
358
+ render_base += vec3<f32>(
359
+ color
360
+ * clamp(1.0 - nishita.dir_light_intensity / 1000.0, 0.0, 1.0)) // sun brightness
361
+ * brightness // star brightness
362
+ * pow(smoothstep(size, 1.0, stardirdot), 3.0) // distance from middle of the star
363
+ * clamp(ray.y * 10.0, 0.0, 1.0); // distance above horizon
364
+ }
365
+ }
366
+ }
367
+
368
+ let render = render_cloud(render_base, nishita.ray_origin * 0.0, normalize(ray));
369
+
370
+ let store_value = mix(render, vec3(0.0), smoothstep(0.0, -0.5, initial_y));
371
+
372
+ textureStore(
373
+ image,
374
+ vec2<i32>(invocation_id.xy),
375
+ i32(invocation_id.z),
376
+ vec4<f32>(store_value, 1.0)
377
+ );
378
+ }
@@ -0,0 +1,69 @@
1
+ #import bevy_pbr::{
2
+ pbr_types::STANDARD_MATERIAL_FLAGS_EMISSIVE_TEXTURE_BIT,
3
+ mesh_view_bindings::view,
4
+ prepass_utils::{prepass_depth, prepass_normal},
5
+ pbr_types,
6
+ }
7
+
8
+ #ifdef DEPTH_PREPASS
9
+ fn get_depth(pos: vec4<f32>, si: u32) -> f32 {
10
+ return view.clip_from_view[3][2] / prepass_depth(pos, si);
11
+ }
12
+ #endif
13
+
14
+ fn apply_outline(position: vec4<f32>, color_in: vec4<f32>, hilight: bool, sample_index: u32) -> vec4<f32> {
15
+ var out = color_in;
16
+ #ifdef DEPTH_PREPASS
17
+
18
+ var edge1 = false;
19
+ var edge2 = false;
20
+
21
+ let is_orthographic = view.clip_from_view[3].w == 1.0;
22
+ var mid = 0.0;
23
+ if is_orthographic {
24
+ mid = 2.0 / view.clip_from_view[1].y;
25
+ } else {
26
+ mid = get_depth(position, sample_index);
27
+ }
28
+ let width = (1.0 / mid) * view.viewport.z / 640.0;
29
+ let d = clamp(width, 1.0, 5.0);
30
+
31
+ let pxpy = get_depth(position + vec4<f32>(d, d, 0.0, 0.0), sample_index);
32
+ let pxmy = get_depth(position + vec4<f32>(d, -d, 0.0, 0.0), sample_index);
33
+ let mxpy = get_depth(position + vec4<f32>(-d, d, 0.0, 0.0), sample_index);
34
+ let mxmy = get_depth(position + vec4<f32>(-d, -d, 0.0, 0.0), sample_index);
35
+
36
+ let expected = (pxpy + pxmy + mxpy + mxmy) / 4.0;
37
+
38
+ if (expected / mid - 1) > 0.03 {
39
+ edge1 = true;
40
+ }
41
+
42
+ #ifdef NORMAL_PREPASS
43
+ let nd = 1.0;
44
+ let nmid = prepass_normal(position, sample_index);
45
+ let npxpy = prepass_normal(position + vec4<f32>(nd, nd, 0.0, 0.0), sample_index);
46
+ let npxmy = prepass_normal(position + vec4<f32>(nd, -nd, 0.0, 0.0), sample_index);
47
+ let nmxpy = prepass_normal(position + vec4<f32>(-nd, nd, 0.0, 0.0), sample_index);
48
+ let nmxmy = prepass_normal(position + vec4<f32>(-nd, -nd, 0.0, 0.0), sample_index);
49
+
50
+ let nexpected = (npxpy + nmxmy) / 2.0;
51
+ let nexpected2 = (npxmy + nmxpy) / 2.0;
52
+ if length(nmid - nexpected) + length(nmid - nexpected2) > 0.4 {
53
+ edge2 = true;
54
+ }
55
+ #endif
56
+
57
+ var hi = 0.0;
58
+ if hilight {
59
+ hi = 1.0;
60
+ }
61
+ if edge1 {
62
+ out = vec4<f32>(10.0 * hi, 0.0, 0.0, out.a);
63
+ } else if edge2 {
64
+ out = vec4<f32>(out.rgb * vec3<f32>(4.5 * hi + 0.5, 0.5, 0.5), out.a);
65
+ }
66
+ #endif
67
+
68
+ return out;
69
+ }