Dynamic shadows:
----------------
To use the shadow system call:
Cast_Shadow for each object you want to cast a shadow,
Receive_Shadow for each object you want to receive a shadow,
Cast_Light for each object you want to be a light source.
You need at least one of each to see any shadows.
Then every frame call update_shadows between updateworld and renderworld. (You call it between them because updateworld changes the positions of objects after they collide with something.)
UpdateWorld
Update_Shadows(Camera)
Renderworld
If you want an object to stop casting light, or stop receiving shadows, or stop casting shadows, use these functions:
Delete_Shadow_Caster(Entity)
Delete_Shadow_Receiver(Entity)
Delete_Light_Caster(Entity)
Static shadows:
---------------
If you want objects to cast static shadows, set up your receivers and light casters, and then call Cast_Static_Shadow for each static shadowcaster. Then call Update_Static_Shadows() ONCE. That will create the static shadows and the shadow maps required. You should do this outside your main loop.
If you want to change the static shadows later, you can delete a static shadow and disable the static shadow caster simply by calling Delete_Static_Shadow_Caster.
If you want to ADD a static shadow caster, then you'll need to call Cast_Static_Shadow for that object, and then call Update_Static_Shadows once to create the shadow.
Advanced options:
-----------------
If you are seeing Z-fighting in your scene... shadows rendering behind objects, you can adjust the variable Shadow_Nudge# at any time. The default value is 0.01. Increasing it will reduce Z fighting. Decreasing it will move the shadows closer to the surface so they don't appear to float over it.
Adjusting these global variables adjusts the amount of ambient light that affects the shadows. Higher values mean lighter shadows. Values of 0 will produce dark black shadows.
Shadow_Ambient_Light_R# = 0
Shadow_Ambient_Light_G# = 0
Shadow_Ambient_Light_B# = 0
And finally, if you want softer shadows, you can set the global variable Blur_Quality. Increasing this value improves the quality of the blur. 0 is the default. Blur_Radius# is another value you can adjust. It adjusts the radius of the blur. Larger radius + more quality = more blur. You'll have to play with these values to see how they affect the shadows. Blurring slows down shadow rendering a little.
(I've just added this to the system zip to provide some basic documentation.)
----------------
To use the shadow system call:
Cast_Shadow for each object you want to cast a shadow,
Receive_Shadow for each object you want to receive a shadow,
Cast_Light for each object you want to be a light source.
You need at least one of each to see any shadows.
Then every frame call update_shadows between updateworld and renderworld. (You call it between them because updateworld changes the positions of objects after they collide with something.)
UpdateWorld
Update_Shadows(Camera)
Renderworld
If you want an object to stop casting light, or stop receiving shadows, or stop casting shadows, use these functions:
Delete_Shadow_Caster(Entity)
Delete_Shadow_Receiver(Entity)
Delete_Light_Caster(Entity)
Static shadows:
---------------
If you want objects to cast static shadows, set up your receivers and light casters, and then call Cast_Static_Shadow for each static shadowcaster. Then call Update_Static_Shadows() ONCE. That will create the static shadows and the shadow maps required. You should do this outside your main loop.
If you want to change the static shadows later, you can delete a static shadow and disable the static shadow caster simply by calling Delete_Static_Shadow_Caster.
If you want to ADD a static shadow caster, then you'll need to call Cast_Static_Shadow for that object, and then call Update_Static_Shadows once to create the shadow.
Advanced options:
-----------------
If you are seeing Z-fighting in your scene... shadows rendering behind objects, you can adjust the variable Shadow_Nudge# at any time. The default value is 0.01. Increasing it will reduce Z fighting. Decreasing it will move the shadows closer to the surface so they don't appear to float over it.
Adjusting these global variables adjusts the amount of ambient light that affects the shadows. Higher values mean lighter shadows. Values of 0 will produce dark black shadows.
Shadow_Ambient_Light_R# = 0
Shadow_Ambient_Light_G# = 0
Shadow_Ambient_Light_B# = 0
And finally, if you want softer shadows, you can set the global variable Blur_Quality. Increasing this value improves the quality of the blur. 0 is the default. Blur_Radius# is another value you can adjust. It adjusts the radius of the blur. Larger radius + more quality = more blur. You'll have to play with these values to see how they affect the shadows. Blurring slows down shadow rendering a little.
(I've just added this to the system zip to provide some basic documentation.)