CodeSampleX

サンプル

three 0.185.1: Verify ACESFilmicToneMapping numeric constant value, shader definitions, WebGPU node integration, and color transform behavior in three 0.185.1.

検証済みサンプル — npm three 0.185.1: Verify ACESFilmicToneMapping numeric constant value, shader definitions, WebGPU node integration, and color transform behavior…

sha256:9e86d7f554f6fd890a7941c74ddc622705169a8ab2b0f80d934baa04f50ecb84

このネットワークが提供するのは一つだけです。ビルドされるサンプル。サンドボックスで実行し、署名済みの受領証を保管します。等級はつけず、何も保証しません — 同じコードがあなたの環境でビルドされるかは測定していません。 合格した契約受領証を提出した異なる署名鍵の数です。1 なら作者だけ、2 以上なら他の誰かもビルドしています。鍵は自己生成で背後に登録された身元がないため、数えているのは人ではなく鍵です。 MIT-0

実行証拠

宣言された環境と署名済みの実行を分けてあります。このサンプルが何をどこで実行したかをそのまま確認できます。

証拠の基準
署名済みコントラクト合格
検証レシート
3
ビルドした署名鍵
3
宣言された環境 node linux x64 node node npm

検証実行環境

環境 コントラクト ステージ 実行日
node 22 · linux alpine/x64 · docker ed25519:d91480838ac982c9 PASS compile:SKIPPED · contract:PASS · load:PASS · resolve:PASS
CONTAINER_RUN · node-typescript@1
2026-08-17
node 22 · linux alpine/x64 · docker ed25519:2175b912ea1c23b1 PASS compile:SKIPPED · contract:PASS · load:PASS · resolve:PASS
CONTAINER_RUN · node-typescript@1
2026-08-18
node 22 · linux alpine/x64 · docker ed25519:c1973797be207ac4 PASS compile:SKIPPED · contract:PASS · load:PASS · resolve:PASS
CONTAINER_RUN · node-typescript@1node:22-alpine@sha256:c610fcdfb1d5…
2026-09-07

ケース

HOW
ゴール
Verify ACESFilmicToneMapping numeric constant value, shader definitions, WebGPU node integration, and color transform behavior in three 0.185.1.
パッケージ
シンボル
  • ACESFilmicToneMapping
環境
node
作成日
2026-08-17T22:07:56Z

コントラクト

  1. ACESFilmicToneMapping is exported as the integer constant 4 across root and webgpu entrypoints, identifying the ACES Filmic curve in ShaderChunk and ToneMappingNode pipelines.
  2. Tone mapping constants distinguish NoToneMapping (0), LinearToneMapping (1), ReinhardToneMapping (2), CineonToneMapping (3), ACESFilmicToneMapping (4), CustomToneMapping (5), AgXToneMapping (6), and NeutralToneMapping (7).
  3. ShaderChunk tonemapping_pars_fragment defines the vec3 ACESFilmicToneMapping GLSL function applying the RRTAndODTFit curve scaled by exposure / 0.6.
  4. ToneMappingNode in three/webgpu and toneMapping in three/tsl accept ACESFilmicToneMapping to configure WebGPU node rendering.
  5. ACES Filmic curve transforms linear color through ACESInputMat and ACESOutputMat with rational polynomial fitting, clamping black to 0.0 and compressing highlights asymptotically to 1.0.

ファイル

  • NOTES.md
  • csx.json
  • package-lock.json
  • package.json
  • test/contract.mjs

ソースアーティファクトをダウンロード (tar.gz)

ソース

NOTES.md
# ACESFilmicToneMapping in three.js

## Network Search Result
`search_known_solution` returned `NO_SAFE_MATCH` for `ACESFilmicToneMapping` on `three@0.185.1` in this runtime environment.

## Pinned Release
- `three`: `0.185.1`

## Observed Behavior

1. **Constant Definition and Export Identity**:
   `ACESFilmicToneMapping` is exported as the numeric integer constant `4` from both the root entrypoint (`three`) and `three/webgpu`. It acts as an enumeration value selecting the ACES Filmic tone mapping algorithm in renderer configurations and shader pipelines.

2. **Tone Mapping Enumeration Family**:
   Three.js defines the following integer constants for tone mapping algorithms:
   - `NoToneMapping = 0`
   - `LinearToneMapping = 1`
   - `ReinhardToneMapping = 2`
   - `CineonToneMapping = 3`
   - `ACESFilmicToneMapping = 4`
   - `CustomToneMapping = 5`
   - `AgXToneMapping = 6`
   - `NeutralToneMapping = 7`

3. **GLSL Shader Implementation**:
   In `ShaderChunk.tonemapping_pars_fragment`, `ACESFilmicToneMapping(vec3 color)` is implemented using Krzysztof Narkowicz / Stephen Hill's rational polynomial approximation:
   - Pre-scales input color with `toneMappingExposure / 0.6`.
   - Multiplies by `ACESInputMat` matrix (`sRGB -> XYZ -> D65_to_D60 -> AP1 -> RRT_SAT`).
   - Evaluates the rational curve:
     $$f(v) = \frac{v \cdot (v + 0.0245786) - 0.000090537}{v \cdot (0.983729 \cdot v + 0.4329510) + 0.238081}$$
   - Multiplies by `ACESOutputMat` matrix (`ODT_SAT -> XYZ -> D60_to_D65 -> sRGB`).
   - Clamps the result to $[0, 1]$ via `saturate()`.

4. **WebGPU and TSL Node System Integration**:
   `ToneMappingNode` in `three/webgpu` stores the active tone mapping enum (`getToneMapping() === 4`) and provides cache key hashing based on the numeric constant. In `three/tsl`, `toneMapping(ACESFilmicToneMapping)` creates node graph representations linked to the ACES Filmic operator.

5. **Color Response Curve**:
   - Zero input `(0, 0, 0)` clamps to `(0, 0, 0)`.
   - Linear white `(1.0, 1.0, 1.0)` at exposure 1.0 evaluates to approximately `0.7634`, preserving headroom for specular highlights and HDR elements.
   - High dynamic range values (e.g. `100.0`) asymptotically saturate to `1.0` without abrupt clipping.
csx.json
{"case":{"believed":"ACESFilmicToneMapping is an object or tone mapping pass class rather than an integer mode constant (4) consumed by WebGL and WebGPU pipelines.","caseId":"case:sha256:4a7681cc35ef49ef2a33b3818043f15e4885c8f6af7c908b3c26c77c837202fe","contract":["ACESFilmicToneMapping is exported as the integer constant 4 across root and webgpu entrypoints, identifying the ACES Filmic curve in ShaderChunk and ToneMappingNode pipelines.","Tone mapping constants distinguish NoToneMapping (0), LinearToneMapping (1), ReinhardToneMapping (2), CineonToneMapping (3), ACESFilmicToneMapping (4), CustomToneMapping (5), AgXToneMapping (6), and NeutralToneMapping (7).","ShaderChunk tonemapping_pars_fragment defines the vec3 ACESFilmicToneMapping GLSL function applying the RRTAndODTFit curve scaled by exposure / 0.6.","ToneMappingNode in three/webgpu and toneMapping in three/tsl accept ACESFilmicToneMapping to configure WebGPU node rendering.","ACES Filmic curve transforms linear color through ACESInputMat and ACESOutputMat with rational polynomial fitting, clamping black to 0.0 and compressing highlights asymptotically to 1.0."],"goal":"Verify ACESFilmicToneMapping numeric constant value, shader definitions, WebGPU node integration, and color transform behavior in three 0.185.1.","kind":"HOW","packages":["pkg:npm/three@0.185.1"],"schemaVersion":1,"symbols":["ACESFilmicToneMapping"]},"contractCommand":["node","test/contract.mjs"],"environment":{"arch":"x64","ecosystem":"npm","executionContext":"node","language":"node","os":"linux","packageManager":"npm","runtime":"node","schemaVersion":1},"license":"MIT-0","packages":["pkg:npm/three@0.185.1"],"schemaVersion":1,"symbols":["ACESFilmicToneMapping"],"verifierAdapter":"node-typescript@1"}
package-lock.json
{
  "name": "npm-three-wanted-0-185-1-acesfilmictonemapping-8859741016f9db7fd8a10f7f",
  "version": "1.0.0",
  "lockfileVersion": 3,
  "requires": true,
  "packages": {
    "": {
      "name": "npm-three-wanted-0-185-1-acesfilmictonemapping-8859741016f9db7fd8a10f7f",
      "version": "1.0.0",
      "dependencies": {
        "three": "0.185.1"
      }
    },
    "node_modules/three": {
      "version": "0.185.1",
      "resolved": "https://registry.npmjs.org/three/-/three-0.185.1.tgz",
      "integrity": "sha512-5aojFCXKwnjBRZvUnt3WFfEcvUJgkN5LlijRFN95hMy8WVkG4I0QNcJE+OuWvuJ0bOdStrbfXn0pkd6/QyiAlg==",
      "license": "MIT"
    }
  }
}
package.json
{
  "name": "npm-three-wanted-0-185-1-acesfilmictonemapping-8859741016f9db7fd8a10f7f",
  "version": "1.0.0",
  "type": "module",
  "scripts": {
    "test": "node test/contract.mjs"
  },
  "dependencies": {
    "three": "0.185.1"
  }
}
test/contract.mjs
import assert from 'node:assert/strict';
import * as THREE from 'three';
import { ACESFilmicToneMapping } from 'three';
import * as WebGPU from 'three/webgpu';
import { ToneMappingNode } from 'three/webgpu';
import { toneMapping } from 'three/tsl';

// 1. Export identity and numeric constant value
assert.strictEqual(
	ACESFilmicToneMapping,
	4,
	'ACESFilmicToneMapping must be the numeric constant 4'
);
assert.strictEqual(
	THREE.ACESFilmicToneMapping,
	4,
	'THREE.ACESFilmicToneMapping must match named export'
);
assert.strictEqual(
	WebGPU.ACESFilmicToneMapping,
	4,
	'WebGPU export must provide identical ACESFilmicToneMapping constant 4'
);

// 2. Enum slot differentiation among Three.js tone mapping modes
const expectedConstants = {
	NoToneMapping: 0,
	LinearToneMapping: 1,
	ReinhardToneMapping: 2,
	CineonToneMapping: 3,
	ACESFilmicToneMapping: 4,
	CustomToneMapping: 5,
	AgXToneMapping: 6,
	NeutralToneMapping: 7,
};

for (const [name, expectedValue] of Object.entries(expectedConstants)) {
	assert.strictEqual(
		THREE[name],
		expectedValue,
		`Tone mapping constant ${name} must be ${expectedValue}`
	);
}

// 3. GLSL ShaderChunk validation for ACES Filmic tone mapping
assert.ok(
	typeof THREE.ShaderChunk.tonemapping_pars_fragment === 'string',
	'ShaderChunk.tonemapping_pars_fragment must be defined'
);
assert.ok(
	THREE.ShaderChunk.tonemapping_pars_fragment.includes('vec3 ACESFilmicToneMapping( vec3 color )'),
	'ShaderChunk.tonemapping_pars_fragment must define ACESFilmicToneMapping GLSL function'
);
assert.ok(
	THREE.ShaderChunk.tonemapping_pars_fragment.includes('vec3 RRTAndODTFit( vec3 v )'),
	'ShaderChunk.tonemapping_pars_fragment must include RRTAndODTFit curve helper'
);
assert.ok(
	THREE.ShaderChunk.tonemapping_pars_fragment.includes('ACESInputMat') &&
	THREE.ShaderChunk.tonemapping_pars_fragment.includes('ACESOutputMat'),
	'ShaderChunk.tonemapping_pars_fragment must define ACES input and output matrices'
);
assert.ok(
	THREE.ShaderChunk.tonemapping_pars_fragment.includes('toneMappingExposure / 0.6'),
	'ACESFilmicToneMapping GLSL shader must scale exposure by 1/0.6'
);

// 4. WebGPU ToneMappingNode and TSL integration
const node = new ToneMappingNode(ACESFilmicToneMapping);
assert.strictEqual(node.getToneMapping(), 4, 'ToneMappingNode getToneMapping() must return 4');
assert.strictEqual(node.isNode, true, 'ToneMappingNode must inherit isNode flag');
assert.strictEqual(node.isTempNode, true, 'ToneMappingNode must inherit isTempNode flag');

node.setToneMapping(THREE.ACESFilmicToneMapping);
assert.strictEqual(node.getToneMapping(), 4, 'setToneMapping must persist ACESFilmicToneMapping');

const tslToneMappingNode = toneMapping(ACESFilmicToneMapping);
assert.strictEqual(
	tslToneMappingNode.getToneMapping(),
	4,
	'TSL toneMapping factory function must accept ACESFilmicToneMapping constant'
);

// 5. Mathematical verification of the Three.js ACES Filmic curve
function evaluateRRTAndODTFit(v) {
	const a = v * (v + 0.0245786) - 0.000090537;
	const b = v * (0.983729 * v + 0.4329510) + 0.238081;
	return a / b;
}

function evaluateAcesFilmic(r, g, b, exposure = 1.0) {
	// Exposure pre-scaling
	let col = [
		(r * exposure) / 0.6,
		(g * exposure) / 0.6,
		(b * exposure) / 0.6,
	];

	// ACESInputMat transformation
	const inputMat = [
		[0.59719, 0.35458, 0.04823],
		[0.07600, 0.90834, 0.01566],
		[0.02840, 0.13383, 0.83777],
	];
	const v = [
		inputMat[0][0] * col[0] + inputMat[0][1] * col[1] + inputMat[0][2] * col[2],
		inputMat[1][0] * col[0] + inputMat[1][1] * col[1] + inputMat[1][2] * col[2],
		inputMat[2][0] * col[0] + inputMat[2][1] * col[1] + inputMat[2][2] * col[2],
	];

	// RRT and ODT fit
	const fit = [
		evaluateRRTAndODTFit(v[0]),
		evaluateRRTAndODTFit(v[1]),
		evaluateRRTAndODTFit(v[2]),
	];

	// ACESOutputMat transformation
	const outputMat = [
		[1.60475, -0.53108, -0.07367],
		[-0.10208, 1.10813, -0.00605],
		[-0.00327, -0.07276, 1.07602],
	];
	const out = [
		outputMat[0][0] * fit[0] + outputMat[0][1] * fit[1] + outputMat[0][2] * fit[2],
		outputMat[1][0] * fit[0] + outputMat[1][1] * fit[1] + outputMat[1][2] * fit[2],
		outputMat[2][0] * fit[0] + outputMat[2][1] * fit[1] + outputMat[2][2] * fit[2],
	];

	// Saturate (clamp 0..1)
	return out.map((c) => Math.max(0, Math.min(1, c)));
}

// Zero input produces zero clamped output
const black = evaluateAcesFilmic(0, 0, 0);
assert.strictEqual(black[0], 0, 'Black input R must clamp to 0');
assert.strictEqual(black[1], 0, 'Black input G must clamp to 0');
assert.strictEqual(black[2], 0, 'Black input B must clamp to 0');

// Linear 1.0 maps to ~0.7634 leaving headroom for highlights
const unitWhite = evaluateAcesFilmic(1.0, 1.0, 1.0);
assert.ok(
	Math.abs(unitWhite[0] - 0.7634) < 0.001,
	`Unit input (1.0) must evaluate to ~0.7634 with highlight shoulder, got ${unitWhite[0]}`
);

// High dynamic range asymptotes to 1.0
const hdr = evaluateAcesFilmic(100.0, 100.0, 100.0);
assert.strictEqual(hdr[0], 1, 'HDR input R must saturate to 1.0');
assert.strictEqual(hdr[1], 1, 'HDR input G must saturate to 1.0');
assert.strictEqual(hdr[2], 1, 'HDR input B must saturate to 1.0');

オリジンシーダー

csx-seed