3D with 2D backgrounds

I’ve been working on a game which uses 3D models for characters but does backgrounds and likely all scenery items in 2D. The best example I can think of from well-known games is something like The Longest Journey: screen, video.

Is implementing this in Panda3D possible? I’m guessing basic movement (including off into the distance) from a single camera position against a fixed bitmap background wouldn’t be hard, but I would also want the ability to sometimes zoom in and out just a little, on both the 3D models and the 2D background and scenery images simultaneously, as if the “camera” has just zoomed in a little. The zooming mechanic might get problematic because I might want to make it so you zoom in on different sprites by different amounts, depending on their perceived “distance” to the camera.

If you go to 1:55 in that video, you’ll see a good demonstration of the need for both background panning, as the background reorients around the character while she’s running left, and imaginary/invisible terrain, as the character goes down some fake 2D stairs.

Will Panda3D be able to do both background-panning of that sort and simulate imaginary terrain, as shown there? Plus, I would need a way to have certain, partially transparent (think the railings in that video as the character moves left) sprites appear behind the character when they’re nearby, but in front of them when they’re far away.

Is this stuff achievable in Panda3D? Thanks a lot for any responses.

Yes. You could have the backgrounds wobble from side to side while being sucked through a hyperdimensional vortex as far as Panda3D’s concerned, though it’s of course up to you to code the logic to do this.

Depending on your various needs, there are are many ways to achieve what you’re talking about; if the camera should only pan, this is easy. You could just have a giant billboard in the back that displays the background image. If the camera moves to the left, its view of the billboard would, too. You may have to use an orthographic camera or use a low FOV on the perspective camera in order for the player not to notice that his sense of perspective is being cheated, but this may not actually be noticeable; this is something to experiment with.
You could also put a card in a separate 2D display region that is layered behind the 3D display region but uses the same camera or uses a camera that links its position to the main 3D camera. This would allow you to use an orthographic camera for the background but a perspective camera for the 3D characters, but the effect may be trickier to get right this way.
If the camera has to rotate or move forward (‘zoom’) in perspective, then you may have to use multiple billboards representing separate objects or parts of the scene so that there is still some sort of 3D positioning to them. This means you have to split up your images into parts that are further to the front or back.

If you have the original renders of the backgrounds, then you could play funny games with Panda3D by rendering the depth map and then using some mechanism in Panda3D to tell it how much that part of the background should move with the camera, to create a fake perspective. This may require a shader, though. This may be a nonsensical idea that wouldn’t work, I just figured I’d put it out there in case you’re feeling adventurous.

If the backgrounds are completely static, you’d need to either program all of the paths that the characters take which you can do using motion paths, or you’d need to make a navmesh specifically for the purpose of pathfinding (or at the very least, for specifying where your characters can and can’t walk); this need not be complex or detailed.

Thanks a lot for replying. Some interesting things to think about there. I’m not sure how Panda3D’s navmeshes work yet but I’m guessing I can use them to adjust the 3D position of the character, thus allowing them to simulate climbing steps and other “terrain”. I should also be able to make certain 2D objects clickable and generate pathfinding to them as long as they have 3D positions.

Going through the Panda3D documentation, I’m not sure if I can create partially-transparent 2D foreground objects (like that railing, again) that could sit in front of the 3D character, or behind them, as the character’s location in the room dictates. Is that definitely possible?

Interesting point there. You mean like creating a parallax scrolling effect, where the background image scrolls at a different rate than the foreground images? TLJ actually has a moment like that too, as I recall: video. It’s a good technique if used sparingly. I was curious though, why do you think I might need to use a shader to accomplish it? I was hoping I could just adjust the parallax billboard positions as the camera pans based on some kind of formula that incorporates both the change in the camera position as well as the distance from the camera to the billboard.

It should be quite easy – just set the appropriate transparency mode and it should work, I think, although I’m not sure of how it would respond if placed in a lower display region. I think that display regions have an option to disable the clearing of the depth buffer (or perhaps by default don’t clear it, and the option allows one to enable clearing it?), which you might want to check when implementing foreground sections.

I think that what rdb is describing there goes a little further than parallax billboards; I get the impression that he’s suggesting the use of the depth map to create a whole-image or per-pixel parallax disortion, rather than the movement of discrete boards relative to each other.

Basic parallax should indeed be very simple; with a clever setup you may even manage to get a perspective camera to do the work for you (after all, objects placed further back should naturally move according to parallax when viewed through a perspective camera). As I recall, I’ve done this myself, and so can with confidence vouch for it working in Panda.

It is possible, and not difficult.

Though a parallax scrolling effect might be interesting (in fact, this is what I was thinking when I mentioned “multiple billboards”), but that’s not what I was referring to in the quoted segment. I meant that if you have a background rendered in a 3D modeller, you might also render a depth map that you can then use with a parallax mapping algorithm to still make an otherwise static background image seem 3D when moving the camera around, basically by offsetting the pixels based on how far away you know the pixel is from the rest of the background and on the camera angle.
Panda supports parallax mapping natively, though all this is a bit of an advanced trick and it may not be worth making depth maps for; I don’t even know if it’d look right.
Instead, it is probably a lot easier to use separate foreground images for the things that you want to look perspective-y when the camera moves.

Toontown Online had something similar. They had a giant 3D box around the world with textures on it for sky and distant BGs, and then flat models cut to the shape of mountains, etc. in front of that, so when you move it changes the perspective somewhat. Not sure if that’s what your looking for or not. If so, there’s a lot of game footage on youtube, but the game itself if closed now.