mirror of https://github.com/bjornbytes/lovr.git
Handle missing textures better;
This commit is contained in:
parent
0add9526ad
commit
d25f59582e
|
@ -618,6 +618,11 @@ ModelData* lovrModelDataInit(ModelData* model, Blob* source, ModelDataIO io) {
|
|||
material->scalars[SCALAR_ROUGHNESS] = 1.f;
|
||||
material->colors[COLOR_DIFFUSE] = (Color) { 1.f, 1.f, 1.f, 1.f };
|
||||
material->colors[COLOR_EMISSIVE] = (Color) { 1.f, 1.f, 1.f, 1.f };
|
||||
|
||||
for (int j = 0; j < MAX_MATERIAL_TEXTURES; j++) {
|
||||
material->textures[j] = -1;
|
||||
}
|
||||
|
||||
for (int k = (token++)->size; k > 0; k--) {
|
||||
gltfString key = NOM_STR(json, token);
|
||||
if (STR_EQ(key, "pbrMetallicRoughness")) {
|
||||
|
|
|
@ -154,16 +154,18 @@ Model* lovrModelInit(Model* model, ModelData* data) {
|
|||
for (int j = 0; j < MAX_MATERIAL_TEXTURES; j++) {
|
||||
int index = data->materials[i].textures[j];
|
||||
|
||||
if (!model->textures[index]) {
|
||||
ModelTexture* texture = &data->textures[index];
|
||||
TextureData* image = data->images[texture->imageIndex];
|
||||
bool srgb = j == TEXTURE_DIFFUSE || j == TEXTURE_EMISSIVE;
|
||||
model->textures[index] = lovrTextureCreate(TEXTURE_2D, &image, 1, srgb, texture->mipmaps, 0);
|
||||
lovrTextureSetFilter(model->textures[index], texture->filter);
|
||||
lovrTextureSetWrap(model->textures[index], texture->wrap);
|
||||
}
|
||||
if (index != -1) {
|
||||
if (!model->textures[index]) {
|
||||
ModelTexture* texture = &data->textures[index];
|
||||
TextureData* image = data->images[texture->imageIndex];
|
||||
bool srgb = j == TEXTURE_DIFFUSE || j == TEXTURE_EMISSIVE;
|
||||
model->textures[index] = lovrTextureCreate(TEXTURE_2D, &image, 1, srgb, texture->mipmaps, 0);
|
||||
lovrTextureSetFilter(model->textures[index], texture->filter);
|
||||
lovrTextureSetWrap(model->textures[index], texture->wrap);
|
||||
}
|
||||
|
||||
lovrMaterialSetTexture(material, j, model->textures[index]);
|
||||
lovrMaterialSetTexture(material, j, model->textures[index]);
|
||||
}
|
||||
}
|
||||
|
||||
model->materials[i] = material;
|
||||
|
|
Loading…
Reference in New Issue