1
0
Fork 0
mirror of https://github.com/luanti-org/luanti.git synced 2025-08-21 18:11:11 +00: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
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
35 changed files with 117 additions and 411 deletions

View file

@ -33,16 +33,13 @@ Clouds::Clouds(scene::ISceneManager* mgr, IShaderSource *ssrc,
m_seed(seed)
{
assert(ssrc);
m_enable_shaders = g_settings->getBool("enable_shaders");
m_material.BackfaceCulling = true;
m_material.FogEnable = true;
m_material.AntiAliasing = video::EAAM_SIMPLE;
if (m_enable_shaders) {
{
auto sid = ssrc->getShader("cloud_shader", TILE_MATERIAL_ALPHA);
m_material.MaterialType = ssrc->getShaderInfo(sid).material;
} else {
m_material.MaterialType = video::EMT_TRANSPARENT_ALPHA_CHANNEL;
}
m_params = SkyboxDefaults::getCloudDefaults();
@ -119,15 +116,11 @@ void Clouds::updateMesh()
// Colors with primitive shading
video::SColorf c_top_f(m_color);
video::SColorf c_side_1_f(m_color);
video::SColorf c_side_2_f(m_color);
video::SColorf c_bottom_f(m_color);
if (m_enable_shaders) {
// shader mixes the base color, set via ColorParam
c_top_f = c_side_1_f = c_side_2_f = c_bottom_f = video::SColorf(1.0f, 1.0f, 1.0f, 1.0f);
}
video::SColorf shadow = m_params.color_shadow;
video::SColorf c_top_f(1, 1, 1, 1);
video::SColorf c_side_1_f(1, 1, 1, 1);
video::SColorf c_side_2_f(1, 1, 1, 1);
video::SColorf c_bottom_f(1, 1, 1, 1);
const video::SColorf shadow = m_params.color_shadow;
c_side_1_f.r *= shadow.r * 0.25f + 0.75f;
c_side_1_f.g *= shadow.g * 0.25f + 0.75f;
@ -385,8 +378,7 @@ void Clouds::render()
}
m_material.BackfaceCulling = is3D();
if (m_enable_shaders)
m_material.ColorParam = m_color.toSColor();
m_material.ColorParam = m_color.toSColor();
driver->setTransform(video::ETS_WORLD, AbsoluteTransformation);
driver->setMaterial(m_material);

View file

@ -169,7 +169,7 @@ private:
v3s16 m_camera_offset;
bool m_camera_inside_cloud = false;
bool m_enable_shaders, m_enable_3d;
bool m_enable_3d;
video::SColorf m_color = video::SColorf(1.0f, 1.0f, 1.0f, 1.0f);
CloudParams m_params;
};

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);
}
}
}

View file

@ -116,8 +116,6 @@ private:
// Material
video::E_MATERIAL_TYPE m_material_type;
f32 m_material_type_param;
// Settings
bool m_enable_shaders = false;
bool visualExpiryRequired(const ObjectProperties &newprops) const;

View file

@ -67,8 +67,6 @@ MapblockMeshGenerator::MapblockMeshGenerator(MeshMakeData *input, MeshCollector
nodedef(data->nodedef),
meshmanip(mm),
blockpos_nodes(data->m_blockpos * MAP_BLOCKSIZE),
enable_mesh_cache(g_settings->getBool("enable_mesh_cache") &&
!data->m_smooth_lighting), // Mesh cache is not supported with smooth lighting
smooth_liquids(g_settings->getBool("enable_water_reflections"))
{
}
@ -1657,31 +1655,27 @@ void MapblockMeshGenerator::drawMeshNode()
} else if (cur_node.f->param_type_2 == CPT2_WALLMOUNTED ||
cur_node.f->param_type_2 == CPT2_COLORED_WALLMOUNTED) {
// Convert wallmounted to 6dfacedir.
// When cache enabled, it is already converted.
facedir = cur_node.n.getWallMounted(nodedef);
if (!enable_mesh_cache)
facedir = wallmounted_to_facedir[facedir];
facedir = wallmounted_to_facedir[facedir];
} else if (cur_node.f->param_type_2 == CPT2_DEGROTATE ||
cur_node.f->param_type_2 == CPT2_COLORED_DEGROTATE) {
degrotate = cur_node.n.getDegRotate(nodedef);
}
if (!data->m_smooth_lighting && cur_node.f->mesh_ptr[facedir] && !degrotate) {
// use cached meshes
private_mesh = false;
mesh = cur_node.f->mesh_ptr[facedir];
} else if (cur_node.f->mesh_ptr[0]) {
// no cache, clone and rotate mesh
if (cur_node.f->mesh_ptr) {
// clone and rotate mesh
private_mesh = true;
mesh = cloneMesh(cur_node.f->mesh_ptr[0]);
mesh = cloneMesh(cur_node.f->mesh_ptr);
if (facedir)
rotateMeshBy6dFacedir(mesh, facedir);
else if (degrotate)
rotateMeshXZby(mesh, 1.5f * degrotate);
recalculateBoundingBox(mesh);
meshmanip->recalculateNormals(mesh, true, false);
} else
} else {
warningstream << "drawMeshNode(): missing mesh" << std::endl;
return;
}
int mesh_buffer_count = mesh->getMeshBufferCount();
for (int j = 0; j < mesh_buffer_count; j++) {

View file

@ -60,9 +60,6 @@ private:
const v3s16 blockpos_nodes;
// options
const bool enable_mesh_cache;
// current node
struct {
v3s16 p;

View file

@ -84,15 +84,11 @@ Hud::Hud(Client *client, LocalPlayer *player,
}
// Initialize m_selection_material
if (g_settings->getBool("enable_shaders")) {
IShaderSource *shdrsrc = client->getShaderSource();
IShaderSource *shdrsrc = client->getShaderSource();
{
auto shader_id = shdrsrc->getShader(
m_mode == HIGHLIGHT_HALO ? "selection_shader" : "default_shader", TILE_MATERIAL_ALPHA);
m_selection_material.MaterialType = shdrsrc->getShaderInfo(shader_id).material;
} else {
m_selection_material.MaterialType = video::EMT_TRANSPARENT_ALPHA_CHANNEL;
}
if (m_mode == HIGHLIGHT_BOX) {
@ -106,12 +102,9 @@ Hud::Hud(Client *client, LocalPlayer *player,
}
// Initialize m_block_bounds_material
if (g_settings->getBool("enable_shaders")) {
IShaderSource *shdrsrc = client->getShaderSource();
{
auto shader_id = shdrsrc->getShader("default_shader", TILE_MATERIAL_ALPHA);
m_block_bounds_material.MaterialType = shdrsrc->getShaderInfo(shader_id).material;
} else {
m_block_bounds_material.MaterialType = video::EMT_TRANSPARENT_ALPHA_CHANNEL;
}
m_block_bounds_material.Thickness =
rangelim(g_settings->getS16("selectionbox_width"), 1, 5);
@ -1171,6 +1164,7 @@ void drawItemStack(
auto &p = imesh->buffer_colors[j];
p.applyOverride(c);
// TODO: could be moved to a shader
if (p.needColorize(c)) {
buf->setDirty(scene::EBT_VERTEX);
if (imesh->needs_shading)

View file

@ -25,10 +25,9 @@
MeshMakeData
*/
MeshMakeData::MeshMakeData(const NodeDefManager *ndef, u16 side_length, bool use_shaders):
MeshMakeData::MeshMakeData(const NodeDefManager *ndef, u16 side_length):
side_length(side_length),
nodedef(ndef),
m_use_shaders(use_shaders)
nodedef(ndef)
{}
void MeshMakeData::fillBlockDataBegin(const v3s16 &blockpos)
@ -267,7 +266,8 @@ u16 getSmoothLightTransparent(const v3s16 &p, const v3s16 &corner, MeshMakeData
return getSmoothLightCombined(p, dirs, data);
}
void get_sunlight_color(video::SColorf *sunlight, u32 daynight_ratio){
void get_sunlight_color(video::SColorf *sunlight, u32 daynight_ratio)
{
f32 rg = daynight_ratio / 1000.0f - 0.04f;
f32 b = (0.98f * daynight_ratio) / 1000.0f + 0.078f;
sunlight->r = rg;
@ -594,14 +594,12 @@ MapBlockMesh::MapBlockMesh(Client *client, MeshMakeData *data, v3s16 camera_offs
m_shdrsrc(client->getShaderSource()),
m_bounding_sphere_center((data->side_length * 0.5f - 0.5f) * BS),
m_animation_force_timer(0), // force initial animation
m_last_crack(-1),
m_last_daynight_ratio((u32) -1)
m_last_crack(-1)
{
ZoneScoped;
for (auto &m : m_mesh)
m = make_irr<scene::SMesh>();
m_enable_shaders = data->m_use_shaders;
auto mesh_grid = client->getMeshGrid();
v3s16 bp = data->m_blockpos;
@ -695,30 +693,6 @@ MapBlockMesh::MapBlockMesh(Client *client, MeshMakeData *data, v3s16 camera_offs
p.layer.texture = (*p.layer.frames)[0].texture;
}
if (!m_enable_shaders) {
// Extract colors for day-night animation
// Dummy sunlight to handle non-sunlit areas
video::SColorf sunlight;
get_sunlight_color(&sunlight, 0);
std::map<u32, video::SColor> colors;
const u32 vertex_count = p.vertices.size();
for (u32 j = 0; j < vertex_count; j++) {
video::SColor *vc = &p.vertices[j].Color;
video::SColor copy = *vc;
if (vc->getAlpha() == 0) // No sunlight - no need to animate
final_color_blend(vc, copy, sunlight); // Finalize color
else // Record color to animate
colors[j] = copy;
// The sunlight ratio has been stored,
// delete alpha (for the final rendering).
vc->setAlpha(255);
}
if (!colors.empty())
m_daynight_diffs[{layer, i}] = std::move(colors);
}
// Create material
video::SMaterial material;
material.BackfaceCulling = true;
@ -729,12 +703,10 @@ MapBlockMesh::MapBlockMesh(Client *client, MeshMakeData *data, v3s16 camera_offs
tex.MagFilter = video::ETMAGF_NEAREST;
});
if (m_enable_shaders) {
{
material.MaterialType = m_shdrsrc->getShaderInfo(
p.layer.shader_id).material;
p.layer.applyMaterialOptionsWithShaders(material);
} else {
p.layer.applyMaterialOptions(material);
}
scene::SMeshBuffer *buf = new scene::SMeshBuffer();
@ -771,7 +743,6 @@ MapBlockMesh::MapBlockMesh(Client *client, MeshMakeData *data, v3s16 camera_offs
// Check if animation is required for this mesh
m_has_animation =
!m_crack_materials.empty() ||
!m_daynight_diffs.empty() ||
!m_animation_info.empty();
}
@ -844,24 +815,6 @@ bool MapBlockMesh::animate(bool faraway, float time, int crack,
buf->getMaterial().setTexture(0, frame.texture);
}
// Day-night transition
if (!m_enable_shaders && (daynight_ratio != m_last_daynight_ratio)) {
video::SColorf day_color;
get_sunlight_color(&day_color, daynight_ratio);
for (auto &daynight_diff : m_daynight_diffs) {
auto *mesh = m_mesh[daynight_diff.first.first].get();
mesh->setDirty(scene::EBT_VERTEX); // force reload to VBO
scene::IMeshBuffer *buf = mesh->
getMeshBuffer(daynight_diff.first.second);
video::S3DVertex *vertices = (video::S3DVertex *)buf->getVertices();
for (const auto &j : daynight_diff.second)
final_color_blend(&(vertices[j.first].Color), j.second,
day_color);
}
m_last_daynight_ratio = daynight_ratio;
}
return true;
}

View file

@ -35,9 +35,8 @@ struct MeshMakeData
u16 side_length;
const NodeDefManager *nodedef;
bool m_use_shaders;
MeshMakeData(const NodeDefManager *ndef, u16 side_length, bool use_shaders);
MeshMakeData(const NodeDefManager *ndef, u16 side_length);
/*
Copy block data manually (to allow optimizations by the caller)
@ -235,8 +234,6 @@ private:
f32 m_bounding_radius;
v3f m_bounding_sphere_center;
bool m_enable_shaders;
// Must animate() be called before rendering?
bool m_has_animation;
int m_animation_force_timer;
@ -252,14 +249,6 @@ private:
// Keys are pairs of (mesh index, buffer index in the mesh)
std::map<std::pair<u8, u32>, AnimationInfo> m_animation_info;
// Animation info: day/night transitions
// Last daynight_ratio value passed to animate()
u32 m_last_daynight_ratio;
// For each mesh and mesh buffer, stores pre-baked colors
// of sunlit vertices
// Keys are pairs of (mesh index, buffer index in the mesh)
std::map<std::pair<u8, u32>, std::map<u32, video::SColor > > m_daynight_diffs;
// list of all semitransparent triangles in the mapblock
std::vector<MeshTriangle> m_transparent_triangles;
// Binary Space Partitioning tree for the block

View file

@ -39,7 +39,6 @@ QueuedMeshUpdate::~QueuedMeshUpdate()
MeshUpdateQueue::MeshUpdateQueue(Client *client):
m_client(client)
{
m_cache_enable_shaders = g_settings->getBool("enable_shaders");
m_cache_smooth_lighting = g_settings->getBool("smooth_lighting");
}
@ -177,7 +176,7 @@ void MeshUpdateQueue::done(v3s16 pos)
void MeshUpdateQueue::fillDataFromMapBlocks(QueuedMeshUpdate *q)
{
auto mesh_grid = m_client->getMeshGrid();
MeshMakeData *data = new MeshMakeData(m_client->ndef(), MAP_BLOCKSIZE * mesh_grid.cell_size, m_cache_enable_shaders);
MeshMakeData *data = new MeshMakeData(m_client->ndef(), MAP_BLOCKSIZE * mesh_grid.cell_size);
q->data = data;
data->fillBlockDataBegin(q->p);

View file

@ -70,11 +70,9 @@ private:
std::mutex m_mutex;
// TODO: Add callback to update these when g_settings changes
bool m_cache_enable_shaders;
bool m_cache_smooth_lighting;
void fillDataFromMapBlocks(QueuedMeshUpdate *q);
void cleanupCache();
};
struct MeshUpdateResult

View file

@ -173,7 +173,6 @@ Minimap::Minimap(Client *client)
m_current_mode_index = 0;
// Initialize static settings
m_enable_shaders = g_settings->getBool("enable_shaders");
m_surface_mode_scan_height =
g_settings->getBool("minimap_double_scan_height") ? 256 : 128;
@ -599,7 +598,7 @@ void Minimap::drawMinimap(core::rect<s32> rect)
material.TextureLayers[0].Texture = minimap_texture;
material.TextureLayers[1].Texture = data->heightmap_texture;
if (m_enable_shaders && data->mode.type == MINIMAP_TYPE_SURFACE) {
if (data->mode.type == MINIMAP_TYPE_SURFACE) {
auto sid = m_shdrsrc->getShader("minimap_shader", TILE_MATERIAL_ALPHA);
material.MaterialType = m_shdrsrc->getShaderInfo(sid).material;
} else {

View file

@ -152,7 +152,6 @@ private:
const NodeDefManager *m_ndef;
std::unique_ptr<MinimapUpdateThread> m_minimap_update_thread;
irr_ptr<scene::SMeshBuffer> m_meshbuffer;
bool m_enable_shaders;
std::vector<MinimapModeDef> m_modes;
size_t m_current_mode_index;
u16 m_surface_mode_scan_height;

View file

@ -87,7 +87,7 @@ void UpscaleStep::run(PipelineContext &context)
std::unique_ptr<RenderStep> create3DStage(Client *client, v2f scale)
{
RenderStep *step = new Draw3D();
if (g_settings->getBool("enable_shaders") && g_settings->getBool("enable_post_processing")) {
if (g_settings->getBool("enable_post_processing")) {
RenderPipeline *pipeline = new RenderPipeline();
pipeline->addStep(pipeline->own(std::unique_ptr<RenderStep>(step)));
@ -111,8 +111,8 @@ RenderStep* addUpscaling(RenderPipeline *pipeline, RenderStep *previousStep, v2f
if (downscale_factor.X == 1.0f && downscale_factor.Y == 1.0f)
return previousStep;
// When shaders are enabled, post-processing pipeline takes care of rescaling
if (g_settings->getBool("enable_shaders") && g_settings->getBool("enable_post_processing"))
// post-processing pipeline takes care of rescaling
if (g_settings->getBool("enable_post_processing"))
return previousStep;

View file

@ -307,9 +307,6 @@ public:
private:
// Are shaders even enabled?
bool m_enabled;
// The id of the thread that is allowed to use irrlicht directly
std::thread::id m_main_thread;
@ -348,12 +345,6 @@ ShaderSource::ShaderSource()
// Add a dummy ShaderInfo as the first index, named ""
m_shaderinfo_cache.emplace_back();
m_enabled = g_settings->getBool("enable_shaders");
if (!m_enabled) {
warningstream << "You are running " PROJECT_NAME_C " with shaders disabled, "
"this is not a recommended configuration." << std::endl;
}
// Add main global constant setter
addShaderConstantSetterFactory(new MainShaderConstantSetterFactory());
}
@ -362,11 +353,9 @@ ShaderSource::~ShaderSource()
{
MutexAutoLock lock(m_shaderinfo_cache_mutex);
if (!m_enabled)
return;
// Delete materials
auto *gpu = RenderingEngine::get_video_driver()->getGPUProgrammingServices();
assert(gpu);
for (ShaderInfo &i : m_shaderinfo_cache) {
if (!i.name.empty())
gpu->deleteShaderMaterial(i.material);
@ -495,11 +484,9 @@ void ShaderSource::rebuildShaders()
{
MutexAutoLock lock(m_shaderinfo_cache_mutex);
if (!m_enabled)
return;
// Delete materials
auto *gpu = RenderingEngine::get_video_driver()->getGPUProgrammingServices();
assert(gpu);
for (ShaderInfo &i : m_shaderinfo_cache) {
if (!i.name.empty()) {
gpu->deleteShaderMaterial(i.material);
@ -546,14 +533,14 @@ ShaderInfo ShaderSource::generateShader(const std::string &name,
}
shaderinfo.material = shaderinfo.base_material;
if (!m_enabled)
video::IVideoDriver *driver = RenderingEngine::get_video_driver();
// The null driver doesn't support shaders (duh), but we can pretend it does.
if (driver->getDriverType() == video::EDT_NULL)
return shaderinfo;
video::IVideoDriver *driver = RenderingEngine::get_video_driver();
auto *gpu = driver->getGPUProgrammingServices();
if (!driver->queryFeature(video::EVDF_ARB_GLSL) || !gpu) {
throw ShaderException(gettext("Shaders are enabled but GLSL is not "
"supported by the driver."));
throw ShaderException(gettext("GLSL is not supported by the driver"));
}
// Create shaders header

View file

@ -107,25 +107,13 @@ void ShadowRenderer::disable()
void ShadowRenderer::preInit(IWritableShaderSource *shsrc)
{
if (g_settings->getBool("enable_shaders") &&
g_settings->getBool("enable_dynamic_shadows")) {
if (g_settings->getBool("enable_dynamic_shadows")) {
shsrc->addShaderConstantSetterFactory(new ShadowConstantSetterFactory());
}
}
void ShadowRenderer::initialize()
{
auto *gpu = m_driver->getGPUProgrammingServices();
// we need glsl
if (!m_shadows_supported || !gpu || !m_driver->queryFeature(video::EVDF_ARB_GLSL)) {
m_shadows_supported = false;
warningstream << "Shadows: GLSL Shader not supported on this system."
<< std::endl;
return;
}
createShaders();
@ -533,7 +521,7 @@ void ShadowRenderer::mixShadowsQuad()
void ShadowRenderer::createShaders()
{
video::IGPUProgrammingServices *gpu = m_driver->getGPUProgrammingServices();
auto *gpu = m_driver->getGPUProgrammingServices();
if (depth_shader == -1) {
std::string depth_shader_vs = getShaderPath("shadow_shaders", "pass1_vertex.glsl");
@ -706,14 +694,12 @@ std::string ShadowRenderer::readShaderFile(const std::string &path)
ShadowRenderer *createShadowRenderer(IrrlichtDevice *device, Client *client)
{
// disable if unsupported
if (g_settings->getBool("enable_dynamic_shadows") && (
device->getVideoDriver()->getDriverType() != video::EDT_OPENGL ||
!g_settings->getBool("enable_shaders"))) {
if (g_settings->getBool("enable_dynamic_shadows") &&
device->getVideoDriver()->getDriverType() != video::EDT_OPENGL) {
g_settings->setBool("enable_dynamic_shadows", false);
}
if (g_settings->getBool("enable_shaders") &&
g_settings->getBool("enable_dynamic_shadows")) {
if (g_settings->getBool("enable_dynamic_shadows")) {
ShadowRenderer *shadow_renderer = new ShadowRenderer(device, client);
shadow_renderer->initialize();
return shadow_renderer;

View file

@ -53,8 +53,6 @@ Sky::Sky(s32 id, RenderingEngine *rendering_engine, ITextureSource *tsrc, IShade
m_box.MaxEdge.set(0, 0, 0);
m_box.MinEdge.set(0, 0, 0);
m_enable_shaders = g_settings->getBool("enable_shaders");
m_sky_params = SkyboxDefaults::getSkyDefaults();
m_sun_params = SkyboxDefaults::getSunDefaults();
m_moon_params = SkyboxDefaults::getMoonDefaults();
@ -63,9 +61,8 @@ Sky::Sky(s32 id, RenderingEngine *rendering_engine, ITextureSource *tsrc, IShade
// Create materials
m_materials[0] = baseMaterial();
m_materials[0].MaterialType = m_enable_shaders ?
ssrc->getShaderInfo(ssrc->getShader("stars_shader", TILE_MATERIAL_ALPHA)).material :
video::EMT_TRANSPARENT_ALPHA_CHANNEL;
m_materials[0].MaterialType =
ssrc->getShaderInfo(ssrc->getShader("stars_shader", TILE_MATERIAL_ALPHA)).material;
m_materials[1] = baseMaterial();
m_materials[1].MaterialType = video::EMT_TRANSPARENT_ALPHA_CHANNEL;
@ -668,10 +665,7 @@ void Sky::draw_stars(video::IVideoDriver * driver, float wicked_time_of_day)
color.a *= alpha;
if (color.a <= 0.0f) // Stars are only drawn when not fully transparent
return;
if (m_enable_shaders)
m_materials[0].ColorParam = color.toSColor();
else
setMeshBufferColor(m_stars.get(), color.toSColor());
m_materials[0].ColorParam = color.toSColor();
auto sky_rotation = core::matrix4().setRotationAxisRadians(2.0f * M_PI * (wicked_time_of_day - 0.25f), v3f(0.0f, 0.0f, 1.0f));
auto world_matrix = driver->getTransform(video::ETS_WORLD);
@ -841,8 +835,7 @@ void Sky::updateStars()
indices.push_back(i * 4 + 3);
indices.push_back(i * 4 + 0);
}
if (m_enable_shaders)
m_stars->setHardwareMappingHint(scene::EHM_STATIC);
m_stars->setHardwareMappingHint(scene::EHM_STATIC);
}
void Sky::setSkyColors(const SkyColor &sky_color)

View file

@ -173,7 +173,6 @@ private:
bool m_clouds_enabled = true; // Initialised to true, reset only by set_sky API
bool m_directional_colored_fog;
bool m_in_clouds = true; // Prevent duplicating bools to remember old values
bool m_enable_shaders = false;
video::SColorf m_bgcolor_bright_f = video::SColorf(1.0f, 1.0f, 1.0f, 1.0f);
video::SColorf m_skycolor_bright_f = video::SColorf(1.0f, 1.0f, 1.0f, 1.0f);

View file

@ -78,7 +78,6 @@ struct TileLayer
return !(*this == other);
}
// Sets everything else except the texture in the material
void applyMaterialOptions(video::SMaterial &material) const;
void applyMaterialOptionsWithShaders(video::SMaterial &material) const;

View file

@ -184,7 +184,6 @@ WieldMeshSceneNode::WieldMeshSceneNode(scene::ISceneManager *mgr, s32 id):
scene::ISceneNode(mgr->getRootSceneNode(), mgr, id),
m_material_type(video::EMT_TRANSPARENT_ALPHA_CHANNEL_REF)
{
m_enable_shaders = g_settings->getBool("enable_shaders");
m_anisotropic_filter = g_settings->getBool("anisotropic_filter");
m_bilinear_filter = g_settings->getBool("bilinear_filter");
m_trilinear_filter = g_settings->getBool("trilinear_filter");
@ -233,7 +232,7 @@ void WieldMeshSceneNode::setCube(const ContentFeatures &f,
scene::IMesh *cubemesh = g_extrusion_mesh_cache->createCube();
scene::SMesh *copy = cloneMesh(cubemesh);
cubemesh->drop();
postProcessNodeMesh(copy, f, false, true, &m_material_type, &m_colors, true);
postProcessNodeMesh(copy, f, false, &m_material_type, &m_colors, true);
changeToMesh(copy);
copy->drop();
m_meshnode->setScale(wield_scale * WIELD_SCALE_FACTOR);
@ -297,7 +296,7 @@ void WieldMeshSceneNode::setExtruded(const std::string &imagename,
static scene::SMesh *createSpecialNodeMesh(Client *client, MapNode n,
std::vector<ItemPartColor> *colors, const ContentFeatures &f)
{
MeshMakeData mesh_make_data(client->ndef(), 1, false);
MeshMakeData mesh_make_data(client->ndef(), 1);
MeshCollector collector(v3f(0.0f * BS), v3f());
mesh_make_data.setSmoothLighting(false);
MapblockMeshGenerator gen(&mesh_make_data, &collector,
@ -354,10 +353,8 @@ void WieldMeshSceneNode::setItem(const ItemStack &item, Client *client, bool che
scene::SMesh *mesh = nullptr;
if (m_enable_shaders) {
u32 shader_id = shdrsrc->getShader("object_shader", TILE_MATERIAL_BASIC, NDT_NORMAL);
m_material_type = shdrsrc->getShaderInfo(shader_id).material;
}
u32 shader_id = shdrsrc->getShader("object_shader", TILE_MATERIAL_BASIC, NDT_NORMAL);
m_material_type = shdrsrc->getShaderInfo(shader_id).material;
// Color-related
m_colors.clear();
@ -500,10 +497,7 @@ void WieldMeshSceneNode::setColor(video::SColor c)
if (m_colors[j].needColorize(buffercolor)) {
buf->setDirty(scene::EBT_VERTEX);
if (m_enable_shaders)
setMeshBufferColor(buf, buffercolor);
else
colorizeMeshBuffer(buf, &buffercolor);
setMeshBufferColor(buf, buffercolor);
}
}
}
@ -513,13 +507,11 @@ void WieldMeshSceneNode::setNodeLightColor(video::SColor color)
if (!m_meshnode)
return;
if (m_enable_shaders) {
{
for (u32 i = 0; i < m_meshnode->getMaterialCount(); ++i) {
video::SMaterial &material = m_meshnode->getMaterial(i);
material.ColorParam = color;
}
} else {
setColor(color);
}
}
@ -538,12 +530,7 @@ void WieldMeshSceneNode::changeToMesh(scene::IMesh *mesh)
dummymesh->drop(); // m_meshnode grabbed it
} else {
m_meshnode->setMesh(mesh);
// without shaders recolored often for lighting
// otherwise only once
if (m_enable_shaders)
mesh->setHardwareMappingHint(scene::EHM_STATIC);
else
mesh->setHardwareMappingHint(scene::EHM_DYNAMIC);
mesh->setHardwareMappingHint(scene::EHM_STATIC);
}
m_meshnode->setVisible(true);
@ -596,7 +583,7 @@ void getItemMesh(Client *client, const ItemStack &item, ItemMesh *result)
} else
scaleMesh(mesh, v3f(1.2, 1.2, 1.2));
// add overlays
postProcessNodeMesh(mesh, f, false, false, nullptr,
postProcessNodeMesh(mesh, f, false, nullptr,
&result->buffer_colors, true);
if (f.drawtype == NDT_ALLFACES)
scaleMesh(mesh, v3f(f.visual_scale));
@ -704,7 +691,7 @@ scene::SMesh *getExtrudedMesh(ITextureSource *tsrc,
}
void postProcessNodeMesh(scene::SMesh *mesh, const ContentFeatures &f,
bool use_shaders, bool set_material, const video::E_MATERIAL_TYPE *mattype,
bool set_material, const video::E_MATERIAL_TYPE *mattype,
std::vector<ItemPartColor> *colors, bool apply_scale)
{
const u32 mc = mesh->getMeshBufferCount();

View file

@ -117,7 +117,6 @@ private:
scene::IMeshSceneNode *m_meshnode = nullptr;
video::E_MATERIAL_TYPE m_material_type;
bool m_enable_shaders;
bool m_anisotropic_filter;
bool m_bilinear_filter;
bool m_trilinear_filter;
@ -152,6 +151,6 @@ scene::SMesh *getExtrudedMesh(ITextureSource *tsrc, const std::string &imagename
* be NULL to leave the original material.
* \param colors returns the colors of the mesh buffers in the mesh.
*/
void postProcessNodeMesh(scene::SMesh *mesh, const ContentFeatures &f, bool use_shaders,
void postProcessNodeMesh(scene::SMesh *mesh, const ContentFeatures &f,
bool set_material, const video::E_MATERIAL_TYPE *mattype,
std::vector<ItemPartColor> *colors, bool apply_scale = false);

View file

@ -102,7 +102,6 @@ void set_default_settings()
settings->setDefault("sound_volume_unfocused", "0.3");
settings->setDefault("mute_sound", "false");
settings->setDefault("sound_extensions_blacklist", "");
settings->setDefault("enable_mesh_cache", "false");
settings->setDefault("mesh_generation_interval", "0");
settings->setDefault("mesh_generation_threads", "0");
settings->setDefault("free_move", "false");
@ -299,7 +298,6 @@ void set_default_settings()
settings->setDefault("enable_local_map_saving", "false");
settings->setDefault("show_entity_selectionbox", "false");
settings->setDefault("ambient_occlusion_gamma", "1.8");
settings->setDefault("enable_shaders", "true");
settings->setDefault("enable_particles", "true");
settings->setDefault("arm_inertia", "true");
settings->setDefault("show_nametag_backgrounds", "true");

View file

@ -17,7 +17,6 @@ Environment::Environment(IGameDef *gamedef):
m_day_count(0),
m_gamedef(gamedef)
{
m_cache_enable_shaders = g_settings->getBool("enable_shaders");
m_cache_active_block_mgmt_interval = g_settings->getFloat("active_block_mgmt_interval");
m_cache_abm_interval = g_settings->getFloat("abm_interval");
m_cache_nodetimer_interval = g_settings->getFloat("nodetimer_interval");
@ -32,7 +31,7 @@ u32 Environment::getDayNightRatio()
MutexAutoLock lock(m_time_lock);
if (m_enable_day_night_ratio_override)
return m_day_night_ratio_override;
return time_to_daynight_ratio(m_time_of_day_f * 24000, m_cache_enable_shaders);
return time_to_daynight_ratio(m_time_of_day_f * 24000, true);
}
void Environment::setTimeOfDaySpeed(float speed)

View file

@ -131,7 +131,6 @@ protected:
* (as opposed to the this local caching). This can be addressed in
* a later release.
*/
bool m_cache_enable_shaders;
float m_cache_active_block_mgmt_interval;
float m_cache_abm_interval;
float m_cache_nodetimer_interval;

View file

@ -98,11 +98,6 @@ void GUIScene::draw()
if (m_inf_rot)
rotateCamera(v3f(0.f, -0.03f * (float)dtime_ms, 0.f));
// HACK restore mesh vertex colors to full brightness:
// They may have been mutated in entity rendering code before.
if (!g_settings->getBool("enable_shaders"))
setMeshColor(m_mesh->getMesh(), irr::video::SColor(0xFFFFFFFF));
m_smgr->drawAll();
if (m_initial_rotation && m_mesh) {

View file

@ -270,18 +270,12 @@ void TextureSettings::readSettings()
{
connected_glass = g_settings->getBool("connected_glass");
translucent_liquids = g_settings->getBool("translucent_liquids");
bool smooth_lighting = g_settings->getBool("smooth_lighting");
enable_mesh_cache = g_settings->getBool("enable_mesh_cache");
enable_minimap = g_settings->getBool("enable_minimap");
node_texture_size = std::max<u16>(g_settings->getU16("texture_min_size"), 1);
std::string leaves_style_str = g_settings->get("leaves_style");
std::string world_aligned_mode_str = g_settings->get("world_aligned_mode");
std::string autoscale_mode_str = g_settings->get("autoscale_mode");
// Mesh cache is not supported in combination with smooth lighting
if (smooth_lighting)
enable_mesh_cache = false;
if (leaves_style_str == "fancy") {
leaves_style = LEAVES_FANCY;
} else if (leaves_style_str == "simple") {
@ -357,8 +351,7 @@ void ContentFeatures::reset()
drawtype = NDT_NORMAL;
mesh.clear();
#if CHECK_CLIENT_BUILD()
for (auto &i : mesh_ptr)
i = NULL;
mesh_ptr = nullptr;
minimap_color = video::SColor(0, 0, 0, 0);
#endif
visual_scale = 1.0;
@ -952,48 +945,14 @@ void ContentFeatures::updateTextures(ITextureSource *tsrc, IShaderSource *shdsrc
if (drawtype == NDT_MESH && !mesh.empty()) {
// Meshnode drawtype
// Read the mesh and apply scale
mesh_ptr[0] = client->getMesh(mesh);
if (mesh_ptr[0]){
v3f scale = v3f(1.0, 1.0, 1.0) * BS * visual_scale;
scaleMesh(mesh_ptr[0], scale);
recalculateBoundingBox(mesh_ptr[0]);
meshmanip->recalculateNormals(mesh_ptr[0], true, false);
mesh_ptr = client->getMesh(mesh);
if (mesh_ptr) {
v3f scale = v3f(BS) * visual_scale;
scaleMesh(mesh_ptr, scale);
recalculateBoundingBox(mesh_ptr);
meshmanip->recalculateNormals(mesh_ptr, true, false);
}
}
//Cache 6dfacedir and wallmounted rotated clones of meshes
if (tsettings.enable_mesh_cache && mesh_ptr[0] &&
(param_type_2 == CPT2_FACEDIR
|| param_type_2 == CPT2_COLORED_FACEDIR)) {
for (u16 j = 1; j < 24; j++) {
mesh_ptr[j] = cloneMesh(mesh_ptr[0]);
rotateMeshBy6dFacedir(mesh_ptr[j], j);
recalculateBoundingBox(mesh_ptr[j]);
meshmanip->recalculateNormals(mesh_ptr[j], true, false);
}
} else if (tsettings.enable_mesh_cache && mesh_ptr[0] &&
(param_type_2 == CPT2_4DIR
|| param_type_2 == CPT2_COLORED_4DIR)) {
for (u16 j = 1; j < 4; j++) {
mesh_ptr[j] = cloneMesh(mesh_ptr[0]);
rotateMeshBy6dFacedir(mesh_ptr[j], j);
recalculateBoundingBox(mesh_ptr[j]);
meshmanip->recalculateNormals(mesh_ptr[j], true, false);
}
} else if (tsettings.enable_mesh_cache && mesh_ptr[0]
&& (param_type_2 == CPT2_WALLMOUNTED ||
param_type_2 == CPT2_COLORED_WALLMOUNTED)) {
static const u8 wm_to_6d[6] = { 20, 0, 16 + 1, 12 + 3, 8, 4 + 2 };
for (u16 j = 1; j < 6; j++) {
mesh_ptr[j] = cloneMesh(mesh_ptr[0]);
rotateMeshBy6dFacedir(mesh_ptr[j], wm_to_6d[j]);
recalculateBoundingBox(mesh_ptr[j]);
meshmanip->recalculateNormals(mesh_ptr[j], true, false);
}
rotateMeshBy6dFacedir(mesh_ptr[0], wm_to_6d[0]);
recalculateBoundingBox(mesh_ptr[0]);
meshmanip->recalculateNormals(mesh_ptr[0], true, false);
}
}
#endif
@ -1014,10 +973,8 @@ NodeDefManager::~NodeDefManager()
{
#if CHECK_CLIENT_BUILD()
for (ContentFeatures &f : m_content_features) {
for (auto &j : f.mesh_ptr) {
if (j)
j->drop();
}
if (f.mesh_ptr)
f.mesh_ptr->drop();
}
#endif
}

View file

@ -171,7 +171,6 @@ public:
int node_texture_size;
bool translucent_liquids;
bool connected_glass;
bool enable_mesh_cache;
bool enable_minimap;
TextureSettings() = default;
@ -337,7 +336,7 @@ struct ContentFeatures
enum NodeDrawType drawtype;
std::string mesh;
#if CHECK_CLIENT_BUILD()
scene::IMesh *mesh_ptr[24];
scene::IMesh *mesh_ptr; // mesh in case of mesh node
video::SColor minimap_color;
#endif
float visual_scale; // Misc. scale parameter

View file

@ -36,9 +36,9 @@ public:
node_mgr()->resolveCrossrefs();
}
MeshMakeData makeSingleNodeMMD(bool smooth_lighting = true, bool for_shaders = true)
MeshMakeData makeSingleNodeMMD(bool smooth_lighting = true)
{
MeshMakeData data{ndef(), 1, for_shaders};
MeshMakeData data{ndef(), 1};
data.setSmoothLighting(smooth_lighting);
data.m_blockpos = {0, 0, 0};
for (s16 x = -1; x <= 1; x++)