2019-12-27 09:26:59 -05:00
|
|
|
// Copyright Epic Games, Inc. All Rights Reserved.
|
2017-07-26 10:00:02 -04:00
|
|
|
|
|
|
|
|
/*=============================================================================
|
2022-08-24 03:50:23 -04:00
|
|
|
FastMath.ush: Fast/approximated math functions
|
2017-07-26 10:00:02 -04:00
|
|
|
=============================================================================*/
|
|
|
|
|
|
|
|
|
|
#pragma once
|
|
|
|
|
|
2022-08-24 03:50:23 -04:00
|
|
|
#include "FastMathThirdParty.ush"
|
2017-07-26 10:00:02 -04:00
|
|
|
|
2022-08-24 03:50:23 -04:00
|
|
|
// Reference: http://www.humus.name/Articles/Persson_LowLevelThinking.pdf p.27
|
|
|
|
|
#define FastExp_N(T) T FastExp(T x) { return exp2(1.442695f * x); }
|
|
|
|
|
FastExp_N(float)
|
|
|
|
|
FastExp_N(float2)
|
|
|
|
|
FastExp_N(float3)
|
|
|
|
|
FastExp_N(float4)
|
2017-07-26 10:00:02 -04:00
|
|
|
|
2022-08-24 03:50:23 -04:00
|
|
|
// Reference: http://www.humus.name/Articles/Persson_LowLevelThinking.pdf p.27
|
|
|
|
|
// Warning: This is a coarse approximation
|
|
|
|
|
#define FastLog_N(T) T FastLog(T x) { return log2(0.693147f * x); }
|
|
|
|
|
FastLog_N(float)
|
|
|
|
|
FastLog_N(float2)
|
|
|
|
|
FastLog_N(float3)
|
|
|
|
|
FastLog_N(float4)
|