[Question] FreeWorld3D Alphamaps? Splatting?

Dibalo

02-12-2006 19:14:26

Hi again. I´m asking stupid questions again. Now I have no problem... yet.

I´ve decided that I need some kind of heightmap editor for creating heightmaps. I´ve tested many demos and I think FreeWorld3D is perfect for me. Especially exporting alpha maps is very interesting feature. That´s why I´m wondering: do FW3D exported alpha maps work with PLSM2 splatting? If they work, how difficult is to adapt them to the PLSM2? I haven´t bought FW3D yet and that´s why I´d like to know about the compatibility with PLSM2.

I have tried to search about this issue and found some material (mainly written by Falagar) but there is still many unclear thing for me.

Again, thanks for your patience. 8)

tuan kuranes

06-12-2006 14:08:57

Would be better to get some real freeworld3d user, but AFAICT it's working ok.

Falagard

06-12-2006 15:47:34

You can probably get it working easily with multi-pass materials on the terrain. What this means is each splat ends up being its own pass. I haven't worked with Freeworld in a while but I think it has an exporter for the Terrain scene manager and spits out material files that work with it. To get it to work with the PLM2 you'd probably have to set PLM2 to TextureFormat=Image and then provide your own material script files named appropriately to what PLM2 expects.

Having a pass per splatting texture isn't very efficient though, and eventually you'll want to look into fixing this by massaging the alphas that are spit out by Freeworld into a single coverage map. This would mean using a fixed number of splatting alphas, (such as 4) and modifying the alphas themselves so all alphas together always add to 1.0 (fully white) when each pixel is added. There's been a discussion somewhere on this forum about how this could be done.

syedhs

06-12-2006 16:07:53

Freeworld3d currently export 1 Alpha map per splatting texture. Therefore if you have 4 splatting texture, you will get 4 separate 4 Alpha maps (4 PNGs) but they are all using only 1 channel. AFAIK (please correct me if I am wrong), PLSM2 has alpha map too, but one single file and uses all 4 channels so you will have to combine that using Photoshop for example.

Falagard

06-12-2006 16:17:44

Partially correct, syedhs. You need to combine them but also change them if you want to use PLM2's splatting shader. The shader assumes that all alpha splats add together to 1, so when it performs splatting in the pixel shader it simply adds each splat. With Freeworld, each splat overlays over the previous instead of adding together to 1, so you'd either need to use lerp() in the shader to get the same result, or modify the alpha textures themselves.

syedhs

06-12-2006 16:40:44

Okay thanks Falagard :)

syedhs

06-12-2006 17:06:16

Okay I dont want pretend that I know the solution, so I ask: how can you possibly combine 4 Alpha Maps into one if the sum of each of the channel != 1.0?

Let say I have 4 splat texture - grass, sand, rock and sand2. And lets do case study on just one single sport and see the right solution:-

- Sand: 80%, Grass 10% -> end up Sand :80/90*100=88.9, Grass=11.1

Question: How am I going to do that within GIMP/Photoshop - ie combining all 4 of them so that the sum is always 1.0?

Falagard

06-12-2006 19:17:24

You probably can't use Gimp since you'd need to do it programmatically, but read this discussion:

http://www.ogre3d.org/phpBB2addons/viewtopic.php?t=2234

Shadow007 presents some pseudo code. It's a bit difficult to understand, probably, but basically it works out like this:

Let's assume you have three splatting alphas exported out of Freeworld 3D. That would give you four layers of textures in Freeworld, the base layer, + 3 splatting layers.

You need to convert this to 4 splatting textures that together each pixel sums to 1.0

Use the following multipliers:

alpha0 = (1-x)(1-y)(1-z);
alpha1 = (x)(1-y)(1-z)
alpha2 = (y)(1-z)
alpha3 = (z)

Let's say you're calculating the first splatting alpha for use with PLM2.

Pseudo code:


for(x = 0; x < imageWidth, ++x)
{
for(y = 0; y < imageHeight, ++y)
{
newSplatValue = (1 - oldSplat1.GetPixel(x,y)) * (1 - oldSplat2.GetPixel(x,y)) * (1 - oldSplat3.GetPixel(x,y));
newSplat1.SetPixel(x, y, newSplatValue);
}
}


Where oldSplat1, oldSplat2, and oldSplat3 are separated alpha textures exported from Freeworld. As you can see, I took the first formula alpha0 = (1-x)(1-y)(1-z) and used it here, where x is a pixel from the first Freeworld splatting alpha, y from the second, and z from the 3rd.

That was for the first splat.

The second would be using alpha1 = (x)(1-y)(1-z)


for(x = 0; x < imageWidth, ++x)
{
for(y = 0; y < imageHeight, ++y)
{
newSplatValue = oldSplat1.GetPixel(x,y) * (1 - oldSplat2.GetPixel(x,y)) * (1 - oldSplat3.GetPixel(x,y));
newSplat2.SetPixel(x, y, newSplatValue);
}
}


Etc. for all four.

Of course I'm just making up the GetPixel and SetPixel functions. You could probably use Ogre's Image class and do something like that, but more likely you'd have to access the buffer data directly. Tuan is doing this already for the terrain painting and even paints to specific channels in the coverage texture, so that'd be a good place to look. You'd probably have to take the value as a 256 uchar, convert it into float, do the multiplications, and convert it back into a uchar. Sounds hard, but probably wouldn't be very. I meant to give it a try but haven't got around to it.

So anyhow, you do that for the four textures but put them all into one texture, each alpha into a one of the RGBA channels of the final coverage texture.

syedhs

07-12-2006 01:11:04

Nice.. thanks again..