Something seems to be is broken in the compiler (or I made a mistake that goes unnoticed somewhere)...
This code fails with 'compilation failed!' and no errors.
float CalculateCoC(float2 texcoord)
{
float scenedepth = tex2D(RFX_depthTexColor, texcoord).r;
float toReturn = 0.0f;
if(scenedepth > DEH_NEARPLANE)
{
float depthdiff = abs(scenedepth-DEH_NEARPLANE);
float power = pow(depthdiff, DEH_FARBLURCURVE);
toReturn = saturate(power);
}
return toReturn;
}
this succeeds (I pass a constant there and not the variable 'power'). If I inline the pow() call, same results: failure without an error.
float CalculateCoC(float2 texcoord)
{
float scenedepth = tex2D(RFX_depthTexColor, texcoord).r;
float toReturn = 0.0f;
if(scenedepth > DEH_NEARPLANE)
{
float depthdiff = abs(scenedepth-DEH_NEARPLANE);
float power = pow(depthdiff, DEH_FARBLURCURVE);
toReturn = saturate(1.0f);
}
return toReturn;
}
I used an if etc. to see what fragment of the ?: expression I used failed. I don't see how passing 'power' (or whatever I call it, doesn't matter) to saturate there makes the compiler fail, as it's just a float, and that's a call-by-value.
Full code:
gist.github.com/FransBouma/11cefab9e50a910c6835 (code is WIP, and will 100% for sure bug, but it should at least pass the compiler

)