Note that there are some explanatory texts on larger screens.

plurals
  1. POMultiple textures on a heightmap with blending?
    primarykey
    data
    text
    <p>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).</p> <p>I've written a custom Effect File here: <a href="http://pastebin.com/CUFtB8Z9" rel="nofollow">http://pastebin.com/CUFtB8Z9</a></p> <p>It blends textures just fine, except it blends over the entire map.</p> <p>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.</p> <p>I thought about assigning a <code>float</code> 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?</p> <p>Sorry about not being very clear, here is my Draw code and my Vertex Declaration:</p> <p>(Excuse the random number changing, It was my attempt to try and get each vertex to pick a random texture)</p> <pre><code>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) ); </code></pre>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload