Skip to content

A fast 2D and 3D game engine — TypeScript SDK, C++/WebAssembly core, visual editor. Ship one project to web, desktop, WeChat MiniGames, playable ads, and native Android / iOS.

test(shaders): the tone curve is pinned where it now has its one definition

esenginea04c4204411d
diff --git a/sdk/tests/postprocess.test.ts b/sdk/tests/postprocess.test.ts
index 760ca4ffa..d3dfdc9b0 100644
--- a/sdk/tests/postprocess.test.ts
+++ b/sdk/tests/postprocess.test.ts
@@ -462,8 +462,10 @@ describe('PostProcess API', () => {
const handle = postProcessEffects.createTonemap();
const src = lastSource();
expect(src).toContain('#pragma param u_exposure float');
- // ACES Narkowicz curve constant — guards the operator identity.
- expect(src).toContain('2.51');
+ // The curve is pinned where it is defined (test_shader_variant.cpp);
+ // what this layer owns is that the effect REACHES it, in both dialects.
+ expect(src).toContain('vec4(acesFilmic(c), src.a)');
+ expect(src).toContain('vec4f(acesFilmic(c), src.a)');
expect(handle).toBe(42);
});
diff --git a/tests/renderer/test_shader_variant.cpp b/tests/renderer/test_shader_variant.cpp
index eeb769e38..edc776a75 100644
--- a/tests/renderer/test_shader_variant.cpp
+++ b/tests/renderer/test_shader_variant.cpp
@@ -372,6 +372,19 @@ static void testFragmentOnly() {
ppv.find("u_projection *") == std::string::npos,
"PostProcess canonical vertex is the clip-space pass-through (no projection)");
+ // The tone curve has ONE definition, injected here, so this is the only
+ // place its identity can be pinned. Nothing else in the repo asserts it.
+ for (auto lang : {ShaderTargetLanguage::GLSL_ES300, ShaderTargetLanguage::WGSL}) {
+ const std::string ppf = ShaderParser::assembleStage(pp, ShaderStage::Fragment, "", {}, lang);
+ const bool glsl = lang == ShaderTargetLanguage::GLSL_ES300;
+ CHECK(ppf.find("acesFilmic") != std::string::npos
+ && ppf.find("2.51") != std::string::npos
+ && ppf.find("2.43") != std::string::npos
+ && ppf.find("0.59") != std::string::npos,
+ glsl ? "the ACES Narkowicz curve reaches a GLSL fragment stage, constants and all"
+ : "and the WGSL twin carries the same curve");
+ }
+
// A particle is drawn from an instanced vertex source, so the canonical stage
// has a third shape. Both dialects: a twin that will not build is a pipeline
// the device refuses with no mention of a shader.