This week, I will added support for textures for the models we export from Maya and use in our game.
We had to change a few things to make this happen. First, in our fragment shaders we need to add a "sampler" to sample our textures for a set of texture coordinates and render it onto the screen. These texture coordinates (obtained from Maya),, also known as UV coordinates help us map a texture to a mesh.
I also added a texture builder that converts the textures into a DDS format that can be easily loaded by our Graphics API.
The material builder we built last week also need to be modified since our material files now include a texture as well. The material builder loads the texture along with the sampler uniform so that the texture can be loaded along with the material and rendered.
The image below shows my new material format in binary. The highlighted portion shows the new data that is added to my material file containing the name of my sampler and the texture.
To use this data in my game I had to decide whether to make a separate class for the textures or merge this data as part of my material class. I decided to have the texture data along with my material data since it made more sense for me to have all of it in one place since I was reading it from the same file. The only reason I can think of why having a different texture class would be useful is if there are multiple textures on the same mesh. This scenario also seems highly unlikely in my project.
Below are 2 screenshots comparing my game in Direct3D and OpenGl.. The textures look smoother on OpenGL and sharper on Direct3D. This is due to different default sampler states for each platform.
The screenshots show the textures on my objects as part of my work for the game I am building for our final project. This is the last of our assignments. More on the final project next week.
Download my current build here.
I have controls for my upcoming game, so use the WASD to move the gun and space bar to shoot the spheres. Esc to quit.
Leave a Reply.
This is a blog that documents my work for my graphics Game Engineering class at the University of Utah.