ris-framework 0.2.0-dev.14 → 0.2.0-dev.16
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 +39 -2
- package/README.md +8 -6
- package/dist/api/IFramework.d.ts +1 -1
- package/dist/api/IFramework.d.ts.map +1 -1
- package/dist/api/_export.d.ts +3 -0
- package/dist/api/_export.d.ts.map +1 -1
- package/dist/api/camera/CameraTransformUtilities.d.ts +65 -0
- package/dist/api/camera/CameraTransformUtilities.d.ts.map +1 -0
- package/dist/api/camera/ICamera.d.ts +36 -2
- package/dist/api/camera/ICamera.d.ts.map +1 -1
- package/dist/api/camera/OrbitCamera.d.ts +22 -14
- package/dist/api/camera/OrbitCamera.d.ts.map +1 -1
- package/dist/api/camera/OrthographicCamera.d.ts +33 -11
- package/dist/api/camera/OrthographicCamera.d.ts.map +1 -1
- package/dist/api/camera/PerspectiveCamera.d.ts +32 -18
- package/dist/api/camera/PerspectiveCamera.d.ts.map +1 -1
- package/dist/api/content/ContentManager.d.ts.map +1 -1
- package/dist/api/lights/AmbientLight.d.ts +7 -2
- package/dist/api/lights/AmbientLight.d.ts.map +1 -1
- package/dist/api/lights/DirectionalLight.d.ts +18 -4
- package/dist/api/lights/DirectionalLight.d.ts.map +1 -1
- package/dist/api/lights/ILight.d.ts +18 -0
- package/dist/api/lights/ILight.d.ts.map +1 -0
- package/dist/api/lights/PointLight.d.ts +17 -4
- package/dist/api/lights/PointLight.d.ts.map +1 -1
- package/dist/api/lights/_export.d.ts +1 -0
- package/dist/api/lights/_export.d.ts.map +1 -1
- package/dist/api/material/ForwardBlinnPhongMaterial.d.ts +2 -2
- package/dist/api/material/ForwardBlinnPhongMaterial.d.ts.map +1 -1
- package/dist/api/material/IMaterial.d.ts +7 -0
- package/dist/api/material/IMaterial.d.ts.map +1 -1
- package/dist/api/material/IMaterialFactory.d.ts +3 -2
- package/dist/api/material/IMaterialFactory.d.ts.map +1 -1
- package/dist/api/material/IUnlitMaterialDescriptor.d.ts +16 -0
- package/dist/api/material/IUnlitMaterialDescriptor.d.ts.map +1 -0
- package/dist/api/material/MaterialFactory.d.ts +3 -2
- package/dist/api/material/MaterialFactory.d.ts.map +1 -1
- package/dist/api/material/SpriteMaterial.d.ts +3 -0
- package/dist/api/material/SpriteMaterial.d.ts.map +1 -1
- package/dist/api/material/UnlitMaterial.d.ts +5 -12
- package/dist/api/material/UnlitMaterial.d.ts.map +1 -1
- package/dist/api/material/_export.d.ts +1 -1
- package/dist/api/material/_export.d.ts.map +1 -1
- package/dist/api/meshes/IRenderableMesh.d.ts +3 -14
- package/dist/api/meshes/IRenderableMesh.d.ts.map +1 -1
- package/dist/api/meshes/RenderableMesh.d.ts +5 -20
- package/dist/api/meshes/RenderableMesh.d.ts.map +1 -1
- package/dist/api/rendering/IGraphicsDevice.d.ts +2 -2
- package/dist/api/rendering/IGraphicsDevice.d.ts.map +1 -1
- package/dist/api/rendering/IRenderer.d.ts +6 -4
- package/dist/api/rendering/IRenderer.d.ts.map +1 -1
- package/dist/api/rendering/_export-rendering.d.ts +1 -0
- package/dist/api/rendering/_export-rendering.d.ts.map +1 -1
- package/dist/api/rendering/primitive/IPrimitiveStateDescriptor.d.ts +24 -0
- package/dist/api/rendering/primitive/IPrimitiveStateDescriptor.d.ts.map +1 -0
- package/dist/api/rendering/primitive/_export.d.ts +1 -1
- package/dist/api/rendering/primitive/_export.d.ts.map +1 -1
- package/dist/api/rendering/render-pipelines/IMainRenderTargetRenderPipeline.d.ts +5 -0
- package/dist/api/rendering/render-pipelines/IMainRenderTargetRenderPipeline.d.ts.map +1 -1
- package/dist/api/rendering/texture/ITextureDescriptor.d.ts +5 -1
- package/dist/api/rendering/texture/ITextureDescriptor.d.ts.map +1 -1
- package/dist/api/rendering/texture/ITextureFactory.d.ts +3 -1
- package/dist/api/rendering/texture/ITextureFactory.d.ts.map +1 -1
- package/dist/api/rendering/texture/TextureUtilities.d.ts +7 -0
- package/dist/api/rendering/texture/TextureUtilities.d.ts.map +1 -1
- package/dist/api/scene/ISceneObject.d.ts +12 -0
- package/dist/api/scene/ISceneObject.d.ts.map +1 -0
- package/dist/api/scene/Scene.d.ts +17 -6
- package/dist/api/scene/Scene.d.ts.map +1 -1
- package/dist/api/scene/node/Node.d.ts +26 -0
- package/dist/api/scene/node/Node.d.ts.map +1 -0
- package/dist/api/scene/node/TransformNode.d.ts +46 -0
- package/dist/api/scene/node/TransformNode.d.ts.map +1 -0
- package/dist/core/material/UnlitMaterialDescriptorUtilities.d.ts +17 -0
- package/dist/core/material/UnlitMaterialDescriptorUtilities.d.ts.map +1 -0
- package/dist/core/rendering/AGraphicsDevice.d.ts +2 -2
- package/dist/core/rendering/AGraphicsDevice.d.ts.map +1 -1
- package/dist/core/rendering/ARenderer.d.ts +5 -2
- package/dist/core/rendering/ARenderer.d.ts.map +1 -1
- package/dist/core/rendering/primitive/PrimitiveStateDescriptorUtilities.d.ts +15 -0
- package/dist/core/rendering/primitive/PrimitiveStateDescriptorUtilities.d.ts.map +1 -0
- package/dist/core/rendering/texture/TextureDescriptorUtilities.d.ts +2 -2
- package/dist/core/rendering/texture/TextureDescriptorUtilities.d.ts.map +1 -1
- package/dist/index.js +704 -272
- package/dist/webgl/WebGlGraphicsDevice.d.ts +2 -2
- package/dist/webgl/WebGlGraphicsDevice.d.ts.map +1 -1
- package/dist/webgl/lights/WebGlLightsBuffer.d.ts.map +1 -1
- package/dist/webgl/primitive/WebGlPrimitiveState.d.ts +3 -3
- package/dist/webgl/primitive/WebGlPrimitiveState.d.ts.map +1 -1
- package/dist/webgl/render-pipelines/WebGlMainRenderTargetRenderPipeline.d.ts +8 -0
- package/dist/webgl/render-pipelines/WebGlMainRenderTargetRenderPipeline.d.ts.map +1 -1
- package/dist/webgl/texture/WebGlTextureFactory.d.ts +1 -1
- package/dist/webgl/texture/WebGlTextureFactory.d.ts.map +1 -1
- package/dist/webgl/utilities/WebGlTextureUtilities.d.ts.map +1 -1
- package/dist/webgpu/WebGpuGraphicsDevice.d.ts +2 -2
- package/dist/webgpu/WebGpuGraphicsDevice.d.ts.map +1 -1
- package/dist/webgpu/primitive/WebGpuPrimitiveState.d.ts +2 -2
- package/dist/webgpu/primitive/WebGpuPrimitiveState.d.ts.map +1 -1
- package/dist/webgpu/render-pipelines/WebGpuMainRenderTargetRenderPipeline.d.ts +5 -0
- package/dist/webgpu/render-pipelines/WebGpuMainRenderTargetRenderPipeline.d.ts.map +1 -1
- package/dist/webgpu/texture/WebGpuTextureFactory.d.ts.map +1 -1
- package/package.json +2 -2
- package/src/Framework.ts +1 -1
- package/src/api/IFramework.ts +1 -1
- package/src/api/_export.ts +3 -0
- package/src/api/camera/CameraTransformUtilities.ts +182 -0
- package/src/api/camera/ICamera.ts +42 -2
- package/src/api/camera/OrbitCamera.ts +71 -38
- package/src/api/camera/OrthographicCamera.ts +71 -28
- package/src/api/camera/PerspectiveCamera.ts +69 -33
- package/src/api/content/ContentManager.ts +9 -5
- package/src/api/lights/AmbientLight.ts +8 -2
- package/src/api/lights/DirectionalLight.ts +30 -5
- package/src/api/lights/ILight.ts +22 -0
- package/src/api/lights/PointLight.ts +26 -5
- package/src/api/lights/_export.ts +1 -0
- package/src/api/material/ForwardBlinnPhongMaterial.ts +2 -2
- package/src/api/material/IMaterial.ts +8 -0
- package/src/api/material/IMaterialFactory.ts +3 -2
- package/src/api/material/IUnlitMaterialDescriptor.ts +18 -0
- package/src/api/material/MaterialFactory.ts +4 -3
- package/src/api/material/SpriteMaterial.ts +4 -0
- package/src/api/material/UnlitMaterial.ts +11 -18
- package/src/api/material/_export.ts +1 -1
- package/src/api/meshes/IRenderableMesh.ts +3 -18
- package/src/api/meshes/RenderableMesh.ts +15 -45
- package/src/api/rendering/IGraphicsDevice.ts +2 -2
- package/src/api/rendering/IRenderer.ts +6 -4
- package/src/api/rendering/_export-rendering.ts +2 -1
- package/src/api/rendering/primitive/IPrimitiveStateDescriptor.ts +27 -0
- package/src/api/rendering/primitive/_export.ts +1 -1
- package/src/api/rendering/render-pipelines/IMainRenderTargetRenderPipeline.ts +6 -0
- package/src/api/rendering/texture/ITextureDescriptor.ts +6 -1
- package/src/api/rendering/texture/ITextureFactory.ts +3 -1
- package/src/api/rendering/texture/TextureUtilities.ts +16 -0
- package/src/api/scene/ISceneObject.ts +13 -0
- package/src/api/scene/Scene.ts +52 -11
- package/src/api/scene/node/Node.ts +54 -0
- package/src/api/scene/node/TransformNode.ts +88 -0
- package/src/core/material/UnlitMaterialDescriptorUtilities.ts +21 -0
- package/src/core/rendering/AGraphicsDevice.ts +2 -2
- package/src/core/rendering/ARenderer.ts +23 -5
- package/src/core/rendering/primitive/PrimitiveStateDescriptorUtilities.ts +22 -0
- package/src/core/rendering/texture/TextureDescriptorUtilities.ts +3 -2
- package/src/webgl/WebGlGraphicsDevice.ts +2 -3
- package/src/webgl/lights/WebGlLightsBuffer.ts +21 -8
- package/src/webgl/primitive/WebGlPrimitiveState.ts +8 -6
- package/src/webgl/render-pipelines/WebGlMainRenderTargetRenderPipeline.ts +14 -0
- package/src/webgl/texture/WebGlTextureFactory.ts +27 -16
- package/src/webgl/utilities/WebGlTextureUtilities.ts +10 -4
- package/src/webgpu/WebGpuGraphicsDevice.ts +3 -3
- package/src/webgpu/primitive/WebGpuPrimitiveState.ts +7 -5
- package/src/webgpu/render-pipelines/WebGpuMainRenderTargetRenderPipeline.ts +6 -0
- package/src/webgpu/texture/WebGpuTextureFactory.ts +1 -1
- package/dist/api/material/ICameraMaterial.d.ts +0 -18
- package/dist/api/material/ICameraMaterial.d.ts.map +0 -1
- package/dist/api/rendering/primitive/PrimitiveStateDescriptor.d.ts +0 -24
- package/dist/api/rendering/primitive/PrimitiveStateDescriptor.d.ts.map +0 -1
- package/src/api/material/ICameraMaterial.ts +0 -22
- package/src/api/rendering/primitive/PrimitiveStateDescriptor.ts +0 -27
|
@@ -2,14 +2,14 @@ import {
|
|
|
2
2
|
Color,
|
|
3
3
|
type IFramework,
|
|
4
4
|
type ITexture2D,
|
|
5
|
-
type ITextureFactory,
|
|
6
5
|
type ITextureDescriptor,
|
|
6
|
+
type ITextureFactory,
|
|
7
7
|
TextureFormat,
|
|
8
8
|
TextureUsage,
|
|
9
9
|
TextureUtilities
|
|
10
10
|
} from "../../api/index.ts"
|
|
11
11
|
import {WebGlTexture2D} from "./WebGlTexture2D.ts";
|
|
12
|
-
import {type IKtx2Texture,
|
|
12
|
+
import {type IKtx2Texture, KtxTranscodeFlags, KtxTranscodeFormat, VkFormat} from "ris-ktx2";
|
|
13
13
|
import {vec2} from "gl-matrix";
|
|
14
14
|
import {ColorSpace} from "../../api/rendering/enums.ts";
|
|
15
15
|
import {resolveTextureDescriptor} from "../../core/rendering/texture/TextureDescriptorUtilities.ts";
|
|
@@ -34,8 +34,10 @@ export class WebGlTextureFactory implements ITextureFactory {
|
|
|
34
34
|
let textureFormat = desc.textureFormat;
|
|
35
35
|
const gpuFeatures = this._framework.graphicsDevice.features;
|
|
36
36
|
|
|
37
|
-
|
|
38
|
-
const preferSrgb = this._framework.renderer.
|
|
37
|
+
// Textures always adapt to the framework's preferred color space, unless user defined it's preferred.
|
|
38
|
+
const preferSrgb = (descriptor?.preferredColorSpace ?? this._framework.renderer.colorSpace) == ColorSpace.SRGB;
|
|
39
|
+
// An explicit texture format overrides both color space preferences.
|
|
40
|
+
const userSpecifiedTextureFormat = desc.textureFormat != TextureFormat.UNDEFINED;
|
|
39
41
|
|
|
40
42
|
if (ktxTexture.needsTranscoding && vkFormat == VkFormat.UNDEFINED)
|
|
41
43
|
{
|
|
@@ -46,22 +48,22 @@ export class WebGlTextureFactory implements ITextureFactory {
|
|
|
46
48
|
if(gpuFeatures.supportsTextureCompressionBC)
|
|
47
49
|
{
|
|
48
50
|
transcodeFormat = KtxTranscodeFormat.BC7_RGBA;
|
|
49
|
-
textureFormat =
|
|
51
|
+
textureFormat = preferSrgb ? TextureFormat.BC7_RGBA_SRGB : TextureFormat.BC7_RGBA_UNORM;
|
|
50
52
|
}
|
|
51
53
|
else if(gpuFeatures.supportsTextureCompressionASTC)
|
|
52
54
|
{
|
|
53
55
|
transcodeFormat = KtxTranscodeFormat.ASTC_4X4_RGBA;
|
|
54
|
-
textureFormat =
|
|
56
|
+
textureFormat = preferSrgb ? TextureFormat.ASTC_4X4_RGBA_SRGB : TextureFormat.ASTC_4X4_RGBA_UNORM;
|
|
55
57
|
}
|
|
56
58
|
else if(gpuFeatures.supportsTextureCompressionS3TC)
|
|
57
59
|
{
|
|
58
60
|
transcodeFormat = KtxTranscodeFormat.BC3_RGBA;
|
|
59
|
-
textureFormat =
|
|
61
|
+
textureFormat = preferSrgb ? TextureFormat.BC3_RGBA_SRGB : TextureFormat.BC3_RGBA_UNORM;
|
|
60
62
|
}
|
|
61
63
|
else if(gpuFeatures.supportsTextureCompressionETC2)
|
|
62
64
|
{
|
|
63
65
|
transcodeFormat = KtxTranscodeFormat.ETC2_RGBA;
|
|
64
|
-
textureFormat =
|
|
66
|
+
textureFormat = preferSrgb ? TextureFormat.ETC2_RGBA8_SRGB : TextureFormat.ETC2_RGBA8_UNORM;
|
|
65
67
|
}
|
|
66
68
|
else if(gpuFeatures.supportsTextureCompressionPVRTC)
|
|
67
69
|
{
|
|
@@ -72,7 +74,7 @@ export class WebGlTextureFactory implements ITextureFactory {
|
|
|
72
74
|
else
|
|
73
75
|
{
|
|
74
76
|
transcodeFormat = KtxTranscodeFormat.RGBA32;
|
|
75
|
-
textureFormat =
|
|
77
|
+
textureFormat = preferSrgb ? TextureFormat.RGBA_8_UNORM_SRGB : TextureFormat.RGBA_8_UNORM;
|
|
76
78
|
}
|
|
77
79
|
}
|
|
78
80
|
else
|
|
@@ -83,13 +85,18 @@ export class WebGlTextureFactory implements ITextureFactory {
|
|
|
83
85
|
ktxTexture.transcodeBasis(transcodeFormat, KtxTranscodeFlags.HIGH_QUALITY);
|
|
84
86
|
}
|
|
85
87
|
else {
|
|
86
|
-
// No transcoding path
|
|
88
|
+
// No transcoding path: map the vkFormat, then switch to the preferred color space variant.
|
|
87
89
|
textureFormat = TextureUtilities.convertVkFormatToTextureFormat(vkFormat);
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
90
|
+
|
|
91
|
+
if (userSpecifiedTextureFormat) {
|
|
92
|
+
// The data can only be reinterpreted as the file's format or its sRGB/linear variant.
|
|
93
|
+
textureFormat = TextureUtilities.resolveExplicitFormat(textureFormat, desc.textureFormat);
|
|
94
|
+
} else {
|
|
95
|
+
if (preferSrgb && !TextureUtilities.isSrgbFormat(textureFormat)) {
|
|
96
|
+
textureFormat = TextureUtilities.convertToSrgbVariant(textureFormat);
|
|
97
|
+
} else if (!preferSrgb && TextureUtilities.isSrgbFormat(textureFormat)) {
|
|
98
|
+
textureFormat = TextureUtilities.convertToLinearVariant(textureFormat);
|
|
99
|
+
}
|
|
93
100
|
}
|
|
94
101
|
}
|
|
95
102
|
|
|
@@ -125,8 +132,12 @@ export class WebGlTextureFactory implements ITextureFactory {
|
|
|
125
132
|
channels: number = 4,
|
|
126
133
|
label: string | null | undefined = null,
|
|
127
134
|
textureUsage = TextureUsage.COPY_DST | TextureUsage.TEXTURE_BINDING,
|
|
128
|
-
textureFormat= TextureFormat.
|
|
135
|
+
textureFormat = TextureFormat.UNDEFINED,
|
|
129
136
|
useMipMaps = false): ITexture2D {
|
|
137
|
+
if (textureFormat == TextureFormat.UNDEFINED) {
|
|
138
|
+
textureFormat = this._framework.renderer.preferredTextureFormat;
|
|
139
|
+
}
|
|
140
|
+
|
|
130
141
|
|
|
131
142
|
if (!data) {
|
|
132
143
|
throw new Error("Data must not be null.");
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import {WebGlConverter} from "./WebGlConverter.ts";
|
|
2
|
-
import {
|
|
2
|
+
import { TextureFormat} from "../../api/index.ts";
|
|
3
3
|
import {vec2} from "gl-matrix";
|
|
4
4
|
import {WebGlUtilities} from "./WebGlUtilities.ts";
|
|
5
5
|
|
|
@@ -127,6 +127,9 @@ export class WebGlTextureUtilities {
|
|
|
127
127
|
gl.texStorage2D(gl.TEXTURE_2D, mipLevels, internalFormat, baseWidth, baseHeight);
|
|
128
128
|
}
|
|
129
129
|
|
|
130
|
+
// Texture data might not be aligned to 4. So disable it.
|
|
131
|
+
gl.pixelStorei(gl.UNPACK_ALIGNMENT, 1);
|
|
132
|
+
|
|
130
133
|
if (data && data.length > 0) {
|
|
131
134
|
|
|
132
135
|
let width = baseWidth;
|
|
@@ -140,9 +143,9 @@ export class WebGlTextureUtilities {
|
|
|
140
143
|
if (useTexStorage) {
|
|
141
144
|
gl.compressedTexSubImage2D(gl.TEXTURE_2D, i, 0, 0, width, height, internalFormat, mipLevelData, 0);
|
|
142
145
|
} else {
|
|
143
|
-
const alignedWidth = AlignUtilities.align(width, blockSize[0]);
|
|
144
|
-
const alignedHeight = AlignUtilities.align(height, blockSize[1]);
|
|
145
|
-
gl.compressedTexImage2D(gl.TEXTURE_2D, i, internalFormat,
|
|
146
|
+
// const alignedWidth = AlignUtilities.align(width, blockSize[0]);
|
|
147
|
+
// const alignedHeight = AlignUtilities.align(height, blockSize[1]);
|
|
148
|
+
gl.compressedTexImage2D(gl.TEXTURE_2D, i, internalFormat, width, height, 0, mipLevelData, 0);
|
|
146
149
|
}
|
|
147
150
|
} else {
|
|
148
151
|
throw new Error("unsupported data type");
|
|
@@ -153,6 +156,9 @@ export class WebGlTextureUtilities {
|
|
|
153
156
|
}
|
|
154
157
|
}
|
|
155
158
|
|
|
159
|
+
// Restore to default.
|
|
160
|
+
gl.pixelStorei(gl.UNPACK_ALIGNMENT, 4);
|
|
161
|
+
|
|
156
162
|
gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_WRAP_S, gl.CLAMP_TO_EDGE);
|
|
157
163
|
gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_WRAP_T, gl.CLAMP_TO_EDGE);
|
|
158
164
|
|
|
@@ -9,7 +9,7 @@ import {
|
|
|
9
9
|
type ISampler,
|
|
10
10
|
type ISwapChain,
|
|
11
11
|
type IWindowManager,
|
|
12
|
-
|
|
12
|
+
type IPrimitiveStateDescriptor,
|
|
13
13
|
RenderPassDescriptor,
|
|
14
14
|
SwapChainDescriptor,
|
|
15
15
|
} from "../api/index.ts";
|
|
@@ -158,8 +158,8 @@ export class WebGpuGraphicsDevice extends AGraphicsDevice {
|
|
|
158
158
|
}
|
|
159
159
|
|
|
160
160
|
/** @inheritDoc */
|
|
161
|
-
public createPrimitiveState(descriptor?:
|
|
162
|
-
return new WebGpuPrimitiveState(descriptor
|
|
161
|
+
public createPrimitiveState(descriptor?: IPrimitiveStateDescriptor): IPrimitiveState {
|
|
162
|
+
return new WebGpuPrimitiveState(descriptor);
|
|
163
163
|
}
|
|
164
164
|
|
|
165
165
|
/** @inheritDoc */
|
|
@@ -2,10 +2,11 @@ import {
|
|
|
2
2
|
type CullMode,
|
|
3
3
|
type FrontFace,
|
|
4
4
|
type IPrimitiveState,
|
|
5
|
-
type
|
|
5
|
+
type IPrimitiveStateDescriptor,
|
|
6
6
|
type PrimitiveTopology,
|
|
7
7
|
} from "../../api/index.ts";
|
|
8
8
|
import type {GpuCullMode, GpuFrontFace, GpuPrimitiveTopology} from "../WebGpuTypes.ts";
|
|
9
|
+
import {resolvePrimitiveStateDescriptor} from "../../core/rendering/primitive/PrimitiveStateDescriptorUtilities.ts";
|
|
9
10
|
import {WebGpuConverter} from "../utilities/WebGpuConverter.ts";
|
|
10
11
|
|
|
11
12
|
/**
|
|
@@ -18,10 +19,11 @@ export class WebGpuPrimitiveState implements IPrimitiveState {
|
|
|
18
19
|
* The constructor.
|
|
19
20
|
* @param descriptor The primitive state descriptor.
|
|
20
21
|
*/
|
|
21
|
-
public constructor(descriptor
|
|
22
|
-
|
|
23
|
-
this.
|
|
24
|
-
this.
|
|
22
|
+
public constructor(descriptor?: IPrimitiveStateDescriptor) {
|
|
23
|
+
const resolved = resolvePrimitiveStateDescriptor(descriptor);
|
|
24
|
+
this.topology = resolved.topology;
|
|
25
|
+
this.cullFace = resolved.cullFace;
|
|
26
|
+
this.frontFace = resolved.frontFace;
|
|
25
27
|
this.gpuTopology = WebGpuConverter.convertTopology(this.topology);
|
|
26
28
|
this.gpuCullMode = WebGpuConverter.convertCullMode(this.cullFace);
|
|
27
29
|
this.gpuFrontFace = WebGpuConverter.convertFrontFace(this.frontFace);
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import {ColorSpace} from "../../api/rendering/enums.ts";
|
|
1
2
|
import {vec2} from "gl-matrix";
|
|
2
3
|
import {
|
|
3
4
|
BufferUsage,
|
|
@@ -81,6 +82,11 @@ export class WebGpuMainRenderTargetRenderPipeline extends AWebGpuRenderPipeline
|
|
|
81
82
|
this._graphicsDevice.swapChain?.textureFormat ?? this._framework.renderer.preferredTextureFormat);
|
|
82
83
|
}
|
|
83
84
|
|
|
85
|
+
/**
|
|
86
|
+
* The color space. Stored only; it has no effect on WebGPU yet.
|
|
87
|
+
*/
|
|
88
|
+
public colorSpace: ColorSpace = ColorSpace.LINEAR;
|
|
89
|
+
|
|
84
90
|
private _getBindGroup(): GpuBindGroup {
|
|
85
91
|
if (!this._bindGroup) {
|
|
86
92
|
this._bindGroup = this._graphicsDevice.device.createBindGroup({
|
|
@@ -36,7 +36,7 @@ export class WebGpuTextureFactory implements ITextureFactory {
|
|
|
36
36
|
channels: number = 4,
|
|
37
37
|
label: string | null | undefined = null,
|
|
38
38
|
textureUsage = TextureUsage.COPY_DST | TextureUsage.TEXTURE_BINDING,
|
|
39
|
-
textureFormat = TextureFormat.
|
|
39
|
+
textureFormat = TextureFormat.UNDEFINED,
|
|
40
40
|
useMipMaps = false): ITexture2D {
|
|
41
41
|
|
|
42
42
|
if (!data) {
|
|
@@ -1,18 +0,0 @@
|
|
|
1
|
-
import type { IMaterial } from "./IMaterial.js";
|
|
2
|
-
import type { ICamera } from "../camera/ICamera.js";
|
|
3
|
-
/**
|
|
4
|
-
* A material that renders with a camera (unlit, Blinn-Phong, inspect mips).
|
|
5
|
-
* A `Scene` assigns its camera to these materials in `scene.update()`.
|
|
6
|
-
* @public
|
|
7
|
-
*/
|
|
8
|
-
export interface ICameraMaterial extends IMaterial {
|
|
9
|
-
/** The camera. Setting it binds the camera's buffers. */
|
|
10
|
-
camera?: ICamera;
|
|
11
|
-
}
|
|
12
|
-
/**
|
|
13
|
-
* Whether a material is an {@link ICameraMaterial}.
|
|
14
|
-
* @param material The material.
|
|
15
|
-
* @public
|
|
16
|
-
*/
|
|
17
|
-
export declare function isCameraMaterial(material: IMaterial | undefined): material is ICameraMaterial;
|
|
18
|
-
//# sourceMappingURL=ICameraMaterial.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"ICameraMaterial.d.ts","sourceRoot":"","sources":["../../../src/api/material/ICameraMaterial.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,gBAAgB,CAAC;AAChD,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,sBAAsB,CAAC;AAEpD;;;;GAIG;AACH,MAAM,WAAW,eAAgB,SAAQ,SAAS;IAE9C,yDAAyD;IACzD,MAAM,CAAC,EAAE,OAAO,CAAC;CACpB;AAED;;;;GAIG;AACH,wBAAgB,gBAAgB,CAAC,QAAQ,EAAE,SAAS,GAAG,SAAS,GAAG,QAAQ,IAAI,eAAe,CAE7F"}
|
|
@@ -1,24 +0,0 @@
|
|
|
1
|
-
import { PrimitiveTopology } from "./PrimitiveTopology.js";
|
|
2
|
-
import { CullMode } from "./CullMode.js";
|
|
3
|
-
import { FrontFace } from "./FrontFace.js";
|
|
4
|
-
/**
|
|
5
|
-
* Describes the state of a primitive.
|
|
6
|
-
*/
|
|
7
|
-
export declare class PrimitiveStateDescriptor {
|
|
8
|
-
/**
|
|
9
|
-
* The topology of the primitive.
|
|
10
|
-
* By default, it is set to TRIANGLE_LIST.
|
|
11
|
-
*/
|
|
12
|
-
topology: PrimitiveTopology;
|
|
13
|
-
/**
|
|
14
|
-
* The culling mode.
|
|
15
|
-
* By default, it is set to BACK.
|
|
16
|
-
*/
|
|
17
|
-
cullFace: CullMode;
|
|
18
|
-
/**
|
|
19
|
-
* The front face.
|
|
20
|
-
* By default, it is set to CCW(counter clock-wise).
|
|
21
|
-
*/
|
|
22
|
-
frontFace: FrontFace;
|
|
23
|
-
}
|
|
24
|
-
//# sourceMappingURL=PrimitiveStateDescriptor.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"PrimitiveStateDescriptor.d.ts","sourceRoot":"","sources":["../../../../src/api/rendering/primitive/PrimitiveStateDescriptor.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,iBAAiB,EAAC,MAAM,wBAAwB,CAAC;AACzD,OAAO,EAAC,QAAQ,EAAC,MAAM,eAAe,CAAC;AACvC,OAAO,EAAC,SAAS,EAAC,MAAM,gBAAgB,CAAC;AAEzC;;GAEG;AACH,qBAAa,wBAAwB;IAEjC;;;OAGG;IACI,QAAQ,EAAE,iBAAiB,CAAmC;IAErE;;;OAGG;IACI,QAAQ,EAAE,QAAQ,CAAiB;IAE1C;;;OAGG;IACI,SAAS,EAAE,SAAS,CAAiB;CAC/C"}
|
|
@@ -1,22 +0,0 @@
|
|
|
1
|
-
import type { IMaterial } from "./IMaterial.ts";
|
|
2
|
-
import type { ICamera } from "../camera/ICamera.ts";
|
|
3
|
-
|
|
4
|
-
/**
|
|
5
|
-
* A material that renders with a camera (unlit, Blinn-Phong, inspect mips).
|
|
6
|
-
* A `Scene` assigns its camera to these materials in `scene.update()`.
|
|
7
|
-
* @public
|
|
8
|
-
*/
|
|
9
|
-
export interface ICameraMaterial extends IMaterial {
|
|
10
|
-
|
|
11
|
-
/** The camera. Setting it binds the camera's buffers. */
|
|
12
|
-
camera?: ICamera;
|
|
13
|
-
}
|
|
14
|
-
|
|
15
|
-
/**
|
|
16
|
-
* Whether a material is an {@link ICameraMaterial}.
|
|
17
|
-
* @param material The material.
|
|
18
|
-
* @public
|
|
19
|
-
*/
|
|
20
|
-
export function isCameraMaterial(material: IMaterial | undefined): material is ICameraMaterial {
|
|
21
|
-
return !!material && "camera" in material;
|
|
22
|
-
}
|
|
@@ -1,27 +0,0 @@
|
|
|
1
|
-
import {PrimitiveTopology} from "./PrimitiveTopology.ts";
|
|
2
|
-
import {CullMode} from "./CullMode.ts";
|
|
3
|
-
import {FrontFace} from "./FrontFace.ts";
|
|
4
|
-
|
|
5
|
-
/**
|
|
6
|
-
* Describes the state of a primitive.
|
|
7
|
-
*/
|
|
8
|
-
export class PrimitiveStateDescriptor {
|
|
9
|
-
|
|
10
|
-
/**
|
|
11
|
-
* The topology of the primitive.
|
|
12
|
-
* By default, it is set to TRIANGLE_LIST.
|
|
13
|
-
*/
|
|
14
|
-
public topology: PrimitiveTopology = PrimitiveTopology.TRIANGLE_LIST;
|
|
15
|
-
|
|
16
|
-
/**
|
|
17
|
-
* The culling mode.
|
|
18
|
-
* By default, it is set to BACK.
|
|
19
|
-
*/
|
|
20
|
-
public cullFace: CullMode = CullMode.BACK;
|
|
21
|
-
|
|
22
|
-
/**
|
|
23
|
-
* The front face.
|
|
24
|
-
* By default, it is set to CCW(counter clock-wise).
|
|
25
|
-
*/
|
|
26
|
-
public frontFace: FrontFace = FrontFace.CCW;
|
|
27
|
-
}
|