Shadows Flickering

Posted By: Dooley

Shadows Flickering - 05/12/17 22:58

I'm using A7 (Still) with stencil shadows.
Certain objects, large ones usually, have this bad tendency to show shadows flickering when the camera moves, especially on the light side of the object, which should not be receiving shadows at all.

Is there a way to prevent this without turning off self-shadow, or has this issue been resolved in A8?
Posted By: HenWoll

Re: Shadows Flickering - 05/13/17 05:33

Close your meshes and the flickering goes ,
Posted By: Dooley

Re: Shadows Flickering - 05/13/17 06:40

Meshes are closed, but they may be intersecting other models. Would that be a factor?
Posted By: HenWoll

Re: Shadows Flickering - 05/13/17 11:35

are you played allready with the camera.clip_near/far ?
Posted By: Dooley

Re: Shadows Flickering - 05/22/17 07:00

I have clip levels set for the models.

my.eflags |= CLIP1;

Like this... Each model currently has a main LOD (_0) and a secondary (_1).

I'm using "shadow_lod = 0;" but I have also tried setting to 1. In both cases there is flickering.
Posted By: Dooley

Re: Shadows Flickering - 05/23/17 05:36

I have figured out how to stop the flickering shadows. Remember this is the A7 Engine, so you may not need to do this.

First: Create your model - LOD 0
Second: Create a lower poly 2nd model for LOD 1
Third: Create a third low poly model for LOD 2, but scale the model down about .05, so it will be 95% of the original size.
Fourth: Use shadow_lod = 2 so the slightly smaller model is used to cast shadows. This model is never actually seen in my game.

Result: The shadow polygons do not intersect the actual model polygons. It casts and receives shadows, but there is no flickering!

If you wanted the extra LOD step, I guess you could do this with LOD 3 instead of 2. In this case, make sure your shadow range is low enough that shadows will not show on distant LOD 3 models (or you'll see them flickering)

If this is fixed in A8, no problem, but I thought it might help others with the same problem.
Posted By: Dooley

Re: Shadows Flickering - 05/23/17 23:26

Okay, the above description is accurate and is working mostly. However, when trying to do this with other models, the engine does not seem to recognize LOD steps for some of my models.

I have made the following files:
Ruins_Pillar1_0.mdl
Ruins_Pillar1_1.mdl
Ruins_Pillar1_2.mdl

I set the following flag in the object's action:
my.eflags |= CLIP1;

I set the shadow LOD in the main function:
shadow_lod = 2;

I set the object's shadow:
set(my,SHADOW);

It is casting a shadow, but the shadow appears to be using LOD 0, instead of LOD 2. This results in the flickering issue. For some models, the LOD 2 is working, and they are noticeably smaller than the object. However, with other objects, like the pillar mentioned above, it is not using LOD 2 to cast shadows.

This happened actually the first time I tried to implement this solution. I'm not sure what I did to activate LOD 2 shadows, but it started working right after I changed the shadow_range to 5 (from 10). Now, however, it still works even if I switch the shadow range back to 10, but only for those objects in which it recognizes the LOD 2 model.

I will keep trying to fix this...
Posted By: Dooley

Re: Shadows Flickering - 05/24/17 15:57

Final Update:

I did not realize I had shadow_decal set for the objects in question. This somehow stopped the engine from using the 2nd LOD model to cast shadows. Works great now!
© 2024 lite-C Forums