lightVec = sunPosition - worldPosition;
eyeVec = -(gl_ModelViewMatrix * gl_Vertex).xyz;
+#if (MATERIAL_TYPE == TILE_MATERIAL_PLAIN) || (MATERIAL_TYPE == TILE_MATERIAL_PLAIN_ALPHA)
+ vIDiff = 1.0;
+#else
// This is intentional comparison with zero without any margin.
// If normal is not equal to zero exactly, then we assume it's a valid, just not normalized vector
vIDiff = length(gl_Normal) == 0.0
? 1.0
: directional_ambient(normalize(gl_Normal));
+#endif
gl_FrontColor = gl_BackColor = gl_Color;
}
damage_texture_modifier = "^[brighten",
-- Texture modifier to be applied for a short duration when object is hit
+
+ shaded = true,
+ -- Setting this to 'false' disables diffuse lighting of entity
}
Entity definition
},
})
+minetest.register_entity("testentities:mesh_unshaded", {
+ initial_properties = {
+ visual = "mesh",
+ mesh = "testnodes_pyramid.obj",
+ textures = {
+ "testnodes_mesh_stripes2.png"
+ },
+ shaded = false,
+ },
+})
+
-- Advanced visual tests
-- A test entity for testing animated and yaw-modulated sprites
self.object:set_sprite({x=0, y=0}, 1, 0, true)
end,
})
-
if (m_enable_shaders) {
IShaderSource *shader_source = m_client->getShaderSource();
- u32 shader_id = shader_source->getShader(
- "object_shader",
- (m_prop.use_texture_alpha) ? TILE_MATERIAL_ALPHA : TILE_MATERIAL_BASIC,
- NDT_NORMAL);
+ MaterialType material_type;
+
+ if (m_prop.shaded && m_prop.glow == 0)
+ material_type = (m_prop.use_texture_alpha) ?
+ TILE_MATERIAL_ALPHA : TILE_MATERIAL_BASIC;
+ else
+ material_type = (m_prop.use_texture_alpha) ?
+ TILE_MATERIAL_PLAIN_ALPHA : TILE_MATERIAL_PLAIN;
+
+ u32 shader_id = shader_source->getShader("object_shader", material_type, NDT_NORMAL);
m_material_type = shader_source->getShaderInfo(shader_id).material;
} else {
m_material_type = (m_prop.use_texture_alpha) ?
return old.backface_culling != new_.backface_culling ||
old.is_visible != new_.is_visible ||
old.mesh != new_.mesh ||
+ old.shaded != new_.shaded ||
old.use_texture_alpha != new_.use_texture_alpha ||
old.visual != new_.visual ||
old.visual_size != new_.visual_size ||
// hurting the performance and covering only really weird broken models.
f32 length = buffer->getNormal(0).getLength();
- if (!std::isfinite(length) || std::fabs(length) < 1e-10f)
+ if (!std::isfinite(length) || length < 1e-10f)
return false;
}
shaderinfo.base_material = video::EMT_SOLID;
break;
case TILE_MATERIAL_ALPHA:
+ case TILE_MATERIAL_PLAIN_ALPHA:
case TILE_MATERIAL_LIQUID_TRANSPARENT:
case TILE_MATERIAL_WAVING_LIQUID_TRANSPARENT:
shaderinfo.base_material = video::EMT_TRANSPARENT_ALPHA_CHANNEL;
break;
case TILE_MATERIAL_BASIC:
+ case TILE_MATERIAL_PLAIN:
case TILE_MATERIAL_WAVING_LEAVES:
case TILE_MATERIAL_WAVING_PLANTS:
case TILE_MATERIAL_WAVING_LIQUID_BASIC:
"TILE_MATERIAL_WAVING_LIQUID_BASIC",
"TILE_MATERIAL_WAVING_LIQUID_TRANSPARENT",
"TILE_MATERIAL_WAVING_LIQUID_OPAQUE",
+ "TILE_MATERIAL_PLAIN",
+ "TILE_MATERIAL_PLAIN_ALPHA",
};
- for (int i = 0; i < 10; i++){
+ for (int i = 0; i < 12; i++){
shaders_header += "#define ";
shaders_header += materialTypes[i];
shaders_header += " ";
TILE_MATERIAL_WAVING_LIQUID_BASIC,
TILE_MATERIAL_WAVING_LIQUID_TRANSPARENT,
TILE_MATERIAL_WAVING_LIQUID_OPAQUE,
+ TILE_MATERIAL_PLAIN,
+ TILE_MATERIAL_PLAIN_ALPHA
};
// Material flags
os << ", zoom_fov=" << zoom_fov;
os << ", use_texture_alpha=" << use_texture_alpha;
os << ", damage_texture_modifier=" << damage_texture_modifier;
+ os << ", shaded=" << shaded;
return os.str();
}
writeF32(os, zoom_fov);
writeU8(os, use_texture_alpha);
os << serializeString(damage_texture_modifier);
+ writeU8(os, shaded);
// Add stuff only at the bottom.
// Never remove anything, because we don't want new versions of this
use_texture_alpha = readU8(is);
try {
damage_texture_modifier = deSerializeString(is);
+ u8 tmp = readU8(is);
+ if (is.eof())
+ throw SerializationError("");
+ shaded = tmp;
} catch (SerializationError &e) {}
}
float eye_height = 1.625f;
float zoom_fov = 0.0f;
bool use_texture_alpha = false;
+ bool shaded = true;
ObjectProperties();
std::string dump();
getfloatfield(L, -1, "zoom_fov", prop->zoom_fov);
getboolfield(L, -1, "use_texture_alpha", prop->use_texture_alpha);
+ getboolfield(L, -1, "shaded", prop->shaded);
getstringfield(L, -1, "damage_texture_modifier", prop->damage_texture_modifier);
}
lua_setfield(L, -2, "zoom_fov");
lua_pushboolean(L, prop->use_texture_alpha);
lua_setfield(L, -2, "use_texture_alpha");
+ lua_pushboolean(L, prop->shaded);
+ lua_setfield(L, -2, "shaded");
lua_pushlstring(L, prop->damage_texture_modifier.c_str(), prop->damage_texture_modifier.size());
lua_setfield(L, -2, "damage_texture_modifier");
}