Jump to content
  • Advertisement
Sign in to follow this  
jameswren

Single-pass Texture Splatting

This topic is 4823 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

Maybe this is impossible and I should just do multi-pass... I'm wanting to splat a grass texture as a base, followed by an alpha mapped dirt texture. When I do this:
device.TextureState[0].AlphaOperation = TextureOperation.SelectArg1;
device.TextureState[0].AlphaArgument1 = TextureArgument.TextureColor;

device.TextureState[1].ColorOperation = TextureOperation.SelectArg1;
device.TextureState[1].ColorArgument1 = TextureArgument.TextureColor;
device.TextureState[1].AlphaOperation = TextureOperation.SelectArg1;
device.TextureState[1].AlphaArgument1 = TextureArgument.Current;

device.SetTexture(0, texAlphaGrass);
device.SetTexture(1, texGrass);
device.DrawIndexedPrimitives(PrimitiveType.TriangleList, 0, 0, numVertices, 0, numTriangles);

device.SetTexture(0, texAlphaDirt);
device.SetTexture(1, texDirt);
device.DrawIndexedPrimitives(PrimitiveType.TriangleList, 0, 0, numVertices, 0, numTriangles);


it works! texAlphaGrass is just a white .dds...is there a way to not have to use this alphamap? However, that's multi-pass, and what I want to do is use TextureStages 2 and 3 to set another alphamap and dirt texture, removing the need for another DIP call. When I try it, setting up the TextureStages the same as 0 and 1, I just get the base grass texture showing...my textures 2 and 3 don't seem to have any effect. So, does anyone know if/how I can do this in a single pass? Cheers, James [Edited by - jameswren on July 9, 2005 4:52:00 AM]

Share this post


Link to post
Share on other sites
Advertisement
As far as my research showed, you cannot do texture splatting with alpha maps in a single pass. Since the single-pass blends everything all at once...

Share this post


Link to post
Share on other sites
Oh Indeed.
A shader will allow a single pass no problem, especially cuz you can compact alpha's into each color or a texture.

http://www.gamedev.net/columns/hardcore/splatting/

Read up on that article.
His explanations are said better in the text he refers to at the beginning.
His method is an upgrade tho since it use's a pixel shader. The PS code is provided, I am using it now since it is very small and effecient.
Remember tho, it only shows the most basic approach to texture splatting, it can be way more.

Share this post


Link to post
Share on other sites
I have tried to do this as well. Unfortunately, there is no way to do base textuer + texture splatting using the fixed function pipeline in one pass.

Share this post


Link to post
Share on other sites
I believe it would be possible with vertex alpha. Just change the texture stage state for the second texture to use the vertex alpha component rather than the texture alpha.

Share this post


Link to post
Share on other sites
Thanks everyone.

If I use vertex alpha, I guess that would give me the same alpha resolution as my heightmap, so would this be worse quality than using say a heightmap of 1024 and an alphamap of 4096? Although would that loss in quality be acceptable due to the gain in speed by doing just a single pass instead of 3 or 4?

Share this post


Link to post
Share on other sites
Actually, the blend from one texture to another does not need to be any more linear with vertices than with pixels. You could achieve the same result with a decent resolution mesh. Usually, the alpha map would need to be pretty huge in order to have a resolution that couldn't be handled by vertices. So unless the vertices are really spaced out (like my system - 32 inches apart), or the alpha map is mega huge, you can get just as pretty results with vertices.

I think the alpha map management is a pain. It also hogs memory. Every single layer needs it's own full-scale map, other than the base. So if you want cool spotting effects, your video memory requirements are going to shoot into the sky.

I've also thought about trying an alternative system. Where a precalculated (drawn in a paint program) alpha map per transition type could be used on different areas. For example, you could have a corner section, a straight section, a blurry section, a speckled grass section, a hard edged corner, etc. They could all be stored in the same alpha texture, but each quad would use it's own coordinates (secondary alpha coordinates, where the primary coordinates still tile across the landscape) to reference the mask it wants to use. It should allow you to use extremely high res alpha values for small parts of the terrain, since each quad can share the same texture coordinates. Allowing you to literally provide any shape or pattern you want, specific to any layer or texture, in extreme resolution. At the same time, non-faded quads could be rendered with tiny, totally opaque, single pixel coordinates to speed up the rendering. The most difficult part would be building an editor that used all of this flexibility to make an easy job out of building the terrain :)

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!