TinyRenderer: implement triangle clipping against near-plane

TinyRenderer: implement texture UV-repeat by default (instead of clamp(0,1))
This commit is contained in:
Erwin Coumans
2017-04-06 14:31:34 -07:00
parent 0f2771b1d1
commit deb95c758b
5 changed files with 254 additions and 44 deletions

View File

@@ -140,6 +140,13 @@ void Model::load_texture(std::string filename, const char *suffix, TGAImage &img
TGAColor Model::diffuse(Vec2f uvf) {
if (diffusemap_.get_width() && diffusemap_.get_height())
{
double val;
// bool repeat = true;
// if (repeat)
{
uvf[0] = modf(uvf[0],&val);
uvf[1] = modf(uvf[1],&val);
}
Vec2i uv(uvf[0]*diffusemap_.get_width(), uvf[1]*diffusemap_.get_height());
return diffusemap_.get(uv[0], uv[1]);
}