@footgun/cobalt 0.7.8 → 0.8.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +10 -0
- package/bundle.js +3 -3
- package/package.json +2 -2
- package/src/cobalt.js +1 -0
- package/src/displacement/{displacement-composition.ts → displacement-composition.js} +21 -57
- package/src/displacement/displacement-parameters-buffer.js +21 -0
- package/src/displacement/{displacement-texture.ts → displacement-texture.js} +29 -87
- package/src/displacement/{triangles-buffer.ts → triangles-buffer.js} +18 -44
- package/src/light/{lights-buffer.ts → lights-buffer.js} +13 -36
- package/src/light/{lights-renderer.ts → lights-renderer.js} +24 -72
- package/src/light/texture/{lights-texture-initializer.ts → lights-texture-initializer.js} +11 -27
- package/src/light/texture/{lights-texture-mask.ts → lights-texture-mask.js} +36 -87
- package/src/light/texture/{lights-texture.ts → lights-texture.js} +16 -52
- package/src/light/{viewport.ts → viewport.js} +11 -34
- package/src/scene-composite/scene-composite.js +1 -1
- package/src/displacement/displacement-parameters-buffer.ts +0 -44
- package/src/light/types.ts +0 -23
|
@@ -1,44 +0,0 @@
|
|
|
1
|
-
/// <reference types="@webgpu/types"/>
|
|
2
|
-
|
|
3
|
-
type DisplacementParameters = {
|
|
4
|
-
readonly offsetX: number;
|
|
5
|
-
readonly offsetY: number;
|
|
6
|
-
readonly scale: number;
|
|
7
|
-
};
|
|
8
|
-
|
|
9
|
-
type Parameters = {
|
|
10
|
-
readonly device: GPUDevice;
|
|
11
|
-
readonly initialParameters: DisplacementParameters;
|
|
12
|
-
};
|
|
13
|
-
|
|
14
|
-
class DisplacementParametersBuffer {
|
|
15
|
-
private readonly device: GPUDevice;
|
|
16
|
-
|
|
17
|
-
public readonly bufferGpu: GPUBuffer;
|
|
18
|
-
private needsUpdate: boolean = true;
|
|
19
|
-
|
|
20
|
-
public constructor(params: Parameters) {
|
|
21
|
-
this.device = params.device;
|
|
22
|
-
|
|
23
|
-
this.bufferGpu = this.device.createBuffer({
|
|
24
|
-
label: "DisplacementParametersBuffer buffer",
|
|
25
|
-
size: 16,
|
|
26
|
-
usage: GPUBufferUsage.UNIFORM | GPUBufferUsage.COPY_DST,
|
|
27
|
-
});
|
|
28
|
-
|
|
29
|
-
this.setParameters(params.initialParameters);
|
|
30
|
-
}
|
|
31
|
-
|
|
32
|
-
public setParameters(params: DisplacementParameters): void {
|
|
33
|
-
this.device.queue.writeBuffer(this.bufferGpu, 0, new Float32Array([params.offsetX, params.offsetY, params.scale]));
|
|
34
|
-
}
|
|
35
|
-
|
|
36
|
-
public destroy(): void {
|
|
37
|
-
this.bufferGpu.destroy();
|
|
38
|
-
}
|
|
39
|
-
}
|
|
40
|
-
|
|
41
|
-
export {
|
|
42
|
-
DisplacementParametersBuffer
|
|
43
|
-
};
|
|
44
|
-
|
package/src/light/types.ts
DELETED
|
@@ -1,23 +0,0 @@
|
|
|
1
|
-
type Point = [number, number];
|
|
2
|
-
|
|
3
|
-
type Light = {
|
|
4
|
-
readonly position: Point; // center of the light
|
|
5
|
-
readonly radius: number; // radius of the light
|
|
6
|
-
readonly color: [number, number, number]; // color (normalized)
|
|
7
|
-
readonly intensity: number; // intensity at the center
|
|
8
|
-
readonly attenuationLinear: number; // describes how the intensity declines with distance
|
|
9
|
-
readonly attenuationExp: number; // describes how the intensity declines with distance
|
|
10
|
-
};
|
|
11
|
-
/* The light intensity is computed as follow:
|
|
12
|
-
intensity
|
|
13
|
-
----------------------------------------------------- * cos(x * pi/2)
|
|
14
|
-
1 + attenuationLinear * x + attenuationExp * (x * x)
|
|
15
|
-
|
|
16
|
-
where "x" is the normalized distance to the light position
|
|
17
|
-
*/
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
export {
|
|
21
|
-
type Light,
|
|
22
|
-
type Point,
|
|
23
|
-
};
|