0 votes

Recently I created a simple function that aligns the an object's mesh to one of a given number of orientations relative to the camera vector to emulate the look of multidirectional sprites (like what can be seen in DOOM engine games for example; I had this idea quite a while ago but seeing this video prompted me to realise I probably knew how to actually approach the problem by now and give it a shot). This was pretty straightforward, all things considered; had some difficulty manipulating the UP basis properly but i think i now have a better understanding of how to work with basis in Godot after stumbling on through it.

That all is not the point of the question, but it's relevant as it causes undesired shadows, so I settled on the initial solution of disabling the mesh's shadowcasting, and creating a shadows-only duplicate of it which is not subject to this transform. this creates a new problem, though:
(Ignore the line; RayCasts cast shadows when visible collision is on which is kind of silly but not really much of a problem)
When the mesh deviates from the shadowcaster mesh, this ugliness happens because the two meshes are now intersecting imperfectly. The desired outcome can be described like this – the invisible shadowcaster only casts shadows on the terrain and other objects, and ideally, the visible mesh can still cast shadows, but only on itself. (even if i wanted the compromise of no self-shadowing, given that many games that came before had no self-shadowing and often it would go completely unnoticed, "Do Not Receive Shadows" for example wouldn't work because I still want it to receive shadows from objects other than the shadowcaster.)
Here's a flowchart explaining the desired outcome if it helps:
"Flowchart" demonstrating the desired outcome. Here "terrain" can stand in for any other object in the gameworld that can cast shadows, but at the time I put this together I was only thinking about my tiny test scene.

I've tried using VisualInstance layers to get around this, but no particular configuration seems to do what I want. I thought to try creating a duplicate light that lights just the player's mesh (putting those in a layer all by themselves), but it seems like objects receive shadows even from objects that are outside the light's cull mask. Am I missing something here? I can turn up the bias by some amount, but that just causes other visual problems before this one is even solved. Is there any other way of achieving what I'm after? Thanks in advance for your thoughts.

Godot version 3.2.3.stable.official
in Engine by (53 points)

Please log in or register to answer this question.

Welcome to Godot Engine Q&A, where you can ask questions and receive answers from other members of the community.

Please make sure to read Frequently asked questions and How to use this Q&A? before posting your first questions.
Social login is currently unavailable. If you've previously logged in with a Facebook or GitHub account, use the I forgot my password link in the login box to set a password for your account. If you still can't access your account, send an email to [email protected] with your username.