Added default __white material to standard assets bundle.
Assigned default __white material to all standard asset meshes. Enabled models to be loaded prior to their referenced materials. Refactored ObjectShader glsl for Vulkan use.
This commit is contained in:
@@ -344,7 +344,7 @@ void KRMaterial::bind(KRNode::RenderInfo& ri, ModelFormat modelFormat, __uint32_
|
||||
bool bAlphaBlend = (m_alpha_mode == KRMATERIAL_ALPHA_MODE_BLENDONESIDE) || (m_alpha_mode == KRMATERIAL_ALPHA_MODE_BLENDTWOSIDE);
|
||||
|
||||
PipelineInfo info{};
|
||||
std::string shader_name("ObjectShader");
|
||||
std::string shader_name("object");
|
||||
info.shader_name = &shader_name;
|
||||
info.pCamera = ri.camera;
|
||||
info.point_lights = &ri.point_lights;
|
||||
|
||||
@@ -181,28 +181,31 @@ void KRMesh::loadPack(Block* data)
|
||||
|
||||
void KRMesh::getMaterials()
|
||||
{
|
||||
if (m_materials.size() == 0) {
|
||||
if (m_materials.size() != 0) {
|
||||
return;
|
||||
}
|
||||
|
||||
for (std::vector<KRMesh::Submesh>::iterator itr = m_submeshes.begin(); itr != m_submeshes.end(); itr++) {
|
||||
const char* szMaterialName = (*itr).szMaterialName;
|
||||
KRMaterial* pMaterial = nullptr;
|
||||
if (*szMaterialName != '\0') {
|
||||
pMaterial = getContext().getMaterialManager()->getMaterial(szMaterialName);
|
||||
}
|
||||
m_materials.push_back(pMaterial);
|
||||
if (pMaterial) {
|
||||
m_uniqueMaterials.insert(pMaterial);
|
||||
} else if (*szMaterialName != '\0') {
|
||||
KRContext::Log(KRContext::LOG_LEVEL_WARNING, "Missing material: %s", szMaterialName);
|
||||
}
|
||||
for (std::vector<KRMesh::Submesh>::iterator itr = m_submeshes.begin(); itr != m_submeshes.end(); itr++) {
|
||||
const char* szMaterialName = (*itr).szMaterialName;
|
||||
KRMaterial* pMaterial = nullptr;
|
||||
if (*szMaterialName != '\0') {
|
||||
pMaterial = getContext().getMaterialManager()->getMaterial(szMaterialName);
|
||||
}
|
||||
m_materials.push_back(pMaterial);
|
||||
if (pMaterial) {
|
||||
m_uniqueMaterials.insert(pMaterial);
|
||||
} else if (*szMaterialName != '\0') {
|
||||
KRContext::Log(KRContext::LOG_LEVEL_WARNING, "Missing material: %s", szMaterialName);
|
||||
m_materials.clear();
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
m_hasTransparency = false;
|
||||
for (std::set<KRMaterial*>::iterator mat_itr = m_uniqueMaterials.begin(); mat_itr != m_uniqueMaterials.end(); mat_itr++) {
|
||||
if ((*mat_itr)->isTransparent()) {
|
||||
m_hasTransparency = true;
|
||||
break;
|
||||
}
|
||||
m_hasTransparency = false;
|
||||
for (std::set<KRMaterial*>::iterator mat_itr = m_uniqueMaterials.begin(); mat_itr != m_uniqueMaterials.end(); mat_itr++) {
|
||||
if ((*mat_itr)->isTransparent()) {
|
||||
m_hasTransparency = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -57,7 +57,7 @@ KRMeshCube::KRMeshCube(KRContext& context) : KRMesh(context, "__cube")
|
||||
|
||||
mi.submesh_starts.push_back(0);
|
||||
mi.submesh_lengths.push_back((int)mi.vertices.size());
|
||||
mi.material_names.push_back("");
|
||||
mi.material_names.push_back("__white");
|
||||
mi.format = ModelFormat::KRENGINE_MODEL_FORMAT_STRIP;
|
||||
|
||||
|
||||
|
||||
@@ -52,7 +52,7 @@ KRMeshQuad::KRMeshQuad(KRContext& context) : KRMesh(context, "__quad")
|
||||
|
||||
mi.submesh_starts.push_back(0);
|
||||
mi.submesh_lengths.push_back((int)mi.vertices.size());
|
||||
mi.material_names.push_back("");
|
||||
mi.material_names.push_back("__white");
|
||||
mi.format = ModelFormat::KRENGINE_MODEL_FORMAT_STRIP;
|
||||
|
||||
LoadData(mi, true, true);
|
||||
|
||||
@@ -110,7 +110,7 @@ KRMeshSphere::KRMeshSphere(KRContext& context) : KRMesh(context, "__sphere")
|
||||
|
||||
mi.submesh_starts.push_back(0);
|
||||
mi.submesh_lengths.push_back((int)mi.vertices.size());
|
||||
mi.material_names.push_back("");
|
||||
mi.material_names.push_back("__white");
|
||||
|
||||
|
||||
mi.format = ModelFormat::KRENGINE_MODEL_FORMAT_TRIANGLES;
|
||||
|
||||
Reference in New Issue
Block a user