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
|
@ -18,12 +18,6 @@ enum E_MATERIAL_PROP
|
|||
//! Corresponds to SMaterial::PointCloud.
|
||||
EMP_POINTCLOUD = 0x2,
|
||||
|
||||
//! Corresponds to SMaterial::GouraudShading.
|
||||
EMP_GOURAUD_SHADING = 0x4,
|
||||
|
||||
//! Corresponds to SMaterial::Lighting.
|
||||
EMP_LIGHTING = 0x8,
|
||||
|
||||
//! Corresponds to SMaterial::ZBuffer.
|
||||
EMP_ZBUFFER = 0x10,
|
||||
|
||||
|
@ -48,9 +42,6 @@ enum E_MATERIAL_PROP
|
|||
//! Corresponds to SMaterial::FogEnable.
|
||||
EMP_FOG_ENABLE = 0x800,
|
||||
|
||||
//! Corresponds to SMaterial::NormalizeNormals.
|
||||
EMP_NORMALIZE_NORMALS = 0x1000,
|
||||
|
||||
//! Corresponds to SMaterialLayer::TextureWrapU, TextureWrapV and
|
||||
//! TextureWrapW.
|
||||
EMP_TEXTURE_WRAP = 0x2000,
|
||||
|
@ -61,9 +52,6 @@ enum E_MATERIAL_PROP
|
|||
//! Corresponds to SMaterial::ColorMask.
|
||||
EMP_COLOR_MASK = 0x8000,
|
||||
|
||||
//! Corresponds to SMaterial::ColorMaterial.
|
||||
EMP_COLOR_MATERIAL = 0x10000,
|
||||
|
||||
//! Corresponds to SMaterial::UseMipMaps.
|
||||
EMP_USE_MIP_MAPS = 0x20000,
|
||||
|
||||
|
|
|
@ -194,29 +194,6 @@ enum E_ANTI_ALIASING_MODE
|
|||
EAAM_ALPHA_TO_COVERAGE = 4
|
||||
};
|
||||
|
||||
//! These flags allow to define the interpretation of vertex color when lighting is enabled
|
||||
/** Without lighting being enabled the vertex color is the only value defining the fragment color.
|
||||
Once lighting is enabled, the four values for diffuse, ambient, emissive, and specular take over.
|
||||
With these flags it is possible to define which lighting factor shall be defined by the vertex color
|
||||
instead of the lighting factor which is the same for all faces of that material.
|
||||
The default is to use vertex color for the diffuse value, another pretty common value is to use
|
||||
vertex color for both diffuse and ambient factor. */
|
||||
enum E_COLOR_MATERIAL
|
||||
{
|
||||
//! Don't use vertex color for lighting
|
||||
ECM_NONE = 0,
|
||||
//! Use vertex color for diffuse light, this is default
|
||||
ECM_DIFFUSE,
|
||||
//! Use vertex color for ambient light
|
||||
ECM_AMBIENT,
|
||||
//! Use vertex color for emissive light
|
||||
ECM_EMISSIVE,
|
||||
//! Use vertex color for specular light
|
||||
ECM_SPECULAR,
|
||||
//! Use vertex color for both diffuse and ambient light
|
||||
ECM_DIFFUSE_AND_AMBIENT
|
||||
};
|
||||
|
||||
//! Names for polygon offset direction
|
||||
const c8 *const PolygonOffsetDirectionNames[] = {
|
||||
"Back",
|
||||
|
@ -262,16 +239,14 @@ class SMaterial
|
|||
public:
|
||||
//! Default constructor. Creates a solid, lit material with white colors
|
||||
SMaterial() :
|
||||
MaterialType(EMT_SOLID), AmbientColor(255, 255, 255, 255),
|
||||
DiffuseColor(255, 255, 255, 255), EmissiveColor(0, 0, 0, 0),
|
||||
SpecularColor(255, 255, 255, 255), Shininess(0.0f),
|
||||
MaterialType(EMT_SOLID), ColorParam(0, 0, 0, 0),
|
||||
MaterialTypeParam(0.0f), Thickness(1.0f), ZBuffer(ECFN_LESSEQUAL),
|
||||
AntiAliasing(EAAM_SIMPLE), ColorMask(ECP_ALL), ColorMaterial(ECM_DIFFUSE),
|
||||
AntiAliasing(EAAM_SIMPLE), ColorMask(ECP_ALL),
|
||||
BlendOperation(EBO_NONE), BlendFactor(0.0f), PolygonOffsetDepthBias(0.f),
|
||||
PolygonOffsetSlopeScale(0.f), Wireframe(false), PointCloud(false),
|
||||
GouraudShading(true), Lighting(true), ZWriteEnable(EZW_AUTO),
|
||||
ZWriteEnable(EZW_AUTO),
|
||||
BackfaceCulling(true), FrontfaceCulling(false), FogEnable(false),
|
||||
NormalizeNormals(false), UseMipMaps(true)
|
||||
UseMipMaps(true)
|
||||
{
|
||||
}
|
||||
|
||||
|
@ -281,42 +256,9 @@ public:
|
|||
//! Type of the material. Specifies how everything is blended together
|
||||
E_MATERIAL_TYPE MaterialType;
|
||||
|
||||
//! How much ambient light (a global light) is reflected by this material.
|
||||
/** The default is full white, meaning objects are completely
|
||||
globally illuminated. Reduce this if you want to see diffuse
|
||||
or specular light effects. */
|
||||
SColor AmbientColor;
|
||||
|
||||
//! How much diffuse light coming from a light source is reflected by this material.
|
||||
/** The default is full white. */
|
||||
SColor DiffuseColor;
|
||||
|
||||
//! Light emitted by this material. Default is to emit no light.
|
||||
SColor EmissiveColor;
|
||||
|
||||
//! How much specular light (highlights from a light) is reflected.
|
||||
/** The default is to reflect white specular light. See
|
||||
SMaterial::Shininess on how to enable specular lights. */
|
||||
SColor SpecularColor;
|
||||
|
||||
//! Value affecting the size of specular highlights.
|
||||
/** A value of 20 is common. If set to 0, no specular
|
||||
highlights are being used. To activate, simply set the
|
||||
shininess of a material to a value in the range [0.5;128]:
|
||||
\code
|
||||
sceneNode->getMaterial(0).Shininess = 20.0f;
|
||||
\endcode
|
||||
|
||||
You can change the color of the highlights using
|
||||
\code
|
||||
sceneNode->getMaterial(0).SpecularColor.set(255,255,255,255);
|
||||
\endcode
|
||||
|
||||
The specular color of the dynamic lights
|
||||
(SLight::SpecularColor) will influence the the highlight color
|
||||
too, but they are set to a useful value by default when
|
||||
creating the light scene node.*/
|
||||
f32 Shininess;
|
||||
//! Custom color parameter, can be used by custom shader materials.
|
||||
// See MainShaderConstantSetter in Minetest.
|
||||
SColor ColorParam;
|
||||
|
||||
//! Free parameter, dependent on the material type.
|
||||
/** Mostly ignored, used for example in
|
||||
|
@ -344,14 +286,6 @@ public:
|
|||
depth or stencil buffer, or using Red and Green for Stereo rendering. */
|
||||
u8 ColorMask : 4;
|
||||
|
||||
//! Defines the interpretation of vertex color in the lighting equation
|
||||
/** Values should be chosen from E_COLOR_MATERIAL.
|
||||
When lighting is enabled, vertex color can be used instead of the
|
||||
material values for light modulation. This allows to easily change e.g. the
|
||||
diffuse light behavior of each face. The default, ECM_DIFFUSE, will result in
|
||||
a very similar rendering as with lighting turned off, just with light shading. */
|
||||
u8 ColorMaterial : 3;
|
||||
|
||||
//! Store the blend operation of choice
|
||||
/** Values to be chosen from E_BLEND_OPERATION. */
|
||||
E_BLEND_OPERATION BlendOperation : 4;
|
||||
|
@ -392,12 +326,6 @@ public:
|
|||
//! Draw as point cloud or filled triangles? Default: false
|
||||
bool PointCloud : 1;
|
||||
|
||||
//! Flat or Gouraud shading? Default: true
|
||||
bool GouraudShading : 1;
|
||||
|
||||
//! Will this material be lighted? Default: true
|
||||
bool Lighting : 1;
|
||||
|
||||
//! Is the zbuffer writable or is it read-only. Default: EZW_AUTO.
|
||||
/** If this parameter is not EZW_OFF, you probably also want to set ZBuffer
|
||||
to values other than ECFN_DISABLED */
|
||||
|
@ -412,10 +340,6 @@ public:
|
|||
//! Is fog enabled? Default: false
|
||||
bool FogEnable : 1;
|
||||
|
||||
//! Should normals be normalized?
|
||||
/** Always use this if the mesh lit and scaled. Default: false */
|
||||
bool NormalizeNormals : 1;
|
||||
|
||||
//! Shall mipmaps be used if available
|
||||
/** Sometimes, disabling mipmap usage can be useful. Default: true */
|
||||
bool UseMipMaps : 1;
|
||||
|
@ -486,26 +410,17 @@ public:
|
|||
{
|
||||
bool different =
|
||||
MaterialType != b.MaterialType ||
|
||||
AmbientColor != b.AmbientColor ||
|
||||
DiffuseColor != b.DiffuseColor ||
|
||||
EmissiveColor != b.EmissiveColor ||
|
||||
SpecularColor != b.SpecularColor ||
|
||||
Shininess != b.Shininess ||
|
||||
MaterialTypeParam != b.MaterialTypeParam ||
|
||||
Thickness != b.Thickness ||
|
||||
Wireframe != b.Wireframe ||
|
||||
PointCloud != b.PointCloud ||
|
||||
GouraudShading != b.GouraudShading ||
|
||||
Lighting != b.Lighting ||
|
||||
ZBuffer != b.ZBuffer ||
|
||||
ZWriteEnable != b.ZWriteEnable ||
|
||||
BackfaceCulling != b.BackfaceCulling ||
|
||||
FrontfaceCulling != b.FrontfaceCulling ||
|
||||
FogEnable != b.FogEnable ||
|
||||
NormalizeNormals != b.NormalizeNormals ||
|
||||
AntiAliasing != b.AntiAliasing ||
|
||||
ColorMask != b.ColorMask ||
|
||||
ColorMaterial != b.ColorMaterial ||
|
||||
BlendOperation != b.BlendOperation ||
|
||||
BlendFactor != b.BlendFactor ||
|
||||
PolygonOffsetDepthBias != b.PolygonOffsetDepthBias ||
|
||||
|
|
|
@ -98,12 +98,6 @@ struct SOverrideMaterial
|
|||
case EMP_POINTCLOUD:
|
||||
material.PointCloud = Material.PointCloud;
|
||||
break;
|
||||
case EMP_GOURAUD_SHADING:
|
||||
material.GouraudShading = Material.GouraudShading;
|
||||
break;
|
||||
case EMP_LIGHTING:
|
||||
material.Lighting = Material.Lighting;
|
||||
break;
|
||||
case EMP_ZBUFFER:
|
||||
material.ZBuffer = Material.ZBuffer;
|
||||
break;
|
||||
|
@ -140,9 +134,6 @@ struct SOverrideMaterial
|
|||
case EMP_FOG_ENABLE:
|
||||
material.FogEnable = Material.FogEnable;
|
||||
break;
|
||||
case EMP_NORMALIZE_NORMALS:
|
||||
material.NormalizeNormals = Material.NormalizeNormals;
|
||||
break;
|
||||
case EMP_TEXTURE_WRAP:
|
||||
for (u32 i = 0; i < MATERIAL_MAX_TEXTURES; ++i) {
|
||||
if (EnableLayerProps[i]) {
|
||||
|
@ -158,9 +149,6 @@ struct SOverrideMaterial
|
|||
case EMP_COLOR_MASK:
|
||||
material.ColorMask = Material.ColorMask;
|
||||
break;
|
||||
case EMP_COLOR_MATERIAL:
|
||||
material.ColorMaterial = Material.ColorMaterial;
|
||||
break;
|
||||
case EMP_USE_MIP_MAPS:
|
||||
material.UseMipMaps = Material.UseMipMaps;
|
||||
break;
|
||||
|
|
|
@ -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