Skip to content

Commit

Permalink
exampes fixes and cleanup
Browse files Browse the repository at this point in the history
  • Loading branch information
MagnusThor committed May 7, 2024
1 parent 77c6609 commit d573800
Show file tree
Hide file tree
Showing 15 changed files with 121 additions and 88 deletions.
2 changes: 1 addition & 1 deletion example/ExampleMassive.js
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ document.addEventListener("DOMContentLoaded", () => __awaiter(void 0, void 0, vo
const textures = [
{
key: "iChannel0",
source: "assets/noise2 .png", // ms
source: "assets/noise2.png", // ms
type: ITexture_1.TextureType.IMAGE,
},
{
Expand Down
5 changes: 2 additions & 3 deletions example/ExampleMassive.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,7 @@ import { ITexture, TextureType } from "../src/ITexture";
import { rectGeometry } from "./meshes/Rectangle";
import { Scene } from "../src/Scene";
import { Mesh } from "../src/Mesh";

import { FPS } from 'yy-fps'
import { prismBreakShader } from "./shaders/wglsl/prismBreakShader";
import { flamesShader } from "./shaders/wglsl/flamesShader";

document.addEventListener("DOMContentLoaded", async () => {
Expand All @@ -24,10 +22,11 @@ document.addEventListener("DOMContentLoaded", async () => {

const geometry = new Geometry(device, rectGeometry);


const textures: Array<ITexture> = [
{
key: "iChannel0",
source: "assets/noise2 .png", // ms
source: "assets/noise2.png", // ms
type: TextureType.IMAGE,
},

Expand Down
2 changes: 1 addition & 1 deletion example/build/comp-bundle.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion example/build/frag-bundle.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions example/index3.html
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,8 @@
</head>
<body>
<div id="render-result">
<canvas width="1280" height="720"></canvas>
<canvas width="800" height="450"></canvas>
</div>
<script src="build/massive-bundle.js"></script>
<script src="build/flames-bundle.js"></script>
</body>
</html>
9 changes: 6 additions & 3 deletions example/shaders/wglsl/flamesShader.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,8 @@ exports.flamesShader = {
struct Uniforms {
resolution: vec3<f32>,
time: f32
time: f32,
mouse: vec4<f32>
};
@group(0) @binding(0) var<uniform> uniforms: Uniforms;
Expand Down Expand Up @@ -94,7 +95,7 @@ exports.flamesShader = {
fn mainImage(invocation_id: vec2<f32>) -> vec4<f32> {
let mouse: vec4<f32> = vec4<f32>(0.0,0.0,0.0,0.);
let mouse: vec4<f32> = uniforms.mouse;
let R: vec2<f32> = uniforms.resolution.xy;
let y_inverted_location = vec2<i32>(i32(invocation_id.x), i32(R.y) - i32(invocation_id.y));
Expand All @@ -106,7 +107,9 @@ exports.flamesShader = {
let q: vec2<f32> = fragCoord.xy / uniforms.resolution.xy;
let p: vec2<f32> = (-1. + 2. * q) * vec2<f32>(uniforms.resolution.x / uniforms.resolution.y, 1.);
var mo: vec2<f32> = mouse.xy / uniforms.resolution.xy;
if (mouse.w <= 0.00001) { mo = vec2<f32>(0.); }
//if (mouse.w <= 0.00001) { mo = vec2<f32>(0.); }
let an: f32 = -0.07 * uniforms.time + 3. * mo.x;
var ro: vec3<f32> = 4.5 * normalize(vec3<f32>(cos(an), 0.5, sin(an)));
ro.y = ro.y + (1.);
Expand Down
9 changes: 6 additions & 3 deletions example/shaders/wglsl/flamesShader.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,8 @@ export const flamesShader: IMaterialShader = {
struct Uniforms {
resolution: vec3<f32>,
time: f32
time: f32,
mouse: vec4<f32>
};
@group(0) @binding(0) var<uniform> uniforms: Uniforms;
Expand Down Expand Up @@ -94,7 +95,7 @@ export const flamesShader: IMaterialShader = {
fn mainImage(invocation_id: vec2<f32>) -> vec4<f32> {
let mouse: vec4<f32> = vec4<f32>(0.0,0.0,0.0,0.);
let mouse: vec4<f32> = uniforms.mouse;
let R: vec2<f32> = uniforms.resolution.xy;
let y_inverted_location = vec2<i32>(i32(invocation_id.x), i32(R.y) - i32(invocation_id.y));
Expand All @@ -106,7 +107,9 @@ export const flamesShader: IMaterialShader = {
let q: vec2<f32> = fragCoord.xy / uniforms.resolution.xy;
let p: vec2<f32> = (-1. + 2. * q) * vec2<f32>(uniforms.resolution.x / uniforms.resolution.y, 1.);
var mo: vec2<f32> = mouse.xy / uniforms.resolution.xy;
if (mouse.w <= 0.00001) { mo = vec2<f32>(0.); }
//if (mouse.w <= 0.00001) { mo = vec2<f32>(0.); }
let an: f32 = -0.07 * uniforms.time + 3. * mo.x;
var ro: vec3<f32> = 4.5 * normalize(vec3<f32>(cos(an), 0.5, sin(an)));
ro.y = ro.y + (1.);
Expand Down
Loading

0 comments on commit d573800

Please sign in to comment.