Search code examples
directxshaderhlslpixel-shader

Comparison operations in HLSL


I am reading through a HLSL implementation of CSM shadow mapping and have come across a line of code i don't quite understande

float3 pos;
float3 CascadeDistances;
...
float3 weights = ( pos.z < CascadeDistances );

Can someone please tell me what is happening here and what is the result of this assignment.

I think it may expand out to something like

float3 weights;
weights.x = ( pos.z < CascadeDistances.x ) ? 1 : 0;
weights.y = ( pos.z < CascadeDistances.y ) ? 1 : 0;
weights.z = ( pos.z < CascadeDistances.z ) ? 1 : 0;

Can someone please confirm if this is correct of if i am way off.

Any help would be appreciated.


Solution

  • I contacted the author of this shader and after some time he replied and confirmed that this is how this particular expression evaluates