Add some fallback for legacy pipeline for SP
This commit is contained in:
parent
a3a00f70f8
commit
cbd7b3fd84
@ -247,19 +247,19 @@ void CPUParticleManager::drawAll()
|
||||
[](const std::pair<Material*, std::string>& a,
|
||||
const std::pair<Material*, std::string>& b)->bool
|
||||
{
|
||||
return a.first->getShaderType() > b.first->getShaderType();
|
||||
return a.first->getShaderName() > b.first->getShaderName();
|
||||
});
|
||||
|
||||
Material::ShaderType st = Material::SHADERTYPE_COUNT;
|
||||
std::string shader_name;
|
||||
for (auto& p : particle_drawn)
|
||||
{
|
||||
const bool flips = isFlipsMaterial(p.second);
|
||||
const float billboard = p.second.substr(0, 4) == "_bb_" ? 1.0f : 0.0f;
|
||||
Material* cur_mat = p.first;
|
||||
if (cur_mat->getShaderType() != st)
|
||||
if (cur_mat->getShaderName() != shader_name)
|
||||
{
|
||||
st = cur_mat->getShaderType();
|
||||
if (cur_mat->getShaderType() == Material::SHADERTYPE_ADDITIVE)
|
||||
shader_name = cur_mat->getShaderName();
|
||||
if (cur_mat->getShaderName() == "additive")
|
||||
{
|
||||
ParticleRenderer::getInstance()->use();
|
||||
glEnable(GL_DEPTH_TEST);
|
||||
@ -270,8 +270,7 @@ void CPUParticleManager::drawAll()
|
||||
glBlendEquation(GL_FUNC_ADD);
|
||||
glBlendFunc(GL_ONE, GL_ONE);
|
||||
}
|
||||
else if (cur_mat
|
||||
->getShaderType() == Material::SHADERTYPE_ALPHA_BLEND)
|
||||
else if (cur_mat->getShaderName() == "alphablend")
|
||||
{
|
||||
ParticleRenderer::getInstance()->use();
|
||||
glEnable(GL_DEPTH_TEST);
|
||||
@ -293,8 +292,8 @@ void CPUParticleManager::drawAll()
|
||||
}
|
||||
}
|
||||
|
||||
if (cur_mat->getShaderType() == Material::SHADERTYPE_ADDITIVE ||
|
||||
cur_mat->getShaderType() == Material::SHADERTYPE_ALPHA_BLEND)
|
||||
if (cur_mat->getShaderName() == "additive" ||
|
||||
cur_mat->getShaderName() == "alphablend")
|
||||
{
|
||||
ParticleRenderer::getInstance()->setTextureUnits
|
||||
(cur_mat->getTexture()->getOpenGLTextureName(),
|
||||
|
@ -1015,35 +1015,15 @@ void IrrDriver::setAllMaterialFlags(scene::IMesh *mesh) const
|
||||
{
|
||||
scene::IMeshBuffer *mb = mesh->getMeshBuffer(i);
|
||||
video::SMaterial &irr_material = mb->getMaterial();
|
||||
|
||||
// special case : for splatting, the main material is on layer 1.
|
||||
// it was done this way to provide a fallback for computers
|
||||
// where shaders are not supported
|
||||
video::ITexture* t2 = irr_material.getTexture(1);
|
||||
bool is_splatting = false;
|
||||
if (t2)
|
||||
video::ITexture* t = irr_material.getTexture(0);
|
||||
if (t)
|
||||
{
|
||||
Material* mat = material_manager->getMaterialFor(t2, mb);
|
||||
if (mat != NULL && mat->getShaderType() == Material::SHADERTYPE_SPLATTING)
|
||||
{
|
||||
material_manager->setAllMaterialFlags(t2, mb);
|
||||
is_splatting = true;
|
||||
}
|
||||
material_manager->setAllMaterialFlags(t, mb);
|
||||
}
|
||||
|
||||
if (!is_splatting)
|
||||
else
|
||||
{
|
||||
video::ITexture* t = irr_material.getTexture(0);
|
||||
if (t)
|
||||
{
|
||||
material_manager->setAllMaterialFlags(t, mb);
|
||||
}
|
||||
else
|
||||
{
|
||||
material_manager->setAllUntexturedMaterialFlags(mb);
|
||||
}
|
||||
material_manager->setAllUntexturedMaterialFlags(mb);
|
||||
}
|
||||
|
||||
} // for i<getMeshBufferCount()
|
||||
} // setAllMaterialFlags
|
||||
|
||||
@ -1209,17 +1189,17 @@ scene::ISceneNode *IrrDriver::addBillboard(const core::dimension2d< f32 > size,
|
||||
/*strip_path*/full_path, /*install*/false);
|
||||
|
||||
video::ITexture* tex = m->getTexture(true/*srgb*/,
|
||||
m->getShaderType() == Material::SHADERTYPE_ADDITIVE ||
|
||||
m->getShaderType() == Material::SHADERTYPE_ALPHA_BLEND ?
|
||||
m->getShaderName() == "additive" ||
|
||||
m->getShaderName() == "alphablend" ?
|
||||
true : false/*premul_alpha*/);
|
||||
|
||||
assert(node->getMaterialCount() > 0);
|
||||
node->setMaterialTexture(0, tex);
|
||||
if (!(m->getShaderType() == Material::SHADERTYPE_ADDITIVE ||
|
||||
m->getShaderType() == Material::SHADERTYPE_ALPHA_BLEND))
|
||||
if (!(m->getShaderName() == "additive" ||
|
||||
m->getShaderName() == "alphablend"))
|
||||
{
|
||||
// Alpha test for billboard otherwise
|
||||
m->setShaderType(Material::SHADERTYPE_ALPHA_TEST);
|
||||
m->setShaderName("alphatest");
|
||||
}
|
||||
m->setMaterialProperties(&(node->getMaterial(0)), NULL);
|
||||
return node;
|
||||
@ -1929,16 +1909,6 @@ bool IrrDriver::OnEvent(const irr::SEvent &event)
|
||||
return false;
|
||||
} // OnEvent
|
||||
|
||||
// ----------------------------------------------------------------------------
|
||||
bool IrrDriver::supportsSplatting()
|
||||
{
|
||||
#ifndef SERVER_ONLY
|
||||
return CVS->isGLSL();
|
||||
#else
|
||||
return false;
|
||||
#endif
|
||||
} // supportsSplatting
|
||||
|
||||
// ----------------------------------------------------------------------------
|
||||
scene::ISceneNode *IrrDriver::addLight(const core::vector3df &pos,
|
||||
float energy, float radius,
|
||||
|
@ -289,7 +289,6 @@ public:
|
||||
core::position2di getMouseLocation();
|
||||
|
||||
void printRenderStats();
|
||||
bool supportsSplatting();
|
||||
void requestScreenshot();
|
||||
class GPUTimer &getGPUTimer(unsigned);
|
||||
|
||||
|
@ -56,7 +56,6 @@ const unsigned int VCLAMP = 2;
|
||||
Material::Material(const XMLNode *node, bool deprecated)
|
||||
{
|
||||
m_shader_name = "solid";
|
||||
m_shader_type = SHADERTYPE_SOLID;
|
||||
m_deprecated = deprecated;
|
||||
m_installed = false;
|
||||
|
||||
@ -194,41 +193,8 @@ Material::Material(const XMLNode *node, bool deprecated)
|
||||
node->get("normal-map", &normal_map_tex);
|
||||
if (node->get("shader", &s))
|
||||
{
|
||||
if (s == "solid")
|
||||
if (s == "splatting")
|
||||
{
|
||||
m_shader_type = SHADERTYPE_SOLID;
|
||||
}
|
||||
else if (s == "unlit")
|
||||
{
|
||||
m_shader_type = SHADERTYPE_SOLID_UNLIT;
|
||||
}
|
||||
else if (s == "additive")
|
||||
{
|
||||
m_shader_type = SHADERTYPE_ADDITIVE;
|
||||
}
|
||||
else if (s == "alphatest")
|
||||
{
|
||||
m_shader_type = SHADERTYPE_ALPHA_TEST;
|
||||
}
|
||||
else if (s == "alphablend")
|
||||
{
|
||||
m_shader_type = SHADERTYPE_ALPHA_BLEND;
|
||||
}
|
||||
else if (s == "spheremap")
|
||||
{
|
||||
m_shader_type = SHADERTYPE_SPHERE_MAP;
|
||||
}
|
||||
else if (s == "water_shader")
|
||||
{
|
||||
m_shader_type = SHADERTYPE_WATER;
|
||||
}
|
||||
else if (s == "grass")
|
||||
{
|
||||
m_shader_type = SHADERTYPE_VEGETATION;
|
||||
}
|
||||
else if (s == "splatting")
|
||||
{
|
||||
m_shader_type = SHADERTYPE_SPLATTING;
|
||||
node->get("splatting-texture-1", &m_sampler_path[2]);
|
||||
node->get("splatting-texture-2", &m_sampler_path[3]);
|
||||
node->get("splatting-texture-3", &m_sampler_path[4]);
|
||||
@ -244,7 +210,6 @@ Material::Material(const XMLNode *node, bool deprecated)
|
||||
if (b)
|
||||
{
|
||||
m_shader_name = "alphablend";
|
||||
m_shader_type = SHADERTYPE_ADDITIVE;
|
||||
}
|
||||
|
||||
b = false;
|
||||
@ -252,7 +217,6 @@ Material::Material(const XMLNode *node, bool deprecated)
|
||||
if (b)
|
||||
{
|
||||
m_shader_name = "alphatest";
|
||||
m_shader_type = SHADERTYPE_ALPHA_TEST;
|
||||
}
|
||||
|
||||
//node->get("lightmap", &m_lightmap);
|
||||
@ -262,7 +226,6 @@ Material::Material(const XMLNode *node, bool deprecated)
|
||||
if (b)
|
||||
{
|
||||
m_shader_name = "alphablend";
|
||||
m_shader_type = SHADERTYPE_ALPHA_BLEND;
|
||||
}
|
||||
|
||||
b = true;
|
||||
@ -270,36 +233,24 @@ Material::Material(const XMLNode *node, bool deprecated)
|
||||
if (!b)
|
||||
{
|
||||
m_shader_name = "unlit";
|
||||
m_shader_type = SHADERTYPE_SOLID_UNLIT;
|
||||
}
|
||||
|
||||
b = false;
|
||||
node->get("smooth-reflection", &b);
|
||||
if (b)
|
||||
m_shader_type = SHADERTYPE_SPHERE_MAP;
|
||||
|
||||
|
||||
if (node->get("compositing", &s))
|
||||
{
|
||||
if (s == "blend")
|
||||
{
|
||||
m_shader_name = "alphablend";
|
||||
m_shader_type = SHADERTYPE_ALPHA_BLEND;
|
||||
}
|
||||
else if (s == "test")
|
||||
{
|
||||
m_shader_name = "alphatest";
|
||||
m_shader_type = SHADERTYPE_ALPHA_TEST;
|
||||
}
|
||||
else if (s == "additive")
|
||||
{
|
||||
m_shader_name = "additive";
|
||||
m_shader_type = SHADERTYPE_ADDITIVE;
|
||||
}
|
||||
else if (s == "coverage")
|
||||
{
|
||||
m_shader_name = "alphatest";
|
||||
m_shader_type = SHADERTYPE_ALPHA_TEST;
|
||||
}
|
||||
else if (s != "none")
|
||||
Log::warn("material", "Unknown compositing mode '%s'", s.c_str());
|
||||
@ -308,26 +259,12 @@ Material::Material(const XMLNode *node, bool deprecated)
|
||||
s = "";
|
||||
node->get("graphical-effect", &s);
|
||||
|
||||
if (s == "grass")
|
||||
if (s == "normal_map")
|
||||
{
|
||||
m_shader_type = SHADERTYPE_VEGETATION;
|
||||
}
|
||||
else if (s == "water_shader")
|
||||
{
|
||||
m_shader_type = SHADERTYPE_WATER;
|
||||
}
|
||||
else if (s == "normal_map")
|
||||
{
|
||||
m_shader_type = SHADERTYPE_SOLID;
|
||||
node->get("normal-map", &normal_map_tex);
|
||||
}
|
||||
else if (s == "spheremap")
|
||||
{
|
||||
m_shader_type = SHADERTYPE_SPHERE_MAP;
|
||||
}
|
||||
else if (s == "splatting")
|
||||
{
|
||||
m_shader_type = SHADERTYPE_SPLATTING;
|
||||
node->get("splatting-texture-1", &m_sampler_path[2]);
|
||||
node->get("splatting-texture-2", &m_sampler_path[3]);
|
||||
node->get("splatting-texture-3", &m_sampler_path[4]);
|
||||
@ -358,21 +295,6 @@ Material::Material(const XMLNode *node, bool deprecated)
|
||||
"Could not find normal map image in materials.xml");
|
||||
}
|
||||
}
|
||||
|
||||
bool sphere_map = false;
|
||||
node->get("sphere", &sphere_map);
|
||||
if (sphere_map)
|
||||
{
|
||||
m_shader_type = SHADERTYPE_SPHERE_MAP;
|
||||
}
|
||||
|
||||
bool water_shader = false;
|
||||
node->get("water-shader", &water_shader);
|
||||
if (water_shader)
|
||||
{
|
||||
m_shader_type = SHADERTYPE_WATER;
|
||||
}
|
||||
|
||||
// ---- End backwards compatibility
|
||||
}
|
||||
|
||||
@ -578,7 +500,6 @@ void Material::init()
|
||||
{
|
||||
m_texture = NULL;
|
||||
m_clamp_tex = 0;
|
||||
m_shader_type = SHADERTYPE_SOLID;
|
||||
m_high_tire_adhesion = false;
|
||||
m_below_surface = false;
|
||||
m_falling_effect = false;
|
||||
@ -897,7 +818,7 @@ void Material::setMaterialProperties(video::SMaterial *m, scene::IMeshBuffer* m
|
||||
{
|
||||
m->MaterialType = video::EMT_TRANSPARENT_ALPHA_CHANNEL_REF;
|
||||
}
|
||||
else if (m_shader_name == "alphablend")
|
||||
else if (m_shader_name == "alphablend" || m_shader_name == "displace")
|
||||
{
|
||||
// EMT_TRANSPARENT_ALPHA_CHANNEL doesn't include vertex color alpha into
|
||||
// account, which messes up fading in/out effects. So we use the more
|
||||
@ -938,7 +859,7 @@ void Material::setMaterialProperties(video::SMaterial *m, scene::IMeshBuffer* m
|
||||
#endif
|
||||
}
|
||||
|
||||
if (m_shader_name == "alphablend" || m_shader_name == "additive")
|
||||
if (isTransparent())
|
||||
{
|
||||
m->ZWriteEnable = false;
|
||||
}
|
||||
|
@ -46,23 +46,6 @@ class ParticleKind;
|
||||
class Material : public NoCopy
|
||||
{
|
||||
public:
|
||||
enum ShaderType
|
||||
{
|
||||
SHADERTYPE_SOLID = 0,
|
||||
SHADERTYPE_ALPHA_TEST,
|
||||
SHADERTYPE_ALPHA_BLEND,
|
||||
SHADERTYPE_ADDITIVE,
|
||||
SHADERTYPE_SOLID_UNLIT,
|
||||
/** Effect that makes grass wave as in the wind */
|
||||
SHADERTYPE_VEGETATION,
|
||||
SHADERTYPE_WATER,
|
||||
SHADERTYPE_SPHERE_MAP,
|
||||
SHADERTYPE_NORMAL_MAP,
|
||||
SHADERTYPE_DETAIL_MAP,
|
||||
SHADERTYPE_SPLATTING,
|
||||
SHADERTYPE_COUNT,
|
||||
};
|
||||
|
||||
enum ParticleConditions
|
||||
{
|
||||
EMIT_ON_DRIVE = 0,
|
||||
@ -93,8 +76,6 @@ private:
|
||||
* "" if no special sfx exists. */
|
||||
std::string m_sfx_name;
|
||||
|
||||
ShaderType m_shader_type;
|
||||
|
||||
/** Either ' ' (no mirroring), 'U' or 'V' if a texture needs to be
|
||||
* mirrored when driving in reverse. Typically used for arrows indicating
|
||||
* the direction. */
|
||||
@ -293,9 +274,8 @@ public:
|
||||
// ------------------------------------------------------------------------
|
||||
bool isTransparent () const
|
||||
{
|
||||
return m_shader_type == SHADERTYPE_ADDITIVE ||
|
||||
m_shader_type == SHADERTYPE_ALPHA_BLEND ||
|
||||
m_shader_type == SHADERTYPE_ALPHA_TEST;
|
||||
return m_shader_name == "additive" || m_shader_name == "alphablend" ||
|
||||
m_shader_name == "displace";
|
||||
}
|
||||
|
||||
// ------------------------------------------------------------------------
|
||||
@ -362,9 +342,6 @@ public:
|
||||
* on lower speeds. A negative value indicates no minimum speed. */
|
||||
float getZipperMinSpeed() const { return m_zipper_min_speed; }
|
||||
// ------------------------------------------------------------------------
|
||||
ShaderType getShaderType() const { return m_shader_type; }
|
||||
void setShaderType(ShaderType st) { m_shader_type = st; }
|
||||
// ------------------------------------------------------------------------
|
||||
/** True if this texture should have the U coordinates mirrored. */
|
||||
char getMirrorAxisInReverse() const { return m_mirror_axis_when_reverse; }
|
||||
// ------------------------------------------------------------------------
|
||||
@ -373,6 +350,8 @@ public:
|
||||
const std::string& getColorizationMask() const
|
||||
{ return m_colorization_mask; }
|
||||
// ------------------------------------------------------------------------
|
||||
void setShaderName(const std::string& name) { m_shader_name = name; }
|
||||
// ------------------------------------------------------------------------
|
||||
const std::string& getShaderName() const { return m_shader_name; }
|
||||
// ------------------------------------------------------------------------
|
||||
/* This is used for finding correct material for spm*/
|
||||
|
@ -232,8 +232,8 @@ Material* ParticleKind::getMaterial() const
|
||||
Material* material = material_manager->getMaterial(m_material_file);
|
||||
if (material == NULL ||
|
||||
material->getTexture(true/*srgb*/,
|
||||
material->getShaderType() == Material::SHADERTYPE_ADDITIVE ||
|
||||
material->getShaderType() == Material::SHADERTYPE_ALPHA_BLEND ?
|
||||
material->getShaderName() == "additive" ||
|
||||
material->getShaderName() == "alphablend" ?
|
||||
true : false/*premul_alpha*/) == NULL)
|
||||
{
|
||||
throw std::runtime_error("[ParticleKind] Cannot locate file " + m_material_file);
|
||||
|
Loading…
Reference in New Issue
Block a user