From 057de2bbb59a3a307747b39ebfbec133debb26e1 Mon Sep 17 00:00:00 2001 From: Jerome St-Louis Date: Tue, 2 Aug 2016 20:19:25 -0400 Subject: [PATCH] ecere/gfx/3D/3DS Models: Work around for diffuse map specified as bump map --- ecere/src/gfx/3D/models/Object3DSFormat.ec | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) diff --git a/ecere/src/gfx/3D/models/Object3DSFormat.ec b/ecere/src/gfx/3D/models/Object3DSFormat.ec index 4e8b972..e7a2ff4 100644 --- a/ecere/src/gfx/3D/models/Object3DSFormat.ec +++ b/ecere/src/gfx/3D/models/Object3DSFormat.ec @@ -1074,6 +1074,7 @@ static bool ReadMap(FileInfo * info, Material mat) { char * name; char location[MAX_LOCATION]; + char bumpName[MAX_LOCATION+5]; ReadASCIIZ(info->f, &name); @@ -1086,14 +1087,15 @@ static bool ReadMap(FileInfo * info, Material mat) strcpy(location, info->textureDirectory); PathCat(location, name); } + strcpy(bumpName, "BUMP:"); + strcat(bumpName, location); if(info->parent->chunkId == MAT_BUMPMAP) { // To avoid messing up the diffuse texture if same bitmap is specified by mistake... - char bumpName[MAX_LOCATION+5]; - strcpy(bumpName, "BUMP:"); - strcat(bumpName, location); - if(!mat.bumpMap) + if(displaySystem.GetTexture(location)) + mat.bumpMap = null; // Bad bump map if it's the same as the diffuse map... + else if(!mat.bumpMap) { mat.bumpMap = displaySystem.GetTexture(bumpName); if(!mat.bumpMap) @@ -1164,6 +1166,10 @@ static bool ReadMap(FileInfo * info, Material mat) if(!mat.baseMap) { mat.baseMap = Bitmap { }; + if(displaySystem.GetTexture(bumpName)) + { + mat.bumpMap = null; // Bad bump map if it's the same as the diffuse map... + } if(!mat.baseMap.Load(location, null, null) || !mat.baseMap.Convert(null, pixelFormat888, null) || !displaySystem.AddTexture(location, mat.baseMap)) -- 1.8.3.1