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
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
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.
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);
}
}
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))
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).