textured meshes

    This site uses cookies. By continuing to browse this site, you are agreeing to our Cookie Policy.

    • textured meshes

      Hi everyone ;)
      After I read the book i got teapot wars running on vs2010 somehow :D and think ive got a basic understanding of how all fits together, especially the graphics part, since i offered the last days looking at directx samples and mesh.cpp, the shaders and so on.

      First few facts:

      In mesh.cpp it says in case of directx 9 before loading the mesh: "// Load the Mesh with D3DX and get back a ID3DXMesh*. For this sample we'll ignore the X file's embedded materials since we know exactly the model we're loading."

      And for directx 11 it says before rendering the mesh" // FUTURE WORK - this code WON'T be able to find texture resources referred to by the sdkmesh file in the Resource cache."

      These meshes will get their colors from the actor xml files loaded from the zip.

      So here comes my question:
      Is there already a way to display textured mehes, like in the directx samples and did i overlook something completly or is that not supported?

      I already tried to grab code from the sdk sample "optimized meshes", but i didnt succeed getting things working.

      Would be cool if sb helped me because i dont only want monoton meshes like a complete green human :D
    • RE: textured meshes

      Maybe my question was not well worded.

      I ask for a way to display textured meshes.

      I thought about creating and texturing the meshes in blender and then load them as .x or .sdkmeshes into the game, just like the sphere and the teapot, except that these arent textured.

      I think this is a very basic question, and I would apprechiate your help.
    • If you are wondering about the concept behind textured geometry than I can help, if you are wondering about Direct3D specifics you'll have to do some searching (or wait for Rez or Mike to reply).

      Texturing geometry requires that you first pass texture coordinates to your shader, if I remember correctly, Direct3D needs you to update your 'flexible vertex format' to include texture coordinates, if your mesh has these exported into the model, than the Direct3D mesh loading you use should load these as well into a buffer. Now that you have texture coordinates passed as a vertex attribute (assuming you're using shaders here) than for each vertice you will pass the coordinate to the fragment shader. In your fragment shader you will need to pass a texture in (as a uniform variable), at this point you would use the texture coordinates and the texture to sample a fragment colour. Here is an example in GLSL


      Source Code

      1. layout (location = 0) in vec3 position;
      2. layout (location = 1) in vec2 texCoord;
      3. out vec2 texCoord0;
      4. void main()
      5. {
      6. //Do your position stuff as normal
      7. texCoord0 = texCoord;
      8. }


      Source Code

      1. uniform sampler2D texture;
      2. in vec2 texCoord0;
      3. out vec3 fragColour;
      4. void main()
      5. {
      6. fragColour = texture2D(texture, texCoord.st);
      7. }

      This is the best I can do to help as I only use OpenGL, I hope this was useful.
      PC - Custom Built
      CPU: 3rd Gen. Intel i7 3770 3.4Ghz
      GPU: ATI Radeon HD 7959 3GB
      RAM: 16GB

      Laptop - Alienware M17x
      CPU: 3rd Gen. Intel i7 - Ivy Bridge
      GPU: NVIDIA GeForce GTX 660M - 2GB GDDR5
      RAM: 8GB Dual Channel DDR3 @ 1600mhz