Tile Blending

Started by Minigame, February 01, 2013, 10:48:56 PM

Previous topic - Next topic

Minigame

I have been toying with jPCT for over a year now, and have created a lightweight "game engine" that I use for something I call my 3D digital world project, and a few utilities.

Here is a preview of the map editor utility, and the million dollar question is: how can I blend the tiles?


I've looked at the terrain release, which features some sort of blending, but I wasn't able to get what I needed out of it.
A nice explanation on how to approach blending tiles would be excellent, because I feel it would take my project to a new level (in terms of visual appearance).

Thanks

EgonOlsen

Each tile is an individual textured object?

Minigame

#2
Edit:
Bryan will provide a proper response, as he was the original author for the map editor and knows more about it.

Bryan

Quote from: EgonOlsen on February 01, 2013, 11:01:33 PM
Each tile is an individual textured object?

I was the one to actually write the terrain code he is using right now (which was also based off a generation example).

What I did was generate each tile with 2 polys (trigs) and there are a specified amount of tiles in an object. Each object is also a "Region" in code and they are just placed adjacent to the previous Region/Object.

He wanted me to let you know how it worked. But if he wants tile blending, he will also have to blend through multiple objects to make the Region->Region blend for edge tiles.

Minigame

Quick note: If this map editor is ever completed, I plan publishing for all jPCT users, with some instructions on how to use it in hopes that it will help people design maps for their games, with ease, and implement them into jPCT powered games ;D

EgonOlsen

Difficult...i have no clever idea for solving this. The terrain example that you are referring to uses vertex alpha to do the blending. That requires multiple rendering passes and to use alpha values for blending, you actually have to have something to blend into. In your case, that would mean that objects would have to overlap/tiles which against the idea of using tiles.
In my current Android project, i'm using shaders and a splatting texture to do it, but again, this doesn't transfer very well to tiles. IMHO, i might work best to create additional textures that do the blending, i.e. if sand touches grass, create a texture in which sand slowly fades into grass. One of the earlier jPCT projects (Technopolis)  did that and the results were pretty nice:

Thomas.

It has nothing to do with the question, but project Technopolis looks really nice!

EgonOlsen

Quote from: Thomas. on February 02, 2013, 09:39:52 PM
It has nothing to do with the question, but project Technopolis looks really nice!
Yes, but it has been abandoned years ago... :( It really pushed jPCT to its limits (at that time) and i added a lot of stuff just for it (...like i did for your project too... ;) ).

Minigame

Quote from: EgonOlsen on February 02, 2013, 09:30:47 PM
Difficult...i have no clever idea for solving this. The terrain example that you are referring to uses vertex alpha to do the blending. That requires multiple rendering passes and to use alpha values for blending, you actually have to have something to blend into. In your case, that would mean that objects would have to overlap/tiles which against the idea of using tiles.
In my current Android project, i'm using shaders and a splatting texture to do it, but again, this doesn't transfer very well to tiles. IMHO, i might work best to create additional textures that do the blending, i.e. if sand touches grass, create a texture in which sand slowly fades into grass. One of the earlier jPCT projects (Technopolis)  did that and the results were pretty nice:

Alright. I already have a set of 100 tiles that match the ones in the image I posted, for manual blending, from a previous 2D project. You think it will cause any overhead having 100 tile textures + game assets loaded? If so, is there a solution? I'm using raft's texture pack.

EgonOlsen

Quote from: corey on February 02, 2013, 10:13:32 PM
Alright. I already have a set of 100 tiles that match the ones in the image I posted, for manual blending, from a previous 2D project. You think it will cause any overhead having 100 tile textures + game assets loaded? If so, is there a solution? I'm using raft's texture pack.
It will use more memory of course. On Android, this might be an issue...on a current desktop machine, i don't see a real problem with that approach.

Bryan

So what if things weren't tile based. What is the best way to handle terrain, like you said texture splatting for your project but it not translating well to tile based textures.

Can you provide a good example of texture splatting on a terrain type mesh? I'd be curious to see and/or re-write the terrain stuff he has now to utilize your method.

EgonOlsen

Quote from: Bryan on February 03, 2013, 03:17:44 AM
Can you provide a good example of texture splatting on a terrain type mesh? I'd be curious to see and/or re-write the terrain stuff he has now to utilize your method.
I'm not sure what you mean by "good example"...the basic idea is simple: You use different texture layers where one is the splatting texture. The splatting texture contains the intensity of each of the other layers coded into rgba values (i'm using rgb only, but you might want to add alpha to the mix). The shader then mixes the remaining layers based on the color in the splatting texture at that particular point. In addition, you can use the splatting texture to place entities (like: No trees or grass on paths and things like that).

Example image: