ColorMask support. Allows for selective disabling of color planes upon rendering.
git-svn-id: svn://svn.code.sf.net/p/irrlicht/code/trunk@2130 dfc29bdd-3216-0410-991c-e03cc46cb475master
parent
a8d090c43b
commit
d51b2f8349
|
@ -1,5 +1,9 @@
|
||||||
Changes in version 1.6
|
Changes in version 1.6
|
||||||
|
|
||||||
|
- Added ColorMask support to selectively disable color planes on rendering.
|
||||||
|
|
||||||
|
- Added support for all available depth test functions.
|
||||||
|
|
||||||
- Add an outNode to getCollisionPoint() that returns the scene node that was hit, as well as the triangle.
|
- Add an outNode to getCollisionPoint() that returns the scene node that was hit, as well as the triangle.
|
||||||
|
|
||||||
- Initial support for Alpha To Coverage, needs some more fixing until it works on all supported platforms.
|
- Initial support for Alpha To Coverage, needs some more fixing until it works on all supported platforms.
|
||||||
|
|
|
@ -85,6 +85,12 @@ namespace video
|
||||||
//! Are vertex buffer objects supported?
|
//! Are vertex buffer objects supported?
|
||||||
EVDF_VERTEX_BUFFER_OBJECT,
|
EVDF_VERTEX_BUFFER_OBJECT,
|
||||||
|
|
||||||
|
//! Supports Alpha To Coverage
|
||||||
|
EVDF_ALPHA_TO_COVERAGE,
|
||||||
|
|
||||||
|
//! Supports Color masks (disabling color planes in output)
|
||||||
|
EVDF_COLOR_MASK,
|
||||||
|
|
||||||
//! Only used for counting the elements of this enum
|
//! Only used for counting the elements of this enum
|
||||||
EVDF_COUNT
|
EVDF_COUNT
|
||||||
};
|
};
|
||||||
|
|
|
@ -71,6 +71,9 @@ namespace video
|
||||||
//! AntiAliasing mode
|
//! AntiAliasing mode
|
||||||
EMF_ANTI_ALIASING,
|
EMF_ANTI_ALIASING,
|
||||||
|
|
||||||
|
//! ColorMask bits, for enabling the color planes
|
||||||
|
EMF_COLOR_MASK,
|
||||||
|
|
||||||
//! This is not a flag, but a value indicating how much flags there are.
|
//! This is not a flag, but a value indicating how much flags there are.
|
||||||
EMF_MATERIAL_FLAG_COUNT
|
EMF_MATERIAL_FLAG_COUNT
|
||||||
};
|
};
|
||||||
|
|
|
@ -63,6 +63,25 @@ namespace video
|
||||||
ECFN_ALWAYS
|
ECFN_ALWAYS
|
||||||
};
|
};
|
||||||
|
|
||||||
|
//! Enum values for enabling/disabling color planes for rendering
|
||||||
|
enum E_COLOR_PLANE
|
||||||
|
{
|
||||||
|
//! No color enabled
|
||||||
|
ECP_NONE=0,
|
||||||
|
//! Alpha enabled
|
||||||
|
ECP_ALPHA=1,
|
||||||
|
//! Red enabled
|
||||||
|
ECP_RED=2,
|
||||||
|
//! Green enabled
|
||||||
|
ECP_GREEN=4,
|
||||||
|
//! Blue enabled
|
||||||
|
ECP_BLUE=8,
|
||||||
|
//! All colors, no alpha
|
||||||
|
ECP_RGB=14,
|
||||||
|
//! All planes enabled
|
||||||
|
ECP_ALL=15
|
||||||
|
};
|
||||||
|
|
||||||
//! EMT_ONETEXTURE_BLEND: pack srcFact & dstFact and Modulo to MaterialTypeParam
|
//! EMT_ONETEXTURE_BLEND: pack srcFact & dstFact and Modulo to MaterialTypeParam
|
||||||
inline f32 pack_texureBlendFunc ( const E_BLEND_FACTOR srcFact, const E_BLEND_FACTOR dstFact, const E_MODULATE_FUNC modulate )
|
inline f32 pack_texureBlendFunc ( const E_BLEND_FACTOR srcFact, const E_BLEND_FACTOR dstFact, const E_MODULATE_FUNC modulate )
|
||||||
{
|
{
|
||||||
|
@ -119,7 +138,7 @@ namespace video
|
||||||
Shininess(0.0f), MaterialTypeParam(0.0f), MaterialTypeParam2(0.0f), Thickness(1.0f),
|
Shininess(0.0f), MaterialTypeParam(0.0f), MaterialTypeParam2(0.0f), Thickness(1.0f),
|
||||||
Wireframe(false), PointCloud(false), GouraudShading(true), Lighting(true),
|
Wireframe(false), PointCloud(false), GouraudShading(true), Lighting(true),
|
||||||
ZWriteEnable(true), BackfaceCulling(true), FrontfaceCulling(false),
|
ZWriteEnable(true), BackfaceCulling(true), FrontfaceCulling(false),
|
||||||
FogEnable(false), NormalizeNormals(false), ZBuffer(ECFN_LESSEQUAL), AntiAliasing(EAAM_SIMPLE|EAAM_LINE_SMOOTH)
|
FogEnable(false), NormalizeNormals(false), ZBuffer(ECFN_LESSEQUAL), AntiAliasing(EAAM_SIMPLE|EAAM_LINE_SMOOTH), ColorMask(ECP_ALL)
|
||||||
{ }
|
{ }
|
||||||
|
|
||||||
//! Copy constructor
|
//! Copy constructor
|
||||||
|
@ -166,6 +185,7 @@ namespace video
|
||||||
NormalizeNormals = other.NormalizeNormals;
|
NormalizeNormals = other.NormalizeNormals;
|
||||||
ZBuffer = other.ZBuffer;
|
ZBuffer = other.ZBuffer;
|
||||||
AntiAliasing = other.AntiAliasing;
|
AntiAliasing = other.AntiAliasing;
|
||||||
|
ColorMask = other.ColorMask;
|
||||||
|
|
||||||
return *this;
|
return *this;
|
||||||
}
|
}
|
||||||
|
@ -279,6 +299,13 @@ namespace video
|
||||||
//! Sets the antialiasing mode
|
//! Sets the antialiasing mode
|
||||||
u8 AntiAliasing;
|
u8 AntiAliasing;
|
||||||
|
|
||||||
|
//! Defines the enabled color planes
|
||||||
|
/** Values are defined as or'ed values of the E_COLOR_PLANE enum.
|
||||||
|
Only enabled color planes will be rendered to the current render
|
||||||
|
target. Typical use is to disable all colors when rendering only to
|
||||||
|
depth or stencil buffer, or using Red and Green for Stereo rendering. */
|
||||||
|
u8 ColorMask;
|
||||||
|
|
||||||
//! Gets the texture transformation matrix for level i
|
//! Gets the texture transformation matrix for level i
|
||||||
/** \param i The desired level. Must not be larger than MATERIAL_MAX_TEXTURES.
|
/** \param i The desired level. Must not be larger than MATERIAL_MAX_TEXTURES.
|
||||||
\return Texture matrix for texture level i. */
|
\return Texture matrix for texture level i. */
|
||||||
|
@ -383,7 +410,11 @@ namespace video
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case EMF_ANTI_ALIASING:
|
case EMF_ANTI_ALIASING:
|
||||||
AntiAliasing = value?1:0;
|
AntiAliasing = value?EAAM_SIMPLE:EAAM_OFF;
|
||||||
|
break;
|
||||||
|
case EMF_COLOR_MASK:
|
||||||
|
ColorMask = value?ECP_ALL:ECP_NONE;
|
||||||
|
break;
|
||||||
default:
|
default:
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
@ -429,6 +460,8 @@ namespace video
|
||||||
TextureLayer[3].TextureWrap);
|
TextureLayer[3].TextureWrap);
|
||||||
case EMF_ANTI_ALIASING:
|
case EMF_ANTI_ALIASING:
|
||||||
return (AntiAliasing==1);
|
return (AntiAliasing==1);
|
||||||
|
case EMF_COLOR_MASK:
|
||||||
|
return (ColorMask!=ECP_NONE);
|
||||||
case EMF_MATERIAL_FLAG_COUNT:
|
case EMF_MATERIAL_FLAG_COUNT:
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
@ -460,8 +493,9 @@ namespace video
|
||||||
BackfaceCulling != b.BackfaceCulling ||
|
BackfaceCulling != b.BackfaceCulling ||
|
||||||
FrontfaceCulling != b.FrontfaceCulling ||
|
FrontfaceCulling != b.FrontfaceCulling ||
|
||||||
FogEnable != b.FogEnable ||
|
FogEnable != b.FogEnable ||
|
||||||
NormalizeNormals != b.NormalizeNormals||
|
NormalizeNormals != b.NormalizeNormals ||
|
||||||
AntiAliasing != b.AntiAliasing;
|
AntiAliasing != b.AntiAliasing ||
|
||||||
|
ColorMask != b.ColorMask;
|
||||||
for (u32 i=0; (i<MATERIAL_MAX_TEXTURES) && !different; ++i)
|
for (u32 i=0; (i<MATERIAL_MAX_TEXTURES) && !different; ++i)
|
||||||
{
|
{
|
||||||
different |= (TextureLayer[i] != b.TextureLayer[i]);
|
different |= (TextureLayer[i] != b.TextureLayer[i]);
|
||||||
|
|
|
@ -566,6 +566,8 @@ bool CD3D8Driver::queryFeature(E_VIDEO_DRIVER_FEATURE feature) const
|
||||||
return (Caps.TextureCaps & D3DPTEXTURECAPS_SQUAREONLY) == 0;
|
return (Caps.TextureCaps & D3DPTEXTURECAPS_SQUAREONLY) == 0;
|
||||||
case EVDF_TEXTURE_NPOT:
|
case EVDF_TEXTURE_NPOT:
|
||||||
return (Caps.TextureCaps & D3DPTEXTURECAPS_POW2) == 0;
|
return (Caps.TextureCaps & D3DPTEXTURECAPS_POW2) == 0;
|
||||||
|
case EVDF_COLOR_MASK:
|
||||||
|
return (Caps.PrimitiveMiscCaps & D3DPMISCCAPS_COLORWRITEENABLE) != 0;
|
||||||
default:
|
default:
|
||||||
return false;
|
return false;
|
||||||
};
|
};
|
||||||
|
@ -1446,6 +1448,18 @@ void CD3D8Driver::setBasicRenderStates(const SMaterial& material, const SMateria
|
||||||
pID3DDevice->SetRenderState(D3DRS_NORMALIZENORMALS, material.NormalizeNormals);
|
pID3DDevice->SetRenderState(D3DRS_NORMALIZENORMALS, material.NormalizeNormals);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Color Mask
|
||||||
|
if (queryFeature(EVDF_COLOR_MASK) &&
|
||||||
|
(resetAllRenderstates || lastmaterial.ColorMask != material.ColorMask))
|
||||||
|
{
|
||||||
|
const DWORD flag =
|
||||||
|
((material.ColorMask & ECP_RED)?D3DCOLORWRITEENABLE_RED:0) |
|
||||||
|
((material.ColorMask & ECP_GREEN)?D3DCOLORWRITEENABLE_GREEN:0) |
|
||||||
|
((material.ColorMask & ECP_BLUE)?D3DCOLORWRITEENABLE_BLUE:0) |
|
||||||
|
((material.ColorMask & ECP_ALPHA)?D3DCOLORWRITEENABLE_ALPHA:0);
|
||||||
|
pID3DDevice->SetRenderState(D3DRS_COLORWRITEENABLE, flag);
|
||||||
|
}
|
||||||
|
|
||||||
// thickness
|
// thickness
|
||||||
if (resetAllRenderstates || lastmaterial.Thickness != material.Thickness)
|
if (resetAllRenderstates || lastmaterial.Thickness != material.Thickness)
|
||||||
{
|
{
|
||||||
|
|
|
@ -614,6 +614,8 @@ bool CD3D9Driver::queryFeature(E_VIDEO_DRIVER_FEATURE feature) const
|
||||||
return (Caps.TextureCaps & D3DPTEXTURECAPS_SQUAREONLY) == 0;
|
return (Caps.TextureCaps & D3DPTEXTURECAPS_SQUAREONLY) == 0;
|
||||||
case EVDF_TEXTURE_NPOT:
|
case EVDF_TEXTURE_NPOT:
|
||||||
return (Caps.TextureCaps & D3DPTEXTURECAPS_POW2) == 0;
|
return (Caps.TextureCaps & D3DPTEXTURECAPS_POW2) == 0;
|
||||||
|
case EVDF_COLOR_MASK:
|
||||||
|
return (Caps.PrimitiveMiscCaps & D3DPMISCCAPS_COLORWRITEENABLE) != 0;
|
||||||
default:
|
default:
|
||||||
return false;
|
return false;
|
||||||
};
|
};
|
||||||
|
@ -1772,6 +1774,18 @@ void CD3D9Driver::setBasicRenderStates(const SMaterial& material, const SMateria
|
||||||
pID3DDevice->SetRenderState(D3DRS_NORMALIZENORMALS, material.NormalizeNormals);
|
pID3DDevice->SetRenderState(D3DRS_NORMALIZENORMALS, material.NormalizeNormals);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Color Mask
|
||||||
|
if (queryFeature(EVDF_COLOR_MASK) &&
|
||||||
|
(resetAllRenderstates || lastmaterial.ColorMask != material.ColorMask))
|
||||||
|
{
|
||||||
|
const DWORD flag =
|
||||||
|
((material.ColorMask & ECP_RED)?D3DCOLORWRITEENABLE_RED:0) |
|
||||||
|
((material.ColorMask & ECP_GREEN)?D3DCOLORWRITEENABLE_GREEN:0) |
|
||||||
|
((material.ColorMask & ECP_BLUE)?D3DCOLORWRITEENABLE_BLUE:0) |
|
||||||
|
((material.ColorMask & ECP_ALPHA)?D3DCOLORWRITEENABLE_ALPHA:0);
|
||||||
|
pID3DDevice->SetRenderState(D3DRS_COLORWRITEENABLE, flag);
|
||||||
|
}
|
||||||
|
|
||||||
// Anti Aliasing
|
// Anti Aliasing
|
||||||
if (resetAllRenderstates || lastmaterial.AntiAliasing != material.AntiAliasing)
|
if (resetAllRenderstates || lastmaterial.AntiAliasing != material.AntiAliasing)
|
||||||
{
|
{
|
||||||
|
|
|
@ -2146,6 +2146,16 @@ void COpenGLDriver::setBasicRenderStates(const SMaterial& material, const SMater
|
||||||
glDisable(GL_NORMALIZE);
|
glDisable(GL_NORMALIZE);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Color Mask
|
||||||
|
if (resetAllRenderStates || lastmaterial.ColorMask != material.ColorMask)
|
||||||
|
{
|
||||||
|
glColorMask(
|
||||||
|
(material.ColorMask & ECP_RED)?GL_TRUE:GL_FALSE,
|
||||||
|
(material.ColorMask & ECP_GREEN)?GL_TRUE:GL_FALSE,
|
||||||
|
(material.ColorMask & ECP_BLUE)?GL_TRUE:GL_FALSE,
|
||||||
|
(material.ColorMask & ECP_ALPHA)?GL_TRUE:GL_FALSE);
|
||||||
|
}
|
||||||
|
|
||||||
// thickness
|
// thickness
|
||||||
if (resetAllRenderStates || lastmaterial.Thickness != material.Thickness)
|
if (resetAllRenderStates || lastmaterial.Thickness != material.Thickness)
|
||||||
{
|
{
|
||||||
|
|
|
@ -485,6 +485,10 @@ bool COpenGLExtensionHandler::queryFeature(E_VIDEO_DRIVER_FEATURE feature) const
|
||||||
return FeatureAvailable[IRR_EXT_framebuffer_object];
|
return FeatureAvailable[IRR_EXT_framebuffer_object];
|
||||||
case EVDF_VERTEX_BUFFER_OBJECT:
|
case EVDF_VERTEX_BUFFER_OBJECT:
|
||||||
return FeatureAvailable[IRR_ARB_vertex_buffer_object];
|
return FeatureAvailable[IRR_ARB_vertex_buffer_object];
|
||||||
|
case EVDF_COLOR_MASK:
|
||||||
|
return true;
|
||||||
|
case EVDF_ALPHA_TO_COVERAGE:
|
||||||
|
return FeatureAvailable[IRR_ARB_multisample];
|
||||||
default:
|
default:
|
||||||
return false;
|
return false;
|
||||||
};
|
};
|
||||||
|
@ -495,5 +499,3 @@ bool COpenGLExtensionHandler::queryFeature(E_VIDEO_DRIVER_FEATURE feature) const
|
||||||
}
|
}
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue