- Home /
Problem is not reproducible or outdated
Blending textures for a random 2D(ish) map?
Is there any better way to do this or any input on which way is more likely to work, or some entirely new approach suggested for that matter?
I'm looking at designing a simple procedurally generated random 2D like outdoor map using hexes, a bit stylized like a board game map.
Ideally, I would like to be able to define the hexes with 'overlays' of textures, overlay 1 might be ground, overlay 2 might be some trees in the NW corner, overlay 3 might be a road from N to S, overlay 4 might be a river from the SE to the W, etc. I want to use a texture atlas for each layer and modify the UV values to pick a different part of that atlas for the specific graphic.
In DOS/Windows, the way to do this is to take over the entire screen and paint the first layer, then the second layer, then the third layer, etc. Pixel by Pixel. Works great on a PC, but I'd really like to take advantage of the GPU for smooth panning and zooming. (Plus some 3D decals, etc.)
One way to do this would be to do this the DOS way and paint into a shared texture atlas (or several atlases) and use that on the hexes and let the GPU do it's magic.
A different way would be to give them slightly different depths (which would limit how closely the camera could zoom, but it might be OK if I limit the camera) I haven't seen any way to do this without many meshes/objects (one per layer per hex)
Thanks in advance
Just making sure this is related to Unity: Are you using Unity? (It's impossible to tell from your question and your karma/history)
Yes, I expect to use Unity. I'm just starting with Unity (already read/worked through Unity Game Development Essentials), and I'm an experienced C++/C# developer. When I was looking OpenGL, the same issue seems to exist there.
I think it would be easiest to just make layered objects, btw in Unity you don't have access to the rendering code, so you can't implement your own OpenGL stuff, but you can write shaders
DID THIS HELP? PLEASE "TIC$$anonymous$$" ANY ANSWER TO CLOSE THE QUESTION - THAN$$anonymous$$S!
@Fattie Why do people like this exist. They come asking questions and don't have the courtesy to maintain their posts...
Answer by Fattie · May 05, 2013 at 08:58 AM
Ralph, it is absolutely trivial to do this in Unity. It would be as if asking, in Illustrator, can I add type?" - heh
Imagine square images say 10m x 10m. (A "sprite" if you will.) So you would simply have a trivial plane (in unity click "add plane", resize it to the size you want) and drop that texture on it. So you might have say a dozen different such images, perhaps.
You'd simply sit them next to each other. You mentioned you might want the adges to blend, if so no problem, just have them somewhat overlapped, and the edges would blend. Nothing to it.
What you said about different layers on top, road etc - again nothing to it.
This sort of "2.5D" thing is absolutely commonplace:
notice the three flat planes there, each with different images ... actually it's nothing more than a "drop shadow" - heh. the yellow image is a drawing of a cat, and the red/black are just a frame around the image. they are a meter apart or whatever (the camera would be on your right in this example)
doing 2.5D in unity is great, it's fantastic. Once you do it you'll likely never ho back to another metaphor/pipeline. Apart from anything else you can completely use 3D physics normally, and so on. Everything is a breeze. Note you may choose to use an orthographic camera in (just look at "camera" in the inspector and click to orthographic, if you want).
You are right that it is somewhat confusing "how the hell do I do 2D in a 3D engine" until you have a quick play, then it all makes sense.
(JUst TBC you would not have to touch shaders, etc, in the slightest to do a whole project like this. It's totally taken care of.)
you should definitely grab 2DToolkit (and the other such competing products) from the asset store, and decide which one you like.
2DTK offers an unbelievable amount of development already done. You just drop PNGs in a folder and it does everything, optimises sprite sheets, even makes them for different resolutions, etc etc. It completely and utterly handles 2D animations, sprites, colliders, blah blah, it sets up proper two-triangle planes and so on and so forth.
(Regarding what you say about shaders, again for 2.5D, 2DToolkit completely takes care of it, offering a selection of the typical shaders you would use in a side-scroller, overhead game as you describe, etc.)
PS when you get to wanting to add type, here is exactly the pipeline we now use having suffered greatly trying to find the best approach: http://answers.unity3d.com/questions/384623/setting-font-size-according-to-screen-dpi.html?sort=oldest
hope something helps ! Enjoy Unity !
Thanks for promoting this to an answer ins$$anonymous$$d of a comment. It's a well thought answer and I hope it helps someone.
It looks like an excellent approach for some games, but I've decided for my game to do a slightly different route. I'm going to try using the HexTech engine as a starting point. While it's not being actively developed, I believe that it's far enough along to give me a good start. It seems incredibly inefficient for my purposes, but that is actually a good thing, since if I clean it up, I may be able to use a simple approach and still get good performance.
The main difference with that approach is that I should be able to move the camera around and zoom in without artifacts, which I don't think would work with a 2.5D approach. I'm going to try doing multiple layers and hand generating meshes to see if that will give me the performance I want without Z fighting.
Follow this Question
Related Questions
Geometry shader output to mesh in Unity 4 0 Answers
How can you represent overlapping energy fields? 0 Answers
Is it possible to import maya mental ray light effects in unity without using baking?? 2 Answers
Specific texturing 1 Answer
Does using "half res" in the quality settings reduce texture RAM usage? 1 Answer