I currently have a jpeg texture stored as a Color array in XNA as RGBA. I also have the vertices of a cube in OBJ format mapped to VertexPositionColor vertex buffer using the VertexBuffer and Indices of the GraphicsDevice class. The OBJ has my jpeg mapped as a UV texture. I think I have all the Texture Coordinates as well(not sure, the array has 24 Vector3D values). I'm not sure where to go from here. I'm not using the Content Pipeline for my cube model or its texture though I'm wiling to add a custom .fx file if i need to. I realize I will have to add info about texture coords and color to my VertexDeclaration but do i need to write a custom effects file in HLSL to display my textured cube model or is there another way?
A custom shader is not required; you can accomplish this with
BasicEffect. You will need to set the
TexturesEnabled properties. Those properties will tell the shader:
- Expect and enforce texture coordinates in your vertex data
- Which texture data to sample.
This relevant article discusses drawing a textured quad with
BasicEffect, and it's a short step from that to drawing a textured cube.