From 8f84e54bb053cad9599e443675761087ce884563 Mon Sep 17 00:00:00 2001 From: Robert Beckebans Date: Thu, 12 Oct 2023 10:11:00 +0200 Subject: [PATCH] Restored ternary operator usage for older DXC compilers. Thanks SRSaunders --- neo/shaders/builtin/SSAO/ssao_compute.cs.hlsl | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/neo/shaders/builtin/SSAO/ssao_compute.cs.hlsl b/neo/shaders/builtin/SSAO/ssao_compute.cs.hlsl index e81c796a..445c5546 100644 --- a/neo/shaders/builtin/SSAO/ssao_compute.cs.hlsl +++ b/neo/shaders/builtin/SSAO/ssao_compute.cs.hlsl @@ -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 ); }