Godot Version
4.5
Question
I’m trying to create a basic, simplified minimap in 3D. So far, I’ve set up a Subviewport with a Camera3D that shows everything from a top view, while also filtering out actors and objects such as the player. Here’s my work so far:
However, my big question is: can I render terrain as a flat color for the minimap camera? I’ve got tiles and pieces that I use to build all my levels, like so:
It would be ideal to render the entirety of this tile as a flat color, so it shows up as a simplified texture on the minimap. I know this can be done with a shader, but I’ve got no experience on how to apply this to an imported mesh, that is also being used as part of the level.
I would like to avoid having to create a sprite of the whole map in 2D, since that is a hassle to update an manage.
What would be the best way to go around implementing this sort of thing?
You could create a MeshInstance3D and add a PlaneMesh to it. Stick it on the bottom on the tile, and make it only visible to the mini-map camera. Make the rest of the tile object invisible to the mini-map character. The player would never see it in-game.
I did think about that, the problem is that it’s not a scalable solution since I’d have to customize every tile of every map to accomodate the minimap. Hence my question about using a shader to black out the whole mesh, thus avoiding this kind of work.
What constitutes a “tile” in your system? Post a more complicated use case. Showing just one plane doesn’t really define the problem well.
In general, you can always preprocess your level geometry at startup and build a simplified representation that is drawn as the map.
So, the general workflow is that I have a bunch of pieces imported from Blender-- for terrain, then large structures such as buildings, then small decorations.
A terrain set looks like this:
I could do the entire thing in Blender, but for rapid iteration this feels faster and more flexible.
Most tiles have a standard size of 4x4m, but there are some special cases, like the ramp. Going by what @dragonforge-dev said, I could make a bunch of planes and place them underneath each tile. The problem, as I mentioned, is scalability and manually editing each tile to have a minimap overlay. It would allow me to customize the appearance of the tile in the minimap, though.
I am already doing some of that editing, by composing some intermediate scenes out of individual tiles (like making a custom building out of floor and roof tiles), but if possible I’d like to make it faster to iterate.
There is also the question of making the minimap discoverable, by hiding certain tiles until you’ve visited them.
You mentioned preprocessing on startup. How could this be done?
I’m barely delving into Godot, but my first uneducated guess would be to:
- Attach a script to each tile
- In the script, place a scene under the tile that serves as minimap mesh. Maybe just a basic plane.
- Calculate the overall dimensions of the mesh (how?), and cover it all in the X and Z axis.
- Maybe even get the position of the tile in the map, and check against an array of coordinates to see if the mesh has been discovered yet?
Don’t know if this would be workable.
I’d go with making a map plane for each tile in Blender and use a naming convention to tell the engine it’s a map tile. So the map plane is part of the asset. Then on startup you can iterate through those map planes, and set their visual instance layer. You can also store visited status in mesh node’s metadata.
Doing some black magic without separate map geometry may be possible but it’d really depend on how exactly you want to “reduce” the look of each tile for the map.
1 Like
Nope, shaders don’t determine what can see them - meshes do.