Unlimited Textures, and different textures per page

Falagard

16-01-2006 16:33:10

Tuan Kuranes,

I'd like to do something like this:

In the map editor, allow the user to add any number of terrain textures to a list of available textures to paint onto the terrain, with a checkbox next to each texture.

Then, on each page, the user can check off which textures he wants to use for that page.

Currently, I believe the splatting painting uses a technique of drawing to various channels RGBA on a splatting texture per page. When you draw grass over dirt, it actually subtracts from whatever was below it so the entire thing adds up to 1.0 using coefficients or something like that. Correct me if I'm wrong here, but if I wanted to support N number of textures on a page, I'd have to draw to a grayscale bitmap per texture layer and change how the existing painting works, right? Create a new type of SplattingEdit mode?

My theory is that while editing the terrain, the user might add 15 textures that are available to paint onto the terrain, but however will only use up to say... 6 textures to splat per page. Then, in a post process after the terrain is finished, I'll pick different pixel shaders depending upon the number of textures and merge the alpha textures back into a RGBA channels of one or two textures.

I assume some changes would also have to be made somewhere so that each page can have its own list of textures.

Thoughts?

Clay

tuan kuranes

17-01-2006 09:38:16

if I wanted to support N number of textures on a page, I'd have to draw to a grayscale bitmap per texture layer and change how the existing painting works, right? Create a new type of SplattingEdit mode?
yes, a new splatting edit mode derived from splatting shader, adding a 3 pass to aim up to 16 splat possible (1rgba containt alpha maps + 3 color splats per pass)

I assume some changes would also have to be made somewhere so that each page can have its own list of textures.
Either export them with a consistent naming scheme with a new texture mode up to 16 splat possible (texture mode will remove unneeded passes and Texture units if files are missing) or go for a material per page (actually supported.).

Falagard

17-01-2006 15:16:38

3 pass to aim up to 16 splat possible (1rgba containt alpha maps + 3 color splats per pass)

Wouldn't that make a total possible of 9 for 3 passes?

I was thinking of just doing a pass per texture while editing, so I can easily enable and disable textures when the user clicks on the checkboxes, and then adding an "erase" feature. What this means is that it'll work more along the lines of Freeworld3D, where you have layers of textures that just overlay one over the other. Then when you want to use the actual splatting in your game, you "export" the terrain through a process that will merge the alphas together into a single RGBA texture, or multiple passes depending upon the number of textures.

Another option is to keep the limit at 4 textures per page, but still have the checkboxes for textures so each page can have its own textures. The trick is when the user decides to uncheck one of the existing textures and choose a new texture, to be able to extract the alpha properly from the already painted splat texture.

Clay

tuan kuranes

17-01-2006 15:33:00

arf, sorry it's 1rgba containt alpha maps + 4 color splats per pass (as rgba is 4 channel...)

where you have layers of textures that just overlay one over the other.
Multiple splat per pass was to get max splat possible at same time. User interface concept (layers of textures) doesn't have to be exacly mapped to real underlying code, especially when it slows down a lot the whole thing (a 4 pass Terrain is much slower to display than 1 pass.)

Another option is to keep the limit at 4 textures per page, but still have the checkboxes for textures so each page can have its own textures. The trick is when the user decides to uncheck one of the existing textures and choose a new texture, to be able to extract the alpha properly from the already painted splat texture

As stated above, I would make user interface and underlying code separate, user limit would be a max texture usable on the same page at the same (the 16 limit), but having a huge unlimited list of texture he can choose from.

A special edit Texture Mode can really be agile and transform on the fly the material, depending on the needs, optimizing fps for visual comfort.
Once optimized, The material can even save itself in its optimised form.

I can provide code if you wish. (Extract a single channel from RGBA, and the inverse, optimizing passes and texture unit depending on input (I think there's already one done in "splatting" texture mode.)

Falagard

17-01-2006 18:15:20

Yeah, I completely agree with separating the UI from the actual implementation. I was just thinking it was going to be complicated to do it.

Can you explain what you mean by colour splats?

What I'm wondering is how many texture units are you using in the pixel shader?

Lets say I have grass, sand, dirt and rock textures that are to be splatted, and I have the alphas that define the splatting areas.

I understand putting all those alphas into the RGBA of one texture. I assume grass, sand, dirt and rock are all still separate textures, or are you saying those are the colour splats that are all put into a single texture?

Something isn't making sense here, and I think it's maybe terminology.

Another thing I don't understand is this:

The first pass can do all 4 textures at once, sure. But subsequent passes would have to actually output an alpha channel to the rasterizer (1 - srcalpha or whatever) so that it doesn't completely overwrite the first pass right? Is that done in the shader or in advance (such as premultiplying the alphas together into another channel that represents the final alpha that is output to "outColour.a")

Thanks for the explanation, and the offer of sample code.

Regarding separate materials per page, yeah I did that a while back for my original terrain demo. I'll probably go with that solution actually.

This will turn out really well :-)

tuan kuranes

17-01-2006 19:22:17

Colour splat is rgb textures (rock, grass, road, sand, etc...)
Actually splattingshader using 5 tu => rgba alpha + rock + sand + snow+ grass
Changing from pass to texture units don't change visibility factor in alpha maps. Pass or texture units doesn't change the law =>
all alpha splatting factor once summed must be 1.0
so first pass can have r=0,g=0,b=0,a=0 and second pass r=1.0f.
Depending on Texture units availaible and accessible in pixel shaders, texture mode can optimize.
But I would go for 3-4 per pass, leaving some room for normal map + light map and why not some detail normal map. (I think FarCry used a detail normal map for sand (but only for sand.))

Falagard

17-01-2006 21:24:52

Gotcha now I think :-) The three passes add together to make the final color we want, adding all factors to 1.

I'll take a look at the existing splatting code to see if it sheds more light on it.