smaa
smaa copied to clipboard
Custom decode velocity function compilation error
When defining SMAA_DECODE_VELOCITY to point towards a function that takes a float4 vector an error is generated at line 1323 because the input will be a float2 from swizzling the rg components of the texture sampling, whereas in the other three cases there is no swizzling so a float4 is passed.
I was just about to create an issue for the same bug. There's an error in the usage of the SMAA_DECODE_VELOCITY macro here on line 1323:
float2 velocity = -SMAA_DECODE_VELOCITY(SMAASamplePoint(velocityTex, texcoord).rg);
It assumes the value returned from SMAASamplePoint only uses components rg. In other words, a float2 is passed to the macro. This is an error because it conflicts with the other uses of the SMAA_DECODE_VELOCITY macro. For example, see line 1272:
float2 velocity = SMAA_DECODE_VELOCITY(SMAASampleLevelZero(velocityTex, texcoord));
Notice this line passes the entire float4 to the macro, instead of the float2.
The fix is to change line 1323 to pass the entire float4 to the macro:
float2 velocity = -SMAA_DECODE_VELOCITY(SMAASamplePoint(velocityTex, texcoord));