Skip to content

Commit

Permalink
fix to dx9_normalize macro
Browse files Browse the repository at this point in the history
-possible error fix to 0 length situation
-related to #52
  • Loading branch information
megai2 committed Feb 9, 2019
1 parent 41ea0ab commit 92933ef
Showing 1 changed file with 5 additions and 2 deletions.
7 changes: 5 additions & 2 deletions bin/d912pxy/shaders/common.hlsli
Original file line number Diff line number Diff line change
Expand Up @@ -307,10 +307,13 @@ float4 dx9_fix_halfpixel_offset(float4 inPos)
#define dx9_expp(a) exp2(a)
#define dx9_exp(a) exp2(a)
#define dx9_lerp(a,b,c) lerp(a,b,c)
#define dx9_rcp(a) (a != 0 ? rcp(a) : 1e9)
//megai2: looks like it works fine, but just in case left a note here
//#define dx9_rcp(a) (a != 0 ? rcp(a) : 1e9)
#define dx9_rcp(a) rcp(a)
#define dx9_max(a,b) max(a,b)
#define dx9_min(a,b) min(a,b)
#define dx9_rsqrt(a) rsqrt(abs(a))
#define dx9_frac(a) frac(a)
#define dx9_pow(a,b) pow(abs(a), b)
#define dx9_normalize(a) normalize(a)
//megai2: TODO optimize it thru HLSL generation cause normalize(a) says indefinete results on length(a) == 0
#define dx9_normalize(a) (length(a) != 0 ? (a/length(a)) : a)

0 comments on commit 92933ef

Please sign in to comment.