-
Notifications
You must be signed in to change notification settings - Fork 1
/
index copy.html
105 lines (93 loc) · 4.94 KB
/
index copy.html
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Bevy Vaporwave</title>
<link rel="stylesheet" href="styles.css">
<link href="https://fonts.googleapis.com/css2?family=Roboto:wght@400;700&family=Roboto+Mono&display=swap"
rel="stylesheet">
</head>
<body class="color-scheme-home">
<div class="grid">
<div class="main-column">
<!-- <a href="https://alexharding.ooo" class="back-arrow">alexharding.ooo</a> <a href="https://bsky.app/profile/alexharding.bsky.social" class="back-arrow">bluesky</a> -->
<span class="nav-links">
<a href="https://alexharding.ooo" class="nice-links">alexharding.ooo</a>
<a href="https://bsky.app/profile/alexharding.bsky.social" class="nice-links">bluesky</a>
</span>
<h1 class="main-heading">Bevy Vaporwave</h1>
<div id="wasm-container"></div>
<br>
<h2><a href="https://github.com/arcadeperfect/bevy_vaporwave">Github</a></h2>
<br>
<p>Side project to learn the basics of wgsl and develop a look for my <a href="https://alexharding.ooo/posts/Rustroneer/">main Bevy project</a>.</p>
<br>
<p>The code is pretty garbage. I doubt I will continue work on this, but I will roll what I learned into the main project and hopefully it will be better that time. If you're intetested though the repo is public.</p>
<br>
<p>Features:</p>
<ul>
<li>Arbitrarily define edges to render, not render every triangle </li>
<li>Varying colors per mesh, no textures</li>
<li>Optionally "Solid" wireframe, ie it occludes its own back faces and objects behind it</li>
<li>Outline for silhouette when visible edges are sparse</li>
<li>Support gltf animation</li>
</ul>
<br>
<p>I developed a simple workflow with Blender which allows you to mark edges for rendering, paint vertex colors and store the data in a custom gltf attribute (see video below). It isn't great but it does the job. The blender files and a python script are in the repo. Bevy then builds a mesh out of line primitives for the wireframe and uses the original mesh for a fill. The mesh is duplicated, dilated along normals and pushed backwards in clip space by a shader to create the outline.</p>
<br>
<p>Issues:</p>
<ul>
<li>Wireframe thickness cannot be set because this is not supported by wgpu line primitives</li>
<li>Clip space method for outline isn't ideal, a stencil buffer approach would be better but I couldn't work out how to do that with wgpu / bevy render pipeline</li>
<li>Assets are post processed in a system triggered by SceneInstanceReady events. Something that ties into Bevy's async asset loading would be much better </li>
<li>The mesh building algorithm is very slow with large meshes</li>
</ul>
<br>
<h2>Blender Workflow</h2>
<div class="video-wrapper">
<iframe
src="https://www.youtube.com/embed/rfDhslnPBpA?si=I2cgElg45rW-49li&autoplay=1&mute=1"
title="YouTube video player"
frameborder="0"
allow="accelerometer; autoplay; clipboard-write; encrypted-media; gyroscope; picture-in-picture; web-share"
referrerpolicy="strict-origin-when-cross-origin"
allowfullscreen
></iframe>
</div>
<br>
<br>
<span class="nav-links">
<a href="https://alexharding.ooo" class="nice-links">alexharding.ooo</a>
<a href="https://bsky.app/profile/alexharding.bsky.social" class="nice-links">bluesky</a>
</span>
<br>
<br>
</div>
</div>
</div>
<script type="module">
import init from './out/bevy_vaporwave.js';
async function run() {
const wasmContainer = document.getElementById('wasm-container');
const observer = new MutationObserver((mutations) => {
for (let mutation of mutations) {
for (let node of mutation.addedNodes) {
if (node.tagName === 'CANVAS') {
node.style.width = '100%';
node.style.height = '100%';
wasmContainer.appendChild(node);
observer.disconnect();
}
}
}
});
observer.observe(document.body, { childList: true });
await init();
}
run();
</script>
</body>
</html>