This is my first time here (With an account), I'm looking to make a height-map editor with XNA 4.0 (Somewhat similar to Earth2150's, if you've played it).
I've written a custom Effect File here: http://pastebin.com/CUFtB8Z9
It blends textures just fine, except it blends over the entire map.
What I really want is to be able to have multiple textures on my heightmap (Which i'll then blend with the nearest other texture) and I am looking for ways to do this.
I thought about assigning a float
in my Vertex Declaration, then using an array of textures to "Assign" a texture to a specific vertex. But how would I go about getting my effect file to take in a different value for a texture on each vertex?
Sorry about not being very clear, here is my Draw code and my Vertex Declaration:
(Excuse the random number changing, It was my attempt to try and get each vertex to pick a random texture)
public void Draw(Texture2D[] TextureArray)
{
RasterizerState rs = new RasterizerState();
rs.CullMode = CullMode.None;
//rs.FillMode = FillMode.WireFrame;
EditGame.Instance.GraphicsDevice.RasterizerState = rs;
Random rnd = new Random();
foreach (EffectPass pass in EditGame.Instance.baseEffect.CurrentTechnique.Passes)
{
if (SlowCounter == 60)
{
EditGame.Instance.baseEffect.Parameters["xTexture"].SetValue(TextureArray[rnd.Next(0, 2)]);
EditGame.Instance.baseEffect.Parameters["bTexture"].SetValue(TextureArray[rnd.Next(0, 2)]);
SlowCounter = 0;
}
pass.Apply();
EditGame.Instance.GraphicsDevice.DrawUserIndexedPrimitives(PrimitiveType.TriangleList, vertices, 0, vertices.Length, indices, 0, indices.Length / 3, VP2TC.VertexDeclaration);
}
SlowCounter++;
}
public readonly static VertexDeclaration VertexDeclaration = new VertexDeclaration(
new VertexElement(0, VertexElementFormat.Vector3, VertexElementUsage.Position, 0),
new VertexElement(12, VertexElementFormat.Vector2, VertexElementUsage.TextureCoordinate,0),
new VertexElement(20, VertexElementFormat.Vector2, VertexElementUsage.TextureCoordinate,1),
new VertexElement(28, VertexElementFormat.Single, VertexElementUsage.BlendWeight,0),
new VertexElement(32, VertexElementFormat.Vector3,VertexElementUsage.Normal,0),
new VertexElement(44, VertexElementFormat.Color,VertexElementUsage.Color,0)
);