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!
Texture Splatting problem programmatically
-
- Kobold
- Posts: 30
- Joined: Wed Nov 13, 2013 5:59 pm
- x 1
- c6burns
- Beholder
- Posts: 1512
- Joined: Fri Feb 22, 2013 4:44 am
- Location: Deep behind enemy lines
- x 138
Re: Texture Splatting problem programmatically
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.
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.