Skip to content

Commit

Permalink
Merge branch 'main' into deploy
Browse files Browse the repository at this point in the history
  • Loading branch information
arcadeperfect committed Dec 6, 2024
2 parents 0803c28 + 3dc8e42 commit d87fc05
Show file tree
Hide file tree
Showing 7 changed files with 379 additions and 189 deletions.
76 changes: 76 additions & 0 deletions index copy.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,76 @@
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Bevy Compute Shader</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">
<span class="nav-links">
<a href="https://alexharding.ooo" class="nice-links">alexharding.ooo</a>
&nbsp;&nbsp;&nbsp;
<a href="https://bsky.app/profile/alexharding.bsky.social" class="nice-links">bluesky</a>
</span>
<p>Experiment with compute shader</p>

<div id="wasm-container" tabindex="-1"></div>
<br>
<h2><a href="https://github.com/arcadeperfect/bevy_compute_shader">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> -->

</div>
</div>

<script type="module">
import init from './out/bevy_compute_shader.js';

async function run() {
window.scrollTo(0, 0);

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.setAttribute('tabindex', '-1');

const originalFocus = node.focus.bind(node);
node.focus = function() {
const scrollPos = window.scrollY;
originalFocus();
requestAnimationFrame(() => window.scrollTo(0, scrollPos));
};

node.style.width = '100%';
node.style.height = '100%';
wasmContainer.appendChild(node);
observer.disconnect();
}
}
}
});

observer.observe(document.body, { childList: true });

await init();
}

if ('scrollRestoration' in history) {
history.scrollRestoration = 'manual';
}

if (document.readyState === 'complete') {
run();
} else {
window.addEventListener('load', run);
}
</script>
</body>
</html>
21 changes: 16 additions & 5 deletions index.html
Original file line number Diff line number Diff line change
Expand Up @@ -3,23 +3,34 @@
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Bevy Compute Shader</title>
<title>Compute Shader</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">
<p>Experiment with compute shader</p>

<span class="nav-links">
<a href="https://alexharding.ooo" class="nice-links">alexharding.ooo</a>
&nbsp;&nbsp;&nbsp;
<a href="https://bsky.app/profile/alexharding.bsky.social" class="nice-links">bluesky</a>
</span>
<h1 class="main-heading">Bevy Compute Shader Thing</h1>
<div id="wasm-container" tabindex="-1"></div>
<br>
<p>Yeah wasm bindgen always makes it scroll to the bottom. I'm not ready to look into this. Scroll up ↑ 𓆩♡𓆪</p>
<h2><a href="https://github.com/arcadeperfect/bevy_compute_shader">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> -->

<p>Side project to learn some compute shader stuff</a>.</p>
<p>Wasm bindgen always makes it scroll to the bottom. I'm not ready to look into this. Scroll up ↑ 𓆩♡𓆪</p>
<span class="nav-links">
<a href="https://alexharding.ooo" class="nice-links">alexharding.ooo</a>
&nbsp;&nbsp;&nbsp;
<a href="https://bsky.app/profile/alexharding.bsky.social" class="nice-links">bluesky</a>
</span>
<br>
<br>
</div>

</div>
Expand Down
12 changes: 10 additions & 2 deletions src/gui.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
use bevy::prelude::*;
use bevy_egui::{egui, EguiContexts};

use crate::ParamsUniform;
use crate::{ParamsUniform, ShaderConfigurator};

#[derive(Event)]
pub struct ParamsChanged {
Expand All @@ -22,6 +22,7 @@ fn ui_system(
mut contexts: EguiContexts,
// mut param_events: EventWriter<ParamsChanged>,
mut params: ResMut<ParamsUniform>,
mut shader_configurator: ResMut<ShaderConfigurator>,
) {
// let mut radius = params.radius;

Expand All @@ -37,7 +38,14 @@ fn ui_system(
ui.add(egui::Slider::new(&mut params.noise_scale, 0.0..=2.).text("scale"));
ui.add(egui::Slider::new(&mut params.noise_offset, 0.0..=20.).text("offset"));
ui.add(egui::Slider::new(&mut params.warp_amount, 0.0..=0.2).text("warp amount"));
ui.add(egui::Slider::new(&mut params.warp_scale, 1.0..=20.).text("warp scale"));
ui.add(egui::Slider::new(&mut params.warp_scale, 1.0..=20.).text("warp scale"));
ui.horizontal(|ui| {
ui.label("war iterations");
ui.add(
egui::DragValue::new(&mut shader_configurator.shader_configs[1].iterations)
.range(0..=50),
);
});
});
});
}
Loading

0 comments on commit d87fc05

Please sign in to comment.