From 339862a6ac1a0d909017589be652becde2987595 Mon Sep 17 00:00:00 2001 From: Andras Schmelczer Date: Sun, 28 May 2023 10:01:11 +0100 Subject: [PATCH] Move files --- src/game-loop/game-presentation.ts | 2 +- src/page/set-up-settings-page.ts | 2 +- src/{utils => page}/settings-slider.ts | 2 +- src/pipelines/diffusion/diffusion-pipeline.ts | 2 +- src/pipelines/render/render-pipeline.ts | 2 +- src/utils/colors/hex.ts | 16 ---------------- src/utils/colors/rgb255.ts | 4 ---- src/utils/colors/rgba.ts | 4 ---- src/utils/colors/rgba255.ts | 4 ---- .../full-screen-quad.ts | 19 +++++++++++++++++-- .../full-screen-quad/full-screen-quad.wgsl | 12 ------------ src/utils/graphics/noise.ts | 2 +- src/utils/{colors => }/hsl.ts | 0 src/utils/{colors => }/rgb.ts | 0 14 files changed, 23 insertions(+), 48 deletions(-) rename src/{utils => page}/settings-slider.ts (98%) delete mode 100644 src/utils/colors/hex.ts delete mode 100644 src/utils/colors/rgb255.ts delete mode 100644 src/utils/colors/rgba.ts delete mode 100644 src/utils/colors/rgba255.ts rename src/utils/graphics/{full-screen-quad => }/full-screen-quad.ts (69%) delete mode 100644 src/utils/graphics/full-screen-quad/full-screen-quad.wgsl rename src/utils/{colors => }/hsl.ts (100%) rename src/utils/{colors => }/rgb.ts (100%) diff --git a/src/game-loop/game-presentation.ts b/src/game-loop/game-presentation.ts index 65ace6e..273f44d 100644 --- a/src/game-loop/game-presentation.ts +++ b/src/game-loop/game-presentation.ts @@ -1,5 +1,5 @@ import { settings } from '../settings'; -import { hsl } from '../utils/colors/hsl'; +import { hsl } from '../utils/hsl'; import { last } from '../utils/last'; import { Random } from '../utils/random'; diff --git a/src/page/set-up-settings-page.ts b/src/page/set-up-settings-page.ts index 2fd05bc..4eb3c10 100644 --- a/src/page/set-up-settings-page.ts +++ b/src/page/set-up-settings-page.ts @@ -1,5 +1,5 @@ import { settings } from '../settings'; -import { SettingsSlider, ValueScaling } from '../utils/settings-slider'; +import { SettingsSlider, ValueScaling } from './settings-slider'; export const setUpSettingsPage = ( settingsPage: HTMLDivElement, diff --git a/src/utils/settings-slider.ts b/src/page/settings-slider.ts similarity index 98% rename from src/utils/settings-slider.ts rename to src/page/settings-slider.ts index b16262f..40204eb 100644 --- a/src/utils/settings-slider.ts +++ b/src/page/settings-slider.ts @@ -1,4 +1,4 @@ -import { formatNumber } from './format-number'; +import { formatNumber } from '../utils/format-number'; export enum ValueScaling { Linear, diff --git a/src/pipelines/diffusion/diffusion-pipeline.ts b/src/pipelines/diffusion/diffusion-pipeline.ts index 4fe649b..e3685d7 100644 --- a/src/pipelines/diffusion/diffusion-pipeline.ts +++ b/src/pipelines/diffusion/diffusion-pipeline.ts @@ -1,4 +1,4 @@ -import { setUpFullScreenQuad } from '../../utils/graphics/full-screen-quad/full-screen-quad'; +import { setUpFullScreenQuad } from '../../utils/graphics/full-screen-quad'; import { smartCompile } from '../../utils/graphics/smart-compile'; import { CommonState } from '../common-state/common-state'; import shader from './diffuse.wgsl'; diff --git a/src/pipelines/render/render-pipeline.ts b/src/pipelines/render/render-pipeline.ts index 376c5ef..2ffce0c 100644 --- a/src/pipelines/render/render-pipeline.ts +++ b/src/pipelines/render/render-pipeline.ts @@ -1,4 +1,4 @@ -import { setUpFullScreenQuad } from '../../utils/graphics/full-screen-quad/full-screen-quad'; +import { setUpFullScreenQuad } from '../../utils/graphics/full-screen-quad'; import { smartCompile } from '../../utils/graphics/smart-compile'; import { CommonState } from '../common-state/common-state'; import { RenderSettings } from './render-settings'; diff --git a/src/utils/colors/hex.ts b/src/utils/colors/hex.ts deleted file mode 100644 index eefc66f..0000000 --- a/src/utils/colors/hex.ts +++ /dev/null @@ -1,16 +0,0 @@ -import { rgb255 } from './rgb255'; - -import { vec3 } from 'gl-matrix'; - -export const hex = (hex: string): vec3 => { - if (hex[0] === '#') { - hex = hex.slice(1); - } - - const bigint = parseInt(hex, 16); - const r = (bigint >> 16) & 255; - const g = (bigint >> 8) & 255; - const b = bigint & 255; - - return rgb255(r, g, b); -}; diff --git a/src/utils/colors/rgb255.ts b/src/utils/colors/rgb255.ts deleted file mode 100644 index 56c47ff..0000000 --- a/src/utils/colors/rgb255.ts +++ /dev/null @@ -1,4 +0,0 @@ -import { vec3 } from 'gl-matrix'; - -export const rgb255 = (r: number, g: number, b: number): vec3 => - vec3.fromValues(r / 255, g / 255, b / 255); diff --git a/src/utils/colors/rgba.ts b/src/utils/colors/rgba.ts deleted file mode 100644 index 39aae1e..0000000 --- a/src/utils/colors/rgba.ts +++ /dev/null @@ -1,4 +0,0 @@ -import { vec4 } from 'gl-matrix'; - -export const rgba = (r: number, g: number, b: number, a: number): vec4 => - vec4.fromValues(r, g, b, a); diff --git a/src/utils/colors/rgba255.ts b/src/utils/colors/rgba255.ts deleted file mode 100644 index 00b7f5a..0000000 --- a/src/utils/colors/rgba255.ts +++ /dev/null @@ -1,4 +0,0 @@ -import { vec4 } from 'gl-matrix'; - -export const rgba255 = (r: number, g: number, b: number, a: number): vec4 => - vec4.fromValues(r / 255, g / 255, b / 255, a / 255); diff --git a/src/utils/graphics/full-screen-quad/full-screen-quad.ts b/src/utils/graphics/full-screen-quad.ts similarity index 69% rename from src/utils/graphics/full-screen-quad/full-screen-quad.ts rename to src/utils/graphics/full-screen-quad.ts index e0c05f4..3790f75 100644 --- a/src/utils/graphics/full-screen-quad/full-screen-quad.ts +++ b/src/utils/graphics/full-screen-quad.ts @@ -1,5 +1,5 @@ -import { smartCompile } from '../smart-compile'; import shader from './full-screen-quad.wgsl'; +import { smartCompile } from './smart-compile'; export const setUpFullScreenQuad = ( device: GPUDevice @@ -26,7 +26,22 @@ export const setUpFullScreenQuad = ( return { buffer, vertex: { - module: smartCompile(device, shader), + module: smartCompile( + device, + /* wgsl */ ` + struct VertexOutput { + @builtin(position) position: vec4, + @location(0) uv: vec2, + } + + @vertex + fn vertex( + @location(0) position: vec2, + @location(1) uv: vec2 + ) -> VertexOutput { + return VertexOutput(vec4(position, 0.0, 1.0), uv); + }` + ), entryPoint: 'vertex', buffers: [ { diff --git a/src/utils/graphics/full-screen-quad/full-screen-quad.wgsl b/src/utils/graphics/full-screen-quad/full-screen-quad.wgsl deleted file mode 100644 index beb8216..0000000 --- a/src/utils/graphics/full-screen-quad/full-screen-quad.wgsl +++ /dev/null @@ -1,12 +0,0 @@ -struct VertexOutput { - @builtin(position) position: vec4, - @location(0) uv: vec2, -} - -@vertex -fn vertex( - @location(0) position: vec2, - @location(1) uv: vec2 -) -> VertexOutput { - return VertexOutput(vec4(position, 0.0, 1.0), uv); -} diff --git a/src/utils/graphics/noise.ts b/src/utils/graphics/noise.ts index c8e32a6..004de5b 100644 --- a/src/utils/graphics/noise.ts +++ b/src/utils/graphics/noise.ts @@ -1,4 +1,4 @@ -import { setUpFullScreenQuad } from './full-screen-quad/full-screen-quad'; +import { setUpFullScreenQuad } from './full-screen-quad'; import { smartCompile } from './smart-compile'; const textureCache = new Map(); diff --git a/src/utils/colors/hsl.ts b/src/utils/hsl.ts similarity index 100% rename from src/utils/colors/hsl.ts rename to src/utils/hsl.ts diff --git a/src/utils/colors/rgb.ts b/src/utils/rgb.ts similarity index 100% rename from src/utils/colors/rgb.ts rename to src/utils/rgb.ts