I've been using the 'Sun' and 'Shadow' commands in my most recent app and have come across some odd behaviour. They work perfectly until you hit the 'home' button or switch to another app in Android, and then switch back. It acts like the sun has been turned off but even putting a SetSunActive(1) in the main loop won't turn it back on.
This applies to apps being broadcast to the AppGameKit Player or being run from an APK.
The following code demonstrates the problem.
// Set general properties
SetErrorMode(2)
SetWindowTitle( "ShadowTest" )
SetWindowSize( 1024, 768, 0 )
SetWindowAllowResize( 1 )
SetVirtualResolution( 1024, 768 )
SetOrientationAllowed( 1, 1, 1, 1 )
SetSyncRate( 30, 0 )
SetScissor( 0,0,0,0 )
UseNewDefaultFonts( 1 )
// Set up SUN
SetSunActive(1)
SetSunColor(255,255,255)
SetSunDirection(-3.0, -4.0, -1.0)
SetShadowMappingMode(2)
// Set up ball to cast shadow
CreateObjectSphere(1,10,10,10)
SetObjectPosition(1, 0, 0, 0)
SetObjectCastShadow(1, 1)
// Set up plane to receive shadow
CreateObjectPlane(2,40,40)
SetObjectPosition(2, 0, -5, 0)
SetObjectReceiveShadow(2, 1)
SetObjectRotation(2, 90,0,0)
do
Print( ScreenFPS() )
Sync()
loop
Attached are screenshots demonstrating how it looks when first run, and then when switching away and back to the app.
UPDATE:
After some more testing, it appears to be linked to the SetShadowMappingMode() command. As soon as I use that command (with Uniform, LiPSM, or Cascade shadows) the problem occurs. If I don't use that command everything works as expected.
Chart data provided with kind permission from
ELSPA