3D model which created on Blender is drawing without texture

I’ve created 3d model (UV Sphere) on Blender and attached texture to it

Then I’ve exported model to .fbx format (even I export to .obj or .dae results are the same)

Then I’ve opened Monogame Pipeline Tool and created new project add my texture and model and built all

Then I moved built files to Monogame application

and run application. Result is sphere without texture

I don’t understand what I do wrong but I’ve searched video, topics, manuals about creating 3d model on Blender for monogame at all google and I’ve been disappointed because searching results were vere poor and that it worked in other developers does not work in me

Perhaps, you incorrectly draw or incorrectly use effect.

Hm. I don’t think so.

public Game1()
        {
            graphics = new GraphicsDeviceManager(this);
            graphics.PreferredBackBufferWidth = 1280;
            graphics.PreferredBackBufferHeight = 720;
            graphics.ApplyChanges();
            Window.IsBorderless = true;
            Content.RootDirectory = "Content";
        }

protected override void Initialize()
        {
            viewMatrix = Matrix.CreateLookAt(new Vector3(0, 0, 6), Vector3.Zero, Vector3.Up);
            projectionMatrix = Matrix.CreatePerspectiveFieldOfView(MathHelper.PiOver4, (float)Window.ClientBounds.Width / (float)Window.ClientBounds.Height, 1, 100);
            worldMatrix = Matrix.CreateWorld(new Vector3(0, 0, 0), new Vector3(0, 0, -1), Vector3.Up);
            base.Initialize();
        }

protected override void Draw(GameTime gameTime)
        {
            GraphicsDevice.Clear(Color.CornflowerBlue);
            foreach (ModelMesh mesh in _model.Meshes)
            {
                foreach (BasicEffect effect in mesh.Effects)
                {
                    effect.View = viewMatrix;
                    effect.World = worldMatrix;
                    effect.Projection = projectionMatrix;
                }
                mesh.Draw();
            }
            base.Draw(gameTime);
        }

Hi,
Make sure you’ve loaded your texture in as Texure2d- normally in LoadContent method. Then make sure you’re setting the effect’s texture parameter for that texture, in effect loop, where you’re setting the matrixes. The basic effect will work okay for a diffuse texture, but if you need more than that you’re gonna need to roll your own (effect aka shader)

Ha, I don’t understand what you write about. I’ve taken simple example where it’s not necessity to load texture, it’s enought to load model just. If you have some another example you can share it

Perhaps in the project there is no texture. Put the breakpoint in line “effect.View = viewMatrix;” and check value of texture.

I do not know as it is correct to work with Linux, but in Win I use Monogame Pipeline Tool in the project. And files where I do not transfer.

Really effect.Texture = null
Why? Why does not model contains texture?

Really effect.Texture = null
Why? Why does not model contains texture?

The wrong transfer from the Blender. I am not a specialist in this program.
It is worth esteeming here.

Or
To use Monogame Pipeline Tool from your project. Then all files will be written down in the project. (If model correct.)

First, you don’t have to include the texture file in the pipeline project. The .fbx ‘should’ include it automatically.
Exclude the png,Clean up the project , rebuild the model and check if it builds the texture xnb.
2) open the fbx in a text editor , if it’s binary reexport as ascii format. Search all references for the png. Some programs will put an absolute path to textures instead of relative to the fbx.

Can I rebuild model and texture out of project?

Additionally check if the vertex declaration in the model mesh contain UV (texture map) coordinates.

Pipeline project did not include texture automaticaly. What must I do next?

How can I do it??? Write full path to this value

So I’ve understood that monogame is not preferable for 3d games or even is not designed

Regular models with just texturing information will work.
You have to set the image mapping option in blender to uv set the image
cut the model before un-wraping it or ensure it works in blender in the preview window.

When exporting as well.

You have to click one of the path options at the bottom when you export.
This is with blender and you don’t convert it at all with that fbx tool at least i didn’t for the below.

It’s copy i think or relative path or something i forget. Ive hit everyone of them on 10 different models 10 different ways when exporting over the last few days of testing.

Here is a cube.fbx i made with blender that works you have to put the texture in content and load it in like you would a normal one for this.


Anything beyond that even multiple textures per model, weight info for bone meshes, ect … forget it.

Put a breakpoint right after the model loads and look thru the model instance. Or turn on your console in Visual Stuidio … project -> properties -> application -> output type (drop down button) call this right after you load the model.
PrintOutWhatsInTheModel(model);

Add this code to your game1 and look at the output.

        string msg = "";
        string space = "";
        public void PrintOutWhatsInTheModel(Model model)
        {
            msg += "\n\n__________________\n";
            BasicModelBoneInfo(model.Root, 0);
            Console.WriteLine(msg);
        }

        public void BasicModelBoneInfo(ModelBone b, int n)
        {
            space = "";
            for (int i = 0; i < n; i++)
                space += "  ";
            msg += "\n" + space + "Bone: " + b.Name;
            if (b.Parent != null)
                msg += "" + space + " Parent: " + b.Parent.Name;
            if(b.Meshes.Count <1)
                msg += "\n" + space + "|_Meshes: None so no MeshParts either";
            foreach (var mm in b.Meshes)
            {
                msg += "\n" + space + "|_Mesh: " + mm.Name;
                if (mm.MeshParts.Count > 0)
                {
                    msg += "\n" + space + "|_MeshParts: " + mm.MeshParts.Count;
                    for(int i = 0; i < mm.MeshParts.Count;i++)
                    {
                        msg += "\n" + space + "|_MeshPart["+i+"]... primitive count:" + mm.MeshParts[i].PrimitiveCount;
                    }
                }
                else
                {
                    msg += "\n" + space + "|_MeshParts: None";
                }
                if (mm.Effects.Count > 0)
                {
                    msg += "\n" + space + "|_Effects: " + mm.Effects.Count;
                    foreach(var emm in mm.Effects)
                    {
                        var te = emm.Parameters["Texture"];
                        if (te != null)
                        {
                            msg += "\n" + space + " : " + te.ToString();
                            var t = te.GetValueTexture2D();
                            if (t != null)
                                msg += "\n" + space + "       Texture: " + t.Name;
                        }
                    }
                }
            }
            if (b.Children.Count > 0)
                msg += "\n" + space + @"|_Children("+ b.Children.Count+")... ";
            else
                msg += "\n" + space + @"|_No Children";
            foreach (var c in b.Children)
            {
                BasicModelBoneInfo(c, n + 1);
            }
        }

There is One especiality that I use monodevelop on Linux instead Visual Studio on Windows.

I’ve been doing some testing today with the new Blender v2.8.
And it turns out that FBX export does not export data about the texture of the material.
I’ve tried every path option, and converted all the .fbx files with Autodesk FBX converter to ASCII human readable format to verify the results - none had any mention of the texture anywhere.
I’m not sure if its a 2.8 thing (they changed the way materials with textures work) or if its been like this for some time now - i think the last “good” version for FBX exporting was v2.68.
I’ll try some 2.7~ versions tomorrow to see if i can get them to export the texture references, but at this point (with 2.8 release right around the corner) it seems like i might just as well go back to 2.68 for exporting.
(Btw that cube model you posted also does not contain any texture references and placing the textures in pipeline with build or copy actions does not make any differences - no textures on model load (which makes sense since there’s no references to them in .fbx file))

1 Like

It looks like you tried to export an .FBX file with material that you created with Blender nodes editor.
This solely works for Blender Cycles.

If you want to export an .FBX file with textures you have to create a material without nodes and add baked Cycles textures as input (under “Texture” tab, “Influence” panel).

Have in mind that most Blender exporters do not support Cycles node based materials at all

Yes, because the version 2.80 does things differently, and you can’t get the texture on the material without the use of nodes (at least that is my understanding).

I’ve also now tried to export to .fbx with version 2.79 and that does seems to work - the texture reference is in the exported .fbx file and the content pipeline will pick up the texture file and convert it as well (for this to work the fbx was exported with Strip path option and the .png file was placed next to the .fbx file in the content directory), it all gets loaded by the .Load at runtime and it displays the texture IF i set the effect.Alpha = 1 (For some reason the alpha gets set to 0 sometime during the processing/loading, i’m still looking into this).