@aura3d/rendering 1.1.0 → 1.3.0
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/dist/ForwardPass.js +18 -13
- package/dist/ForwardPass.js.map +1 -1
- package/dist/MorphTargetPlan.d.ts +42 -0
- package/dist/MorphTargetPlan.d.ts.map +1 -0
- package/dist/MorphTargetPlan.js +129 -0
- package/dist/MorphTargetPlan.js.map +1 -0
- package/dist/MorphUnlitMaterial.d.ts.map +1 -1
- package/dist/MorphUnlitMaterial.js +7 -1
- package/dist/MorphUnlitMaterial.js.map +1 -1
- package/dist/ShaderLibrary.d.ts.map +1 -1
- package/dist/ShaderLibrary.js +34 -6
- package/dist/ShaderLibrary.js.map +1 -1
- package/dist/WebGPUDevice.d.ts +2 -0
- package/dist/WebGPUDevice.d.ts.map +1 -1
- package/dist/WebGPUDevice.js +69 -12
- package/dist/WebGPUDevice.js.map +1 -1
- package/dist/animation/AnimationMaterialStyle.d.ts +19 -0
- package/dist/animation/AnimationMaterialStyle.d.ts.map +1 -0
- package/dist/animation/AnimationMaterialStyle.js +13 -0
- package/dist/animation/AnimationMaterialStyle.js.map +1 -0
- package/dist/animation/AnimationRenderPreset.d.ts +36 -0
- package/dist/animation/AnimationRenderPreset.d.ts.map +1 -0
- package/dist/animation/AnimationRenderPreset.js +23 -0
- package/dist/animation/AnimationRenderPreset.js.map +1 -0
- package/dist/animation/AnimationToonMaterial.d.ts +130 -0
- package/dist/animation/AnimationToonMaterial.d.ts.map +1 -0
- package/dist/animation/AnimationToonMaterial.js +303 -0
- package/dist/animation/AnimationToonMaterial.js.map +1 -0
- package/dist/animation/AnimationVisualQuality.d.ts +28 -0
- package/dist/animation/AnimationVisualQuality.d.ts.map +1 -0
- package/dist/animation/AnimationVisualQuality.js +39 -0
- package/dist/animation/AnimationVisualQuality.js.map +1 -0
- package/dist/animation/applyAnimationRenderPreset.d.ts +79 -0
- package/dist/animation/applyAnimationRenderPreset.d.ts.map +1 -0
- package/dist/animation/applyAnimationRenderPreset.js +88 -0
- package/dist/animation/applyAnimationRenderPreset.js.map +1 -0
- package/dist/animation/index.d.ts +6 -0
- package/dist/animation/index.d.ts.map +1 -0
- package/dist/animation/index.js +6 -0
- package/dist/animation/index.js.map +1 -0
- package/dist/cartoon/CartoonToonMaterial.d.ts +130 -0
- package/dist/cartoon/CartoonToonMaterial.d.ts.map +1 -0
- package/dist/cartoon/CartoonToonMaterial.js +303 -0
- package/dist/cartoon/CartoonToonMaterial.js.map +1 -0
- package/dist/cartoon/applyCartoonRenderPreset.d.ts +79 -0
- package/dist/cartoon/applyCartoonRenderPreset.d.ts.map +1 -0
- package/dist/cartoon/applyCartoonRenderPreset.js +88 -0
- package/dist/cartoon/applyCartoonRenderPreset.js.map +1 -0
- package/dist/cartoon/index.d.ts +2 -0
- package/dist/cartoon/index.d.ts.map +1 -1
- package/dist/cartoon/index.js +2 -0
- package/dist/cartoon/index.js.map +1 -1
- package/dist/index.d.ts +4 -2
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +3 -2
- package/dist/index.js.map +1 -1
- package/package.json +4 -4
- package/src/ForwardPass.ts +18 -13
- package/src/MorphTargetPlan.ts +178 -0
- package/src/MorphUnlitMaterial.ts +7 -1
- package/src/ShaderLibrary.ts +34 -6
- package/src/WebGPUDevice.ts +83 -12
- package/src/{cartoon/CartoonMaterialStyle.ts → animation/AnimationMaterialStyle.ts} +9 -9
- package/src/{cartoon/CartoonRenderPreset.ts → animation/AnimationRenderPreset.ts} +10 -10
- package/src/animation/AnimationToonMaterial.ts +387 -0
- package/src/{cartoon/CartoonVisualQuality.ts → animation/AnimationVisualQuality.ts} +14 -14
- package/src/animation/applyAnimationRenderPreset.ts +180 -0
- package/src/animation/index.ts +5 -0
- package/src/index.ts +10 -2
- package/src/cartoon/index.ts +0 -3
package/src/ShaderLibrary.ts
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { ShaderPreprocessor, type ShaderPreprocessOptions } from "./ShaderPreprocessor";
|
|
2
2
|
import { DEFAULT_PBR_SHADER_MARKER, DEFAULT_PBR_SHADER_NAME } from "./PBRMaterial";
|
|
3
3
|
import { SHADER_CHUNKS, validateShaderChunks } from "./ShaderChunks";
|
|
4
|
+
import { registerAnimationToonShader } from "./animation/AnimationToonMaterial.js";
|
|
4
5
|
|
|
5
6
|
export interface ShaderSourcePair {
|
|
6
7
|
readonly name: string;
|
|
@@ -1322,7 +1323,7 @@ void main() {
|
|
|
1322
1323
|
float metallic = mix(u_metallic, clamp(u_metallic * metallicRoughnessSample.b, 0.0, 1.0), step(0.5, u_metallicRoughnessTextureEnabled));
|
|
1323
1324
|
float roughness = mix(u_roughness, clamp(u_roughness * metallicRoughnessSample.g, 0.0, 1.0), step(0.5, u_metallicRoughnessTextureEnabled));
|
|
1324
1325
|
float occlusion = mix(1.0, mix(1.0, texture(u_occlusionTexture, v_uv).r, clamp(u_occlusionStrength, 0.0, 1.0)), step(0.5, u_occlusionTextureEnabled));
|
|
1325
|
-
vec3 emissive = u_emissiveColor * u_emissiveStrength
|
|
1326
|
+
vec3 emissive = u_emissiveColor * u_emissiveStrength * mix(vec3(1.0), a3dPbrDecodeEnvironmentSrgb(texture(u_emissiveTexture, v_uv).rgb), step(0.5, u_emissiveTextureEnabled));
|
|
1326
1327
|
vec3 materialBase = a3dApplyAdvancedPbrLobes(
|
|
1327
1328
|
baseColor.rgb,
|
|
1328
1329
|
u_clearcoatFactor,
|
|
@@ -1442,16 +1443,39 @@ void main() {
|
|
|
1442
1443
|
precision highp float;
|
|
1443
1444
|
layout(location = 0) in vec3 a_position;
|
|
1444
1445
|
uniform mat4 u_modelViewProjection;
|
|
1446
|
+
// Uniform fast path (<= 4 targets / 64 verts):
|
|
1445
1447
|
uniform vec4 u_morphPositionDeltas[256];
|
|
1446
1448
|
uniform vec4 u_morphWeights;
|
|
1447
1449
|
uniform float u_morphTargetCount;
|
|
1450
|
+
// Texture-backed path (lifts the 4/64 cap; see MorphTargetPlan.ts createMorphTargetPlan):
|
|
1451
|
+
uniform sampler2D u_morphDeltaTexture;
|
|
1452
|
+
uniform float u_morphUsesTexture; // > 0.5 => sample deltas from the texture
|
|
1453
|
+
uniform float u_morphTextureWidth; // = vertexCount
|
|
1454
|
+
uniform float u_morphRowsPerTarget; // 1 = positions only, 2 = positions + normals
|
|
1455
|
+
uniform float u_morphWeightArray[64]; // per-target weights for the texture path
|
|
1456
|
+
vec3 sampleMorphTexel(float row, float vertex) {
|
|
1457
|
+
// Fetch RGBA float texel at (x=vertex, y=row) using normalized coords + nearest filtering.
|
|
1458
|
+
float u = (vertex + 0.5) / max(1.0, u_morphTextureWidth);
|
|
1459
|
+
float height = u_morphTargetCount * u_morphRowsPerTarget;
|
|
1460
|
+
float v = (row + 0.5) / max(1.0, height);
|
|
1461
|
+
return texture(u_morphDeltaTexture, vec2(u, v)).xyz;
|
|
1462
|
+
}
|
|
1448
1463
|
void main() {
|
|
1449
|
-
int morphVertexIndex = clamp(gl_VertexID, 0, 63);
|
|
1450
1464
|
vec3 morphDelta = vec3(0.0);
|
|
1451
|
-
|
|
1452
|
-
|
|
1453
|
-
|
|
1454
|
-
|
|
1465
|
+
if (u_morphUsesTexture > 0.5) {
|
|
1466
|
+
float vertex = float(gl_VertexID);
|
|
1467
|
+
for (int target = 0; target < 64; ++target) {
|
|
1468
|
+
if (float(target) >= u_morphTargetCount) break;
|
|
1469
|
+
float row = float(target) * u_morphRowsPerTarget;
|
|
1470
|
+
morphDelta += sampleMorphTexel(row, vertex) * u_morphWeightArray[target];
|
|
1471
|
+
}
|
|
1472
|
+
} else {
|
|
1473
|
+
int morphVertexIndex = clamp(gl_VertexID, 0, 63);
|
|
1474
|
+
for (int target = 0; target < 4; ++target) {
|
|
1475
|
+
if (float(target) < u_morphTargetCount) {
|
|
1476
|
+
int morphIndex = target * 64 + morphVertexIndex;
|
|
1477
|
+
morphDelta += u_morphPositionDeltas[morphIndex].xyz * u_morphWeights[target];
|
|
1478
|
+
}
|
|
1455
1479
|
}
|
|
1456
1480
|
}
|
|
1457
1481
|
vec3 morphedPosition = a_position + morphDelta;
|
|
@@ -2734,5 +2758,9 @@ void main() {
|
|
|
2734
2758
|
}
|
|
2735
2759
|
`
|
|
2736
2760
|
});
|
|
2761
|
+
// Register the animation/cel toon program (banded N·L ramp + Fresnel rim).
|
|
2762
|
+
// This is a real GLSL program compiled through the same library path as the
|
|
2763
|
+
// built-in shaders; AnimationToonMaterial targets it via ANIMATION_TOON_SHADER_NAME.
|
|
2764
|
+
registerAnimationToonShader(library);
|
|
2737
2765
|
return library;
|
|
2738
2766
|
}
|
package/src/WebGPUDevice.ts
CHANGED
|
@@ -360,6 +360,9 @@ class WebGPURenderTarget implements RenderTarget {
|
|
|
360
360
|
}
|
|
361
361
|
}
|
|
362
362
|
|
|
363
|
+
/** Joint-palette capacity of the WebGPU skinning path — parity with the WebGL2 `u_jointMatrices[96]`. */
|
|
364
|
+
export const MAX_WEBGPU_SKINNING_JOINTS = 96;
|
|
365
|
+
|
|
363
366
|
export class WebGPUDevice implements RenderDevice {
|
|
364
367
|
public readonly kind = "webgpu";
|
|
365
368
|
public readonly info: RenderDeviceInfo;
|
|
@@ -1162,6 +1165,17 @@ export class WebGPUDevice implements RenderDevice {
|
|
|
1162
1165
|
const modelMatrices = uniformRasterModelMatrices(command.uniforms, command.instanceCount ?? 1);
|
|
1163
1166
|
const depthTest = command.renderState?.depthTest !== false && this.activeRenderTarget.depthPixels !== null;
|
|
1164
1167
|
const depthWrite = command.renderState?.depthWrite !== false;
|
|
1168
|
+
// Full joint-palette skinning (up to 96 joints, WebGL2 parity). readLocal applies morph then skin.
|
|
1169
|
+
const jointPalette = jointPaletteFor(command.uniforms);
|
|
1170
|
+
const format = command.vertexFormat;
|
|
1171
|
+
const readLocal = (index: number): readonly [number, number, number] =>
|
|
1172
|
+
skinLocalPosition(
|
|
1173
|
+
readMorphedPosition(vertexBuffer.bytes, format.stride, position.offset, index, command.uniforms),
|
|
1174
|
+
vertexBuffer.bytes,
|
|
1175
|
+
format,
|
|
1176
|
+
index,
|
|
1177
|
+
jointPalette
|
|
1178
|
+
);
|
|
1165
1179
|
for (let instanceIndex = 0; instanceIndex < instanceMatrices.length; instanceIndex += 1) {
|
|
1166
1180
|
const matrix = instanceMatrices[instanceIndex] ?? identityMatrix();
|
|
1167
1181
|
const modelMatrix = modelMatrices[instanceIndex] ?? identityMatrix();
|
|
@@ -1170,9 +1184,9 @@ export class WebGPUDevice implements RenderDevice {
|
|
|
1170
1184
|
const indexA = indices[offset]!;
|
|
1171
1185
|
const indexB = indices[offset + 1]!;
|
|
1172
1186
|
const indexC = indices[offset + 2]!;
|
|
1173
|
-
const localA =
|
|
1174
|
-
const localB =
|
|
1175
|
-
const localC =
|
|
1187
|
+
const localA = readLocal(indexA);
|
|
1188
|
+
const localB = readLocal(indexB);
|
|
1189
|
+
const localC = readLocal(indexC);
|
|
1176
1190
|
const a = transformPosition(localA, matrix);
|
|
1177
1191
|
const b = transformPosition(localB, matrix);
|
|
1178
1192
|
const c = transformPosition(localC, matrix);
|
|
@@ -1191,15 +1205,15 @@ export class WebGPUDevice implements RenderDevice {
|
|
|
1191
1205
|
for (let offset = 0; offset + 1 < indices.length; offset += 2) {
|
|
1192
1206
|
const indexA = indices[offset]!;
|
|
1193
1207
|
const indexB = indices[offset + 1]!;
|
|
1194
|
-
const a = transformPosition(
|
|
1195
|
-
const b = transformPosition(
|
|
1208
|
+
const a = transformPosition(readLocal(indexA), matrix);
|
|
1209
|
+
const b = transformPosition(readLocal(indexB), matrix);
|
|
1196
1210
|
const colorA = readVertexColor(vertexBuffer.bytes, command.vertexFormat.stride, colorAttribute?.offset, indexA);
|
|
1197
1211
|
const colorB = readVertexColor(vertexBuffer.bytes, command.vertexFormat.stride, colorAttribute?.offset, indexB);
|
|
1198
1212
|
rasterizeLine(this.activeRenderTarget, a, b, color, colorA, colorB, depthTest, depthWrite);
|
|
1199
1213
|
}
|
|
1200
1214
|
} else {
|
|
1201
1215
|
for (const index of indices) {
|
|
1202
|
-
const point = transformPosition(
|
|
1216
|
+
const point = transformPosition(readLocal(index), matrix);
|
|
1203
1217
|
const vertexColor = readVertexColor(vertexBuffer.bytes, command.vertexFormat.stride, colorAttribute?.offset, index);
|
|
1204
1218
|
rasterizePoint(this.activeRenderTarget, point, multiplyColor(color, vertexColor), depthTest, depthWrite);
|
|
1205
1219
|
}
|
|
@@ -1531,7 +1545,8 @@ export class WebGPUDevice implements RenderDevice {
|
|
|
1531
1545
|
|
|
1532
1546
|
private createNativeDrawUniformBuffer(command: DrawCommand): WebGPUBufferLike | null {
|
|
1533
1547
|
if (!this.device.createBindGroup) return null;
|
|
1534
|
-
|
|
1548
|
+
// 188 floats for the scalar/matrix fields + 96 joint matrices (16 floats each) appended at 188.
|
|
1549
|
+
const data = new Float32Array(188 + MAX_WEBGPU_SKINNING_JOINTS * 16);
|
|
1535
1550
|
const baseColorBinding = uniformBaseColorTextureBinding(command.uniforms);
|
|
1536
1551
|
const environmentBinding = uniformTextureBinding(command.uniforms, "u_environmentMapTexture");
|
|
1537
1552
|
const normalBinding = uniformTextureBinding(command.uniforms, "u_normalTexture");
|
|
@@ -1573,9 +1588,13 @@ export class WebGPUDevice implements RenderDevice {
|
|
|
1573
1588
|
for (let index = 0; index < 4; index += 1) {
|
|
1574
1589
|
data.set(instanceMatrices[index] ?? (index === 0 ? modelMatrix : identityMatrix()), 32 + index * 16);
|
|
1575
1590
|
}
|
|
1576
|
-
|
|
1577
|
-
|
|
1578
|
-
|
|
1591
|
+
// Legacy 2-slot joint fields (offsets 96/112) kept as identity for layout stability.
|
|
1592
|
+
data.set(identityMatrix(), 96);
|
|
1593
|
+
data.set(identityMatrix(), 112);
|
|
1594
|
+
// Full 96-joint palette (WebGL2 parity), appended after normalMatrix at offset 188.
|
|
1595
|
+
const jointMatrices = uniformMat4Array(command.uniforms?.get("u_jointMatrices"), MAX_WEBGPU_SKINNING_JOINTS);
|
|
1596
|
+
for (let index = 0; index < MAX_WEBGPU_SKINNING_JOINTS; index += 1) {
|
|
1597
|
+
data.set(jointMatrices[index] ?? identityMatrix(), 188 + index * 16);
|
|
1579
1598
|
}
|
|
1580
1599
|
const morphDeltas = command.uniforms?.get("u_morphPositionDeltas");
|
|
1581
1600
|
const morphNumbers = morphDeltas instanceof Float32Array || Array.isArray(morphDeltas) ? Array.from(morphDeltas).slice(0, 32) : [];
|
|
@@ -2097,6 +2116,54 @@ function identityMatrix(): readonly number[] {
|
|
|
2097
2116
|
return [1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1];
|
|
2098
2117
|
}
|
|
2099
2118
|
|
|
2119
|
+
function readVec4Attribute(bytes: Uint8Array, stride: number, offset: number, vertexIndex: number): readonly [number, number, number, number] {
|
|
2120
|
+
const view = new DataView(bytes.buffer, bytes.byteOffset, bytes.byteLength);
|
|
2121
|
+
const base = vertexIndex * stride + offset;
|
|
2122
|
+
return [
|
|
2123
|
+
view.getFloat32(base, true),
|
|
2124
|
+
view.getFloat32(base + 4, true),
|
|
2125
|
+
view.getFloat32(base + 8, true),
|
|
2126
|
+
view.getFloat32(base + 12, true)
|
|
2127
|
+
];
|
|
2128
|
+
}
|
|
2129
|
+
|
|
2130
|
+
// CPU skinning for the WebGPU emulation rasterizer: blend the joint palette (up to the full
|
|
2131
|
+
// WebGL2-parity 96-joint count) by the vertex's 4 joint indices + weights, then transform the local
|
|
2132
|
+
// position by the blended matrix. Mirrors the WebGL2 skinning path so a skinned character deforms
|
|
2133
|
+
// identically on both backends. `palette` may hold up to 96 matrices (parity with WebGL2).
|
|
2134
|
+
function skinLocalPosition(
|
|
2135
|
+
local: readonly [number, number, number],
|
|
2136
|
+
bytes: Uint8Array,
|
|
2137
|
+
format: VertexFormat,
|
|
2138
|
+
vertexIndex: number,
|
|
2139
|
+
palette: readonly (readonly number[])[]
|
|
2140
|
+
): readonly [number, number, number] {
|
|
2141
|
+
if (palette.length === 0 || !format.hasAttribute("joints") || !format.hasAttribute("weights")) {
|
|
2142
|
+
return local;
|
|
2143
|
+
}
|
|
2144
|
+
const joints = readVec4Attribute(bytes, format.stride, format.getAttribute("joints").offset, vertexIndex);
|
|
2145
|
+
const weights = readVec4Attribute(bytes, format.stride, format.getAttribute("weights").offset, vertexIndex);
|
|
2146
|
+
const weightSum = weights[0] + weights[1] + weights[2] + weights[3];
|
|
2147
|
+
if (weightSum <= 1e-4) return local;
|
|
2148
|
+
const blended = new Array<number>(16).fill(0);
|
|
2149
|
+
const maxJoint = palette.length - 1;
|
|
2150
|
+
for (let influence = 0; influence < 4; influence += 1) {
|
|
2151
|
+
const weight = weights[influence] ?? 0;
|
|
2152
|
+
if (weight === 0) continue;
|
|
2153
|
+
const jointIndex = Math.max(0, Math.min(maxJoint, Math.round(joints[influence] ?? 0)));
|
|
2154
|
+
const jointMatrix = palette[jointIndex] ?? identityMatrix();
|
|
2155
|
+
for (let k = 0; k < 16; k += 1) blended[k] += (jointMatrix[k] ?? 0) * weight;
|
|
2156
|
+
}
|
|
2157
|
+
return transformPosition(local, blended);
|
|
2158
|
+
}
|
|
2159
|
+
|
|
2160
|
+
function jointPaletteFor(uniforms: DrawCommand["uniforms"]): readonly (readonly number[])[] {
|
|
2161
|
+
const value = uniforms?.get("u_jointMatrices");
|
|
2162
|
+
const length = value instanceof Float32Array || Array.isArray(value) ? (value as ArrayLike<number>).length : 0;
|
|
2163
|
+
const count = Math.min(MAX_WEBGPU_SKINNING_JOINTS, Math.floor(length / 16));
|
|
2164
|
+
return count > 0 ? uniformMat4Array(value, count) : [];
|
|
2165
|
+
}
|
|
2166
|
+
|
|
2100
2167
|
function readVertexColor(bytes: Uint8Array, stride: number, offset: number | undefined, vertexIndex: number): readonly [number, number, number, number] {
|
|
2101
2168
|
if (offset === undefined) return [1, 1, 1, 1];
|
|
2102
2169
|
const view = new DataView(bytes.buffer, bytes.byteOffset, bytes.byteLength);
|
|
@@ -2385,6 +2452,7 @@ function nativeUniformStruct(): string {
|
|
|
2385
2452
|
joint0: mat4x4<f32>,
|
|
2386
2453
|
joint1: mat4x4<f32>,
|
|
2387
2454
|
morph0: vec4<f32>,
|
|
2455
|
+
// (joint palette appended at struct end below as \`joints\` for 96-joint WebGL2 parity)
|
|
2388
2456
|
morph1: vec4<f32>,
|
|
2389
2457
|
morph2: vec4<f32>,
|
|
2390
2458
|
morph3: vec4<f32>,
|
|
@@ -2396,6 +2464,9 @@ function nativeUniformStruct(): string {
|
|
|
2396
2464
|
camera: vec4<f32>,
|
|
2397
2465
|
materialFlags: vec4<f32>,
|
|
2398
2466
|
normalMatrix: mat4x4<f32>,
|
|
2467
|
+
// 96-joint skinning palette (WebGL2 \`u_jointMatrices[96]\` parity). Appended at the struct end so
|
|
2468
|
+
// the existing field offsets are unchanged.
|
|
2469
|
+
joints: array<mat4x4<f32>, 96>,
|
|
2399
2470
|
};
|
|
2400
2471
|
|
|
2401
2472
|
@group(0) @binding(0) var<uniform> u_draw: DrawUniforms;
|
|
@@ -2717,8 +2788,8 @@ struct VertexOutput {
|
|
|
2717
2788
|
};
|
|
2718
2789
|
|
|
2719
2790
|
fn jointMatrix(index: f32) -> mat4x4<f32> {
|
|
2720
|
-
|
|
2721
|
-
return u_draw.
|
|
2791
|
+
let i = clamp(i32(index + 0.5), 0, 95);
|
|
2792
|
+
return u_draw.joints[i];
|
|
2722
2793
|
}
|
|
2723
2794
|
|
|
2724
2795
|
@vertex
|
|
@@ -1,16 +1,16 @@
|
|
|
1
|
-
export type
|
|
1
|
+
export type AnimationMaterialTreatment = "preserve-pbr" | "soft-toon" | "cel" | "flat-readable";
|
|
2
2
|
|
|
3
|
-
export interface
|
|
4
|
-
readonly treatment?:
|
|
3
|
+
export interface AnimationMaterialStyleOptions {
|
|
4
|
+
readonly treatment?: AnimationMaterialTreatment | undefined;
|
|
5
5
|
readonly outline?: boolean | undefined;
|
|
6
6
|
readonly rampSteps?: number | undefined;
|
|
7
7
|
readonly saturationBoost?: number | undefined;
|
|
8
8
|
readonly roughnessFloor?: number | undefined;
|
|
9
9
|
}
|
|
10
10
|
|
|
11
|
-
export interface
|
|
12
|
-
readonly kind: "
|
|
13
|
-
readonly treatment:
|
|
11
|
+
export interface AnimationMaterialStyle {
|
|
12
|
+
readonly kind: "animation-material-style";
|
|
13
|
+
readonly treatment: AnimationMaterialTreatment;
|
|
14
14
|
readonly outline: boolean;
|
|
15
15
|
readonly rampSteps: number;
|
|
16
16
|
readonly saturationBoost: number;
|
|
@@ -18,15 +18,15 @@ export interface CartoonMaterialStyle {
|
|
|
18
18
|
readonly assetOverrideMetadata: readonly string[];
|
|
19
19
|
}
|
|
20
20
|
|
|
21
|
-
export function
|
|
21
|
+
export function createAnimationMaterialStyle(options: AnimationMaterialStyleOptions = {}): AnimationMaterialStyle {
|
|
22
22
|
const treatment = options.treatment ?? "soft-toon";
|
|
23
23
|
return {
|
|
24
|
-
kind: "
|
|
24
|
+
kind: "animation-material-style",
|
|
25
25
|
treatment,
|
|
26
26
|
outline: options.outline ?? treatment === "cel",
|
|
27
27
|
rampSteps: options.rampSteps ?? (treatment === "cel" ? 4 : 7),
|
|
28
28
|
saturationBoost: options.saturationBoost ?? 0.08,
|
|
29
29
|
roughnessFloor: options.roughnessFloor ?? 0.48,
|
|
30
|
-
assetOverrideMetadata: ["
|
|
30
|
+
assetOverrideMetadata: ["animationMaterialTreatment", "toonRampSteps", "outlineEligible", "preserveSkinning"]
|
|
31
31
|
};
|
|
32
32
|
}
|
|
@@ -1,33 +1,33 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { createAnimationMaterialStyle, type AnimationMaterialStyle, type AnimationMaterialStyleOptions } from "./AnimationMaterialStyle.js";
|
|
2
2
|
|
|
3
|
-
export interface
|
|
3
|
+
export interface AnimationRenderPresetOptions {
|
|
4
4
|
readonly name?: string | undefined;
|
|
5
5
|
readonly resolution?: { readonly width: number; readonly height: number } | undefined;
|
|
6
|
-
readonly materialStyle?:
|
|
6
|
+
readonly materialStyle?: AnimationMaterialStyleOptions | undefined;
|
|
7
7
|
readonly reducedMotion?: boolean | undefined;
|
|
8
8
|
readonly reducedFlash?: boolean | undefined;
|
|
9
9
|
}
|
|
10
10
|
|
|
11
|
-
export interface
|
|
12
|
-
readonly kind: "
|
|
11
|
+
export interface AnimationRenderPresetEvidence {
|
|
12
|
+
readonly kind: "animation-render-preset-evidence";
|
|
13
13
|
readonly name: string;
|
|
14
14
|
readonly resolution: { readonly width: number; readonly height: number };
|
|
15
15
|
readonly lights: readonly string[];
|
|
16
16
|
readonly shadows: { readonly soft: boolean; readonly contact: boolean };
|
|
17
17
|
readonly postprocess: { readonly bloom: number; readonly colorGrade: string; readonly fogDepthCue: boolean };
|
|
18
|
-
readonly materialStyle:
|
|
18
|
+
readonly materialStyle: AnimationMaterialStyle;
|
|
19
19
|
readonly frameBudgetMs: number;
|
|
20
20
|
readonly debugOverlaysAllowedInExport: false;
|
|
21
21
|
readonly reducedMotion: boolean;
|
|
22
22
|
readonly reducedFlash: boolean;
|
|
23
23
|
}
|
|
24
24
|
|
|
25
|
-
export function
|
|
25
|
+
export function createAnimationRenderPreset(options: AnimationRenderPresetOptions = {}): AnimationRenderPresetEvidence {
|
|
26
26
|
const reducedMotion = options.reducedMotion ?? false;
|
|
27
27
|
const reducedFlash = options.reducedFlash ?? false;
|
|
28
28
|
return {
|
|
29
|
-
kind: "
|
|
30
|
-
name: options.name ?? "moon-garden-
|
|
29
|
+
kind: "animation-render-preset-evidence",
|
|
30
|
+
name: options.name ?? "moon-garden-animation",
|
|
31
31
|
resolution: options.resolution ?? { width: 1280, height: 720 },
|
|
32
32
|
lights: ["soft-key", "cool-rim", "set-fill", "emissive-practicals"],
|
|
33
33
|
shadows: { soft: true, contact: true },
|
|
@@ -36,7 +36,7 @@ export function createCartoonRenderPreset(options: CartoonRenderPresetOptions =
|
|
|
36
36
|
colorGrade: "storybook-night",
|
|
37
37
|
fogDepthCue: true
|
|
38
38
|
},
|
|
39
|
-
materialStyle:
|
|
39
|
+
materialStyle: createAnimationMaterialStyle(options.materialStyle),
|
|
40
40
|
frameBudgetMs: 16.7,
|
|
41
41
|
debugOverlaysAllowedInExport: false,
|
|
42
42
|
reducedMotion,
|