fix: support shaders without textures (like flat), improves #184

Signed-off-by: Alexis Maiquez <almamu@almamu.com>
This commit is contained in:
Alexis Maiquez 2023-12-14 03:10:41 +01:00
parent 170af5ff7c
commit bd5e452d34
3 changed files with 10 additions and 5 deletions

View File

@ -76,7 +76,14 @@ CEffect* CEffect::fromJSON (json data, CUserSettingBoolean* visible, CObject* ob
if (textureNumber == 0) { if (textureNumber == 0) {
auto* image = object->as<CImage> (); auto* image = object->as<CImage> ();
texture = (*(*image->getMaterial ()->getPasses ().begin ())->getTextures ().begin ()); auto passTextures = (*image->getMaterial ()->getPasses ().begin ())->getTextures ();
if (passTextures.empty ()) {
// TODO: SET CHECKERBOARD TEXTURE AS DEFAULT IN THESE SITUATIONS
texture = "";
} else {
texture = *passTextures.begin ();
}
} else { } else {
texture = ""; texture = "";
} }

View File

@ -257,12 +257,10 @@ CFBO* CWallpaper::createFBO (const std::string& name, ITexture::TextureFormat fo
return fbo; return fbo;
} }
void CWallpaper::aliasFBO(const std::string& alias, CFBO* original) void CWallpaper::aliasFBO (const std::string& alias, CFBO* original) {
{
this->m_fbos.insert (std::make_pair (alias, original)); this->m_fbos.insert (std::make_pair (alias, original));
} }
const std::map<std::string, CFBO*>& CWallpaper::getFBOs () const { const std::map<std::string, CFBO*>& CWallpaper::getFBOs () const {
return this->m_fbos; return this->m_fbos;
} }

View File

@ -519,7 +519,7 @@ void CPass::setupUniforms () {
this->addUniform ("g_UserAlpha", this->m_material->getImage ()->getImage ()->getAlpha ()); this->addUniform ("g_UserAlpha", this->m_material->getImage ()->getImage ()->getAlpha ());
this->addUniform ("g_Alpha", this->m_material->getImage ()->getImage ()->getAlpha ()); this->addUniform ("g_Alpha", this->m_material->getImage ()->getImage ()->getAlpha ());
this->addUniform ("g_Color", this->m_material->getImage ()->getImage ()->getColor ()); this->addUniform ("g_Color", this->m_material->getImage ()->getImage ()->getColor ());
this->addUniform ("g_Color4", glm::vec4(this->m_material->getImage ()->getImage ()->getColor (), 1)); this->addUniform ("g_Color4", glm::vec4 (this->m_material->getImage ()->getImage ()->getColor (), 1));
// TODO: VALIDATE THAT G_COMPOSITECOLOR REALLY COMES FROM THIS ONE // TODO: VALIDATE THAT G_COMPOSITECOLOR REALLY COMES FROM THIS ONE
this->addUniform ("g_CompositeColor", this->m_material->getImage ()->getImage ()->getColor ()); this->addUniform ("g_CompositeColor", this->m_material->getImage ()->getImage ()->getColor ());
// add some external variables // add some external variables