Various improvements

This commit is contained in:
Andras Schmelczer 2023-05-28 22:28:44 +01:00
parent 488494634d
commit abf3803cdc
No known key found for this signature in database
GPG key ID: FC8F2C3D3D1A718C
15 changed files with 259 additions and 226 deletions

View file

@ -7,5 +7,5 @@ export const formatNumber = (value: number, unit = ''): string => {
return `${(value / 1e3).toFixed(1)} thousand ${unit}`;
}
return `${value === Math.floor(value) ? value : value.toFixed(2)}${unit}`;
return `${value === Math.floor(value) ? value : value.toFixed(2)} ${unit}`;
};

View file

@ -1,4 +1,3 @@
import shader from './full-screen-quad.wgsl';
import { smartCompile } from './smart-compile';
export const setUpFullScreenQuad = (

View file

@ -5,12 +5,12 @@ const textureCache = new Map<string, GPUTexture>();
export const generateNoise = ({
device,
width = 1024,
height = 1024,
width,
height,
}: {
device: GPUDevice;
width?: number;
height?: number;
width: number;
height: number;
}): GPUTextureView => {
const cacheKey = `${width}x${height}`;
if (!textureCache.has(cacheKey)) {
@ -31,10 +31,10 @@ export const generateNoise = ({
@fragment
fn fragment(@location(0) uv: vec2<f32>) -> @location(0) vec4<f32> {
return vec4(
random_with_seed(uv, 0),
random_with_seed(uv, 1),
random_with_seed(uv, 2),
random_with_seed(uv, 3),
random_with_seed(uv, 4),
);
}`
),

View file

@ -20,12 +20,9 @@ export class ResizableTexture {
const newTexture = this.device.createTexture({
format: 'rgba16float',
dimension: '2d',
mipLevelCount: 1,
size: {
width: size.x,
height: size.y,
depthOrArrayLayers: 1,
},
usage:
GPUTextureUsage.STORAGE_BINDING |