1
0
mirror of https://github.com/luanti-org/luanti.git synced 2025-10-13 00:25:19 +02:00

Drop fixed pipeline support code (#15421)

OpenGL 2.0 is now mandatory.
This commit is contained in:
sfan5
2024-11-13 14:24:01 +01:00
committed by GitHub
parent 0fde9ab7e8
commit 794aea8e92
35 changed files with 117 additions and 411 deletions

View File

@@ -349,8 +349,6 @@ bool GenericCAO::collideWithObjects() const
void GenericCAO::initialize(const std::string &data)
{
processInitData(data);
m_enable_shaders = g_settings->getBool("enable_shaders");
}
void GenericCAO::processInitData(const std::string &data)
@@ -603,7 +601,7 @@ void GenericCAO::addToScene(ITextureSource *tsrc, scene::ISceneManager *smgr)
m_material_type_param = 0.5f; // May cut off alpha < 128 depending on m_material_type
if (m_enable_shaders) {
{
IShaderSource *shader_source = m_client->getShaderSource();
MaterialType material_type;
@@ -616,13 +614,6 @@ void GenericCAO::addToScene(ITextureSource *tsrc, scene::ISceneManager *smgr)
u32 shader_id = shader_source->getShader("object_shader", material_type, NDT_NORMAL);
m_material_type = shader_source->getShaderInfo(shader_id).material;
} else {
if (m_prop.use_texture_alpha) {
m_material_type = video::EMT_TRANSPARENT_ALPHA_CHANNEL;
m_material_type_param = 1.0f / 256.f; // minimal alpha for texture rendering
} else {
m_material_type = video::EMT_TRANSPARENT_ALPHA_CHANNEL_REF;
}
}
auto grabMatrixNode = [this] {
@@ -688,9 +679,7 @@ void GenericCAO::addToScene(ITextureSource *tsrc, scene::ISceneManager *smgr)
// Set material
setMaterial(buf->getMaterial());
if (m_enable_shaders) {
buf->getMaterial().ColorParam = c;
}
buf->getMaterial().ColorParam = c;
// Add to mesh
mesh->addMeshBuffer(buf);
@@ -714,9 +703,7 @@ void GenericCAO::addToScene(ITextureSource *tsrc, scene::ISceneManager *smgr)
// Set material
setMaterial(buf->getMaterial());
if (m_enable_shaders) {
buf->getMaterial().ColorParam = c;
}
buf->getMaterial().ColorParam = c;
// Add to mesh
mesh->addMeshBuffer(buf);
@@ -741,8 +728,7 @@ void GenericCAO::addToScene(ITextureSource *tsrc, scene::ISceneManager *smgr)
});
} else if (m_prop.visual == "mesh") {
grabMatrixNode();
// can't cache mesh if shaders disabled, since we modify vertices
scene::IAnimatedMesh *mesh = m_client->getMesh(m_prop.mesh, m_enable_shaders);
scene::IAnimatedMesh *mesh = m_client->getMesh(m_prop.mesh, true);
if (mesh) {
if (!checkMeshNormals(mesh)) {
infostream << "GenericCAO: recalculating normals for mesh "
@@ -795,7 +781,7 @@ void GenericCAO::addToScene(ITextureSource *tsrc, scene::ISceneManager *smgr)
/* Set VBO hint */
// wieldmesh sets its own hint, no need to handle it
if (m_enable_shaders && (m_meshnode || m_animated_meshnode)) {
if (m_meshnode || m_animated_meshnode) {
// sprite uses vertex animation
if (m_meshnode && m_prop.visual != "upright_sprite")
m_meshnode->getMesh()->setHardwareMappingHint(scene::EHM_STATIC);
@@ -893,10 +879,7 @@ void GenericCAO::updateLight(u32 day_night_ratio)
// Encode light into color, adding a small boost
// based on the entity glow.
if (m_enable_shaders)
light = encode_light(light_at_pos, m_prop.glow);
else
final_color_blend(&light, light_at_pos, day_night_ratio);
light = encode_light(light_at_pos, m_prop.glow);
if (light != m_last_light) {
m_last_light = light;
@@ -912,22 +895,11 @@ void GenericCAO::setNodeLight(const video::SColor &light_color)
return;
}
if (m_enable_shaders) {
{
auto *node = getSceneNode();
if (!node)
return;
setColorParam(node, light_color);
} else {
// TODO refactor vertex colors to be separate from the other vertex attributes
// instead of mutating meshes / buffers for everyone via setMeshColor.
// (Note: There are a couple more places here where setMeshColor is used.)
if (m_meshnode) {
setMeshColor(m_meshnode->getMesh(), light_color);
} else if (m_animated_meshnode) {
setMeshColor(m_animated_meshnode->getMesh(), light_color);
} else if (m_spritenode) {
m_spritenode->setColor(light_color);
}
}
}