Crew Sprite Testing, Fixes, and More Pathfinding
Hey Folks! Hope everyone had a good weekend. Our last four days were unfortunately largely spent driving, in hotels, or in waiting rooms. One of the benefits of immigration! It's good to be back at home, though, and decompressing.
Despite the tedious roadtrip, I did manage to break out the laptop in the evenings after checking-into each hotel. But first:
I guess the cat's really out of the bag now, huh? This is simultaneously really exciting and scary. Exciting because more people suddenly were made aware of my next project, and better yet, seem excited by it! Scary because, well, I haven't built it yet :) Hopefully, expectations won't outstrip what I can build!
As for progress, I've tried tackling a few things. I looked into alternatives for making crew sprites, fixed a few bugs in crew sprites, worked on pathfinding code, and fixed some hardware-related bugs.
After chatting with some friends, it was starting to look like hand-painting normal maps on animated sprites was, as my friend put it, "maybe insane." Even just drawing them would be a ton of work, as the number of animations increased.
In my last devlog post, matsy pointed out that Project Zomboid switched from hand-painted sprites to using 3D mesh to render sprites for their animations, all while trying to maintain the pixel-art style they originally had.
Now, having worked on 3D characters in my last job, I was loathe to try and tackle this. 3D is no joke, and it can take an army of people to produce and maintain the content for anything but the simplest of games. However, since my view was top-down orthographic, and low-res, maybe it was worth a look.
I set about grabbing the first low-res human mesh I could find, and found this helpful example by Clint Bellanger. And this useful Blender tutorial helped me setup a normal-mapped material for rendering the scene as a normal map. A few camera and rendering setting tweaks, a quick-n-dirty UV unwrap and texture splash, and here's what we get:
What we see above is an in-game shot of a rendered sprite (top) vs. a hand-painted sprite (bottom). For reference, I included a few insets along the right to show what the rendered normal map, Blender model, and UV unwraps look like. It is low, low res, and low-effort at this point. I'm not thinking this is ready for prime time or anything, but for the amount of effort I spent painting blue, brown, and black on that unwrap, the results aren't terrible.
The main problems I see are a lack of crispness in the rendered mesh, and some garbled areas where there are tiny details in the render. But I spent way more time painting details on that hand-painted crew than I did on the solid-color clothes of the rendered one. So there may be hope yet.
Also, all this fiddling with sprites revealed a bug in my shadow code. I was generating shadow mesh incorrectly, resulting in weird holes, and self-shadowing due to the height of the crew, its shadow, and lights in the scene. So this experiment helped solve some rendering issues, even if I don't go with it.
This is going to need more investigation, and probably some art with more care put into it, in order for me to compare more fairly.
Moving on, I also spent a bunch of time working on pathfinding. The heatmap algorithm finally started generating good data, and I began working on walls. And this is where I noticed a problem.
The way I was dealing with walls, I just gave them a +10 pathfinding cost per tile, where normal floor would be +1 per tile. I was thinking this would make AI prefer floor over walls.
Instead, what I discovered was that the heatmap algorithm would break in situations where the walls blocked the majority (but not all) of shortest paths to the goal. It looks like my simple, brute-force heatmap approach is actually not so simple. I may have to explore more traditional approaches, such as A* or Dijkstra's methods. Or maybe my queue just prioritizes wrong. We'll have to see.
Finally, I ran into an alarming bug while on the road. Using my laptop to dev for the first time, the Unity graphics were garbled all to hell. In a panic, I started Googling "Unity textures messed up" before I realized it could be a driver issue. Sure enough, my Bootcamp driver for the MacBook was out of date, and manually installing an update helped. Some minor mesh importing and other setting changes in Unity did the rest, and I was back in business.
Not as productive as I would've normally liked in a 5-day period, but not bad considering the road trip. Hopefully, we'll be back to more or less normal tomorrow. Have a good night, all!