Preparing the first post-jam release


As the end of the voting period of Godot Wild Jam #82 is approaching, I'm trying to fix the bugs that have been found in Little Shadow, and some of them are quite interesting:

  • the first problem is that shadows sometimes change when moving around, and it makes it difficult to navigate safely with your cute slug-like creature
  • the second bug is directly related to light detection and is mainly visible in the final level of the game: the small creature is clearly in shadows but takes damage as if in bright light
  • the last and most annoying problem is a flickering bug that shows from time to time

Light detection

Unsurprisingly, most of those problems are related to the light detection feature, and since this has been requested in the comments, I'll first describe how this is done.

I started with this very nice video tutorial, that explain how a small subviewport can be used together with a very simple mesh and a dedicated camera to measure light:

  • place the mesh (with a white material) where you want to measure light
  • point the camera to the mesh (it is a good idea to place the camera close to the mesh, so we're sure it does not capture some other object in the scene)
  • render in a small subviewport, configured for drawing lighting (using the debug draw option)
  • get the image from the viewport texture, resize it to a single pixel, and read the color of that pixel, and voila, you have the intensity of light at the desired location
I still found a couple of minor improvements for this tutorial:
  • Instead of moving the light detection related nodes in the script, I used RemoteTransforms
  • the subviewport just renders on a 4x4 pixels image
  • Instead of using a sphere or an octahedron to capture light from all angles, I wrote a very simple shader that removes the light direction part from the light function. Diffuse light is calculated as follows: DIFFUSE_LIGHT += ATTENUATION * LIGHT_COLOR / PI.

Moving shadows

The first bug is about shadows that change depending on the view angle, and is clearly visible in the forest area.

    

This problem is quite easy to understand: shadows are stored in an atlas, and the number of shadows stored in each part of the atlas can be configured. The default configuration stores a few shadows in the first quadrants and lots of others in the last one, and consequently, not all shadows are stored with the same precision. An easy workaround is to change that part of the configuration to store 16 shadows in each quadrant (we want to handle 64 lights, because that game is all about shadows). Shadows are a little bit less precise (and this could be compensated by increasing the shadow atlas resolution), but they do not change anymore.

Light detection errors

This problem is also related to shadows, but a little bit different: our cute creature takes damage while in shadow.


This one is due to the fact the view and light detection use different cameras, and consequently, the renderer also generates different shadow atlases. Moving the light detection camera to the exact location of the view camera, and pointing it to the light detection mesh with a very small view angle (and near and far distances carefully selected so only the detection mesh is captured) completely solved the problem.

Flickering

I don't know yet why this flickering problem occurs, but I know it is related to the light detection viewport (the flickering frequency is the same as the update frequency of the light detection viewport). It seems it could be a bug in Godot's Compatibility renderer, and it might be related to this issue, but I am not completely sure yet.

An easy fix is to switch to the Forward+ renderer (since the Web export is important for gamejams, we are not sure we want to keep it) and tweak the light detection system so it measures the same values with both renderers.

Conclusion

All those problems (plus a few others) will be gone soon after the end of Godot Wild Jam #82. If you noticed other problems, please don't hesitate to report them in this devlog comments so I can fix them as well.

Have fun and stay in the shadows!

Get Little Shadow

Leave a comment

Log in with itch.io to leave a comment.