Engineering Two Assignment 8

Assignment 8 Download!

So we were supposed to get a texture pipeline working and get textures into the game. I got the first part complete, but ended up running out of time before I could get the textures working. It’s almost there, just fell a bit short.

So once again, the build process wasn’t too bad to add textures into a binary format. I’ve got them loading into the game fine too. So the material handles its own texture. So after getting the build process fixed up, I needed to adjust my mesh file to add in UV, which is just a coordinate system to line up the texture’s image. The scale is from 0 to 1, and for cubes and squares it is pretty easy. Top left corner is 0,0 and bottom right corner is 1,1. It’s flipped from what you normally see in coordinate planes. So after adjusting the mesh file, I needed to change the builder to accommodate the new structure. Which means I needed to update the sVertex struct that makes sure that DirectX’s buffer knows we’re going to be putting in two more floats per vertex into its system.

I did need to duplicate my material, but that wasn’t too hard. My system was already set up to use multiple materials, so it was really a copy paste and change what texture was to be used for each material.

So where did everything go wrong? Well, we need to query the constants table for the fragment shader and figure out the register for the “g_color_sampler” From there, we need to tell DirectX what register and what texture to use. My register was always 0, so I’m not sure if that’s how it is supposed to look and I have the UVs messed up or if I’m missing something else entirely, but it is causing problems there. It’s still drawing everything, so my struct and how I passed in my data to DirectX is working. My textures compile, so I know it isn’t that. In PIX, I can see the texture getting set:


But you can see that the textures aren’t actually showing up in the full render:


So since it’s getting the texture and it’s being recognized by DirectX, but still not rendering the texture, I can only assume something is wrong with the UVs. The build process is still moving the UVs over like I expect them to. I changed the declaration for the sVertex to include 2 floats as texture coordinates:
const D3DVERTEXELEMENT9 vertexElements[] =
// Stream 0

// POSITION, 3 floats == 12 bytes


And since color is still showing up, the only thing I can think of is that the declaration for the TEXCOORD might be something else. I messed around with the ground and inverted the UVs to make sure I wasn’t doing something wrong, but it still isn’t showing up. I tried to get the table index every frame, and it’s still turning out to be 0 every time. But since the textures are showing up in PIX, that actually must be working. So going back to UVs, it must not be…inputting them correctly? I’ll have to look in to that more closely.

If I had been a responsible person and actually did my work ahead of time, perhaps I could have figured out where I went wrong. Instead, I spent the weekend watching Blizzcon and shirking my duties. And before that, I just had no motivation after IGF. It isn’t an excuse, but insight on to why I’m not finishing.

Time Spent:
Texture builder and game-side loader: 1 Hour
Adjusting all the mesh, vertex updates, etc: 1.5 Hours
Debugging and failure: 1.5 Hours
Writeup: 30 Minutes

Total: 4.5 Hours

Leave a Reply