I have successfully allowed a shadow to be turned on and off without erasing the shadow data (does NOT turn the entity on and off - use "EntityAlpha". By not automatically using "EntityAlpha" it allows you to do some LOD stuff a.k.a. not having entities more than a certain distance from the camera casting shadows but still have the entity visible). The way I did it bypasses the shadowvolume creation, thus saving processing time and not drawing the shadow.
I added these two commands to "DevilShadowSystem.bb"
Added the field "hidden" to the ETE_Mesh type in "ShadowVolumes.bb"
And added a IF/Then to the "UpdateVolumes" function in "ShadowVolumes.bb"
Please verify that my modifications don't cause problems (I don't seem to have any).
I added these two commands to "DevilShadowSystem.bb"
Function HideShadowMesh(ent) For etem.ETE_Mesh=Each ETE_Mesh If etem\ent=ent Then etem\hidden=True Next End Function Function ShowShadowMesh(ent) For etem.ETE_Mesh=Each ETE_Mesh If etem\ent=ent Then etem\hidden=False Next End Function
Added the field "hidden" to the ETE_Mesh type in "ShadowVolumes.bb"
Type ETE_Mesh Field ent,hidden Field cnt_tris, tri.ETE_Triangle[ETE_MaxTriang] End Type
And added a IF/Then to the "UpdateVolumes" function in "ShadowVolumes.bb"
Function UpdateVolumes(light, parallel = False, top_caps = True) light_x# = EntityX(light, True) * (1 + parallel * 1000000) light_y# = EntityY(light, True) * (1 + parallel * 1000000) light_z# = EntityZ(light, True) * (1 + parallel * 1000000) For etem.ETE_Mesh = Each ETE_Mesh If etem\hidden=False; <---Added "If" here cnt_tris = etem\cnt_tris For v = 0 To cnt_tris etet.ETE_Triangle = etem\tri[v] ... Next EndIf; <---And "EndIf" here Next End Function
Please verify that my modifications don't cause problems (I don't seem to have any).