Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8845955
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 14, 20262026-06-14T11:51:31+00:00 2026-06-14T11:51:31+00:00

This is my first time here (With an account), I’m looking to make a

  • 0

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)
);
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-14T11:51:32+00:00Added an answer on June 14, 2026 at 11:51 am

    As I said in my comment, I’m not certain this is what you’re looking for but I’ll go ahead anyway.

    I think what you probably want is described here.

    Essentially you have a Vector 4 which stores the weights of each texture and then take a weighted average of all 4 textures weighted by the individual elements in the vector (acting as 4 blend weights).

    If you want to blend textures without having to have a blend element for every single texture things get more fun.

    You could have a single blend weight, which essentially picks the blending of 2 adjacent textures in order. So if you have:

    1. Snow
    2. Grass
    3. Rock
    4. Sand

    Blend Weight = 0.5

    Would pick a blend of Grass (0.25) and Rock (0.75). Blended in equal amounts (since it’s halfway between them).

    If you want lots of textures, your shader is going to become very cumbersome with ~50 texture samplers. If you really want this many textures you should consider a texture atlas or just procedurally generated virtual textures with the blending already done at generation time.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

This is my first time here and I am a beginner so kindly bear
This is my first time here so I hope I post this question at
this is my first time posting here, I have a question which I have
this is my first time asking a question here. I tried to be well
Sorry, this's my first time to ask a question here. So, I don't have
Here's the scenario: if this is a user's first time logging into my web
This is my first time here so I apologize in advance if this question
This is the first time I make a database for user interaction and I
This is my first time working with a WPF datagrid. From what I understand
This is my first time that I use WCF and Android. So, sorry for

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.