@flighthq/effects 0.1.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/autoExposureEffect.d.ts +3 -0
- package/dist/autoExposureEffect.d.ts.map +1 -0
- package/dist/autoExposureEffect.js +4 -0
- package/dist/autoExposureEffect.js.map +1 -0
- package/dist/barrelDistortionEffect.d.ts +3 -0
- package/dist/barrelDistortionEffect.d.ts.map +1 -0
- package/dist/barrelDistortionEffect.js +4 -0
- package/dist/barrelDistortionEffect.js.map +1 -0
- package/dist/bloomEffect.d.ts +6 -0
- package/dist/bloomEffect.d.ts.map +1 -0
- package/dist/bloomEffect.js +16 -0
- package/dist/bloomEffect.js.map +1 -0
- package/dist/bokehDepthOfFieldEffect.d.ts +3 -0
- package/dist/bokehDepthOfFieldEffect.d.ts.map +1 -0
- package/dist/bokehDepthOfFieldEffect.js +4 -0
- package/dist/bokehDepthOfFieldEffect.js.map +1 -0
- package/dist/brightnessContrastEffect.d.ts +3 -0
- package/dist/brightnessContrastEffect.d.ts.map +1 -0
- package/dist/brightnessContrastEffect.js +4 -0
- package/dist/brightnessContrastEffect.js.map +1 -0
- package/dist/cameraMotionBlurEffect.d.ts +3 -0
- package/dist/cameraMotionBlurEffect.d.ts.map +1 -0
- package/dist/cameraMotionBlurEffect.js +4 -0
- package/dist/cameraMotionBlurEffect.js.map +1 -0
- package/dist/channelMixerEffect.d.ts +3 -0
- package/dist/channelMixerEffect.d.ts.map +1 -0
- package/dist/channelMixerEffect.js +4 -0
- package/dist/channelMixerEffect.js.map +1 -0
- package/dist/chromaticAberrationEffect.d.ts +3 -0
- package/dist/chromaticAberrationEffect.d.ts.map +1 -0
- package/dist/chromaticAberrationEffect.js +4 -0
- package/dist/chromaticAberrationEffect.js.map +1 -0
- package/dist/colorBlindSimulationEffect.d.ts +3 -0
- package/dist/colorBlindSimulationEffect.d.ts.map +1 -0
- package/dist/colorBlindSimulationEffect.js +4 -0
- package/dist/colorBlindSimulationEffect.js.map +1 -0
- package/dist/colorGradeEffect.d.ts +3 -0
- package/dist/colorGradeEffect.d.ts.map +1 -0
- package/dist/colorGradeEffect.js +4 -0
- package/dist/colorGradeEffect.js.map +1 -0
- package/dist/colorScienceMath.d.ts +9 -0
- package/dist/colorScienceMath.d.ts.map +1 -0
- package/dist/colorScienceMath.js +135 -0
- package/dist/colorScienceMath.js.map +1 -0
- package/dist/colorTemperatureMath.d.ts +5 -0
- package/dist/colorTemperatureMath.d.ts.map +1 -0
- package/dist/colorTemperatureMath.js +45 -0
- package/dist/colorTemperatureMath.js.map +1 -0
- package/dist/contactShadowsEffect.d.ts +3 -0
- package/dist/contactShadowsEffect.d.ts.map +1 -0
- package/dist/contactShadowsEffect.js +4 -0
- package/dist/contactShadowsEffect.js.map +1 -0
- package/dist/crtEffect.d.ts +3 -0
- package/dist/crtEffect.d.ts.map +1 -0
- package/dist/crtEffect.js +4 -0
- package/dist/crtEffect.js.map +1 -0
- package/dist/customShaderEffect.d.ts +3 -0
- package/dist/customShaderEffect.d.ts.map +1 -0
- package/dist/customShaderEffect.js +4 -0
- package/dist/customShaderEffect.js.map +1 -0
- package/dist/depthMath.d.ts +4 -0
- package/dist/depthMath.d.ts.map +1 -0
- package/dist/depthMath.js +55 -0
- package/dist/depthMath.js.map +1 -0
- package/dist/directionalBlurEffect.d.ts +3 -0
- package/dist/directionalBlurEffect.d.ts.map +1 -0
- package/dist/directionalBlurEffect.js +4 -0
- package/dist/directionalBlurEffect.js.map +1 -0
- package/dist/displacementEffect.d.ts +3 -0
- package/dist/displacementEffect.d.ts.map +1 -0
- package/dist/displacementEffect.js +4 -0
- package/dist/displacementEffect.js.map +1 -0
- package/dist/ditherEffect.d.ts +3 -0
- package/dist/ditherEffect.d.ts.map +1 -0
- package/dist/ditherEffect.js +4 -0
- package/dist/ditherEffect.js.map +1 -0
- package/dist/edgeDetectMath.d.ts +6 -0
- package/dist/edgeDetectMath.d.ts.map +1 -0
- package/dist/edgeDetectMath.js +72 -0
- package/dist/edgeDetectMath.js.map +1 -0
- package/dist/exposureEffect.d.ts +3 -0
- package/dist/exposureEffect.d.ts.map +1 -0
- package/dist/exposureEffect.js +4 -0
- package/dist/exposureEffect.js.map +1 -0
- package/dist/filmEmulationEffect.d.ts +3 -0
- package/dist/filmEmulationEffect.d.ts.map +1 -0
- package/dist/filmEmulationEffect.js +4 -0
- package/dist/filmEmulationEffect.js.map +1 -0
- package/dist/filmGrainEffect.d.ts +3 -0
- package/dist/filmGrainEffect.d.ts.map +1 -0
- package/dist/filmGrainEffect.js +4 -0
- package/dist/filmGrainEffect.js.map +1 -0
- package/dist/fxaaEffect.d.ts +3 -0
- package/dist/fxaaEffect.d.ts.map +1 -0
- package/dist/fxaaEffect.js +4 -0
- package/dist/fxaaEffect.js.map +1 -0
- package/dist/gaussianMath.d.ts +5 -0
- package/dist/gaussianMath.d.ts.map +1 -0
- package/dist/gaussianMath.js +42 -0
- package/dist/gaussianMath.js.map +1 -0
- package/dist/glitchEffect.d.ts +3 -0
- package/dist/glitchEffect.d.ts.map +1 -0
- package/dist/glitchEffect.js +4 -0
- package/dist/glitchEffect.js.map +1 -0
- package/dist/godRaysEffect.d.ts +3 -0
- package/dist/godRaysEffect.d.ts.map +1 -0
- package/dist/godRaysEffect.js +4 -0
- package/dist/godRaysEffect.js.map +1 -0
- package/dist/godRaysMath.d.ts +8 -0
- package/dist/godRaysMath.d.ts.map +1 -0
- package/dist/godRaysMath.js +49 -0
- package/dist/godRaysMath.js.map +1 -0
- package/dist/grayscaleEffect.d.ts +3 -0
- package/dist/grayscaleEffect.d.ts.map +1 -0
- package/dist/grayscaleEffect.js +4 -0
- package/dist/grayscaleEffect.js.map +1 -0
- package/dist/halftoneEffect.d.ts +3 -0
- package/dist/halftoneEffect.d.ts.map +1 -0
- package/dist/halftoneEffect.js +4 -0
- package/dist/halftoneEffect.js.map +1 -0
- package/dist/hueSaturationEffect.d.ts +3 -0
- package/dist/hueSaturationEffect.d.ts.map +1 -0
- package/dist/hueSaturationEffect.js +4 -0
- package/dist/hueSaturationEffect.js.map +1 -0
- package/dist/index.d.ts +67 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +67 -0
- package/dist/index.js.map +1 -0
- package/dist/invertEffect.d.ts +3 -0
- package/dist/invertEffect.d.ts.map +1 -0
- package/dist/invertEffect.js +4 -0
- package/dist/invertEffect.js.map +1 -0
- package/dist/kuwaharaEffect.d.ts +3 -0
- package/dist/kuwaharaEffect.d.ts.map +1 -0
- package/dist/kuwaharaEffect.js +4 -0
- package/dist/kuwaharaEffect.js.map +1 -0
- package/dist/kuwaharaMath.d.ts +6 -0
- package/dist/kuwaharaMath.d.ts.map +1 -0
- package/dist/kuwaharaMath.js +70 -0
- package/dist/kuwaharaMath.js.map +1 -0
- package/dist/lensDirtEffect.d.ts +3 -0
- package/dist/lensDirtEffect.d.ts.map +1 -0
- package/dist/lensDirtEffect.js +4 -0
- package/dist/lensDirtEffect.js.map +1 -0
- package/dist/lensDistortionEffect.d.ts +3 -0
- package/dist/lensDistortionEffect.d.ts.map +1 -0
- package/dist/lensDistortionEffect.js +4 -0
- package/dist/lensDistortionEffect.js.map +1 -0
- package/dist/lensFlareEffect.d.ts +3 -0
- package/dist/lensFlareEffect.d.ts.map +1 -0
- package/dist/lensFlareEffect.js +4 -0
- package/dist/lensFlareEffect.js.map +1 -0
- package/dist/liftGammaGainEffect.d.ts +3 -0
- package/dist/liftGammaGainEffect.d.ts.map +1 -0
- package/dist/liftGammaGainEffect.js +4 -0
- package/dist/liftGammaGainEffect.js.map +1 -0
- package/dist/lookupTableGradeEffect.d.ts +3 -0
- package/dist/lookupTableGradeEffect.d.ts.map +1 -0
- package/dist/lookupTableGradeEffect.js +4 -0
- package/dist/lookupTableGradeEffect.js.map +1 -0
- package/dist/lutMath.d.ts +7 -0
- package/dist/lutMath.d.ts.map +1 -0
- package/dist/lutMath.js +39 -0
- package/dist/lutMath.js.map +1 -0
- package/dist/motionBlurEffect.d.ts +3 -0
- package/dist/motionBlurEffect.d.ts.map +1 -0
- package/dist/motionBlurEffect.js +4 -0
- package/dist/motionBlurEffect.js.map +1 -0
- package/dist/outlineEffect.d.ts +3 -0
- package/dist/outlineEffect.d.ts.map +1 -0
- package/dist/outlineEffect.js +4 -0
- package/dist/outlineEffect.js.map +1 -0
- package/dist/panniniProjectionEffect.d.ts +3 -0
- package/dist/panniniProjectionEffect.d.ts.map +1 -0
- package/dist/panniniProjectionEffect.js +4 -0
- package/dist/panniniProjectionEffect.js.map +1 -0
- package/dist/pixelateEffect.d.ts +3 -0
- package/dist/pixelateEffect.d.ts.map +1 -0
- package/dist/pixelateEffect.js +4 -0
- package/dist/pixelateEffect.js.map +1 -0
- package/dist/posterizeEffect.d.ts +3 -0
- package/dist/posterizeEffect.d.ts.map +1 -0
- package/dist/posterizeEffect.js +4 -0
- package/dist/posterizeEffect.js.map +1 -0
- package/dist/radialBlurEffect.d.ts +3 -0
- package/dist/radialBlurEffect.d.ts.map +1 -0
- package/dist/radialBlurEffect.js +4 -0
- package/dist/radialBlurEffect.js.map +1 -0
- package/dist/renderEffectDefaults.d.ts +4 -0
- package/dist/renderEffectDefaults.d.ts.map +1 -0
- package/dist/renderEffectDefaults.js +111 -0
- package/dist/renderEffectDefaults.js.map +1 -0
- package/dist/renderEffectInputs.d.ts +5 -0
- package/dist/renderEffectInputs.d.ts.map +1 -0
- package/dist/renderEffectInputs.js +87 -0
- package/dist/renderEffectInputs.js.map +1 -0
- package/dist/renderEffectInterpolation.d.ts +4 -0
- package/dist/renderEffectInterpolation.d.ts.map +1 -0
- package/dist/renderEffectInterpolation.js +75 -0
- package/dist/renderEffectInterpolation.js.map +1 -0
- package/dist/renderEffectValidation.d.ts +3 -0
- package/dist/renderEffectValidation.d.ts.map +1 -0
- package/dist/renderEffectValidation.js +18 -0
- package/dist/renderEffectValidation.js.map +1 -0
- package/dist/scanlinesEffect.d.ts +3 -0
- package/dist/scanlinesEffect.d.ts.map +1 -0
- package/dist/scanlinesEffect.js +4 -0
- package/dist/scanlinesEffect.js.map +1 -0
- package/dist/screenSpaceFogEffect.d.ts +3 -0
- package/dist/screenSpaceFogEffect.d.ts.map +1 -0
- package/dist/screenSpaceFogEffect.js +4 -0
- package/dist/screenSpaceFogEffect.js.map +1 -0
- package/dist/sepiaEffect.d.ts +3 -0
- package/dist/sepiaEffect.d.ts.map +1 -0
- package/dist/sepiaEffect.js +4 -0
- package/dist/sepiaEffect.js.map +1 -0
- package/dist/sharpenEffect.d.ts +3 -0
- package/dist/sharpenEffect.d.ts.map +1 -0
- package/dist/sharpenEffect.js +4 -0
- package/dist/sharpenEffect.js.map +1 -0
- package/dist/sketchEffect.d.ts +3 -0
- package/dist/sketchEffect.d.ts.map +1 -0
- package/dist/sketchEffect.js +4 -0
- package/dist/sketchEffect.js.map +1 -0
- package/dist/smaaEffect.d.ts +3 -0
- package/dist/smaaEffect.d.ts.map +1 -0
- package/dist/smaaEffect.js +4 -0
- package/dist/smaaEffect.js.map +1 -0
- package/dist/ssaoEffect.d.ts +3 -0
- package/dist/ssaoEffect.d.ts.map +1 -0
- package/dist/ssaoEffect.js +4 -0
- package/dist/ssaoEffect.js.map +1 -0
- package/dist/ssrEffect.d.ts +3 -0
- package/dist/ssrEffect.d.ts.map +1 -0
- package/dist/ssrEffect.js +4 -0
- package/dist/ssrEffect.js.map +1 -0
- package/dist/stylizeMath.d.ts +9 -0
- package/dist/stylizeMath.d.ts.map +1 -0
- package/dist/stylizeMath.js +77 -0
- package/dist/stylizeMath.js.map +1 -0
- package/dist/taaEffect.d.ts +3 -0
- package/dist/taaEffect.d.ts.map +1 -0
- package/dist/taaEffect.js +4 -0
- package/dist/taaEffect.js.map +1 -0
- package/dist/tiltShiftEffect.d.ts +3 -0
- package/dist/tiltShiftEffect.d.ts.map +1 -0
- package/dist/tiltShiftEffect.js +4 -0
- package/dist/tiltShiftEffect.js.map +1 -0
- package/dist/toneMapEffect.d.ts +3 -0
- package/dist/toneMapEffect.d.ts.map +1 -0
- package/dist/toneMapEffect.js +4 -0
- package/dist/toneMapEffect.js.map +1 -0
- package/dist/toneMapMath.d.ts +12 -0
- package/dist/toneMapMath.d.ts.map +1 -0
- package/dist/toneMapMath.js +110 -0
- package/dist/toneMapMath.js.map +1 -0
- package/dist/vignetteEffect.d.ts +3 -0
- package/dist/vignetteEffect.d.ts.map +1 -0
- package/dist/vignetteEffect.js +4 -0
- package/dist/vignetteEffect.js.map +1 -0
- package/dist/volumetricLightEffect.d.ts +3 -0
- package/dist/volumetricLightEffect.d.ts.map +1 -0
- package/dist/volumetricLightEffect.js +4 -0
- package/dist/volumetricLightEffect.js.map +1 -0
- package/dist/whiteBalanceEffect.d.ts +3 -0
- package/dist/whiteBalanceEffect.d.ts.map +1 -0
- package/dist/whiteBalanceEffect.js +4 -0
- package/dist/whiteBalanceEffect.js.map +1 -0
- package/package.json +37 -0
- package/src/autoExposureEffect.test.ts +11 -0
- package/src/barrelDistortionEffect.test.ts +11 -0
- package/src/bloomEffect.test.ts +41 -0
- package/src/bokehDepthOfFieldEffect.test.ts +15 -0
- package/src/brightnessContrastEffect.test.ts +14 -0
- package/src/cameraMotionBlurEffect.test.ts +14 -0
- package/src/channelMixerEffect.test.ts +12 -0
- package/src/chromaticAberrationEffect.test.ts +14 -0
- package/src/colorBlindSimulationEffect.test.ts +13 -0
- package/src/colorGradeEffect.test.ts +11 -0
- package/src/colorScienceMath.test.ts +160 -0
- package/src/colorTemperatureMath.test.ts +67 -0
- package/src/contactShadowsEffect.test.ts +14 -0
- package/src/crtEffect.test.ts +16 -0
- package/src/customShaderEffect.test.ts +14 -0
- package/src/depthMath.test.ts +71 -0
- package/src/directionalBlurEffect.test.ts +11 -0
- package/src/displacementEffect.test.ts +15 -0
- package/src/ditherEffect.test.ts +11 -0
- package/src/edgeDetectMath.test.ts +84 -0
- package/src/exposureEffect.test.ts +7 -0
- package/src/filmEmulationEffect.test.ts +14 -0
- package/src/filmGrainEffect.test.ts +15 -0
- package/src/fxaaEffect.test.ts +14 -0
- package/src/gaussianMath.test.ts +93 -0
- package/src/glitchEffect.test.ts +16 -0
- package/src/godRaysEffect.test.ts +15 -0
- package/src/godRaysMath.test.ts +63 -0
- package/src/grayscaleEffect.test.ts +11 -0
- package/src/halftoneEffect.test.ts +11 -0
- package/src/hueSaturationEffect.test.ts +15 -0
- package/src/invertEffect.test.ts +11 -0
- package/src/kuwaharaEffect.test.ts +11 -0
- package/src/kuwaharaMath.test.ts +65 -0
- package/src/lensDirtEffect.test.ts +15 -0
- package/src/lensDistortionEffect.test.ts +11 -0
- package/src/lensFlareEffect.test.ts +16 -0
- package/src/liftGammaGainEffect.test.ts +15 -0
- package/src/lookupTableGradeEffect.test.ts +11 -0
- package/src/lutMath.test.ts +67 -0
- package/src/motionBlurEffect.test.ts +11 -0
- package/src/outlineEffect.test.ts +15 -0
- package/src/panniniProjectionEffect.test.ts +14 -0
- package/src/pixelateEffect.test.ts +11 -0
- package/src/posterizeEffect.test.ts +11 -0
- package/src/radialBlurEffect.test.ts +15 -0
- package/src/renderEffectDefaults.test.ts +70 -0
- package/src/renderEffectInputs.test.ts +60 -0
- package/src/renderEffectInterpolation.test.ts +71 -0
- package/src/renderEffectValidation.test.ts +37 -0
- package/src/scanlinesEffect.test.ts +11 -0
- package/src/screenSpaceFogEffect.test.ts +14 -0
- package/src/sepiaEffect.test.ts +11 -0
- package/src/sharpenEffect.test.ts +11 -0
- package/src/sketchEffect.test.ts +11 -0
- package/src/smaaEffect.test.ts +11 -0
- package/src/ssaoEffect.test.ts +11 -0
- package/src/ssrEffect.test.ts +11 -0
- package/src/stylizeMath.test.ts +99 -0
- package/src/taaEffect.test.ts +11 -0
- package/src/tiltShiftEffect.test.ts +15 -0
- package/src/toneMapEffect.test.ts +7 -0
- package/src/toneMapMath.test.ts +145 -0
- package/src/vignetteEffect.test.ts +16 -0
- package/src/volumetricLightEffect.test.ts +14 -0
- package/src/whiteBalanceEffect.test.ts +11 -0
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"whiteBalanceEffect.d.ts","sourceRoot":"","sources":["../src/whiteBalanceEffect.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,iBAAiB,CAAC;AAE1D,wBAAgB,wBAAwB,CAAC,OAAO,GAAE,QAAQ,CAAC,IAAI,CAAC,kBAAkB,EAAE,MAAM,CAAC,CAAM,GAAG,kBAAkB,CAErH"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"whiteBalanceEffect.js","sourceRoot":"","sources":["../src/whiteBalanceEffect.ts"],"names":[],"mappings":"AAEA,MAAM,UAAU,wBAAwB,CAAC,UAAsD,EAAE;IAC/F,OAAO,EAAE,IAAI,EAAE,oBAAoB,EAAE,GAAG,OAAO,EAAE,CAAC;AACpD,CAAC"}
|
package/package.json
ADDED
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@flighthq/effects",
|
|
3
|
+
"version": "0.1.0",
|
|
4
|
+
"type": "module",
|
|
5
|
+
"main": "dist/index.js",
|
|
6
|
+
"types": "dist/index.d.ts",
|
|
7
|
+
"exports": {
|
|
8
|
+
".": {
|
|
9
|
+
"types": "./dist/index.d.ts",
|
|
10
|
+
"default": "./dist/index.js"
|
|
11
|
+
}
|
|
12
|
+
},
|
|
13
|
+
"files": [
|
|
14
|
+
"dist",
|
|
15
|
+
"src/**/*.test.ts",
|
|
16
|
+
"!dist/**/*.test.js",
|
|
17
|
+
"!dist/**/*.test.d.ts",
|
|
18
|
+
"!dist/**/*.test.js.map",
|
|
19
|
+
"!dist/**/*.test.d.ts.map"
|
|
20
|
+
],
|
|
21
|
+
"scripts": {
|
|
22
|
+
"build": "tsc -b",
|
|
23
|
+
"clean": "tsc -b --clean",
|
|
24
|
+
"test": "vitest run --config vitest.config.ts",
|
|
25
|
+
"test:watch": "vitest --watch --config vitest.config.ts",
|
|
26
|
+
"prepack": "npm run clean && npm run clean:dist && npm run build",
|
|
27
|
+
"clean:dist": "tsx ../../scripts/clean-package-dist.ts"
|
|
28
|
+
},
|
|
29
|
+
"dependencies": {
|
|
30
|
+
"@flighthq/types": "0.1.0"
|
|
31
|
+
},
|
|
32
|
+
"devDependencies": {
|
|
33
|
+
"typescript": "^5.3.0"
|
|
34
|
+
},
|
|
35
|
+
"description": "Render-effect intents and substrate-agnostic recipe math",
|
|
36
|
+
"sideEffects": false
|
|
37
|
+
}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { createAutoExposureEffect } from './autoExposureEffect';
|
|
2
|
+
|
|
3
|
+
describe('createAutoExposureEffect', () => {
|
|
4
|
+
it('carries options', () => {
|
|
5
|
+
expect(createAutoExposureEffect({ adaptationSpeed: 2 })).toMatchObject({ adaptationSpeed: 2 });
|
|
6
|
+
});
|
|
7
|
+
|
|
8
|
+
it('tags the intent type', () => {
|
|
9
|
+
expect(createAutoExposureEffect().kind).toBe('AutoExposureEffect');
|
|
10
|
+
});
|
|
11
|
+
});
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { createBarrelDistortionEffect } from './barrelDistortionEffect';
|
|
2
|
+
|
|
3
|
+
describe('createBarrelDistortionEffect', () => {
|
|
4
|
+
it('carries options', () => {
|
|
5
|
+
expect(createBarrelDistortionEffect({ amount: 0.3 })).toMatchObject({ amount: 0.3 });
|
|
6
|
+
});
|
|
7
|
+
|
|
8
|
+
it('tags the intent type', () => {
|
|
9
|
+
expect(createBarrelDistortionEffect().kind).toBe('BarrelDistortionEffect');
|
|
10
|
+
});
|
|
11
|
+
});
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
import { computeBloomBlurRadius, computeBloomIntensity, computeBloomThreshold, createBloomEffect } from './bloomEffect';
|
|
2
|
+
|
|
3
|
+
describe('computeBloomBlurRadius', () => {
|
|
4
|
+
it('defaults to 8 when radius is unset', () => {
|
|
5
|
+
expect(computeBloomBlurRadius(createBloomEffect())).toBe(8);
|
|
6
|
+
});
|
|
7
|
+
|
|
8
|
+
it('clamps negative radius to zero', () => {
|
|
9
|
+
expect(computeBloomBlurRadius(createBloomEffect({ radius: -4 }))).toBe(0);
|
|
10
|
+
});
|
|
11
|
+
});
|
|
12
|
+
|
|
13
|
+
describe('computeBloomIntensity', () => {
|
|
14
|
+
it('defaults to 1 when intensity is unset', () => {
|
|
15
|
+
expect(computeBloomIntensity(createBloomEffect())).toBe(1);
|
|
16
|
+
});
|
|
17
|
+
|
|
18
|
+
it('passes through an explicit intensity', () => {
|
|
19
|
+
expect(computeBloomIntensity(createBloomEffect({ intensity: 2.5 }))).toBe(2.5);
|
|
20
|
+
});
|
|
21
|
+
});
|
|
22
|
+
|
|
23
|
+
describe('computeBloomThreshold', () => {
|
|
24
|
+
it('defaults to 0.8 when threshold is unset', () => {
|
|
25
|
+
expect(computeBloomThreshold(createBloomEffect())).toBe(0.8);
|
|
26
|
+
});
|
|
27
|
+
|
|
28
|
+
it('passes through an explicit threshold', () => {
|
|
29
|
+
expect(computeBloomThreshold(createBloomEffect({ threshold: 0.25 }))).toBe(0.25);
|
|
30
|
+
});
|
|
31
|
+
});
|
|
32
|
+
|
|
33
|
+
describe('createBloomEffect', () => {
|
|
34
|
+
it('tags the intent type', () => {
|
|
35
|
+
expect(createBloomEffect().kind).toBe('BloomEffect');
|
|
36
|
+
});
|
|
37
|
+
|
|
38
|
+
it('carries options', () => {
|
|
39
|
+
expect(createBloomEffect({ threshold: 0.5, intensity: 2 })).toMatchObject({ threshold: 0.5, intensity: 2 });
|
|
40
|
+
});
|
|
41
|
+
});
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import { createBokehDepthOfFieldEffect } from './bokehDepthOfFieldEffect';
|
|
2
|
+
|
|
3
|
+
describe('createBokehDepthOfFieldEffect', () => {
|
|
4
|
+
it('tags the intent type', () => {
|
|
5
|
+
expect(createBokehDepthOfFieldEffect().kind).toBe('BokehDepthOfFieldEffect');
|
|
6
|
+
});
|
|
7
|
+
|
|
8
|
+
it('carries options', () => {
|
|
9
|
+
expect(createBokehDepthOfFieldEffect({ focusDistance: 0.5, focusRange: 0.2, maxBlur: 4 })).toMatchObject({
|
|
10
|
+
focusDistance: 0.5,
|
|
11
|
+
focusRange: 0.2,
|
|
12
|
+
maxBlur: 4,
|
|
13
|
+
});
|
|
14
|
+
});
|
|
15
|
+
});
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import { createBrightnessContrastEffect } from './brightnessContrastEffect';
|
|
2
|
+
|
|
3
|
+
describe('createBrightnessContrastEffect', () => {
|
|
4
|
+
it('tags the intent type', () => {
|
|
5
|
+
expect(createBrightnessContrastEffect().kind).toBe('BrightnessContrastEffect');
|
|
6
|
+
});
|
|
7
|
+
|
|
8
|
+
it('carries options', () => {
|
|
9
|
+
expect(createBrightnessContrastEffect({ brightness: 0.2, contrast: 1.5 })).toMatchObject({
|
|
10
|
+
brightness: 0.2,
|
|
11
|
+
contrast: 1.5,
|
|
12
|
+
});
|
|
13
|
+
});
|
|
14
|
+
});
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import { createCameraMotionBlurEffect } from './cameraMotionBlurEffect';
|
|
2
|
+
|
|
3
|
+
describe('createCameraMotionBlurEffect', () => {
|
|
4
|
+
it('tags the intent type', () => {
|
|
5
|
+
expect(createCameraMotionBlurEffect().kind).toBe('CameraMotionBlurEffect');
|
|
6
|
+
});
|
|
7
|
+
|
|
8
|
+
it('carries options', () => {
|
|
9
|
+
expect(createCameraMotionBlurEffect({ intensity: 0.5, samples: 12 })).toMatchObject({
|
|
10
|
+
intensity: 0.5,
|
|
11
|
+
samples: 12,
|
|
12
|
+
});
|
|
13
|
+
});
|
|
14
|
+
});
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import { createChannelMixerEffect } from './channelMixerEffect';
|
|
2
|
+
|
|
3
|
+
describe('createChannelMixerEffect', () => {
|
|
4
|
+
it('tags the intent type', () => {
|
|
5
|
+
expect(createChannelMixerEffect({ matrix: [1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0] }).kind).toBe('ChannelMixerEffect');
|
|
6
|
+
});
|
|
7
|
+
|
|
8
|
+
it('carries the matrix', () => {
|
|
9
|
+
const matrix = [1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0];
|
|
10
|
+
expect(createChannelMixerEffect({ matrix }).matrix).toBe(matrix);
|
|
11
|
+
});
|
|
12
|
+
});
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import { createChromaticAberrationEffect } from './chromaticAberrationEffect';
|
|
2
|
+
|
|
3
|
+
describe('createChromaticAberrationEffect', () => {
|
|
4
|
+
it('tags the intent type', () => {
|
|
5
|
+
expect(createChromaticAberrationEffect().kind).toBe('ChromaticAberrationEffect');
|
|
6
|
+
});
|
|
7
|
+
|
|
8
|
+
it('carries options', () => {
|
|
9
|
+
expect(createChromaticAberrationEffect({ intensity: 0.01, radial: false })).toMatchObject({
|
|
10
|
+
intensity: 0.01,
|
|
11
|
+
radial: false,
|
|
12
|
+
});
|
|
13
|
+
});
|
|
14
|
+
});
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { createColorBlindSimulationEffect } from './colorBlindSimulationEffect';
|
|
2
|
+
|
|
3
|
+
describe('createColorBlindSimulationEffect', () => {
|
|
4
|
+
it('carries options', () => {
|
|
5
|
+
expect(createColorBlindSimulationEffect({ type: 'protanopia' })).toMatchObject({
|
|
6
|
+
type: 'protanopia',
|
|
7
|
+
});
|
|
8
|
+
});
|
|
9
|
+
|
|
10
|
+
it('tags the intent type', () => {
|
|
11
|
+
expect(createColorBlindSimulationEffect().kind).toBe('ColorBlindSimulationEffect');
|
|
12
|
+
});
|
|
13
|
+
});
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { createColorGradeEffect } from './colorGradeEffect';
|
|
2
|
+
|
|
3
|
+
describe('createColorGradeEffect', () => {
|
|
4
|
+
it('tags the intent type', () => {
|
|
5
|
+
expect(createColorGradeEffect().kind).toBe('ColorGradeEffect');
|
|
6
|
+
});
|
|
7
|
+
|
|
8
|
+
it('carries options', () => {
|
|
9
|
+
expect(createColorGradeEffect({ exposure: 1, saturation: 1.2 })).toMatchObject({ exposure: 1, saturation: 1.2 });
|
|
10
|
+
});
|
|
11
|
+
});
|
|
@@ -0,0 +1,160 @@
|
|
|
1
|
+
import {
|
|
2
|
+
computeHslToRgb,
|
|
3
|
+
computeLinearToSrgb,
|
|
4
|
+
computeOklabToRgb,
|
|
5
|
+
computeRgbToHsl,
|
|
6
|
+
computeRgbToOklab,
|
|
7
|
+
computeSrgbToLinear,
|
|
8
|
+
getRec709LuminanceWeights,
|
|
9
|
+
getRec2020LuminanceWeights,
|
|
10
|
+
} from './colorScienceMath';
|
|
11
|
+
|
|
12
|
+
describe('computeHslToRgb', () => {
|
|
13
|
+
it('hue=0, full saturation, mid lightness → red', () => {
|
|
14
|
+
const out: [number, number, number] = [0, 0, 0];
|
|
15
|
+
computeHslToRgb(0, 1, 0.5, out);
|
|
16
|
+
expect(out[0]).toBeCloseTo(1, 4);
|
|
17
|
+
expect(out[1]).toBeCloseTo(0, 4);
|
|
18
|
+
expect(out[2]).toBeCloseTo(0, 4);
|
|
19
|
+
});
|
|
20
|
+
it('round-trips with computeRgbToHsl', () => {
|
|
21
|
+
const r = 0.3;
|
|
22
|
+
const g = 0.7;
|
|
23
|
+
const b = 0.1;
|
|
24
|
+
const hsl: [number, number, number] = [0, 0, 0];
|
|
25
|
+
computeRgbToHsl(r, g, b, hsl);
|
|
26
|
+
const rgb: [number, number, number] = [0, 0, 0];
|
|
27
|
+
computeHslToRgb(hsl[0], hsl[1], hsl[2], rgb);
|
|
28
|
+
expect(rgb[0]).toBeCloseTo(r, 4);
|
|
29
|
+
expect(rgb[1]).toBeCloseTo(g, 4);
|
|
30
|
+
expect(rgb[2]).toBeCloseTo(b, 4);
|
|
31
|
+
});
|
|
32
|
+
});
|
|
33
|
+
|
|
34
|
+
describe('computeLinearToSrgb', () => {
|
|
35
|
+
it('0 maps to 0', () => {
|
|
36
|
+
expect(computeLinearToSrgb(0)).toBeCloseTo(0, 5);
|
|
37
|
+
});
|
|
38
|
+
it('1 maps to 1', () => {
|
|
39
|
+
expect(computeLinearToSrgb(1)).toBeCloseTo(1, 5);
|
|
40
|
+
});
|
|
41
|
+
it('round-trips with computeSrgbToLinear', () => {
|
|
42
|
+
const linear = 0.5;
|
|
43
|
+
expect(computeSrgbToLinear(computeLinearToSrgb(linear))).toBeCloseTo(linear, 4);
|
|
44
|
+
});
|
|
45
|
+
it('clamps negative values to 0', () => {
|
|
46
|
+
expect(computeLinearToSrgb(-1)).toBeCloseTo(0, 5);
|
|
47
|
+
});
|
|
48
|
+
});
|
|
49
|
+
|
|
50
|
+
describe('computeOklabToRgb', () => {
|
|
51
|
+
it('round-trips with computeRgbToOklab for a mid-gray', () => {
|
|
52
|
+
const r = 0.5;
|
|
53
|
+
const g = 0.5;
|
|
54
|
+
const b = 0.5;
|
|
55
|
+
const lab: [number, number, number] = [0, 0, 0];
|
|
56
|
+
computeRgbToOklab(r, g, b, lab);
|
|
57
|
+
const rgb: [number, number, number] = [0, 0, 0];
|
|
58
|
+
computeOklabToRgb(lab[0], lab[1], lab[2], rgb);
|
|
59
|
+
expect(rgb[0]).toBeCloseTo(r, 3);
|
|
60
|
+
expect(rgb[1]).toBeCloseTo(g, 3);
|
|
61
|
+
expect(rgb[2]).toBeCloseTo(b, 3);
|
|
62
|
+
});
|
|
63
|
+
it('round-trips with computeRgbToOklab for a saturated color', () => {
|
|
64
|
+
const r = 0.8;
|
|
65
|
+
const g = 0.2;
|
|
66
|
+
const b = 0.1;
|
|
67
|
+
const lab: [number, number, number] = [0, 0, 0];
|
|
68
|
+
computeRgbToOklab(r, g, b, lab);
|
|
69
|
+
const rgb: [number, number, number] = [0, 0, 0];
|
|
70
|
+
computeOklabToRgb(lab[0], lab[1], lab[2], rgb);
|
|
71
|
+
expect(rgb[0]).toBeCloseTo(r, 3);
|
|
72
|
+
expect(rgb[1]).toBeCloseTo(g, 3);
|
|
73
|
+
expect(rgb[2]).toBeCloseTo(b, 3);
|
|
74
|
+
});
|
|
75
|
+
});
|
|
76
|
+
|
|
77
|
+
describe('computeRgbToHsl', () => {
|
|
78
|
+
it('red (1,0,0) has hue 0°', () => {
|
|
79
|
+
const out: [number, number, number] = [0, 0, 0];
|
|
80
|
+
computeRgbToHsl(1, 0, 0, out);
|
|
81
|
+
expect(out[0]).toBeCloseTo(0, 2);
|
|
82
|
+
expect(out[1]).toBeCloseTo(1, 2);
|
|
83
|
+
expect(out[2]).toBeCloseTo(0.5, 2);
|
|
84
|
+
});
|
|
85
|
+
it('green (0,1,0) has hue 120°', () => {
|
|
86
|
+
const out: [number, number, number] = [0, 0, 0];
|
|
87
|
+
computeRgbToHsl(0, 1, 0, out);
|
|
88
|
+
expect(out[0]).toBeCloseTo(120, 2);
|
|
89
|
+
});
|
|
90
|
+
it('white (1,1,1) has lightness 1 and saturation 0', () => {
|
|
91
|
+
const out: [number, number, number] = [0, 0, 0];
|
|
92
|
+
computeRgbToHsl(1, 1, 1, out);
|
|
93
|
+
expect(out[1]).toBeCloseTo(0, 4);
|
|
94
|
+
expect(out[2]).toBeCloseTo(1, 5);
|
|
95
|
+
});
|
|
96
|
+
it('black (0,0,0) has lightness 0 and saturation 0', () => {
|
|
97
|
+
const out: [number, number, number] = [0, 0, 0];
|
|
98
|
+
computeRgbToHsl(0, 0, 0, out);
|
|
99
|
+
expect(out[1]).toBeCloseTo(0, 4);
|
|
100
|
+
expect(out[2]).toBeCloseTo(0, 5);
|
|
101
|
+
});
|
|
102
|
+
});
|
|
103
|
+
|
|
104
|
+
describe('computeRgbToOklab', () => {
|
|
105
|
+
it('black (0,0,0) maps to L=0', () => {
|
|
106
|
+
const out: [number, number, number] = [0, 0, 0];
|
|
107
|
+
computeRgbToOklab(0, 0, 0, out);
|
|
108
|
+
expect(out[0]).toBeCloseTo(0, 4);
|
|
109
|
+
});
|
|
110
|
+
it('white (1,1,1) maps to L~1, a~0, b~0', () => {
|
|
111
|
+
const out: [number, number, number] = [0, 0, 0];
|
|
112
|
+
computeRgbToOklab(1, 1, 1, out);
|
|
113
|
+
expect(out[0]).toBeCloseTo(1, 2);
|
|
114
|
+
expect(out[1]).toBeCloseTo(0, 3);
|
|
115
|
+
expect(out[2]).toBeCloseTo(0, 3);
|
|
116
|
+
});
|
|
117
|
+
});
|
|
118
|
+
|
|
119
|
+
describe('computeSrgbToLinear', () => {
|
|
120
|
+
it('0 maps to 0', () => {
|
|
121
|
+
expect(computeSrgbToLinear(0)).toBeCloseTo(0, 5);
|
|
122
|
+
});
|
|
123
|
+
it('1 maps to 1', () => {
|
|
124
|
+
expect(computeSrgbToLinear(1)).toBeCloseTo(1, 5);
|
|
125
|
+
});
|
|
126
|
+
it('round-trips with computeLinearToSrgb', () => {
|
|
127
|
+
const srgb = 0.5;
|
|
128
|
+
expect(computeLinearToSrgb(computeSrgbToLinear(srgb))).toBeCloseTo(srgb, 4);
|
|
129
|
+
});
|
|
130
|
+
});
|
|
131
|
+
|
|
132
|
+
describe('getRec2020LuminanceWeights', () => {
|
|
133
|
+
it('weights sum to 1', () => {
|
|
134
|
+
const out: [number, number, number] = [0, 0, 0];
|
|
135
|
+
getRec2020LuminanceWeights(out);
|
|
136
|
+
expect(out[0] + out[1] + out[2]).toBeCloseTo(1, 5);
|
|
137
|
+
});
|
|
138
|
+
it('returns canonical Rec.2020 values', () => {
|
|
139
|
+
const out: [number, number, number] = [0, 0, 0];
|
|
140
|
+
getRec2020LuminanceWeights(out);
|
|
141
|
+
expect(out[0]).toBeCloseTo(0.2627, 4);
|
|
142
|
+
expect(out[1]).toBeCloseTo(0.678, 4);
|
|
143
|
+
expect(out[2]).toBeCloseTo(0.0593, 4);
|
|
144
|
+
});
|
|
145
|
+
});
|
|
146
|
+
|
|
147
|
+
describe('getRec709LuminanceWeights', () => {
|
|
148
|
+
it('weights sum to 1', () => {
|
|
149
|
+
const out: [number, number, number] = [0, 0, 0];
|
|
150
|
+
getRec709LuminanceWeights(out);
|
|
151
|
+
expect(out[0] + out[1] + out[2]).toBeCloseTo(1, 5);
|
|
152
|
+
});
|
|
153
|
+
it('returns canonical Rec.709 values', () => {
|
|
154
|
+
const out: [number, number, number] = [0, 0, 0];
|
|
155
|
+
getRec709LuminanceWeights(out);
|
|
156
|
+
expect(out[0]).toBeCloseTo(0.2126, 4);
|
|
157
|
+
expect(out[1]).toBeCloseTo(0.7152, 4);
|
|
158
|
+
expect(out[2]).toBeCloseTo(0.0722, 4);
|
|
159
|
+
});
|
|
160
|
+
});
|
|
@@ -0,0 +1,67 @@
|
|
|
1
|
+
import { computeColorTemperatureRgb, computeWhiteBalanceMultipliers } from './colorTemperatureMath';
|
|
2
|
+
|
|
3
|
+
describe('computeColorTemperatureRgb', () => {
|
|
4
|
+
it('returns values in [0, 1] range', () => {
|
|
5
|
+
const out: [number, number, number] = [0, 0, 0];
|
|
6
|
+
computeColorTemperatureRgb(6500, out);
|
|
7
|
+
expect(out[0]).toBeGreaterThanOrEqual(0);
|
|
8
|
+
expect(out[0]).toBeLessThanOrEqual(1);
|
|
9
|
+
expect(out[1]).toBeGreaterThanOrEqual(0);
|
|
10
|
+
expect(out[1]).toBeLessThanOrEqual(1);
|
|
11
|
+
expect(out[2]).toBeGreaterThanOrEqual(0);
|
|
12
|
+
expect(out[2]).toBeLessThanOrEqual(1);
|
|
13
|
+
});
|
|
14
|
+
it('warm color (2700 K) has high red, low blue', () => {
|
|
15
|
+
const out: [number, number, number] = [0, 0, 0];
|
|
16
|
+
computeColorTemperatureRgb(2700, out);
|
|
17
|
+
expect(out[0]).toBeGreaterThan(out[2]);
|
|
18
|
+
});
|
|
19
|
+
it('cool color (10000 K) has low red, high blue', () => {
|
|
20
|
+
const out: [number, number, number] = [0, 0, 0];
|
|
21
|
+
computeColorTemperatureRgb(10000, out);
|
|
22
|
+
expect(out[2]).toBeGreaterThan(out[0]);
|
|
23
|
+
});
|
|
24
|
+
it('clamps to [1000, 40000] K range', () => {
|
|
25
|
+
const out1: [number, number, number] = [0, 0, 0];
|
|
26
|
+
const out2: [number, number, number] = [0, 0, 0];
|
|
27
|
+
computeColorTemperatureRgb(500, out1);
|
|
28
|
+
computeColorTemperatureRgb(1000, out2);
|
|
29
|
+
expect(out1).toEqual(out2);
|
|
30
|
+
});
|
|
31
|
+
it('writes result to out without reading from it (alias-safe)', () => {
|
|
32
|
+
const out: [number, number, number] = [99, 99, 99];
|
|
33
|
+
computeColorTemperatureRgb(6500, out);
|
|
34
|
+
expect(out[0]).not.toBe(99);
|
|
35
|
+
});
|
|
36
|
+
});
|
|
37
|
+
|
|
38
|
+
describe('computeWhiteBalanceMultipliers', () => {
|
|
39
|
+
it('neutral (0, 0) returns non-zero multipliers', () => {
|
|
40
|
+
const out: [number, number, number] = [0, 0, 0];
|
|
41
|
+
computeWhiteBalanceMultipliers(0, 0, out);
|
|
42
|
+
expect(out[0]).toBeGreaterThan(0);
|
|
43
|
+
expect(out[1]).toBeGreaterThan(0);
|
|
44
|
+
expect(out[2]).toBeGreaterThan(0);
|
|
45
|
+
});
|
|
46
|
+
it('warm temperature increases red relative to cool', () => {
|
|
47
|
+
const warmOut: [number, number, number] = [0, 0, 0];
|
|
48
|
+
const coolOut: [number, number, number] = [0, 0, 0];
|
|
49
|
+
computeWhiteBalanceMultipliers(0.5, 0, warmOut);
|
|
50
|
+
computeWhiteBalanceMultipliers(-0.5, 0, coolOut);
|
|
51
|
+
expect(warmOut[0]).toBeGreaterThan(coolOut[0]);
|
|
52
|
+
});
|
|
53
|
+
it('positive tint (magenta) reduces green relative to negative tint (green)', () => {
|
|
54
|
+
const magentaOut: [number, number, number] = [0, 0, 0];
|
|
55
|
+
const greenOut: [number, number, number] = [0, 0, 0];
|
|
56
|
+
computeWhiteBalanceMultipliers(0, 0.5, magentaOut);
|
|
57
|
+
computeWhiteBalanceMultipliers(0, -0.5, greenOut);
|
|
58
|
+
expect(greenOut[1]).toBeGreaterThan(magentaOut[1]);
|
|
59
|
+
});
|
|
60
|
+
it('all output channels are non-negative', () => {
|
|
61
|
+
const out: [number, number, number] = [0, 0, 0];
|
|
62
|
+
computeWhiteBalanceMultipliers(-1, -1, out);
|
|
63
|
+
expect(out[0]).toBeGreaterThanOrEqual(0);
|
|
64
|
+
expect(out[1]).toBeGreaterThanOrEqual(0);
|
|
65
|
+
expect(out[2]).toBeGreaterThanOrEqual(0);
|
|
66
|
+
});
|
|
67
|
+
});
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import { createContactShadowsEffect } from './contactShadowsEffect';
|
|
2
|
+
|
|
3
|
+
describe('createContactShadowsEffect', () => {
|
|
4
|
+
it('carries options', () => {
|
|
5
|
+
expect(createContactShadowsEffect({ opacity: 0.8, samples: 32 })).toMatchObject({
|
|
6
|
+
opacity: 0.8,
|
|
7
|
+
samples: 32,
|
|
8
|
+
});
|
|
9
|
+
});
|
|
10
|
+
|
|
11
|
+
it('tags the intent type', () => {
|
|
12
|
+
expect(createContactShadowsEffect().kind).toBe('ContactShadowsEffect');
|
|
13
|
+
});
|
|
14
|
+
});
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import { createCrtEffect } from './crtEffect';
|
|
2
|
+
|
|
3
|
+
describe('createCrtEffect', () => {
|
|
4
|
+
it('tags the intent type', () => {
|
|
5
|
+
expect(createCrtEffect().kind).toBe('CrtEffect');
|
|
6
|
+
});
|
|
7
|
+
|
|
8
|
+
it('carries options', () => {
|
|
9
|
+
expect(createCrtEffect({ curvature: 0.2, scanlineIntensity: 0.5, vignette: 0.3, aberration: 0.01 })).toMatchObject({
|
|
10
|
+
curvature: 0.2,
|
|
11
|
+
scanlineIntensity: 0.5,
|
|
12
|
+
vignette: 0.3,
|
|
13
|
+
aberration: 0.01,
|
|
14
|
+
});
|
|
15
|
+
});
|
|
16
|
+
});
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import { createCustomShaderEffect } from './customShaderEffect';
|
|
2
|
+
|
|
3
|
+
describe('createCustomShaderEffect', () => {
|
|
4
|
+
it('carries options', () => {
|
|
5
|
+
expect(createCustomShaderEffect({ shaderKey: 'myEffect', uniforms: { intensity: 0.5 } })).toMatchObject({
|
|
6
|
+
shaderKey: 'myEffect',
|
|
7
|
+
uniforms: { intensity: 0.5 },
|
|
8
|
+
});
|
|
9
|
+
});
|
|
10
|
+
|
|
11
|
+
it('tags the intent type', () => {
|
|
12
|
+
expect(createCustomShaderEffect({ shaderKey: 'test' }).kind).toBe('CustomShaderEffect');
|
|
13
|
+
});
|
|
14
|
+
});
|
|
@@ -0,0 +1,71 @@
|
|
|
1
|
+
import { computeDepthOfFieldCoc, computeLinearDepthFromNonlinear, computeSsaoSampleKernel } from './depthMath';
|
|
2
|
+
|
|
3
|
+
describe('computeDepthOfFieldCoc', () => {
|
|
4
|
+
it('returns 0 when depth equals focusDistance', () => {
|
|
5
|
+
expect(computeDepthOfFieldCoc(5, 5, 1.8, 50)).toBeCloseTo(0, 4);
|
|
6
|
+
});
|
|
7
|
+
it('behind-focus depth returns positive CoC', () => {
|
|
8
|
+
expect(computeDepthOfFieldCoc(10, 5, 1.8, 50)).toBeGreaterThan(0);
|
|
9
|
+
});
|
|
10
|
+
it('in-front-of-focus depth returns negative CoC', () => {
|
|
11
|
+
expect(computeDepthOfFieldCoc(2, 5, 1.8, 50)).toBeLessThan(0);
|
|
12
|
+
});
|
|
13
|
+
it('larger aperture increases CoC magnitude', () => {
|
|
14
|
+
const coc14 = Math.abs(computeDepthOfFieldCoc(10, 5, 1.4, 50));
|
|
15
|
+
const coc8 = Math.abs(computeDepthOfFieldCoc(10, 5, 8, 50));
|
|
16
|
+
expect(coc14).toBeGreaterThan(coc8);
|
|
17
|
+
});
|
|
18
|
+
});
|
|
19
|
+
|
|
20
|
+
describe('computeLinearDepthFromNonlinear', () => {
|
|
21
|
+
it('depth=0 returns near plane', () => {
|
|
22
|
+
expect(computeLinearDepthFromNonlinear(0, 0.1, 1000)).toBeCloseTo(0.1, 3);
|
|
23
|
+
});
|
|
24
|
+
it('depth=1 returns far plane', () => {
|
|
25
|
+
expect(computeLinearDepthFromNonlinear(1, 0.1, 1000)).toBeCloseTo(1000, 0);
|
|
26
|
+
});
|
|
27
|
+
it('depth=0.5 returns a value between near and far', () => {
|
|
28
|
+
const linear = computeLinearDepthFromNonlinear(0.5, 0.1, 100);
|
|
29
|
+
expect(linear).toBeGreaterThan(0.1);
|
|
30
|
+
expect(linear).toBeLessThan(100);
|
|
31
|
+
});
|
|
32
|
+
it('uses the standard hyperbolic depth formula', () => {
|
|
33
|
+
// near=1, far=10, depth=0 → result == (1*10)/(10-0) = 1
|
|
34
|
+
expect(computeLinearDepthFromNonlinear(0, 1, 10)).toBeCloseTo(1, 5);
|
|
35
|
+
});
|
|
36
|
+
});
|
|
37
|
+
|
|
38
|
+
describe('computeSsaoSampleKernel', () => {
|
|
39
|
+
it('returns the requested sample count', () => {
|
|
40
|
+
const out = new Float32Array(16 * 3);
|
|
41
|
+
const count = computeSsaoSampleKernel(16, out);
|
|
42
|
+
expect(count).toBe(16);
|
|
43
|
+
});
|
|
44
|
+
it('all Z components are non-negative (hemisphere along +Z)', () => {
|
|
45
|
+
const out = new Float32Array(16 * 3);
|
|
46
|
+
const count = computeSsaoSampleKernel(16, out);
|
|
47
|
+
for (let i = 0; i < count; i++) {
|
|
48
|
+
expect(out[i * 3 + 2]).toBeGreaterThanOrEqual(0);
|
|
49
|
+
}
|
|
50
|
+
});
|
|
51
|
+
it('all samples are within the unit sphere', () => {
|
|
52
|
+
const out = new Float32Array(16 * 3);
|
|
53
|
+
const count = computeSsaoSampleKernel(16, out);
|
|
54
|
+
for (let i = 0; i < count; i++) {
|
|
55
|
+
const x = out[i * 3 + 0];
|
|
56
|
+
const y = out[i * 3 + 1];
|
|
57
|
+
const z = out[i * 3 + 2];
|
|
58
|
+
const len = Math.sqrt(x * x + y * y + z * z);
|
|
59
|
+
expect(len).toBeLessThanOrEqual(1 + 1e-6);
|
|
60
|
+
}
|
|
61
|
+
});
|
|
62
|
+
it('is deterministic (same output on repeated calls)', () => {
|
|
63
|
+
const out1 = new Float32Array(8 * 3);
|
|
64
|
+
const out2 = new Float32Array(8 * 3);
|
|
65
|
+
computeSsaoSampleKernel(8, out1);
|
|
66
|
+
computeSsaoSampleKernel(8, out2);
|
|
67
|
+
for (let i = 0; i < out1.length; i++) {
|
|
68
|
+
expect(out1[i]).toBeCloseTo(out2[i], 5);
|
|
69
|
+
}
|
|
70
|
+
});
|
|
71
|
+
});
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { createDirectionalBlurEffect } from './directionalBlurEffect';
|
|
2
|
+
|
|
3
|
+
describe('createDirectionalBlurEffect', () => {
|
|
4
|
+
it('tags the intent type', () => {
|
|
5
|
+
expect(createDirectionalBlurEffect().kind).toBe('DirectionalBlurEffect');
|
|
6
|
+
});
|
|
7
|
+
|
|
8
|
+
it('carries options', () => {
|
|
9
|
+
expect(createDirectionalBlurEffect({ angle: 1, length: 8 })).toMatchObject({ angle: 1, length: 8 });
|
|
10
|
+
});
|
|
11
|
+
});
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import { createDisplacementEffect } from './displacementEffect';
|
|
2
|
+
|
|
3
|
+
describe('createDisplacementEffect', () => {
|
|
4
|
+
it('tags the intent type', () => {
|
|
5
|
+
expect(createDisplacementEffect().kind).toBe('DisplacementEffect');
|
|
6
|
+
});
|
|
7
|
+
|
|
8
|
+
it('carries options', () => {
|
|
9
|
+
expect(createDisplacementEffect({ intensity: 10, frequency: 14, seed: 2 })).toMatchObject({
|
|
10
|
+
intensity: 10,
|
|
11
|
+
frequency: 14,
|
|
12
|
+
seed: 2,
|
|
13
|
+
});
|
|
14
|
+
});
|
|
15
|
+
});
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { createDitherEffect } from './ditherEffect';
|
|
2
|
+
|
|
3
|
+
describe('createDitherEffect', () => {
|
|
4
|
+
it('tags the intent type', () => {
|
|
5
|
+
expect(createDitherEffect().kind).toBe('DitherEffect');
|
|
6
|
+
});
|
|
7
|
+
|
|
8
|
+
it('carries options', () => {
|
|
9
|
+
expect(createDitherEffect({ levels: 4 })).toMatchObject({ levels: 4 });
|
|
10
|
+
});
|
|
11
|
+
});
|