Skip to content
Snippets Groups Projects
Commit e76a08c7 authored by Alexander Rose's avatar Alexander Rose
Browse files

remove unused en/decodeFloatLog

parent a0fef0c2
No related branches found
No related tags found
No related merge requests found
...@@ -32,11 +32,6 @@ int imod(const in int a, const in int b) { return a - b * (a / b); } ...@@ -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; } 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) { vec3 packIntToRGB(in float value) {
value = clamp(round(value), 0.0, 16777216.0 - 1.0) + 1.0; value = clamp(round(value), 0.0, 16777216.0 - 1.0) + 1.0;
vec3 c = vec3(0.0); vec3 c = vec3(0.0);
......
/** /**
* 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> * @author Alexander Rose <alexander.rose@weirdbyte.de>
*/ */
import { clamp } from '../mol-math/interpolate'; import { clamp } from '../mol-math/interpolate';
import { fasterExp, fasterLog } from '../mol-math/approx';
import { Vec3, Vec4 } from '../mol-math/linear-algebra'; import { Vec3, Vec4 } from '../mol-math/linear-algebra';
import { NumberArray } from './type-helpers'; 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 */ /** encode positive integer as rgb byte triplet into array at offset */
export function packIntToRGBArray(value: number, array: NumberArray, offset: number) { export function packIntToRGBArray(value: number, array: NumberArray, offset: number) {
value = clamp(Math.round(value), 0, 16777216 - 1) + 1; value = clamp(Math.round(value), 0, 16777216 - 1) + 1;
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment