Quantcast
Channel: GameDev.net
Viewing all articles
Browse latest Browse all 17825

HLSL NaN headache

$
0
0
After getting "black squares" rendered on my "bloom" post process: So i searched and read this thread where i think L.Spiro had same problem. Then i searched my HLSLs programs to find where i could have NaNs. Found one problem in my point light shader: float4 posVS = gbPosition_tex.Sample(sampPointClamp, tc); // this has no effect ! if (IsNAN(posVS)) posVS = float4(0.0f, 0.0f, 0.0f, 1.0f); if (any(isinf(posVS))) posVS = float4(0.0f, 0.0f, 0.0f, 1.0f); ... //code skipped, nothing else touches posVS float3 v = normalize(-posVS.xyz); // but if i uncomment this there is NO more black squares ! //if (IsNAN(v)) // v = float3(0.0f, 0.0f, 0.0f); ...// rest of lightning computation Please read comments in code. IsNAN is defined like this (i cant use "native" isnan function because i cant set /Gis option inside VS2013 for fxc compiler options): bool IsNAN(float n) { return (n < 0.0f || n > 0.0f || n == 0.0f) ? false : true; } bool IsNAN(float2 v) { return (IsNAN(v.x) || IsNAN(v.y)) ? true : false; } bool IsNAN(float3 v) { return (IsNAN(v.x) || IsNAN(v.y) || IsNAN(v.z)) ? true : false; } bool IsNAN(float4 v) { return (IsNAN(v.x) || IsNAN(v.y) || IsNAN(v.z) || IsNAN(v.w)) ? true : false; } wtf is going on?

Viewing all articles
Browse latest Browse all 17825

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>