mirror of
https://github.com/id-Software/DOOM-3-BFG.git
synced 2025-04-24 02:32:18 +00:00
Restored ternary operator usage for older DXC compilers. Thanks SRSaunders
This commit is contained in:
parent
3998702981
commit
8f84e54bb0
1 changed files with 12 additions and 0 deletions
|
@ -104,7 +104,11 @@ static const float g_RandomValues[16] =
|
|||
// over the diagonals in the octahedral map
|
||||
float2 octWrap( float2 v )
|
||||
{
|
||||
#if __HLSL_VERSION >= 2021
|
||||
return ( 1.f - abs( v.yx ) ) * select( v.xy >= 0.f, 1.f, -1.f );
|
||||
#else
|
||||
return ( 1.f - abs( v.yx ) ) * ( v.xy >= 0.f ? 1.f : -1.f );
|
||||
#endif
|
||||
}
|
||||
|
||||
/**********************/
|
||||
|
@ -116,7 +120,11 @@ float2 ndirToOctSigned( float3 n )
|
|||
{
|
||||
// Project the sphere onto the octahedron (|x|+|y|+|z| = 1) and then onto the xy-plane
|
||||
float2 p = n.xy * ( 1.f / ( abs( n.x ) + abs( n.y ) + abs( n.z ) ) );
|
||||
#if __HLSL_VERSION >= 2021
|
||||
return select( n.z < 0.f, octWrap( p ), p );
|
||||
#else
|
||||
return ( n.z < 0.f ) ? octWrap( p ) : p;
|
||||
#endif
|
||||
}
|
||||
|
||||
// Converts a point in the octahedral map to a normalized direction (non-equal area, signed)
|
||||
|
@ -127,7 +135,11 @@ float3 octToNdirSigned( float2 p )
|
|||
// https://twitter.com/Stubbesaurus/status/937994790553227264
|
||||
float3 n = float3( p.x, p.y, 1.0 - abs( p.x ) - abs( p.y ) );
|
||||
float t = max( 0, -n.z );
|
||||
#if __HLSL_VERSION >= 2021
|
||||
n.xy += select( n.xy >= 0.0, -t, t );
|
||||
#else
|
||||
n.xy += n.xy >= 0.0 ? -t : t;
|
||||
#endif
|
||||
return normalize( n );
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue