@dcl-regenesislabs/bevy-explorer-web 0.1.0-18354928058.commit-b951631 → 0.1.0-18381724482.commit-d31fa29

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/.env +1 -1
  2. package/index.html +2 -2
  3. package/main.js +4 -3
  4. package/package.json +3 -3
  5. package/pkg/webgpu_build.d.ts +8 -8
  6. package/pkg/webgpu_build.js +51 -51
  7. package/pkg/webgpu_build_bg.wasm +0 -0
  8. package/pkg/webgpu_build_bg.wasm.d.ts +8 -8
  9. package/assets/animations/Dance_Female.glb +0 -0
  10. package/assets/animations/Dance_Male.glb +0 -0
  11. package/assets/animations/F_FistPump.glb +0 -0
  12. package/assets/animations/F_RobotDance.glb +0 -0
  13. package/assets/animations/Hands_Air.glb +0 -0
  14. package/assets/animations/M_FistPump.glb +0 -0
  15. package/assets/animations/M_RobotDance.glb +0 -0
  16. package/assets/animations/Raise_Hand.glb +0 -0
  17. package/assets/animations/Throw Money-Emote.glb +0 -0
  18. package/assets/animations/Wave_Female.glb +0 -0
  19. package/assets/animations/Wave_Male.glb +0 -0
  20. package/assets/animations/clap.glb +0 -0
  21. package/assets/animations/disco_dance.glb +0 -0
  22. package/assets/animations/dont_wanna_see.glb +0 -0
  23. package/assets/animations/f_head_explode.glb +0 -0
  24. package/assets/animations/idle.glb +0 -0
  25. package/assets/animations/jump2.glb +0 -0
  26. package/assets/animations/kiss.glb +0 -0
  27. package/assets/animations/m_head_explode.glb +0 -0
  28. package/assets/animations/mchammer-dance.glb +0 -0
  29. package/assets/animations/run.glb +0 -0
  30. package/assets/animations/shrug.glb +0 -0
  31. package/assets/animations/tektonik-dance.glb +0 -0
  32. package/assets/animations/thumbnails/clap.png +0 -0
  33. package/assets/animations/thumbnails/dance.png +0 -0
  34. package/assets/animations/thumbnails/disco.png +0 -0
  35. package/assets/animations/thumbnails/dontsee.png +0 -0
  36. package/assets/animations/thumbnails/fistpump.png +0 -0
  37. package/assets/animations/thumbnails/hammer.png +0 -0
  38. package/assets/animations/thumbnails/handsair.png +0 -0
  39. package/assets/animations/thumbnails/headexplode.png +0 -0
  40. package/assets/animations/thumbnails/kiss.png +0 -0
  41. package/assets/animations/thumbnails/money.png +0 -0
  42. package/assets/animations/thumbnails/raisehand.png +0 -0
  43. package/assets/animations/thumbnails/robot.png +0 -0
  44. package/assets/animations/thumbnails/shrug.png +0 -0
  45. package/assets/animations/thumbnails/tektonik.png +0 -0
  46. package/assets/animations/thumbnails/tik.png +0 -0
  47. package/assets/animations/thumbnails/wave.png +0 -0
  48. package/assets/animations/tik-tok-dance.glb +0 -0
  49. package/assets/animations/walk.glb +0 -0
  50. package/assets/fonts/NotoSans-Bold.ttf +0 -0
  51. package/assets/fonts/NotoSans-BoldItalic.ttf +0 -0
  52. package/assets/fonts/NotoSans-Italic.ttf +0 -0
  53. package/assets/fonts/NotoSans-Regular.ttf +0 -0
  54. package/assets/fonts/NotoSansMono-Bold.ttf +0 -0
  55. package/assets/fonts/NotoSansMono-Regular.ttf +0 -0
  56. package/assets/fonts/NotoSerif-Bold.ttf +0 -0
  57. package/assets/fonts/NotoSerif-BoldItalic.ttf +0 -0
  58. package/assets/fonts/NotoSerif-Italic.ttf +0 -0
  59. package/assets/fonts/NotoSerif-Regular.ttf +0 -0
  60. package/assets/fonts/OFL.txt +0 -93
  61. package/assets/images/FriendsIcon.png +0 -0
  62. package/assets/images/ask.png +0 -0
  63. package/assets/images/backpack/Background.jpeg +0 -0
  64. package/assets/images/backpack/empty.png +0 -0
  65. package/assets/images/backpack/item_bg.png +0 -0
  66. package/assets/images/backpack/wearable_categories/body_shape.png +0 -0
  67. package/assets/images/backpack/wearable_categories/earring.png +0 -0
  68. package/assets/images/backpack/wearable_categories/eyebrows.png +0 -0
  69. package/assets/images/backpack/wearable_categories/eyes.png +0 -0
  70. package/assets/images/backpack/wearable_categories/eyewear.png +0 -0
  71. package/assets/images/backpack/wearable_categories/facial_hair.png +0 -0
  72. package/assets/images/backpack/wearable_categories/feet.png +0 -0
  73. package/assets/images/backpack/wearable_categories/hair.png +0 -0
  74. package/assets/images/backpack/wearable_categories/hands_wear.png +0 -0
  75. package/assets/images/backpack/wearable_categories/hat.png +0 -0
  76. package/assets/images/backpack/wearable_categories/helmet.png +0 -0
  77. package/assets/images/backpack/wearable_categories/lower_body.png +0 -0
  78. package/assets/images/backpack/wearable_categories/mask.png +0 -0
  79. package/assets/images/backpack/wearable_categories/mouth.png +0 -0
  80. package/assets/images/backpack/wearable_categories/skin.png +0 -0
  81. package/assets/images/backpack/wearable_categories/tiara.png +0 -0
  82. package/assets/images/backpack/wearable_categories/top_head.png +0 -0
  83. package/assets/images/backpack/wearable_categories/upper_body.png +0 -0
  84. package/assets/images/button copy.png +0 -0
  85. package/assets/images/button.png +0 -0
  86. package/assets/images/button_base.png +0 -0
  87. package/assets/images/chat_button.png +0 -0
  88. package/assets/images/copy.png +0 -0
  89. package/assets/images/crosshair.png +0 -0
  90. package/assets/images/cursor.png +0 -0
  91. package/assets/images/dao_small.png +0 -0
  92. package/assets/images/dcl-godot-bevy.png +0 -0
  93. package/assets/images/discover/art.png +0 -0
  94. package/assets/images/discover/business.png +0 -0
  95. package/assets/images/discover/casino.png +0 -0
  96. package/assets/images/discover/crypto.png +0 -0
  97. package/assets/images/discover/education.png +0 -0
  98. package/assets/images/discover/eye.png +0 -0
  99. package/assets/images/discover/fashion.png +0 -0
  100. package/assets/images/discover/featured.png +0 -0
  101. package/assets/images/discover/game.png +0 -0
  102. package/assets/images/discover/icons.png +0 -0
  103. package/assets/images/discover/music.png +0 -0
  104. package/assets/images/discover/point of interest.png +0 -0
  105. package/assets/images/discover/shop.png +0 -0
  106. package/assets/images/discover/social.png +0 -0
  107. package/assets/images/discover/sports.png +0 -0
  108. package/assets/images/discover/thumbsup.png +0 -0
  109. package/assets/images/emote-button-background.png +0 -0
  110. package/assets/images/emote_button.png +0 -0
  111. package/assets/images/genesis_tx.png +0 -0
  112. package/assets/images/grid.png +0 -0
  113. package/assets/images/grip.png +0 -0
  114. package/assets/images/left-arrow.png +0 -0
  115. package/assets/images/line.png +0 -0
  116. package/assets/images/mic_button_inactive.png +0 -0
  117. package/assets/images/mic_button_off.png +0 -0
  118. package/assets/images/mic_button_on.png +0 -0
  119. package/assets/images/next.png +0 -0
  120. package/assets/images/person.png +0 -0
  121. package/assets/images/person_button.png +0 -0
  122. package/assets/images/profile_button.png +0 -0
  123. package/assets/images/redx.png +0 -0
  124. package/assets/images/right-arrow.png +0 -0
  125. package/assets/images/screenshots/montage.png +0 -0
  126. package/assets/images/screenshots/screenshot%2Fbevy_snapshot_avatar_attach_1.png.png +0 -0
  127. package/assets/images/screenshots/screenshot%2Fbevy_snapshot_avatar_attach_2.png.png +0 -0
  128. package/assets/images/screenshots/screenshot%2Fbevy_snapshot_avatar_attach_3.png.png +0 -0
  129. package/assets/images/screenshots/screenshot%2Fbevy_snapshot_avatar_attach_4.png.png +0 -0
  130. package/assets/images/screenshots/screenshot%2Fbevy_snapshot_gltfcontainer_avocado.png.png +0 -0
  131. package/assets/images/screenshots/screenshot%2Fbevy_snapshot_gltfcontainer_hev.png.png +0 -0
  132. package/assets/images/screenshots/screenshot%2Fbevy_snapshot_material_01.png.png +0 -0
  133. package/assets/images/screenshots/screenshot%2Fbevy_snapshot_material_02.png.png +0 -0
  134. package/assets/images/screenshots/screenshot%2Fbevy_snapshot_material_03.png.png +0 -0
  135. package/assets/images/screenshots/screenshot%2Fbevy_snapshot_material_04.png.png +0 -0
  136. package/assets/images/screenshots/screenshot%2Fbevy_snapshot_material_05.png.png +0 -0
  137. package/assets/images/screenshots/screenshot%2Fbevy_snapshot_material_06.png.png +0 -0
  138. package/assets/images/screenshots/screenshot%2Fbevy_snapshot_material_07.png.png +0 -0
  139. package/assets/images/screenshots/screenshot%2Fbevy_snapshot_material_08.png.png +0 -0
  140. package/assets/images/screenshots/screenshot%2Fbevy_snapshot_material_09.png.png +0 -0
  141. package/assets/images/screenshots/screenshot%2Fbevy_snapshot_material_10.png.png +0 -0
  142. package/assets/images/screenshots/screenshot%2Fbevy_snapshot_material_11.png.png +0 -0
  143. package/assets/images/screenshots/screenshot%2Fbevy_snapshot_material_12.png.png +0 -0
  144. package/assets/images/screenshots/screenshot%2Fbevy_snapshot_material_13.png.png +0 -0
  145. package/assets/images/screenshots/screenshot%2Fbevy_snapshot_material_14.png.png +0 -0
  146. package/assets/images/screenshots/screenshot%2Fbevy_snapshot_mesh_renderer_box.png.png +0 -0
  147. package/assets/images/screenshots/screenshot%2Fbevy_snapshot_mesh_renderer_cylinder.png.png +0 -0
  148. package/assets/images/screenshots/screenshot%2Fbevy_snapshot_mesh_renderer_plane.png.png +0 -0
  149. package/assets/images/screenshots/screenshot%2Fbevy_snapshot_mesh_renderer_sphere.png.png +0 -0
  150. package/assets/images/screenshots/screenshot%2Fbevy_snapshot_text_shape_1.png.png +0 -0
  151. package/assets/images/screenshots/screenshot%2Fbevy_snapshot_text_shape_2.png.png +0 -0
  152. package/assets/images/screenshots/screenshot%2Fbevy_snapshot_text_shape_3.png.png +0 -0
  153. package/assets/images/screenshots/screenshot%2Fbevy_snapshot_text_shape_4.png.png +0 -0
  154. package/assets/images/screenshots/screenshot%2Fbevy_snapshot_text_shape_5.png.png +0 -0
  155. package/assets/images/screenshots/screenshot%2Fbevy_snapshot_text_shape_6.png.png +0 -0
  156. package/assets/images/screenshots/screenshot%2Fbevy_snapshot_ui_background_all_screen_green.png.png +0 -0
  157. package/assets/images/screenshots/screenshot%2Fbevy_snapshot_ui_background_all_screen_red.png.png +0 -0
  158. package/assets/images/screenshots/screenshot%2Fbevy_snapshot_ui_background_all_screen_rocks.png.png +0 -0
  159. package/assets/images/screenshots/screenshot%2Fbevy_snapshot_ui_text_1.png.png +0 -0
  160. package/assets/images/screenshots/screenshot%2Fbevy_snapshot_ui_text_2.png.png +0 -0
  161. package/assets/images/screenshots/screenshot%2Fbevy_snapshot_video_player_1.png.png +0 -0
  162. package/assets/images/screenshots/screenshot%2Fbevy_snapshot_video_player_2.png.png +0 -0
  163. package/assets/images/screenshots/screenshot%2Fbevy_snapshot_video_player_3.png.png +0 -0
  164. package/assets/images/screenshots/screenshot%2Fbevy_snapshot_video_player_4.png.png +0 -0
  165. package/assets/images/screenshots/screenshot%2Fbevy_snapshot_visibility_false.png.png +0 -0
  166. package/assets/images/screenshots/screenshot%2Fbevy_snapshot_visibility_true.png.png +0 -0
  167. package/assets/images/skybox/skybox_cubemap.png +0 -0
  168. package/assets/images/skybox/skybox_cubemap_original.png +0 -0
  169. package/assets/images/spinner.png +0 -0
  170. package/assets/images/spinner_atlas.png +0 -0
  171. package/assets/images/tick.png +0 -0
  172. package/assets/images/toggle-off.png +0 -0
  173. package/assets/images/toggle-on.png +0 -0
  174. package/assets/images/unknown_person.png +0 -0
  175. package/assets/images/you_are_here.png +0 -0
  176. package/assets/nft_shapes/Baroque_Ornament.glb +0 -0
  177. package/assets/nft_shapes/Blocky.glb +0 -0
  178. package/assets/nft_shapes/Canvas.glb +0 -0
  179. package/assets/nft_shapes/Classic.glb +0 -0
  180. package/assets/nft_shapes/Diamond_Ornament.glb +0 -0
  181. package/assets/nft_shapes/Floor_Wood01.png +0 -0
  182. package/assets/nft_shapes/Genesis_TX.png +0 -0
  183. package/assets/nft_shapes/Gold_Carved.glb +0 -0
  184. package/assets/nft_shapes/Gold_Edges.glb +0 -0
  185. package/assets/nft_shapes/Gold_Rounded.glb +0 -0
  186. package/assets/nft_shapes/Gold_Wide.glb +0 -0
  187. package/assets/nft_shapes/Metal_Medium.glb +0 -0
  188. package/assets/nft_shapes/Metal_Rounded.glb +0 -0
  189. package/assets/nft_shapes/Metal_Slim.glb +0 -0
  190. package/assets/nft_shapes/Metal_Wide.glb +0 -0
  191. package/assets/nft_shapes/Minimal_Black.glb +0 -0
  192. package/assets/nft_shapes/Minimal_Grey.glb +0 -0
  193. package/assets/nft_shapes/Minimal_White.glb +0 -0
  194. package/assets/nft_shapes/Minimal_Wide.glb +0 -0
  195. package/assets/nft_shapes/MulticolorDotsLoading.png +0 -0
  196. package/assets/nft_shapes/NFTIcon.png +0 -0
  197. package/assets/nft_shapes/NoneIcon.png +0 -0
  198. package/assets/nft_shapes/Pins.glb +0 -0
  199. package/assets/nft_shapes/Tape.glb +0 -0
  200. package/assets/nft_shapes/Wood_Slim.glb +0 -0
  201. package/assets/nft_shapes/Wood_Twigs.glb +0 -0
  202. package/assets/nft_shapes/Wood_Wide.glb +0 -0
  203. package/assets/shaders/bound_material.wgsl +0 -183
  204. package/assets/shaders/bound_material_baker.wgsl +0 -145
  205. package/assets/shaders/bound_node.wgsl +0 -57
  206. package/assets/shaders/bound_prepass.wgsl +0 -160
  207. package/assets/shaders/floor_bake.wgsl +0 -30
  208. package/assets/shaders/floor_fragment.wgsl +0 -74
  209. package/assets/shaders/floor_vertex.wgsl +0 -47
  210. package/assets/shaders/loading.wgsl +0 -35
  211. package/assets/shaders/mask_material.wgsl +0 -117
  212. package/assets/shaders/nineslice_material.wgsl +0 -47
  213. package/assets/shaders/nishita_cloud.wgsl +0 -378
  214. package/assets/shaders/outline.wgsl +0 -69
  215. package/assets/shaders/simplex.wgsl +0 -77
  216. package/assets/shaders/stretch_uv_material.wgsl +0 -79
  217. package/assets/shaders/text_quad_vertex.wgsl +0 -78
  218. package/assets/sounds/avatar/avatar_footstep_jump01.wav +0 -0
  219. package/assets/sounds/avatar/avatar_footstep_jump02.wav +0 -0
  220. package/assets/sounds/avatar/avatar_footstep_jump03.wav +0 -0
  221. package/assets/sounds/avatar/avatar_footstep_land01.wav +0 -0
  222. package/assets/sounds/avatar/avatar_footstep_land02.wav +0 -0
  223. package/assets/sounds/avatar/avatar_footstep_run01.wav +0 -0
  224. package/assets/sounds/avatar/avatar_footstep_run02.wav +0 -0
  225. package/assets/sounds/avatar/avatar_footstep_run03.wav +0 -0
  226. package/assets/sounds/avatar/avatar_footstep_run04.wav +0 -0
  227. package/assets/sounds/avatar/avatar_footstep_run05.wav +0 -0
  228. package/assets/sounds/avatar/avatar_footstep_run06.wav +0 -0
  229. package/assets/sounds/avatar/avatar_footstep_run07.wav +0 -0
  230. package/assets/sounds/avatar/avatar_footstep_run08.wav +0 -0
  231. package/assets/sounds/avatar/avatar_footstep_walk01.wav +0 -0
  232. package/assets/sounds/avatar/avatar_footstep_walk02.wav +0 -0
  233. package/assets/sounds/avatar/avatar_footstep_walk03.wav +0 -0
  234. package/assets/sounds/avatar/avatar_footstep_walk04.wav +0 -0
  235. package/assets/sounds/avatar/avatar_footstep_walk05.wav +0 -0
  236. package/assets/sounds/avatar/avatar_footstep_walk06.wav +0 -0
  237. package/assets/sounds/avatar/avatar_footstep_walk07.wav +0 -0
  238. package/assets/sounds/avatar/avatar_footstep_walk08.wav +0 -0
  239. package/assets/sounds/ui/generic_button_hover.wav +0 -0
  240. package/assets/sounds/ui/generic_button_press.wav +0 -0
  241. package/assets/sounds/ui/mainmenu_widget_open.wav +0 -0
  242. package/assets/sounds/ui/toggle_disable.wav +0 -0
  243. package/assets/sounds/ui/toggle_enable.wav +0 -0
  244. package/assets/sounds/ui/voice_chat_mic_off.wav +0 -0
  245. package/assets/sounds/ui/voice_chat_mic_on.wav +0 -0
  246. package/assets/sounds/ui/widget_chat_message_private_send.wav +0 -0
  247. package/assets/sounds/ui/widget_emotes_close.wav +0 -0
  248. package/assets/sounds/ui/widget_emotes_highlight.wav +0 -0
  249. package/assets/sounds/ui/widget_emotes_open.wav +0 -0
  250. package/assets/ui/app_settings.dui +0 -91
  251. package/assets/ui/avatar.dui +0 -18
  252. package/assets/ui/button.dui +0 -78
  253. package/assets/ui/change-realm.dui +0 -46
  254. package/assets/ui/chat.dui +0 -182
  255. package/assets/ui/combo.dui +0 -23
  256. package/assets/ui/dialog.dui +0 -46
  257. package/assets/ui/discover.dui +0 -139
  258. package/assets/ui/emote-select.dui +0 -45
  259. package/assets/ui/emote.dui +0 -116
  260. package/assets/ui/foreign-profile-dialog.dui +0 -18
  261. package/assets/ui/fullscreen-block.dui +0 -12
  262. package/assets/ui/login.dui +0 -72
  263. package/assets/ui/map.dui +0 -8
  264. package/assets/ui/minimap.dui +0 -16
  265. package/assets/ui/motd.dui +0 -25
  266. package/assets/ui/nft-dialog.dui +0 -29
  267. package/assets/ui/oow.dui +0 -41
  268. package/assets/ui/permissions-dialog.dui +0 -39
  269. package/assets/ui/permissions.dui +0 -54
  270. package/assets/ui/profile-detail.dui +0 -24
  271. package/assets/ui/profile.dui +0 -29
  272. package/assets/ui/spinner.dui +0 -3
  273. package/assets/ui/toast.dui +0 -27
  274. package/assets/ui/tracker.dui +0 -21
  275. package/assets/ui/update.dui +0 -16
  276. package/assets/ui/utils.dui +0 -40
  277. package/assets/ui/wearables.dui +0 -134
@@ -1,378 +0,0 @@
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
- }
@@ -1,69 +0,0 @@
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
- }
@@ -1,77 +0,0 @@
1
- // simplex noise
2
- fn simplex_noise_3d(v: vec3<f32>) -> f32 {
3
- let C = vec2(1. / 6., 1. / 3.);
4
- let D = vec4(0., 0.5, 1., 2.);
5
-
6
- // first corner
7
- var i = floor(v + dot(v, C.yyy));
8
- let x0 = v - i + dot(i, C.xxx);
9
-
10
- // other corners
11
- let g = step(x0.yzx, x0.xyz);
12
- let l = 1. - g;
13
- let i1 = min(g.xyz, l.zxy);
14
- let i2 = max(g.xyz, l.zxy);
15
-
16
- // x0 = x0 - 0. + 0. * C
17
- let x1 = x0 - i1 + 1. * C.xxx;
18
- let x2 = x0 - i2 + 2. * C.xxx;
19
- let x3 = x0 - 1. + 3. * C.xxx;
20
-
21
- // permutations
22
- i = i % vec3(289.);
23
- let p = permute_4_(permute_4_(permute_4_(
24
- i.z + vec4(0., i1.z, i2.z, 1.)) +
25
- i.y + vec4(0., i1.y, i2.y, 1.)) +
26
- i.x + vec4(0., i1.x, i2.x, 1.)
27
- );
28
-
29
- // gradients (NxN points uniformly over a square, mapped onto an octahedron)
30
- let n_ = 1. / 7.; // N=7
31
- let ns = n_ * D.wyz - D.xzx;
32
-
33
- let j = p - 49. * floor(p * ns.z * ns.z); // mod(p, N*N)
34
-
35
- let x_ = floor(j * ns.z);
36
- let y_ = floor(j - 7. * x_); // mod(j, N)
37
-
38
- let x = x_ * ns.x + ns.yyyy;
39
- let y = y_ * ns.x + ns.yyyy;
40
- let h = 1. - abs(x) - abs(y);
41
-
42
- let b0 = vec4(x.xy, y.xy);
43
- let b1 = vec4(x.zw, y.zw);
44
-
45
- let s0 = floor(b0) * 2. + 1.;
46
- let s1 = floor(b1) * 2. + 1.;
47
- let sh = -step(h, vec4(0.));
48
-
49
- let a0 = b0.xzyw + s0.xzyw * sh.xxyy;
50
- let a1 = b1.xzyw + s1.xzyw * sh.zzww;
51
-
52
- var p0 = vec3(a0.xy, h.x);
53
- var p1 = vec3(a0.zw, h.y);
54
- var p2 = vec3(a1.xy, h.z);
55
- var p3 = vec3(a1.zw, h.w);
56
-
57
- // normalize gradients
58
- let norm = taylor_inv_sqrt_4_(vec4(dot(p0, p0), dot(p1, p1), dot(p2, p2), dot(p3, p3)));
59
- p0 = p0 * norm.x;
60
- p1 = p1 * norm.y;
61
- p2 = p2 * norm.z;
62
- p3 = p3 * norm.w;
63
-
64
- // mix final noise value
65
- var m = 0.6 - vec4(dot(x0, x0), dot(x1, x1), dot(x2, x2), dot(x3, x3));
66
- m = max(m, vec4(0.));
67
- m *= m;
68
- return 42. * dot(m * m, vec4(dot(p0, x0), dot(p1, x1), dot(p2, x2), dot(p3, x3)));
69
- }
70
-
71
- fn permute_4_(x: vec4<f32>) -> vec4<f32> {
72
- return ((x * 34. + 1.) * x) % vec4<f32>(289.);
73
- }
74
-
75
- fn taylor_inv_sqrt_4_(r: vec4<f32>) -> vec4<f32> {
76
- return 1.79284291400159 - 0.85373472095314 * r;
77
- }
@@ -1,79 +0,0 @@
1
- #import bevy_ui::ui_vertex_output::UiVertexOutput
2
-
3
- @group(1) @binding(0) var image_texture: texture_2d<f32>;
4
- @group(1) @binding(1) var image_sampler: sampler;
5
- @group(1) @binding(2) var<uniform> uvs: array<vec4<f32>,2>;
6
- @group(1) @binding(3) var<uniform> color: vec4<f32>;
7
-
8
- fn sd_rounded_box(point: vec2<f32>, size: vec2<f32>, corner_radii: vec4<f32>) -> f32 {
9
- // If 0.0 < y then select bottom left (w) and bottom right corner radius (z).
10
- // Else select top left (x) and top right corner radius (y).
11
- let rs = select(corner_radii.xy, corner_radii.wz, 0.0 < point.y);
12
- // w and z are swapped above so that both pairs are in left to right order, otherwise this second
13
- // select statement would return the incorrect value for the bottom pair.
14
- let radius = select(rs.x, rs.y, 0.0 < point.x);
15
- // Vector from the corner closest to the point, to the point.
16
- let corner_to_point = abs(point) - 0.5 * size;
17
- // Vector from the center of the radius circle to the point.
18
- let q = corner_to_point + radius;
19
- // Length from center of the radius circle to the point, zeros a component if the point is not
20
- // within the quadrant of the radius circle that is part of the curved corner.
21
- let l = length(max(q, vec2(0.0)));
22
- let m = min(max(q.x, q.y), 0.0);
23
- return l + m - radius;
24
- }
25
-
26
- fn sd_inset_rounded_box(point: vec2<f32>, size: vec2<f32>, radius: vec4<f32>, inset: vec4<f32>) -> f32 {
27
- let inner_size = size - inset.xy - inset.zw;
28
- let inner_center = inset.xy + 0.5 * inner_size - 0.5 * size;
29
- let inner_point = point - inner_center;
30
-
31
- var r = radius;
32
-
33
- // Top left corner.
34
- r.x = r.x - max(inset.x, inset.y);
35
-
36
- // Top right corner.
37
- r.y = r.y - max(inset.z, inset.y);
38
-
39
- // Bottom right corner.
40
- r.z = r.z - max(inset.z, inset.w);
41
-
42
- // Bottom left corner.
43
- r.w = r.w - max(inset.x, inset.w);
44
-
45
- let half_size = inner_size * 0.5;
46
- let min_size = min(half_size.x, half_size.y);
47
-
48
- r = min(max(r, vec4(0.0)), vec4<f32>(min_size));
49
-
50
- return sd_rounded_box(inner_point, inner_size, r);
51
- }
52
-
53
- fn draw(in: UiVertexOutput, color: vec4<f32>) -> vec4<f32> {
54
- // Signed distances. The magnitude is the distance of the point from the edge of the shape.
55
- // * Negative values indicate that the point is inside the shape.
56
- // * Zero values indicate the point is on the edge of the shape.
57
- // * Positive values indicate the point is outside the shape.
58
-
59
- let point = (in.uv - vec2<f32>(0.5)) * in.size;
60
-
61
- // Signed distance from the border's internal edge (the signed distance is negative if the point
62
- // is inside the rect but not on the border).
63
- // If the border size is set to zero, this is the same as the external distance.
64
- let internal_distance = -sd_inset_rounded_box(point, in.size, in.border_radius, in.border_widths);
65
-
66
- let t = saturate(internal_distance + 1.0);
67
-
68
- return vec4(color.rgb, saturate(color.a * t));
69
- }
70
-
71
- @fragment
72
- fn fragment(in: UiVertexOutput) -> @location(0) vec4<f32> {
73
- // this is a bit lazy; really we should find a way to push the uvs directly into the vertex buffer
74
- let uv = mix(mix(uvs[0].xy, uvs[1].zw, in.uv.x), mix(uvs[0].zw, uvs[1].xy, in.uv.x), 1.0 - in.uv.y) * vec2<f32>(1.0, -1.0) + vec2<f32>(0.0, 1.0);
75
-
76
- let texture_color = textureSample(image_texture, image_sampler, uv) * color;
77
- return draw(in, texture_color);
78
- // return texture_color;
79
- }
@@ -1,78 +0,0 @@
1
- #import bevy_pbr::{
2
- mesh_functions,
3
- view_transformations::position_world_to_clip,
4
- pbr_bindings::base_color_texture,
5
- mesh_view_bindings::view,
6
- }
7
- #import bevy_render::instance_index::get_instance_index
8
-
9
- #ifdef PREPASS_PIPELINE
10
- #import bevy_pbr::prepass_io::{Vertex, VertexOutput};
11
- #else
12
- #import bevy_pbr::forward_io::{Vertex, VertexOutput};
13
- #endif
14
-
15
- struct TextQuadData {
16
- uvs: vec4<f32>,
17
- valign: f32,
18
- halign: f32,
19
- pix_per_m: f32,
20
- add_y_pix: f32,
21
- vertex_billboard: u32,
22
- }
23
-
24
- @group(2) @binding(200)
25
- var<uniform> quad_data: TextQuadData;
26
-
27
- @vertex
28
- fn vertex(vertex_no_morph: Vertex) -> VertexOutput {
29
- var out: VertexOutput;
30
- var vertex = vertex_no_morph;
31
-
32
- // Use vertex_no_morph.instance_index instead of vertex.instance_index to work around a wgpu dx12 bug.
33
- // See https://github.com/gfx-rs/naga/issues/2416 .
34
- var model = mesh_functions::get_world_from_local(vertex_no_morph.instance_index);
35
-
36
- // we assume a quad with [-0.5, 0.5] bounds in x,y and 0 in z
37
- // then we take the pixels per meter and texture size to determine where the vertices should lie
38
- let tex_dims = textureDimensions(base_color_texture);
39
- let region_dims = quad_data.uvs.zw - quad_data.uvs.xy;
40
- let modified_vertex_position = vec3<f32>(
41
- (vertex.position.x + quad_data.halign) * f32(region_dims.x) / quad_data.pix_per_m,
42
- ((vertex.position.y + quad_data.valign) * f32(region_dims.y) + quad_data.add_y_pix) / quad_data.pix_per_m,
43
- 0.0
44
- );
45
-
46
- if (quad_data.vertex_billboard == 1u) {
47
- out.world_position = mesh_functions::mesh_position_local_to_world(
48
- mat4x4<f32>(
49
- vec4<f32>(view.world_from_view[0].xyz, 0.0),
50
- vec4<f32>(view.world_from_view[1].xyz, 0.0),
51
- vec4<f32>(view.world_from_view[2].xyz, 0.0),
52
- vec4<f32>(model[3].xyz, 1.0)
53
- ),
54
- vec4<f32>(modified_vertex_position, 1.0)
55
- );
56
- } else {
57
- out.world_position = mesh_functions::mesh_position_local_to_world(model, vec4<f32>(modified_vertex_position, 1.0));
58
- }
59
- out.position = position_world_to_clip(out.world_position.xyz);
60
-
61
- out.uv = mix(quad_data.uvs.xy, quad_data.uvs.zw, vertex.uv) / vec2<f32>(tex_dims.xy);
62
-
63
- // Use vertex_no_morph.instance_index instead of vertex.instance_index to work around a wgpu dx12 bug.
64
- // See https://github.com/gfx-rs/naga/issues/2416
65
- out.instance_index = vertex_no_morph.instance_index;
66
-
67
-
68
- #ifdef NORMAL_PREPASS_OR_DEFERRED_PREPASS
69
- out.world_normal = mesh_functions::mesh_normal_local_to_world(
70
- vertex.normal,
71
- // Use vertex_no_morph.instance_index instead of vertex.instance_index to work around a wgpu dx12 bug.
72
- // See https://github.com/gfx-rs/naga/issues/2416
73
- vertex_no_morph.instance_index
74
- );
75
- #endif // NORMAL_PREPASS_OR_DEFERRED_PREPASS
76
-
77
- return out;
78
- }