Texture Splatting problem programmatically

Anything and everything that's related to OGRE or the wider graphics field that doesn't fit into the other forums.
Post Reply
papaonn
Kobold
Posts: 30
Joined: Wed Nov 13, 2013 5:59 pm
x 1

Texture Splatting problem programmatically

Post by papaonn »

Dear All,

I would like to know how do you programmatically blend 2 textures together with the indication of vertices alpha weights on different layers.

I know it could be done in material scripting, but would want to deal it programmatically.

I am trying to specify the vertex alpha weights based on the steep of my terrain,
and by doing so i could specify the blending weights on different textures.

Any advice is much appreciated,

Thanks in Advance!
User avatar
c6burns
Beholder
Posts: 1512
Joined: Fri Feb 22, 2013 4:44 am
Location: Deep behind enemy lines
x 138

Re: Texture Splatting problem programmatically

Post by c6burns »

In a shader, use the dot product between the vertex normal and unit y vector. You can experiment with multiplying the result by a bias factor, etc. This is incredibly similar to how directional lighting works. You can do it in the vertex shader and have it interpolated, or you can do it in the pixel shader.

Another common method for terrain is alpha splatting, where you generate a splat map as a pre-process. You then do a lookup into the splatmap to determine how to blend your 2 or more textures. With just 2 textures you only need 1 channel for the splat map.
Post Reply