diff --git a/src/Shaders/PathtraceBase.fs b/src/Shaders/PathtraceBase.fs index 6b743d423b..8e8dd42ef9 100644 --- a/src/Shaders/PathtraceBase.fs +++ b/src/Shaders/PathtraceBase.fs @@ -347,7 +347,7 @@ vec3 SampleLambertianReflection (in vec3 theWo, out vec3 theWi, inout float theP #ifdef TWO_SIDED_BXDF return UNIT; #else - return mix (UNIT, ZERO, theWo.z <= 0.f); + return UNIT * step (0.f, theWo.z); #endif } diff --git a/src/Shaders/RaytraceBase.fs b/src/Shaders/RaytraceBase.fs index a7f7be191c..f38a132291 100644 --- a/src/Shaders/RaytraceBase.fs +++ b/src/Shaders/RaytraceBase.fs @@ -446,8 +446,7 @@ ivec4 SceneNearestHit (in SRay theRay, in vec3 theInverse, inout SIntersect theH float aTimeLeave = min (aTimeMax.x, min (aTimeMax.y, aTimeMax.z)); float aTimeEnter = max (aTimeMin.x, max (aTimeMin.y, aTimeMin.z)); - aHitTimes.x = mix (MAXFLOAT, aTimeEnter, - aTimeEnter <= aTimeLeave && aTimeEnter <= theHit.Time && aTimeLeave >= 0.f); + aHitTimes.x = (aTimeEnter <= aTimeLeave && aTimeEnter <= theHit.Time && aTimeLeave >= 0.f) ? aTimeEnter : MAXFLOAT; aTimeMax = max (aNodeMin1, aNodeMax1); aTimeMin = min (aNodeMin1, aNodeMax1); @@ -455,8 +454,7 @@ ivec4 SceneNearestHit (in SRay theRay, in vec3 theInverse, inout SIntersect theH aTimeLeave = min (aTimeMax.x, min (aTimeMax.y, aTimeMax.z)); aTimeEnter = max (aTimeMin.x, max (aTimeMin.y, aTimeMin.z)); - aHitTimes.y = mix (MAXFLOAT, aTimeEnter, - aTimeEnter <= aTimeLeave && aTimeEnter <= theHit.Time && aTimeLeave >= 0.f); + aHitTimes.y = (aTimeEnter <= aTimeLeave && aTimeEnter <= theHit.Time && aTimeLeave >= 0.f) ? aTimeEnter : MAXFLOAT; aTimeMax = max (aNodeMin2, aNodeMax2); aTimeMin = min (aNodeMin2, aNodeMax2); @@ -464,8 +462,7 @@ ivec4 SceneNearestHit (in SRay theRay, in vec3 theInverse, inout SIntersect theH aTimeLeave = min (aTimeMax.x, min (aTimeMax.y, aTimeMax.z)); aTimeEnter = max (aTimeMin.x, max (aTimeMin.y, aTimeMin.z)); - aHitTimes.z = mix (MAXFLOAT, aTimeEnter, - aTimeEnter <= aTimeLeave && aTimeEnter <= theHit.Time && aTimeLeave >= 0.f && aData.z > 1); + aHitTimes.z = (aTimeEnter <= aTimeLeave && aTimeEnter <= theHit.Time && aTimeLeave >= 0.f && aData.z > 1) ? aTimeEnter : MAXFLOAT; aTimeMax = max (aNodeMin3, aNodeMax3); aTimeMin = min (aNodeMin3, aNodeMax3); @@ -473,8 +470,7 @@ ivec4 SceneNearestHit (in SRay theRay, in vec3 theInverse, inout SIntersect theH aTimeLeave = min (aTimeMax.x, min (aTimeMax.y, aTimeMax.z)); aTimeEnter = max (aTimeMin.x, max (aTimeMin.y, aTimeMin.z)); - aHitTimes.w = mix (MAXFLOAT, aTimeEnter, - aTimeEnter <= aTimeLeave && aTimeEnter <= theHit.Time && aTimeLeave >= 0.f && aData.z > 2); + aHitTimes.w = (aTimeEnter <= aTimeLeave && aTimeEnter <= theHit.Time && aTimeLeave >= 0.f && aData.z > 2) ? aTimeEnter : MAXFLOAT; ivec4 aChildren = ivec4 (0, 1, 2, 3); @@ -623,8 +619,7 @@ float SceneAnyHit (in SRay theRay, in vec3 theInverse, in float theDistance) float aTimeLeave = min (aTimeMax.x, min (aTimeMax.y, aTimeMax.z)); float aTimeEnter = max (aTimeMin.x, max (aTimeMin.y, aTimeMin.z)); - aHitTimes.x = mix (MAXFLOAT, aTimeEnter, - aTimeEnter <= aTimeLeave && aTimeEnter <= theDistance && aTimeLeave >= 0.f); + aHitTimes.x = (aTimeEnter <= aTimeLeave && aTimeEnter <= theDistance && aTimeLeave >= 0.f) ? aTimeEnter : MAXFLOAT; aTimeMax = max (aNodeMin1, aNodeMax1); aTimeMin = min (aNodeMin1, aNodeMax1); @@ -632,8 +627,7 @@ float SceneAnyHit (in SRay theRay, in vec3 theInverse, in float theDistance) aTimeLeave = min (aTimeMax.x, min (aTimeMax.y, aTimeMax.z)); aTimeEnter = max (aTimeMin.x, max (aTimeMin.y, aTimeMin.z)); - aHitTimes.y = mix (MAXFLOAT, aTimeEnter, - aTimeEnter <= aTimeLeave && aTimeEnter <= theDistance && aTimeLeave >= 0.f); + aHitTimes.y = (aTimeEnter <= aTimeLeave && aTimeEnter <= theDistance && aTimeLeave >= 0.f) ? aTimeEnter : MAXFLOAT; aTimeMax = max (aNodeMin2, aNodeMax2); aTimeMin = min (aNodeMin2, aNodeMax2); @@ -641,8 +635,7 @@ float SceneAnyHit (in SRay theRay, in vec3 theInverse, in float theDistance) aTimeLeave = min (aTimeMax.x, min (aTimeMax.y, aTimeMax.z)); aTimeEnter = max (aTimeMin.x, max (aTimeMin.y, aTimeMin.z)); - aHitTimes.z = mix (MAXFLOAT, aTimeEnter, - aTimeEnter <= aTimeLeave && aTimeEnter <= theDistance && aTimeLeave >= 0.f && aData.z > 1); + aHitTimes.z = (aTimeEnter <= aTimeLeave && aTimeEnter <= theDistance && aTimeLeave >= 0.f && aData.z > 1) ? aTimeEnter : MAXFLOAT; aTimeMax = max (aNodeMin3, aNodeMax3); aTimeMin = min (aNodeMin3, aNodeMax3); @@ -650,8 +643,7 @@ float SceneAnyHit (in SRay theRay, in vec3 theInverse, in float theDistance) aTimeLeave = min (aTimeMax.x, min (aTimeMax.y, aTimeMax.z)); aTimeEnter = max (aTimeMin.x, max (aTimeMin.y, aTimeMin.z)); - aHitTimes.w = mix (MAXFLOAT, aTimeEnter, - aTimeEnter <= aTimeLeave && aTimeEnter <= theDistance && aTimeLeave >= 0.f && aData.z > 2); + aHitTimes.w = (aTimeEnter <= aTimeLeave && aTimeEnter <= theDistance && aTimeLeave >= 0.f && aData.z > 2) ? aTimeEnter : MAXFLOAT; ivec4 aChildren = ivec4 (0, 1, 2, 3); diff --git a/src/Shaders/Shaders_PathtraceBase_fs.pxx b/src/Shaders/Shaders_PathtraceBase_fs.pxx index 59b0fb378e..a0064a213b 100644 --- a/src/Shaders/Shaders_PathtraceBase_fs.pxx +++ b/src/Shaders/Shaders_PathtraceBase_fs.pxx @@ -350,7 +350,7 @@ static const char Shaders_PathtraceBase_fs[] = "#ifdef TWO_SIDED_BXDF\n" " return UNIT;\n" "#else\n" - " return mix (UNIT, ZERO, theWo.z <= 0.f);\n" + " return UNIT * step (0.f, theWo.z);\n" "#endif\n" "}\n" "\n" diff --git a/src/Shaders/Shaders_RaytraceBase_fs.pxx b/src/Shaders/Shaders_RaytraceBase_fs.pxx index 2df52815a1..321a854f89 100644 --- a/src/Shaders/Shaders_RaytraceBase_fs.pxx +++ b/src/Shaders/Shaders_RaytraceBase_fs.pxx @@ -449,8 +449,7 @@ static const char Shaders_RaytraceBase_fs[] = " float aTimeLeave = min (aTimeMax.x, min (aTimeMax.y, aTimeMax.z));\n" " float aTimeEnter = max (aTimeMin.x, max (aTimeMin.y, aTimeMin.z));\n" "\n" - " aHitTimes.x = mix (MAXFLOAT, aTimeEnter,\n" - " aTimeEnter <= aTimeLeave && aTimeEnter <= theHit.Time && aTimeLeave >= 0.f);\n" + " aHitTimes.x = (aTimeEnter <= aTimeLeave && aTimeEnter <= theHit.Time && aTimeLeave >= 0.f) ? aTimeEnter : MAXFLOAT;\n" "\n" " aTimeMax = max (aNodeMin1, aNodeMax1);\n" " aTimeMin = min (aNodeMin1, aNodeMax1);\n" @@ -458,8 +457,7 @@ static const char Shaders_RaytraceBase_fs[] = " aTimeLeave = min (aTimeMax.x, min (aTimeMax.y, aTimeMax.z));\n" " aTimeEnter = max (aTimeMin.x, max (aTimeMin.y, aTimeMin.z));\n" "\n" - " aHitTimes.y = mix (MAXFLOAT, aTimeEnter,\n" - " aTimeEnter <= aTimeLeave && aTimeEnter <= theHit.Time && aTimeLeave >= 0.f);\n" + " aHitTimes.y = (aTimeEnter <= aTimeLeave && aTimeEnter <= theHit.Time && aTimeLeave >= 0.f) ? aTimeEnter : MAXFLOAT;\n" "\n" " aTimeMax = max (aNodeMin2, aNodeMax2);\n" " aTimeMin = min (aNodeMin2, aNodeMax2);\n" @@ -467,8 +465,7 @@ static const char Shaders_RaytraceBase_fs[] = " aTimeLeave = min (aTimeMax.x, min (aTimeMax.y, aTimeMax.z));\n" " aTimeEnter = max (aTimeMin.x, max (aTimeMin.y, aTimeMin.z));\n" "\n" - " aHitTimes.z = mix (MAXFLOAT, aTimeEnter,\n" - " aTimeEnter <= aTimeLeave && aTimeEnter <= theHit.Time && aTimeLeave >= 0.f && aData.z > 1);\n" + " aHitTimes.z = (aTimeEnter <= aTimeLeave && aTimeEnter <= theHit.Time && aTimeLeave >= 0.f && aData.z > 1) ? aTimeEnter : MAXFLOAT;\n" "\n" " aTimeMax = max (aNodeMin3, aNodeMax3);\n" " aTimeMin = min (aNodeMin3, aNodeMax3);\n" @@ -476,8 +473,7 @@ static const char Shaders_RaytraceBase_fs[] = " aTimeLeave = min (aTimeMax.x, min (aTimeMax.y, aTimeMax.z));\n" " aTimeEnter = max (aTimeMin.x, max (aTimeMin.y, aTimeMin.z));\n" "\n" - " aHitTimes.w = mix (MAXFLOAT, aTimeEnter,\n" - " aTimeEnter <= aTimeLeave && aTimeEnter <= theHit.Time && aTimeLeave >= 0.f && aData.z > 2);\n" + " aHitTimes.w = (aTimeEnter <= aTimeLeave && aTimeEnter <= theHit.Time && aTimeLeave >= 0.f && aData.z > 2) ? aTimeEnter : MAXFLOAT;\n" "\n" " ivec4 aChildren = ivec4 (0, 1, 2, 3);\n" "\n" @@ -626,8 +622,7 @@ static const char Shaders_RaytraceBase_fs[] = " float aTimeLeave = min (aTimeMax.x, min (aTimeMax.y, aTimeMax.z));\n" " float aTimeEnter = max (aTimeMin.x, max (aTimeMin.y, aTimeMin.z));\n" "\n" - " aHitTimes.x = mix (MAXFLOAT, aTimeEnter,\n" - " aTimeEnter <= aTimeLeave && aTimeEnter <= theDistance && aTimeLeave >= 0.f);\n" + " aHitTimes.x = (aTimeEnter <= aTimeLeave && aTimeEnter <= theDistance && aTimeLeave >= 0.f) ? aTimeEnter : MAXFLOAT;\n" "\n" " aTimeMax = max (aNodeMin1, aNodeMax1);\n" " aTimeMin = min (aNodeMin1, aNodeMax1);\n" @@ -635,8 +630,7 @@ static const char Shaders_RaytraceBase_fs[] = " aTimeLeave = min (aTimeMax.x, min (aTimeMax.y, aTimeMax.z));\n" " aTimeEnter = max (aTimeMin.x, max (aTimeMin.y, aTimeMin.z));\n" "\n" - " aHitTimes.y = mix (MAXFLOAT, aTimeEnter,\n" - " aTimeEnter <= aTimeLeave && aTimeEnter <= theDistance && aTimeLeave >= 0.f);\n" + " aHitTimes.y = (aTimeEnter <= aTimeLeave && aTimeEnter <= theDistance && aTimeLeave >= 0.f) ? aTimeEnter : MAXFLOAT;\n" "\n" " aTimeMax = max (aNodeMin2, aNodeMax2);\n" " aTimeMin = min (aNodeMin2, aNodeMax2);\n" @@ -644,8 +638,7 @@ static const char Shaders_RaytraceBase_fs[] = " aTimeLeave = min (aTimeMax.x, min (aTimeMax.y, aTimeMax.z));\n" " aTimeEnter = max (aTimeMin.x, max (aTimeMin.y, aTimeMin.z));\n" "\n" - " aHitTimes.z = mix (MAXFLOAT, aTimeEnter,\n" - " aTimeEnter <= aTimeLeave && aTimeEnter <= theDistance && aTimeLeave >= 0.f && aData.z > 1);\n" + " aHitTimes.z = (aTimeEnter <= aTimeLeave && aTimeEnter <= theDistance && aTimeLeave >= 0.f && aData.z > 1) ? aTimeEnter : MAXFLOAT;\n" "\n" " aTimeMax = max (aNodeMin3, aNodeMax3);\n" " aTimeMin = min (aNodeMin3, aNodeMax3);\n" @@ -653,8 +646,7 @@ static const char Shaders_RaytraceBase_fs[] = " aTimeLeave = min (aTimeMax.x, min (aTimeMax.y, aTimeMax.z));\n" " aTimeEnter = max (aTimeMin.x, max (aTimeMin.y, aTimeMin.z));\n" "\n" - " aHitTimes.w = mix (MAXFLOAT, aTimeEnter,\n" - " aTimeEnter <= aTimeLeave && aTimeEnter <= theDistance && aTimeLeave >= 0.f && aData.z > 2);\n" + " aHitTimes.w = (aTimeEnter <= aTimeLeave && aTimeEnter <= theDistance && aTimeLeave >= 0.f && aData.z > 2) ? aTimeEnter : MAXFLOAT;\n" "\n" " ivec4 aChildren = ivec4 (0, 1, 2, 3);\n" "\n"