Game Development Community

Improving the terrain texture blending

by Lukas Joergensen · in Torque 3D Professional · 07/20/2013 (12:10 pm) · 63 replies

Hey guys, I looked into this myself but it seems the terrain texture uses procedural shaders for blending textures and thats wayy too complex for me atm so I thought I would post it here and hope that someone have a better understanding of the procedural shader system and might be able to implement this.

I read this article on Gamasutra and found it very interesting.

It goes through a set of algorithms to go from this kind of blending which is the one it seems T3D has:
www.gamasutra.com/db_area/images/blog/196339/1.jpg
To this much more accurate and natural blending:
www.gamasutra.com/db_area/images/blog/196339/8.jpg
(All images is from the article linked above)

Using this algorithm that seems simple enough:
float3 blend(float4 texture1, float a1, float4 texture2, float a2)
{
    float depth = 0.2;
    float ma = max(texture1.a + a1, texture2.a + a2) - depth;

    float b1 = max(texture1.a + a1 - ma, 0);
    float b2 = max(texture2.a + a2 - ma, 0);

    return (texture1.rgb * b1 + texture2.rgb * b2) / (b1 + b2);
}
Where a1 and a2 is the opacity of the respectively texture1 and texture2 and the alpha channel of texture1 and texture2 is a depth map.

This seems like something that could improve the terrain detail of T3D alot, so whats your thoughts? Would this be possible to do? And it would be awesome if anyone had a good enough understanding of the shader system to actually implement this.

Lastly what do you think about having to have a depth map? obviously it would be best if that could be omitted if desired, using a default depthmap or just a grayscale image.
Page«First 1 2 3 4 Next»
#61
06/25/2014 (1:52 pm)
Just found this great example of the heightmap making its mark:
imageshack.com/a/img853/2606/xhtx.png

Can you see how the sand fills the cracks in the stone?
#62
06/25/2014 (3:55 pm)
Nice work Lukas, this will be a welcome addition when you are finished.
#63
06/26/2014 (2:56 pm)
Huh.. I had no idea this would've been so sought after, apologize community.. hahah. I actually already did this very same thing myself a few years ago. I didn't need the effect though so I just trashed the code. It was really just an experiment. Didn't think anyone else would've even wanted it. Ooops..

But good job with it Lukas. :) Glad you had better sight on the matter than I did and actually released it. lol
Page«First 1 2 3 4 Next»