armory3d/armory

Spot light does not produce shadow

e2002e opened this issue · 5 comments

Spot light shades the object yet doesn't produce shadow.

Screenshot from 2023-03-07 14-52-52

Area lights just crashes the engine as soon as started.

Hi, would you mind sharing an example file or at least your local configuration (i.e. deferred or forward, and so on)? Also, could you please write what OS and GPU you use (I can't reproduce it)? Thanks :)

Ok @MoritzBrueckner , I'm using Ubuntu with nvidia.
The only way I get shadow with spot is when either putting two of them or activating manually atlasing (which is what is done when two or more "non sun" lights are present, or maybe it has to do with clusters, don't remember.)
Deferred renderer, now I'm working on GI i have issue with forward I won't be able to test if that works.

Created a separate issue for the area light crash: #2823. Please create one issue per problem if possible.

I can confirm the missing spot light shadows for both deferred and forward renderpaths (I forgot about this issue when I wrote above that I cannot reproduce it – this was an answer to the area light thing).

Hi, just to let you know: I think I found the reasons for this issue (although there are still some open questions), and one of it I already managed to fix locally. However, since I'm very short in time this month, it will take a little longer until I can provide a fix (if I can, looks partly like a Kha/Kinc issue):

  • The world-view-projection matrix of spot lights is passed in a mat4 array uniform to the shader, but Armory recognizes the uniform as a float array which in turn caused Iron to never call the responsible code to actually pass the values to the shader.
  • Even after the float/matrix confusion was fixed, the shader still receives wrong matrix values which ultimately leads to the issue with missing shadows. This could me more tricky to fix, as I suspect the reason for the wrong values is the same as my second point in Kode/Kinc#730. Sometimes, the compiled shader files do contain array brackets for the uniform names, sometimes (as in the case of the deferred light shader) they don't. This essentially writes all matrices to the same position in the buffer.
e2002e commented

I can confirm that the Spots produce shadows via:
#if (arm_clusters && arm_spot)
case "_biasLightWorldViewProjectionMatrixSpotArray": {
fa = LightObject.updateLWVPMatrixArray(object, "spot");
}
arm_clusters need to be activated by having shadowmap_atlasing on or/and another light in the scene (other than a sun).