[SOLVED ] how to do textures on 3d models.

Following Reimers tutorials applied to my own game, I can place multiple 3d objects in my world and move them etc…
I can construct triangles and bunch them up and draw them textured, or I can load models and draw them in any color I want.
I can even play with the lighting, move it around, it’s quite nice…

However guys, I cannot draw a textured model, it just draws black, and stops responding to light… I am supposed to just import a model and its corresponding texture, the content builder does that, right? I am not supposed to manually load the textures for my models, one at a time, am I? I call load on the model, and it just GETS the associated textures, right?

-My problem is not normals, I’ve reversed them, and stuff just goes inside out.
-My model is visible in windows 3d viewer, textured, and visible in game when I tweak the shader to return some color rather than texture-coordinated colors.

My shader (the “Textured” technique part) takes texture coordinates as an input:

VertexToPixel TexturedVS
( float4 inPos : POSITION, float3 inNormal: NORMAL, float2 inTexCoords: TEXCOORD0)

, and returns the corresponding texture color. Maybe these coordinates are not loaded through the model? Still, even if the texture coordinates were initialized wrong at 0,0 why would that make the pixels BLACK, no part of the texture is black…

Depends on the shader, are you passing it the texture, the lights etc.?

no not the texture. -I was hoping to just use models that come textured… Do I really need all the full textures loaded “besides” just my models? … Monogame content tool already throws a fit if I don’t include the textures with the model, so I assumed it just did that for me.

And thank you. I have been scratching at this problem like a captive with a paper clip… Even a voice through the wall is reassuring at this point.

oh and the shader is reimers tutorial shaders, if you are familiar… It does operate using a texture, which I guess I THOUGHT would be supplied by my model…

Is it possible get color data from the model itself at all, maybe using a different shader, or do I NEED to load textures to do shading? …

…And then… Why does the content app demand a texture file along with the model, if I have to load the texture by hand anyway? …

If the model file asks for a texture, the pipeline will try and build it for you.

The model when sent to the GPU to be rendered is just the vertex and index data, you need to pass a texture and then use the uv data in the vert to texture it.

If your verts have colour channels you can vertex color your mesh.

Progress, thank you very much! - At least now, I can associate a texture with my model. I guess the cool thing is I can hot-swap textures on models, without having to go back to blender…

Also, I just noticed, windows 3d viewer only displays textures when the texture file is INCLUDED in the sime directory, ie, IT does not know the texture data from the 3d file either, it loads it under the hood without even informing me… REVALTAION…

So do people store all their models textures in one big sheet, or do they use some indexed list system to match up certain model bits with their corresponding textures? There could be a whole catalog of textures on certain models, what a mess to think about… It would have been nice if texture data could just be stored within the model… :slight_smile: … How does one keep it tidy with a lot of models, and a lot of textures… folders within folders I guess?..

Anyway, I’m going to mark this as solved, but please include a response below, if you feel you can help me think about this…

1 Like

Not looked at it in a while, but I think the Mesh or MeshPart will hold the reference to the texture mapped.

I think it should be accessible using:

You’ll need to change [0] to whichever meshpart you’re after and “Texture” to the model’s built-in effect parameter name. By putting a breakpoint on this line you can hover over the Parameters when running to get a list of the parameter names.

cool beans, thanks for your replies guys