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

  • Home
  • SEARCH
  • 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 4110564
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 20, 20262026-05-20T21:57:02+00:00 2026-05-20T21:57:02+00:00

I’m using the standard .fbx importer with custom shaders in XNA. The .fbx model

  • 0

I’m using the standard .fbx importer with custom shaders in XNA. The .fbx model is UV wrapped properly and is textured appropriately when I use BasicEffect. However when I use my custom effect I have to load the texture in as a parameter, and it is not mapped correctly.

Questions: 1) How can I texture my .fbx model properly using the included texture’s coordinates with custom effects? 2) Is there a way to access the texture from the loaded .fbx model object? Where does this texture go?

Note: I’ve studied custom content pipelines and don’t believe writing my own Fbx importer/processor will be efficient. However if someone can descriptively supply me with firsthand experience of this being the answer than I will use the custom pipeline.

Thank you for your time and for reading this post.

  • 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-05-20T21:57:03+00:00Added an answer on May 20, 2026 at 9:57 pm

    This is an old question, but I had to figure this out myself yesterday so I thought I’d post a followup:

    If you’re using the default FBX content processor and have the DefaultEffect property set to BasicEffect, you can get the Texture2D for the object via:

    texture = ((BasicEffect)model.Meshes[0].Effects[0]).Texture;
    

    Note that the each mesh in the model may have a different texture.

    The texture coordinates are stored in the MeshPart‘sVertexBuffer along with position, etc. I’ve seen two vertex declarations. For a model/mesh that used a single texture (bitmap material in 3DS Max), the vertex declaration was VertexPositionNormalTexture.

    For a model that had two textures (a bitmap and an opacity/alpha map), the declaration had the elements:

    Position
    Normal
    Texture (usage index 0)
    Texture (usage index 1)
    

    or, wrapped into an IVertexType structure,

    public struct VertexPositionNormalTextureTexture : IVertexType
    {
        public Vector3 Position;
        public Vector3 Normal;
        public Vector4 Texture0;
        public Vector4 Texture1;
    
        public static VertexDeclaration VertexDeclaration
        {
            get
            {
                return new VertexDeclaration
                (
                new VertexElement(0,VertexElementFormat.Vector3, VertexElementUsage.Position, 0)
                ,
                new VertexElement(0,VertexElementFormat.Vector3, VertexElementUsage.Normal, 0)
                ,
                new VertexElement(0,VertexElementFormat.Vector3, VertexElementUsage.TextureCoordinate, 0)
                ,
                new VertexElement(0,VertexElementFormat.Vector3, VertexElementUsage.TextureCoordinate, 1)
                );
            }
        }
    
    
        VertexDeclaration IVertexType.VertexDeclaration
        {
            get { return VertexDeclaration; }
        }
    }
    

    and the equivelant HLSL structure:

    struct VertexPositionNormalTextureTexture
    {
        float3 Position : POSITION0;
        float3 Normal : NORMAL0;
        float4 Texture0 : TEXCOORD0;
        float4 Texture1 : TEXCOORD1;
    };
    

    Note that I changed .Position and .Normal from Vector4 and Vector3 to float4 and float3 before I posted this, and haven’t tested it. It’s possible that they may need to be changed back to Vector4 and float4.

    Of course, you’ll need a sampler and some basic logic in your pixel shader to read each texture. Assuming you’ve set two effect parameters xTexture0 and xTexture1 to Texture2D objects containing your color texture and opacity map,

    // texture sampler
    sampler Sampler0 = sampler_state
    {
        Texture = (xTexture0);
    };
    
    sampler Sampler1 = sampler_state
    {
        Texture = (xTexture1);
    };
    

    and here’s a simple two-texture pixel shader. If you only want one texture, just read from the first sampler and return the value, or apply lighting, etc.

    float4 TwoTexturePixelShader(VertexPositionNormalTextureTexture input) : COLOR0
    {
        float4 texel0;
        float4 texel1;
        float4 pixel;
    
        // check global effect parameter to see if we want textures turned on
        // (useful for debugging geometry weirdness)
        if (TexturesEnabled)
        {
            texel0 = tex2D(Sampler0, input.Texture0);
            texel1 = tex2D(Sampler1, input.Texture1);       
            /// Assume texel1 is an alpha map, so just multiple texel0 by that alpha.
            pixel.rgb=texel0.rgb;
            pixel.a=texel0.a;
        }
        else
            /// return 100% green
            pixel = float4(0,1,0,1);
    
        return pixel;
    
    } 
    

    The relevant points here are that the texture coordinates are already present in the FBX and are already stored in each MeshPart‘s VertexBuffer, so all you need to do is extract the texture, pass it into your shader as a global effect parameter, and proceed as normal.

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

Sidebar

Related Questions

I'm new to using the Perl treebuilder module for HTML parsing and can't figure
That's pretty much it. I'm using Nokogiri to scrape a web page what has
link Im having trouble converting the html entites into html characters, (&# 8217;) i
I want use html5's new tag to play a wav file (currently only supported
We are using XSLT to translate a RIXML file to XML. Our RIXML contains
In order to apply a triggered animation to all ToolTip s in my app,
I want to count how many characters a certain string has in PHP, but
Is it possible to replace javascript w/ HTML if JavaScript is not enabled on
I ran into a problem. Wrote the following code snippet: teksti = teksti.Trim() teksti
Seemingly simple, but I cannot find anything relevant on the web. What is the

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.