cast ist for dynamic light if the models in the light range should cast shadows from the light and not from the sun.
Normally it should work with shadow_stencil = 2;
du you set is in the main function or before you start the main function??