public LiteFloatCrusher(LiteFloatCompressType compressType, Normalization normalization = Normalization.None, LiteOutOfBoundsHandling outOfBoundsHandling = LiteOutOfBoundsHandling.Clamp) { this.compressType = compressType; this.normalization = normalization; switch (normalization) { case Normalization.None: this.min = 0; this.max = 1; accurateCenter = false; break; case Normalization.Positive: this.min = 0; this.max = 1; accurateCenter = false; break; case Normalization.Negative: this.min = -1; this.max = 1; accurateCenter = true; break; } this.outOfBoundsHandling = outOfBoundsHandling; Recalculate(compressType, min, max, accurateCenter, this); }
public LiteFloatCrusher(LiteFloatCompressType compressType, float min, float max, bool accurateCenter, LiteOutOfBoundsHandling outOfBoundsHandling = LiteOutOfBoundsHandling.Clamp) { this.compressType = compressType; this.normalization = Normalization.None; /// Don't allow min and max to equal. if (min == max) { max++; Debug.LogWarning("Float crusher is being given min and max values that are the same. This likely is not intentional. Check your range values. Value is <i>" + min + "</i>, changing the max to " + max + " to avoid division by zero errors."); } if (min < max) { this.min = min; this.max = max; } else { this.min = max; this.max = min; } this.accurateCenter = accurateCenter; this.outOfBoundsHandling = outOfBoundsHandling; Recalculate(compressType, min, max, accurateCenter, this); }
public LiteFloatCrusher(LiteFloatCompressType compressType, float min, float max, bool accurateCenter) { this.compressType = compressType; this.min = min; this.max = max; this.accurateCenter = accurateCenter; Recalculate(compressType, min, max, accurateCenter, ref bits, ref encoder, ref decoder, ref maxCVal); }
public LiteFloatCrusher() { this.compressType = LiteFloatCompressType.Half16; this.min = 0; this.max = 1; this.accurateCenter = true; Recalculate(compressType, min, max, accurateCenter, ref bits, ref encoder, ref decoder, ref maxCVal); }
public LiteFloatCrusher() { this.compressType = LiteFloatCompressType.Half16; this.normalization = Normalization.Positive; this.min = 0; this.max = 1; this.accurateCenter = true; Recalculate(compressType, min, max, accurateCenter, this); }
public static void Recalculate(LiteFloatCompressType compressType, float min, float max, bool accurateCenter, ref int bits, ref float encoder, ref float decoder, ref ulong maxCVal) { bits = (int)compressType; float range = max - min; ulong maxcval = (bits == 64) ? ulong.MaxValue : (((ulong)1 << (int)bits) - 1); if (accurateCenter && maxcval != 0) { maxcval--; } encoder = range == 0 ? 0 : maxcval / range; decoder = maxcval == 0 ? 0 : range / maxcval; maxCVal = maxcval; }
public static void Recalculate(LiteFloatCompressType compressType, float min, float max, bool accurateCenter, LiteFloatCrusher crusher) { int bits = (int)compressType; crusher.bits = bits; float range = max - min; ulong maxcval = (bits == 64) ? ulong.MaxValue : (((ulong)1 << (int)bits) - 1); if (accurateCenter && maxcval != 0) { maxcval--; } crusher.encoder = range == 0 ? 0 : maxcval / range; crusher.decoder = maxcval == 0 ? 0 : range / maxcval; crusher.maxCVal = maxcval; }
public PackRangedAttribute(LiteFloatCompressType compression, Single min, Single max, bool accurateCenter) { LiteFloatCrusher.Recalculate(compression, min, max, accurateCenter, crusher); }