
1. Practical Screen-Space Soft Shadows 307
//input : float value in range [0 . . . 1 ]
uint float_to_r8 ( float val )
{
const uint bits =8;
uint precision_scaler = uint( pow( uint (2) , bits )) − uint(1) ;
return uint( floor ( precision_scaler val ));
}
uint rgba8_to_uint ( vec4 val )
{
uint res = float_to_r8 ( val . x ) << 24;
res |= float_to_r8 ( val . y ) << 16;
res |= float_to_r8 ( val . z ) << 8;
res |= float_to_r8 ( val . w ) << 0;
return res ;
}
Listing 1.2. A function to pack an RGBA8 value into an R32F float.
float threshold =0.25;
float filter_size =
// account for li g h t si z e ( af fe ct s penumbra s i z e )
light_size
//anisotropic term, varies w