Skip to content

Commit

Permalink
support custom textures
Browse files Browse the repository at this point in the history
  • Loading branch information
malytomas committed Aug 26, 2024
1 parent 3a92d07 commit 2fb607a
Show file tree
Hide file tree
Showing 6 changed files with 12 additions and 4 deletions.
3 changes: 3 additions & 0 deletions sources/asset-processor/model.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -304,6 +304,9 @@ void processModel()
case MeshImportTextureType::Normal:
dsm.textureNames[CAGE_SHADER_TEXTURE_NORMAL] = n;
break;
case MeshImportTextureType::Custom:
dsm.textureNames[3] = n;
break;
default:
break;
}
Expand Down
1 change: 1 addition & 0 deletions sources/include/cage-core/meshImport.h
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ namespace cage
Albedo,
Special, // cage material texture: roughness, metallic, emission, mask
Normal,
Custom,
Opacity,
Roughness,
Metallic,
Expand Down
2 changes: 1 addition & 1 deletion sources/include/cage-engine/shaderConventions.h
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@
#define CAGE_SHADER_TEXTURE_ALBEDO_CUBE 6
#define CAGE_SHADER_TEXTURE_SPECIAL_CUBE 7
#define CAGE_SHADER_TEXTURE_NORMAL_CUBE 8
#define CAGE_SHADER_TEXTURE_USER 9
#define CAGE_SHADER_TEXTURE_CUSTOM 9
#define CAGE_SHADER_TEXTURE_SSAO 10
#define CAGE_SHADER_TEXTURE_DEPTH 11
#define CAGE_SHADER_TEXTURE_SHADOWMAP2D0 16
Expand Down
7 changes: 5 additions & 2 deletions sources/libcore/mesh/importAssimp.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,8 @@ namespace cage
return "special";
case MeshImportTextureType::Normal:
return "normal";
case MeshImportTextureType::Custom:
return "custom";
case MeshImportTextureType::Opacity:
return "opacity";
case MeshImportTextureType::Roughness:
Expand Down Expand Up @@ -1026,6 +1028,7 @@ namespace cage
loadTextureCage<MeshImportTextureType::Albedo>(pathBase, +ini, textures, part.textures);
loadTextureCage<MeshImportTextureType::Special>(pathBase, +ini, textures, part.textures);
loadTextureCage<MeshImportTextureType::Normal>(pathBase, +ini, textures, part.textures);
loadTextureCage<MeshImportTextureType::Custom>(pathBase, +ini, textures, part.textures);
part.textures = std::move(textures);

for (const String &n : ini->items("flags"))
Expand Down Expand Up @@ -1076,7 +1079,7 @@ namespace cage
part.boundingBox = Aabb::Universe();
continue;
}
CAGE_LOG_THROW(Stringizer() + "provided flag: '" + v + "'");
CAGE_LOG_THROW(Stringizer() + "provided flag: " + v);
CAGE_THROW_ERROR(Exception, "unknown material flag");
}

Expand Down Expand Up @@ -1258,7 +1261,7 @@ namespace cage
path = pathToAbs(path);

if (config.verbose)
CAGE_LOG(SeverityEnum::Info, "meshImport", Stringizer() + "looking for implicit material at '" + path + "'");
CAGE_LOG(SeverityEnum::Info, "meshImport", Stringizer() + "looking for implicit material at " + path);

if (pathIsFile(path))
loadMaterialCage(path, part);
Expand Down
1 change: 1 addition & 0 deletions sources/libcore/mesh/importConvert.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -344,6 +344,7 @@ namespace cage
case MeshImportTextureType::Special:
case MeshImportTextureType::Normal:
case MeshImportTextureType::Bump:
case MeshImportTextureType::Custom:
return false;
default:
return true;
Expand Down
2 changes: 1 addition & 1 deletion sources/libengine/graphics/renderPipeline.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -507,7 +507,7 @@ namespace cage
}
}
else
renderQueue->bind(textures[i], CAGE_SHADER_TEXTURE_USER);
renderQueue->bind(textures[i], CAGE_SHADER_TEXTURE_CUSTOM);
}
}
updateShaderRoutinesForTextures(textures, uniOptions);
Expand Down

0 comments on commit 2fb607a

Please sign in to comment.