diff --git a/src/mol-gl/shader/chunks/common.glsl.ts b/src/mol-gl/shader/chunks/common.glsl.ts index 4c5c6f8e0a250367c8ef88a4d071755e24d452ea..5b087fbb1e3cbb4504da9683ab5ca33a8e6b9b28 100644 --- a/src/mol-gl/shader/chunks/common.glsl.ts +++ b/src/mol-gl/shader/chunks/common.glsl.ts @@ -32,11 +32,6 @@ int imod(const in int a, const in int b) { return a - b * (a / b); } float pow2(const in float x) { return x * x; } -const float maxFloat = 10000.0; // NOTE constant also set in TypeScript -const float floatLogFactor = 9.210440366976517; // log(maxFloat + 1.0); -float encodeFloatLog(const in float value) { return log(value + 1.0) / floatLogFactor; } -float decodeFloatLog(const in float value) { return exp(value * floatLogFactor) - 1.0; } - vec3 packIntToRGB(in float value) { value = clamp(round(value), 0.0, 16777216.0 - 1.0) + 1.0; vec3 c = vec3(0.0); diff --git a/src/mol-util/float-packing.ts b/src/mol-util/float-packing.ts index 15aa855a23f7987a2059ea1568ce9d4199e8ff33..316674230ceb5bfdbbfdf8aa9414de20f37ba7ca 100644 --- a/src/mol-util/float-packing.ts +++ b/src/mol-util/float-packing.ts @@ -1,23 +1,13 @@ /** - * Copyright (c) 2019-2020 mol* contributors, licensed under MIT, See LICENSE file for more info. + * Copyright (c) 2019-2021 mol* contributors, licensed under MIT, See LICENSE file for more info. * * @author Alexander Rose <alexander.rose@weirdbyte.de> */ import { clamp } from '../mol-math/interpolate'; -import { fasterExp, fasterLog } from '../mol-math/approx'; import { Vec3, Vec4 } from '../mol-math/linear-algebra'; import { NumberArray } from './type-helpers'; -const maxFloat = 10000.0; // NOTE same constant is set in shaders -const floatLogFactor = fasterLog(maxFloat + 1); - -/** encode float logarithmically */ -export function encodeFloatLog(value: number) { return fasterLog(value + 1) / floatLogFactor; } - -/** decode logarithmically encoded float */ -export function decodeFloatLog(value: number) { return fasterExp(value * floatLogFactor) - 1; } - /** encode positive integer as rgb byte triplet into array at offset */ export function packIntToRGBArray(value: number, array: NumberArray, offset: number) { value = clamp(Math.round(value), 0, 16777216 - 1) + 1;