assimp: Add support for texture wrapping modes

This commit is contained in:
rdb 2022-11-02 19:35:10 +01:00
parent 09a81e0d68
commit 2226f8de9e
1 changed files with 53 additions and 0 deletions

View File

@ -348,6 +348,59 @@ load_texture_stage(const aiMaterial &mat, const aiTextureType &ttype, CPT(Textur
}
if (ptex != nullptr) {
// Apply the mapping modes.
switch (mapmode[0]) {
case aiTextureMapMode_Wrap:
ptex->set_wrap_u(SamplerState::WM_repeat);
break;
case aiTextureMapMode_Clamp:
ptex->set_wrap_u(SamplerState::WM_clamp);
break;
case aiTextureMapMode_Decal:
ptex->set_wrap_u(SamplerState::WM_border_color);
ptex->set_border_color(LColor(0, 0, 0, 0));
break;
case aiTextureMapMode_Mirror:
ptex->set_wrap_u(SamplerState::WM_mirror);
break;
default:
break;
}
switch (mapmode[1]) {
case aiTextureMapMode_Wrap:
ptex->set_wrap_v(SamplerState::WM_repeat);
break;
case aiTextureMapMode_Clamp:
ptex->set_wrap_v(SamplerState::WM_clamp);
break;
case aiTextureMapMode_Decal:
ptex->set_wrap_v(SamplerState::WM_border_color);
ptex->set_border_color(LColor(0, 0, 0, 0));
break;
case aiTextureMapMode_Mirror:
ptex->set_wrap_v(SamplerState::WM_mirror);
break;
default:
break;
}
switch (mapmode[2]) {
case aiTextureMapMode_Wrap:
ptex->set_wrap_w(SamplerState::WM_repeat);
break;
case aiTextureMapMode_Clamp:
ptex->set_wrap_w(SamplerState::WM_clamp);
break;
case aiTextureMapMode_Decal:
ptex->set_wrap_w(SamplerState::WM_border_color);
ptex->set_border_color(LColor(0, 0, 0, 0));
break;
case aiTextureMapMode_Mirror:
ptex->set_wrap_w(SamplerState::WM_mirror);
break;
default:
break;
}
tattr = DCAST(TextureAttrib, tattr->add_on_stage(stage, ptex));
}
}