mirror of
https://github.com/luanti-org/luanti.git
synced 2025-08-01 17:38:41 +00:00
Drop fixed pipeline lighting stuff (#15165)
This commit is contained in:
parent
6dfd61cba0
commit
70e169f165
34 changed files with 59 additions and 426 deletions
|
@ -258,7 +258,6 @@ void CAnimatedMeshSceneNode::render()
|
|||
// for debug purposes only:
|
||||
if (DebugDataVisible && PassCount == 1) {
|
||||
video::SMaterial debug_mat;
|
||||
debug_mat.Lighting = false;
|
||||
debug_mat.AntiAliasing = 0;
|
||||
driver->setMaterial(debug_mat);
|
||||
// show normals
|
||||
|
@ -280,7 +279,6 @@ void CAnimatedMeshSceneNode::render()
|
|||
}
|
||||
|
||||
debug_mat.ZBuffer = video::ECFN_DISABLED;
|
||||
debug_mat.Lighting = false;
|
||||
driver->setMaterial(debug_mat);
|
||||
|
||||
if (DebugDataVisible & scene::EDS_BBOX)
|
||||
|
@ -316,7 +314,6 @@ void CAnimatedMeshSceneNode::render()
|
|||
|
||||
// show mesh
|
||||
if (DebugDataVisible & scene::EDS_MESH_WIRE_OVERLAY) {
|
||||
debug_mat.Lighting = false;
|
||||
debug_mat.Wireframe = true;
|
||||
debug_mat.ZBuffer = video::ECFN_DISABLED;
|
||||
driver->setMaterial(debug_mat);
|
||||
|
|
|
@ -485,7 +485,8 @@ bool CB3DMeshFileLoader::readChunkTRIS(scene::SSkinMeshBuffer *meshBuffer, u32 m
|
|||
video::S3DVertex *Vertex = meshBuffer->getVertex(meshBuffer->getVertexCount() - 1);
|
||||
|
||||
if (!HasVertexColors)
|
||||
Vertex->Color = B3dMaterial->Material.DiffuseColor;
|
||||
Vertex->Color = video::SColorf(B3dMaterial->red, B3dMaterial->green,
|
||||
B3dMaterial->blue, B3dMaterial->alpha).toSColor();
|
||||
else if (Vertex->Color.getAlpha() == 255)
|
||||
Vertex->Color.setAlpha((s32)(B3dMaterial->alpha * 255.0f));
|
||||
|
||||
|
@ -890,23 +891,8 @@ bool CB3DMeshFileLoader::readChunkBRUS()
|
|||
}
|
||||
}
|
||||
|
||||
B3dMaterial.Material.DiffuseColor = video::SColorf(B3dMaterial.red, B3dMaterial.green, B3dMaterial.blue, B3dMaterial.alpha).toSColor();
|
||||
B3dMaterial.Material.ColorMaterial = video::ECM_NONE;
|
||||
|
||||
//------ Material fx ------
|
||||
|
||||
if (B3dMaterial.fx & 1) { // full-bright
|
||||
B3dMaterial.Material.AmbientColor = video::SColor(255, 255, 255, 255);
|
||||
B3dMaterial.Material.Lighting = false;
|
||||
} else
|
||||
B3dMaterial.Material.AmbientColor = B3dMaterial.Material.DiffuseColor;
|
||||
|
||||
if (B3dMaterial.fx & 2) // use vertex colors instead of brush color
|
||||
B3dMaterial.Material.ColorMaterial = video::ECM_DIFFUSE_AND_AMBIENT;
|
||||
|
||||
if (B3dMaterial.fx & 4) // flatshaded
|
||||
B3dMaterial.Material.GouraudShading = false;
|
||||
|
||||
if (B3dMaterial.fx & 16) // disable backface culling
|
||||
B3dMaterial.Material.BackfaceCulling = false;
|
||||
|
||||
|
@ -914,8 +900,6 @@ bool CB3DMeshFileLoader::readChunkBRUS()
|
|||
B3dMaterial.Material.MaterialType = video::EMT_TRANSPARENT_VERTEX_ALPHA;
|
||||
B3dMaterial.Material.ZWriteEnable = video::EZW_OFF;
|
||||
}
|
||||
|
||||
B3dMaterial.Material.Shininess = B3dMaterial.shininess;
|
||||
}
|
||||
|
||||
B3dStack.erase(B3dStack.size() - 1);
|
||||
|
|
|
@ -85,7 +85,6 @@ void CBillboardSceneNode::render()
|
|||
if (DebugDataVisible & scene::EDS_BBOX) {
|
||||
driver->setTransform(video::ETS_WORLD, AbsoluteTransformation);
|
||||
video::SMaterial m;
|
||||
m.Lighting = false;
|
||||
driver->setMaterial(m);
|
||||
driver->draw3DBox(BBoxSafe, video::SColor(0, 208, 195, 152));
|
||||
}
|
||||
|
|
|
@ -115,7 +115,6 @@ void CMeshSceneNode::render()
|
|||
// for debug purposes only:
|
||||
if (DebugDataVisible && PassCount == 1) {
|
||||
video::SMaterial m;
|
||||
m.Lighting = false;
|
||||
m.AntiAliasing = 0;
|
||||
driver->setMaterial(m);
|
||||
|
||||
|
|
|
@ -104,7 +104,6 @@ CNullDriver::CNullDriver(io::IFileSystem *io, const core::dimension2d<u32> &scre
|
|||
FeatureEnabled[i] = true;
|
||||
|
||||
InitMaterial2D.AntiAliasing = video::EAAM_OFF;
|
||||
InitMaterial2D.Lighting = false;
|
||||
InitMaterial2D.ZWriteEnable = video::EZW_OFF;
|
||||
InitMaterial2D.ZBuffer = video::ECFN_DISABLED;
|
||||
InitMaterial2D.UseMipMaps = false;
|
||||
|
@ -1131,15 +1130,10 @@ void CNullDriver::drawBuffers(const scene::IVertexBuffer *vb,
|
|||
void CNullDriver::drawMeshBufferNormals(const scene::IMeshBuffer *mb, f32 length, SColor color)
|
||||
{
|
||||
const u32 count = mb->getVertexCount();
|
||||
const bool normalize = mb->getMaterial().NormalizeNormals;
|
||||
|
||||
for (u32 i = 0; i < count; ++i) {
|
||||
core::vector3df normalizedNormal = mb->getNormal(i);
|
||||
if (normalize)
|
||||
normalizedNormal.normalize();
|
||||
|
||||
core::vector3df normal = mb->getNormal(i);
|
||||
const core::vector3df &pos = mb->getPosition(i);
|
||||
draw3DLine(pos, pos + (normalizedNormal * length), color);
|
||||
draw3DLine(pos, pos + (normal * length), color);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -1306,10 +1300,8 @@ void CNullDriver::runOcclusionQuery(scene::ISceneNode *node, bool visible)
|
|||
OcclusionQueries[index].Run = 0;
|
||||
if (!visible) {
|
||||
SMaterial mat;
|
||||
mat.Lighting = false;
|
||||
mat.AntiAliasing = 0;
|
||||
mat.ColorMask = ECP_NONE;
|
||||
mat.GouraudShading = false;
|
||||
mat.ZWriteEnable = EZW_OFF;
|
||||
setMaterial(mat);
|
||||
}
|
||||
|
|
|
@ -182,7 +182,7 @@ IAnimatedMesh *COBJMeshFileLoader::createMesh(io::IReadFile *file)
|
|||
mtlChanged = false;
|
||||
}
|
||||
if (currMtl)
|
||||
v.Color = currMtl->Meshbuffer->Material.DiffuseColor;
|
||||
v.Color = video::SColorf(0.8f, 0.8f, 0.8f, 1.0f).toSColor();
|
||||
|
||||
// get all vertices data in this face (current line of obj file)
|
||||
const core::stringc wordBuffer = copyLine(bufPtr, bufEnd);
|
||||
|
|
|
@ -43,10 +43,6 @@ private:
|
|||
RecalculateNormals(false)
|
||||
{
|
||||
Meshbuffer = new SMeshBuffer();
|
||||
Meshbuffer->Material.Shininess = 0.0f;
|
||||
Meshbuffer->Material.AmbientColor = video::SColorf(0.2f, 0.2f, 0.2f, 1.0f).toSColor();
|
||||
Meshbuffer->Material.DiffuseColor = video::SColorf(0.8f, 0.8f, 0.8f, 1.0f).toSColor();
|
||||
Meshbuffer->Material.SpecularColor = video::SColorf(1.0f, 1.0f, 1.0f, 1.0f).toSColor();
|
||||
}
|
||||
|
||||
SObjMtl(const SObjMtl &o) :
|
||||
|
|
|
@ -1840,112 +1840,11 @@ void COpenGLDriver::setBasicRenderStates(const SMaterial &material, const SMater
|
|||
E_OPENGL_FIXED_PIPELINE_STATE tempState = FixedPipelineState;
|
||||
|
||||
if (resetAllRenderStates || tempState == EOFPS_ENABLE || tempState == EOFPS_DISABLE_TO_ENABLE) {
|
||||
// material colors
|
||||
if (resetAllRenderStates || tempState == EOFPS_DISABLE_TO_ENABLE ||
|
||||
lastmaterial.ColorMaterial != material.ColorMaterial) {
|
||||
switch (material.ColorMaterial) {
|
||||
case ECM_NONE:
|
||||
glDisable(GL_COLOR_MATERIAL);
|
||||
break;
|
||||
case ECM_DIFFUSE:
|
||||
glColorMaterial(GL_FRONT_AND_BACK, GL_DIFFUSE);
|
||||
break;
|
||||
case ECM_AMBIENT:
|
||||
glColorMaterial(GL_FRONT_AND_BACK, GL_AMBIENT);
|
||||
break;
|
||||
case ECM_EMISSIVE:
|
||||
glColorMaterial(GL_FRONT_AND_BACK, GL_EMISSION);
|
||||
break;
|
||||
case ECM_SPECULAR:
|
||||
glColorMaterial(GL_FRONT_AND_BACK, GL_SPECULAR);
|
||||
break;
|
||||
case ECM_DIFFUSE_AND_AMBIENT:
|
||||
glColorMaterial(GL_FRONT_AND_BACK, GL_AMBIENT_AND_DIFFUSE);
|
||||
break;
|
||||
}
|
||||
if (material.ColorMaterial != ECM_NONE)
|
||||
glEnable(GL_COLOR_MATERIAL);
|
||||
}
|
||||
|
||||
if (resetAllRenderStates || tempState == EOFPS_DISABLE_TO_ENABLE ||
|
||||
lastmaterial.AmbientColor != material.AmbientColor ||
|
||||
lastmaterial.DiffuseColor != material.DiffuseColor ||
|
||||
lastmaterial.EmissiveColor != material.EmissiveColor ||
|
||||
lastmaterial.ColorMaterial != material.ColorMaterial) {
|
||||
GLfloat color[4];
|
||||
|
||||
const f32 inv = 1.0f / 255.0f;
|
||||
|
||||
if ((material.ColorMaterial != video::ECM_AMBIENT) &&
|
||||
(material.ColorMaterial != video::ECM_DIFFUSE_AND_AMBIENT)) {
|
||||
color[0] = material.AmbientColor.getRed() * inv;
|
||||
color[1] = material.AmbientColor.getGreen() * inv;
|
||||
color[2] = material.AmbientColor.getBlue() * inv;
|
||||
color[3] = material.AmbientColor.getAlpha() * inv;
|
||||
glMaterialfv(GL_FRONT_AND_BACK, GL_AMBIENT, color);
|
||||
}
|
||||
|
||||
if ((material.ColorMaterial != video::ECM_DIFFUSE) &&
|
||||
(material.ColorMaterial != video::ECM_DIFFUSE_AND_AMBIENT)) {
|
||||
color[0] = material.DiffuseColor.getRed() * inv;
|
||||
color[1] = material.DiffuseColor.getGreen() * inv;
|
||||
color[2] = material.DiffuseColor.getBlue() * inv;
|
||||
color[3] = material.DiffuseColor.getAlpha() * inv;
|
||||
glMaterialfv(GL_FRONT_AND_BACK, GL_DIFFUSE, color);
|
||||
}
|
||||
|
||||
if (material.ColorMaterial != video::ECM_EMISSIVE) {
|
||||
color[0] = material.EmissiveColor.getRed() * inv;
|
||||
color[1] = material.EmissiveColor.getGreen() * inv;
|
||||
color[2] = material.EmissiveColor.getBlue() * inv;
|
||||
color[3] = material.EmissiveColor.getAlpha() * inv;
|
||||
glMaterialfv(GL_FRONT_AND_BACK, GL_EMISSION, color);
|
||||
}
|
||||
}
|
||||
|
||||
if (resetAllRenderStates || tempState == EOFPS_DISABLE_TO_ENABLE ||
|
||||
lastmaterial.SpecularColor != material.SpecularColor ||
|
||||
lastmaterial.Shininess != material.Shininess ||
|
||||
lastmaterial.ColorMaterial != material.ColorMaterial) {
|
||||
GLfloat color[4] = {0.f, 0.f, 0.f, 1.f};
|
||||
const f32 inv = 1.0f / 255.0f;
|
||||
|
||||
glMaterialf(GL_FRONT_AND_BACK, GL_SHININESS, material.Shininess);
|
||||
// disable Specular colors if no shininess is set
|
||||
if ((material.Shininess != 0.0f) &&
|
||||
(material.ColorMaterial != video::ECM_SPECULAR)) {
|
||||
#ifdef GL_EXT_separate_specular_color
|
||||
if (FeatureAvailable[IRR_EXT_separate_specular_color])
|
||||
glLightModeli(GL_LIGHT_MODEL_COLOR_CONTROL, GL_SEPARATE_SPECULAR_COLOR);
|
||||
#endif
|
||||
color[0] = material.SpecularColor.getRed() * inv;
|
||||
color[1] = material.SpecularColor.getGreen() * inv;
|
||||
color[2] = material.SpecularColor.getBlue() * inv;
|
||||
color[3] = material.SpecularColor.getAlpha() * inv;
|
||||
}
|
||||
#ifdef GL_EXT_separate_specular_color
|
||||
else if (FeatureAvailable[IRR_EXT_separate_specular_color])
|
||||
glLightModeli(GL_LIGHT_MODEL_COLOR_CONTROL, GL_SINGLE_COLOR);
|
||||
#endif
|
||||
glMaterialfv(GL_FRONT_AND_BACK, GL_SPECULAR, color);
|
||||
}
|
||||
|
||||
// shademode
|
||||
if (resetAllRenderStates || tempState == EOFPS_DISABLE_TO_ENABLE ||
|
||||
lastmaterial.GouraudShading != material.GouraudShading) {
|
||||
if (material.GouraudShading)
|
||||
glShadeModel(GL_SMOOTH);
|
||||
else
|
||||
glShadeModel(GL_FLAT);
|
||||
}
|
||||
|
||||
// lighting
|
||||
if (resetAllRenderStates || tempState == EOFPS_DISABLE_TO_ENABLE ||
|
||||
lastmaterial.Lighting != material.Lighting) {
|
||||
if (material.Lighting)
|
||||
glEnable(GL_LIGHTING);
|
||||
else
|
||||
glDisable(GL_LIGHTING);
|
||||
if (resetAllRenderStates || tempState == EOFPS_DISABLE_TO_ENABLE) {
|
||||
glDisable(GL_COLOR_MATERIAL);
|
||||
glDisable(GL_LIGHTING);
|
||||
glShadeModel(GL_SMOOTH);
|
||||
glDisable(GL_NORMALIZE);
|
||||
}
|
||||
|
||||
// fog
|
||||
|
@ -1957,15 +1856,6 @@ void COpenGLDriver::setBasicRenderStates(const SMaterial &material, const SMater
|
|||
glDisable(GL_FOG);
|
||||
}
|
||||
|
||||
// normalization
|
||||
if (resetAllRenderStates || tempState == EOFPS_DISABLE_TO_ENABLE ||
|
||||
lastmaterial.NormalizeNormals != material.NormalizeNormals) {
|
||||
if (material.NormalizeNormals)
|
||||
glEnable(GL_NORMALIZE);
|
||||
else
|
||||
glDisable(GL_NORMALIZE);
|
||||
}
|
||||
|
||||
// Set fixed pipeline as active.
|
||||
tempState = EOFPS_ENABLE;
|
||||
} else if (tempState == EOFPS_ENABLE_TO_DISABLE) {
|
||||
|
@ -2405,7 +2295,6 @@ void COpenGLDriver::setRenderStates2DMode(bool alpha, bool texture, bool alphaCh
|
|||
}
|
||||
|
||||
SMaterial currentMaterial = (!OverrideMaterial2DEnabled) ? InitMaterial2D : OverrideMaterial2D;
|
||||
currentMaterial.Lighting = false;
|
||||
|
||||
if (texture) {
|
||||
setTransform(ETS_TEXTURE_0, core::IdentityMatrix);
|
||||
|
|
|
@ -109,10 +109,6 @@ bool CXMeshFileLoader::load(io::IReadFile *file)
|
|||
// default material if nothing loaded
|
||||
if (!mesh->Materials.size()) {
|
||||
mesh->Materials.push_back(video::SMaterial());
|
||||
mesh->Materials[0].DiffuseColor.set(0xff777777);
|
||||
mesh->Materials[0].Shininess = 0.f;
|
||||
mesh->Materials[0].SpecularColor.set(0xff777777);
|
||||
mesh->Materials[0].EmissiveColor.set(0xff000000);
|
||||
}
|
||||
|
||||
u32 i;
|
||||
|
@ -142,7 +138,7 @@ bool CXMeshFileLoader::load(io::IReadFile *file)
|
|||
if (!mesh->HasVertexColors) {
|
||||
for (u32 j = 0; j < mesh->FaceMaterialIndices.size(); ++j) {
|
||||
for (u32 id = j * 3 + 0; id <= j * 3 + 2; ++id) {
|
||||
mesh->Vertices[mesh->Indices[id]].Color = mesh->Buffers[mesh->FaceMaterialIndices[j]]->Material.DiffuseColor;
|
||||
mesh->Vertices[mesh->Indices[id]].Color = 0xff777777;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1478,10 +1478,8 @@ void COpenGL3DriverBase::chooseMaterial2D()
|
|||
Material = InitMaterial2D;
|
||||
|
||||
if (OverrideMaterial2DEnabled) {
|
||||
OverrideMaterial2D.Lighting = false;
|
||||
OverrideMaterial2D.ZWriteEnable = EZW_OFF;
|
||||
OverrideMaterial2D.ZBuffer = ECFN_DISABLED; // it will be ECFN_DISABLED after merge
|
||||
OverrideMaterial2D.Lighting = false;
|
||||
|
||||
Material = OverrideMaterial2D;
|
||||
}
|
||||
|
|
|
@ -24,13 +24,7 @@ COpenGL3MaterialBaseCB::COpenGL3MaterialBaseCB() :
|
|||
|
||||
void COpenGL3MaterialBaseCB::OnSetMaterial(const SMaterial &material)
|
||||
{
|
||||
#ifdef _DEBUG
|
||||
if (material.Lighting)
|
||||
os::Printer::log("Lighted material not supported in unified driver.", ELL_INFORMATION);
|
||||
#endif
|
||||
|
||||
FogEnable = material.FogEnable;
|
||||
|
||||
Thickness = (material.Thickness > 0.f) ? material.Thickness : 1.f;
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue