[Solved] FastExt Shadow Receiver Mesh Issue

Blitz3D Forums/Blitz3D Beginners Area/[Solved] FastExt Shadow Receiver Mesh Issue

RustyKristi(Posted 2014) [#1]
So I was trying out the Fastext library trial with shadows and I was wondering how I can properly use a shadow receiver on my mesh or primitive.

It is always dark and flickering on meshes when I set them as shadow receivers and move. Shadow casting seems to work ok though.

Does anyone have a similar experience or have a solution to fix this?

What shadow system do you recommend?


Yasha(Posted 2014) [#2]
It sounds like you're getting Z-fighting. This is a particular problem for shadow systems that work like FastExt since they usually involve building an exact clone of the receiver and overlaying it on the original.

Normally such engines allow you to workaround this with an "offset" parameter or something similar, that determines how closely the clone's polygons sit to those of the original. Moving them further away lets you fine-tune for bigger scenes with less Z-precision (at the cost of "floating" if you get too close). You should probably investigate the mesh building calls for a parameter named something like that, and increase it in small increments until the effect reduces. It'll probably be something very small by default.


RustyKristi(Posted 2014) [#3]
Hey Yasha, thanks for this explanation and info. I'm really new to this offset thing and mesh calls with Blitz.

Can you provide a simple example so I could have a reference to play around?


RemiD(Posted 2014) [#4]
This problem seems to happen more or less depending on the graphics card, it may help if you use a "smaller" camerarange (0.1,100 or 1,1000) or if you increase the space between the receivers and the shadows. There is also the same problem with stencil shadows...


Yasha(Posted 2014) [#5]
Took me a while to find my copy of FastExt...

The function I'd recommend trying is ShadowOffset (there are two versions of this depending on whether you're using the simple or multiple shadow engine).

It allows you to offset the position of the shadow mesh by an X/Y/Z displacement. It's only demonstrated in ShadowsMultiple_TrickForPlatformers.bb (which showcases the "multiple" version; the difference is that the "single" version doesn't require you to specify the first parameter shade entity). It looks to me like it moves the shadow object by a vector specified in camera space, so normally you'd want to use 0, 0, Z (but other values might be more appropriate? play around). That demo uses 0, 0, 1.5.

Unfortunately this isn't a normal-based offset so it might not work for all camera angles even if it does address the basic problem. You'll have to test and see, and maybe tailor the offsets to your scene.


RustyKristi(Posted 2014) [#6]
Thanks Yasha, I did see that example and now I know where I can get more reference.