UNPKG

react-native-filament

Version:

A real-time physically based 3D rendering engine for React Native

101 lines (96 loc) 3.36 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.optionsToJSI = optionsToJSI; /** * Options for screen space Ambient Occlusion (SSAO) and Screen Space Cone Tracing (SSCT) */ /** * Dynamic resolution can be used to either reach a desired target frame rate * by lowering the resolution of a View, or to increase the quality when the * rendering is faster than the target frame rate. * * This structure can be used to specify the minimum scale factor used when * lowering the resolution of a View, and the maximum scale factor used when * increasing the resolution for higher quality rendering. The scale factors * can be controlled on each X and Y axis independently. By default, all scale * factors are set to 1.0. * * enabled: enable or disables dynamic resolution on a View * * homogeneousScaling: by default the system scales the major axis first. Set this to true * to force homogeneous scaling. * * minScale: the minimum scale in X and Y this View should use * * maxScale: the maximum scale in X and Y this View should use * * quality: upscaling quality. * LOW: 1 bilinear tap, Medium: 4 bilinear taps, High: 9 bilinear taps (tent) * * @note Dynamic resolution is only supported on platforms where the time to render * a frame can be measured accurately. Dynamic resolution is currently only * supported on Android. * * @see Renderer::FrameRateOptions * */ /** * Options for Temporal Anti-aliasing (TAA) * Most TAA parameters are extremely costly to change, as they will trigger the TAA post-process * shaders to be recompiled. These options should be changed or set during initialization. * `filterWidth`, `feedback` and `jitterPattern`, however, can be changed at any time. * * `feedback` of 0.1 effectively accumulates a maximum of 19 samples in steady state. * see "A Survey of Temporal Antialiasing Techniques" by Lei Yang and all for more information. */ const getEntries = obj => Object.entries(obj); function boxClippingToNumber(boxClipping) { switch (boxClipping) { case 'ACCURATE': return 0; case 'CLAMP': return 1; case 'NONE': return 2; } throw new Error(`Unknown boxClipping: ${boxClipping}`); } function jitterPatternToNumber(jitterPattern) { switch (jitterPattern) { case 'RGSS_X4': return 0; case 'UNIFORM_HELIX_X4': return 1; case 'HALTON_23_X8': return 2; case 'HALTON_23_X16': return 3; case 'HALTON_23_X32': return 4; } throw new Error(`Unknown jitterPattern: ${jitterPattern}`); } // Currently on JSi we don't support passing arbitrary objects. // The method for receiving the options is expected to receive a Record<string, number>, where booleans are // represented as 0.0 or 1.0. function optionsToJSI(options) { const result = {}; const entries = getEntries(options); entries.forEach(([key, value]) => { if (typeof value === 'boolean') { result[key] = value ? 1.0 : 0.0; } else { if (key === 'boxClipping') { result[key] = boxClippingToNumber(value); } else if (key === 'jitterPattern') { result[key] = jitterPatternToNumber(value); } else if (value != null) { result[key] = value; } } }); return result; } //# sourceMappingURL=Options.js.map