More work on billboards to render them properly, see #2427
This commit is contained in:
parent
ea02f232dc
commit
0b5fdb6729
@ -65,10 +65,18 @@ MaterialManager::~MaterialManager()
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
Material* MaterialManager::getMaterialFor(video::ITexture* t,
|
||||
scene::IMeshBuffer *mb)
|
||||
scene::IMeshBuffer *mb)
|
||||
{
|
||||
return getMaterialFor(t, mb->getMaterial().MaterialType);
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
Material* MaterialManager::getMaterialFor(video::ITexture* t,
|
||||
video::E_MATERIAL_TYPE material_type)
|
||||
{
|
||||
if (t == NULL)
|
||||
return getDefaultMaterial(mb->getMaterial().MaterialType);
|
||||
return getDefaultMaterial(material_type);
|
||||
|
||||
core::stringc img_path = core::stringc(t->getName());
|
||||
const std::string image = StringUtils::getBasename(img_path.c_str());
|
||||
@ -94,7 +102,7 @@ Material* MaterialManager::getMaterialFor(video::ITexture* t,
|
||||
} // for i
|
||||
}
|
||||
|
||||
return getDefaultMaterial(mb->getMaterial().MaterialType);
|
||||
return getDefaultMaterial(material_type);
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
|
@ -59,6 +59,8 @@ public:
|
||||
void loadMaterial ();
|
||||
Material* getMaterialFor(video::ITexture* t,
|
||||
scene::IMeshBuffer *mb);
|
||||
Material* getMaterialFor(video::ITexture* t,
|
||||
video::E_MATERIAL_TYPE material_type);
|
||||
void setAllMaterialFlags(video::ITexture* t,
|
||||
scene::IMeshBuffer *mb);
|
||||
void adjustForFog(video::ITexture* t,
|
||||
|
@ -1554,8 +1554,6 @@ void IrrDriver::renderTransparent()
|
||||
ListAdditiveTransparent::getInstance());
|
||||
}
|
||||
|
||||
//glBlendFunc(GL_ONE, GL_ONE_MINUS_SRC_ALPHA);
|
||||
glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
|
||||
for (unsigned i = 0; i < BillBoardList::getInstance()->size(); i++)
|
||||
BillBoardList::getInstance()->at(i)->render();
|
||||
|
||||
|
@ -19,6 +19,8 @@
|
||||
|
||||
#include "graphics/glwrap.hpp"
|
||||
#include "graphics/irr_driver.hpp"
|
||||
#include "graphics/material.hpp"
|
||||
#include "graphics/material_manager.hpp"
|
||||
#include "graphics/shaders.hpp"
|
||||
#include "graphics/shared_gpu_objects.hpp"
|
||||
|
||||
@ -92,12 +94,20 @@ void STKBillboard::render()
|
||||
{
|
||||
if (irr_driver->getPhase() != TRANSPARENT_PASS)
|
||||
return;
|
||||
|
||||
core::vector3df pos = getAbsolutePosition();
|
||||
glBindVertexArray(billboardvao);
|
||||
video::ITexture *tex = Material.getTexture(0);
|
||||
if (!tex )
|
||||
return;
|
||||
|
||||
::Material* material = material_manager->getMaterialFor(tex,
|
||||
video::E_MATERIAL_TYPE::EMT_ONETEXTURE_BLEND);
|
||||
if (material->getShaderType() == Material::SHADERTYPE_ADDITIVE)
|
||||
glBlendFunc(GL_ONE, GL_ONE_MINUS_SRC_ALPHA);
|
||||
else
|
||||
glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
|
||||
|
||||
compressTexture(tex, true, true);
|
||||
GLuint texid = getTextureGLuint(tex);
|
||||
BillboardShader::getInstance()->use();
|
||||
|
Loading…
x
Reference in New Issue
Block a user