'Jerky'shadows

Blitz3D Forums/Blitz3D Programming/'Jerky'shadows

Naughty Alien(Posted 2007) [#1]
..this is related to users of Swift Shadow System..basically I did one big nothing but load one of demos provided (simple shadow system setup) and just changed parameter for turning in main loop (TurnEntity samplecone,1,2,3 in to TurnEntity samplecone,.1,.2,.3) and as result I notice that shadow doesnt follow smooth object rotation at all, but its very very jerky...how to fix this? Is that related with shadow update speed or what??


sswift(Posted 2007) [#2]
I'm looking into it now.


sswift(Posted 2007) [#3]
Okay, sorry for the delay.


Here's the issue:


If you look at the globals declared at the top of the shadow system, you'll see this:

; This is the amount which the angle of the caster has to change relative to it's light source before the shadow map
; is rerendered.  You should not need to change this value, I've set it to an optimal one, but if you decide you
; don't mind if your shadows jump around a little in extreme cases, and you want to improve performance by a few fps
; on slow PC's, then you can adjust this value.  You can change this value at runtime just like all the other values
; here.
Global Texture_Angle_Epsilon# = 2.0



If you change that number to 0, your problem will go away completely. If you reduce it to the point where you don't notice the issue anymore, that would be better for performance though.

What that number basically does is tells the system not to re-render the shadow map if your car or crate or whatever other static object you're casting shadows from hasn't rotated enough that it really needs to be rerendered. The only reason you noticed that it was cheating was because you used a worst case scenario of a slowly rotating object. If you had a crate flying across the room, or a car speeding around a track, you'd never tell the difference.

Also, if the object is animated, then you'd also never see this issue because this optimization can't be applied to animated objects. There's no way to tell in Blitz how far a guy's arm has moved for example. So the angle of the object might not change at all, but the guy's arm moves around, and if the shadow doesn't get rerendered then you've got problems.

So there you have it. Easy to fix, if you really need it fixed. Unfortunately, you can't set this value per object, but you could probably modify the functions and types to accept such a value and make the code use that without too much difficulty.


Naughty Alien(Posted 2007) [#4]
THANKS...working like a charm now ;)