Add perspective-correct texture mapping

This commit is contained in:
austin committed 2020-07-01 17:42:53 -07:00
1 parent 370fb7bce0
commit 20402784f7
5 files changed
+188 -38

No files matched your search

+17 -1
View File
@@ -14,9 +14,23 @@ struct Material
ColorF32 kDiffuse;
};
struct Texture
{
ColorU32 **texels;
unsigned int width;
unsigned int height;
};
struct TextureCoord
{
float u;
float v;
};
struct Face
{
unsigned int vertIndex[3];
unsigned int textureIndex[3];
Vector normal;
ColorF32 color;
};
@@ -32,6 +46,7 @@ struct Mesh_LocalData
{
std::vector<Vertex> verts;
std::vector<Face> faces;
std::vector<TextureCoord> uvs;
};
struct Mesh_TransformedData
@@ -73,7 +88,8 @@ void CullBackfaces(
Point &camPosition);
void RenderMesh(
Engine_Buffer &buffer, Mesh_TransformedData &mesh, bool smooth);
Engine_Buffer &buffer, Mesh_TransformedData &mesh, bool smooth, Texture &texture,
std::vector<TextureCoord> &uvs);
#define GEOMETRY_H
+1
View File
@@ -4,6 +4,7 @@
int LoadMesh(char *filename, Mesh &mesh);
int LoadTexture(char *filename, Texture &texture);
#define LOADER_H