pixelkiln 0.98.0 → 0.99.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/index.cjs CHANGED
@@ -106,9 +106,12 @@ __export(index_exports, {
106
106
  MediaType: () => MediaType,
107
107
  NORMAL_MAP_CONVENTIONS: () => NORMAL_MAP_CONVENTIONS,
108
108
  NORMAL_MAP_COST_GENERATIONS: () => NORMAL_MAP_COST_GENERATIONS,
109
+ NORMAL_MAP_KINDS: () => NORMAL_MAP_KINDS,
109
110
  NORMAL_MAP_MAX_FRAMES: () => NORMAL_MAP_MAX_FRAMES,
110
111
  NORMAL_MAP_MAX_SIDE: () => NORMAL_MAP_MAX_SIDE,
111
112
  NORMAL_MAP_MIN_SIDE: () => NORMAL_MAP_MIN_SIDE,
113
+ NORMAL_MAP_MODES: () => NORMAL_MAP_MODES,
114
+ NORMAL_MAP_SHAPE_RANGES: () => NORMAL_MAP_SHAPE_RANGES,
112
115
  NormalMapConventionSchema: () => NormalMapConventionSchema,
113
116
  OverwriteRefusedError: () => OverwriteRefusedError,
114
117
  PIXELATE_COST_GENERATIONS: () => PIXELATE_COST_GENERATIONS,
@@ -276,6 +279,7 @@ __export(index_exports, {
276
279
  mountStyle: () => mountStyle,
277
280
  musicCost: () => musicCost,
278
281
  musicOutputPaths: () => musicOutputPaths,
282
+ normalMapCost: () => normalMapCost,
279
283
  normalMapFile: () => normalMapFile,
280
284
  normalMapResultPng: () => normalMapResultPng,
281
285
  normalMapSizeProblem: () => normalMapSizeProblem,
@@ -961,6 +965,24 @@ var RevisionSchema = import_zod.z.object({
961
965
  removalTask: import_zod.z.enum(["simple", "complex"]).optional(),
962
966
  /** `normal-map` only: `opengl` (green up; PixelLab's default) or `directx` (green down, for Unreal). */
963
967
  convention: NormalMapConventionSchema.optional(),
968
+ /**
969
+ * `normal-map` only: `lite` (PixelLab's default, 0.1 generation) makes the
970
+ * map from the art alone; `pro` (0.5) plans each part's shape, what is in
971
+ * front and what is sunk.
972
+ */
973
+ normalMapMode: import_zod.z.enum(["lite", "pro"]).optional(),
974
+ /** `normal-map` only: what the picture is. Left out, PixelLab reads it from the picture; set it for sidescroller, isometric and UI art. */
975
+ normalMapKind: import_zod.z.enum(["character", "object", "topdown", "side", "iso", "ui"]).optional(),
976
+ /** `normal-map` only: how far every pixel tilts away from facing the viewer, 0 to 2 (the API refuses more). */
977
+ normalMapStrength: import_zod.z.number().min(0).max(2).optional(),
978
+ /** `normal-map` only: how much the outline rounds off, 0 to 3; 0 keeps it flat to the edge. */
979
+ outlineRounding: import_zod.z.number().min(0).max(3).optional(),
980
+ /** `normal-map` only: how much the sprite's 3D parts (a round head, an arm) add, 0 to 2. */
981
+ partShapes: import_zod.z.number().min(0).max(2).optional(),
982
+ /** `normal-map` only: the art's own light and dark as bumps, 0 to 2; 0 for a smooth surface. */
983
+ surfaceDetail: import_zod.z.number().min(0).max(2).optional(),
984
+ /** `normal-map` only: how far that detail is blurred, 0.6 to 3 px. */
985
+ detailSoftness: import_zod.z.number().min(0.6).max(3).optional(),
964
986
  /**
965
987
  * `animate-skeleton`: what the character *looks like*, a noun
966
988
  * phrase (colours, clothing, held items) — distinct from the asset's
@@ -1121,6 +1143,15 @@ var RevisionSchema = import_zod.z.object({
1121
1143
  path: ["convention"]
1122
1144
  });
1123
1145
  }
1146
+ for (const field of ["normalMapMode", "normalMapKind", "normalMapStrength", "outlineRounding", "partShapes", "surfaceDetail", "detailSoftness"]) {
1147
+ if (revision[field] !== void 0 && revision.mode !== "normal-map") {
1148
+ context.addIssue({
1149
+ code: import_zod.z.ZodIssueCode.custom,
1150
+ message: `${field} applies to normal-map revisions only`,
1151
+ path: [field]
1152
+ });
1153
+ }
1154
+ }
1124
1155
  if (revision.description !== void 0 && revision.mode !== "animate-skeleton" && revision.mode !== "remove-background") {
1125
1156
  context.addIssue({
1126
1157
  code: import_zod.z.ZodIssueCode.custom,
@@ -2831,6 +2862,14 @@ function targetPaletteBody(palette) {
2831
2862
  }
2832
2863
  };
2833
2864
  }
2865
+ var NORMAL_MAP_MODES = ["lite", "pro"];
2866
+ var NORMAL_MAP_KINDS = ["character", "object", "topdown", "side", "iso", "ui"];
2867
+ var NORMAL_MAP_SHAPE_RANGES = {
2868
+ outlineRounding: [0, 3],
2869
+ partShapes: [0, 2],
2870
+ surfaceDetail: [0, 2],
2871
+ detailSoftness: [0.6, 3]
2872
+ };
2834
2873
  var PixelLabClient = class {
2835
2874
  constructor(apiKey, timeoutMs = 12e4) {
2836
2875
  this.apiKey = apiKey;
@@ -3909,8 +3948,15 @@ var PixelLabClient = class {
3909
3948
  */
3910
3949
  async normalMap(args) {
3911
3950
  const body = { image: args.image };
3951
+ if (args.mode) body.mode = args.mode;
3952
+ if (args.kind) body.kind = args.kind;
3953
+ if (args.shape?.strength != null) body.strength = args.shape.strength;
3912
3954
  if (args.frames != null && args.frames !== 1) body.frames = args.frames;
3913
3955
  if (args.convention) body.convention = args.convention;
3956
+ if (args.shape?.outlineRounding != null) body.outline_rounding = args.shape.outlineRounding;
3957
+ if (args.shape?.partShapes != null) body.part_shapes = args.shape.partShapes;
3958
+ if (args.shape?.surfaceDetail != null) body.surface_detail = args.shape.surfaceDetail;
3959
+ if (args.shape?.detailSoftness != null) body.detail_softness = args.shape.detailSoftness;
3914
3960
  return validateResponse(
3915
3961
  RevisionJobSubmitSchema,
3916
3962
  await this.request("/normal-map", { method: "POST", body: JSON.stringify(body) }),
@@ -5174,6 +5220,14 @@ function specHash(spec, styleImageHashes, providerOptionIdentity = spec.provider
5174
5220
  description: spec.revision.description,
5175
5221
  removalTask: spec.revision.removalTask,
5176
5222
  convention: spec.revision.convention,
5223
+ // Each only when set, so normal-map revisions made before them keep their hash.
5224
+ normalMapMode: spec.revision.normalMapMode,
5225
+ normalMapKind: spec.revision.normalMapKind,
5226
+ normalMapStrength: spec.revision.normalMapStrength,
5227
+ outlineRounding: spec.revision.outlineRounding,
5228
+ partShapes: spec.revision.partShapes,
5229
+ surfaceDetail: spec.revision.surfaceDetail,
5230
+ detailSoftness: spec.revision.detailSoftness,
5177
5231
  driftThreshold: spec.revision.driftThreshold,
5178
5232
  subjectDescription: spec.revision.subjectDescription,
5179
5233
  initialPose: spec.revision.initialPose,
@@ -5950,6 +6004,9 @@ async function pixelateFile(client2, input, opts = {}) {
5950
6004
  await sleep3(interval);
5951
6005
  }
5952
6006
  }
6007
+ function normalMapCost(mode2) {
6008
+ return mode2 === "pro" ? 0.5 : 0.1;
6009
+ }
5953
6010
  var NORMAL_MAP_COST_GENERATIONS = 0.5;
5954
6011
  var NORMAL_MAP_MIN_SIDE = 8;
5955
6012
  var NORMAL_MAP_MAX_SIDE = 512;
@@ -5994,7 +6051,10 @@ async function normalMapFile(client2, input, opts = {}) {
5994
6051
  const submitted = await client2.normalMap({
5995
6052
  image: { base64: bytes.toString("base64"), format: "png" },
5996
6053
  frames,
5997
- convention: opts.convention
6054
+ convention: opts.convention,
6055
+ shape: opts.shape,
6056
+ mode: opts.mode,
6057
+ kind: opts.kind
5998
6058
  });
5999
6059
  const jobId = submitted.background_job_id;
6000
6060
  const started = Date.now();
@@ -6259,7 +6319,7 @@ var PixelLabProvider = class _PixelLabProvider {
6259
6319
  return { unit: "generations", amount: 1, candidates: 1 };
6260
6320
  }
6261
6321
  if (spec.revision?.mode === "normal-map") {
6262
- return { unit: "generations", amount: NORMAL_MAP_COST_GENERATIONS, candidates: 1 };
6322
+ return { unit: "generations", amount: normalMapCost(spec.revision.normalMapMode), candidates: 1 };
6263
6323
  }
6264
6324
  if (spec.revision?.mode === "reduce-colors" || spec.revision?.mode === "correct-pixelart") {
6265
6325
  return { unit: "generations", amount: 0.1, candidates: 1 };
@@ -7733,7 +7793,20 @@ var PixelLabProvider = class _PixelLabProvider {
7733
7793
  }
7734
7794
  if (revision.mode === "normal-map") {
7735
7795
  const strip = roles ? { base64: joinStripPng(images.map((member) => Buffer.from(member.base64, "base64"))).toString("base64"), format: "png" } : image;
7736
- const res2 = await this.client.normalMap({ image: strip, frames: roles?.length ?? 1, convention: revision.convention });
7796
+ const res2 = await this.client.normalMap({
7797
+ image: strip,
7798
+ frames: roles?.length ?? 1,
7799
+ convention: revision.convention,
7800
+ mode: revision.normalMapMode,
7801
+ kind: revision.normalMapKind,
7802
+ shape: {
7803
+ strength: revision.normalMapStrength,
7804
+ outlineRounding: revision.outlineRounding,
7805
+ partShapes: revision.partShapes,
7806
+ surfaceDetail: revision.surfaceDetail,
7807
+ detailSoftness: revision.detailSoftness
7808
+ }
7809
+ });
7737
7810
  return {
7738
7811
  jobId: res2.background_job_id,
7739
7812
  metadata: roles ? { revisionMembers: roles, ...revision.sourceFps != null ? { revisionFps: revision.sourceFps } : {} } : {}
@@ -12392,6 +12465,13 @@ async function resolveSpecs(loaded, filter) {
12392
12465
  ...asset.revision.description ? { description: asset.revision.description } : {},
12393
12466
  ...asset.revision.removalTask ? { removalTask: asset.revision.removalTask } : {},
12394
12467
  ...asset.revision.convention ? { convention: asset.revision.convention } : {},
12468
+ ...asset.revision.normalMapMode ? { normalMapMode: asset.revision.normalMapMode } : {},
12469
+ ...asset.revision.normalMapKind ? { normalMapKind: asset.revision.normalMapKind } : {},
12470
+ ...asset.revision.normalMapStrength == null ? {} : { normalMapStrength: asset.revision.normalMapStrength },
12471
+ ...asset.revision.outlineRounding == null ? {} : { outlineRounding: asset.revision.outlineRounding },
12472
+ ...asset.revision.partShapes == null ? {} : { partShapes: asset.revision.partShapes },
12473
+ ...asset.revision.surfaceDetail == null ? {} : { surfaceDetail: asset.revision.surfaceDetail },
12474
+ ...asset.revision.detailSoftness == null ? {} : { detailSoftness: asset.revision.detailSoftness },
12395
12475
  ...asset.revision.driftThreshold == null ? {} : { driftThreshold: asset.revision.driftThreshold },
12396
12476
  ...asset.revision.subjectDescription ? { subjectDescription: asset.revision.subjectDescription } : {},
12397
12477
  ...asset.revision.initialPose ? { initialPose: asset.revision.initialPose } : {},
@@ -23479,9 +23559,12 @@ async function workspaceStatus(ws, dir) {
23479
23559
  MediaType,
23480
23560
  NORMAL_MAP_CONVENTIONS,
23481
23561
  NORMAL_MAP_COST_GENERATIONS,
23562
+ NORMAL_MAP_KINDS,
23482
23563
  NORMAL_MAP_MAX_FRAMES,
23483
23564
  NORMAL_MAP_MAX_SIDE,
23484
23565
  NORMAL_MAP_MIN_SIDE,
23566
+ NORMAL_MAP_MODES,
23567
+ NORMAL_MAP_SHAPE_RANGES,
23485
23568
  NormalMapConventionSchema,
23486
23569
  OverwriteRefusedError,
23487
23570
  PIXELATE_COST_GENERATIONS,
@@ -23649,6 +23732,7 @@ async function workspaceStatus(ws, dir) {
23649
23732
  mountStyle,
23650
23733
  musicCost,
23651
23734
  musicOutputPaths,
23735
+ normalMapCost,
23652
23736
  normalMapFile,
23653
23737
  normalMapResultPng,
23654
23738
  normalMapSizeProblem,