mirror of
				https://github.com/luanti-org/luanti.git
				synced 2025-11-04 09:15:29 +01:00 
			
		
		
		
	Reduce size of SMaterial struct
This commit is contained in:
		@@ -20,7 +20,7 @@ class ITexture;
 | 
			
		||||
 | 
			
		||||
//! Flag for MaterialTypeParam (in combination with EMT_ONETEXTURE_BLEND) or for BlendFactor
 | 
			
		||||
//! BlendFunc = source * sourceFactor + dest * destFactor
 | 
			
		||||
enum E_BLEND_FACTOR
 | 
			
		||||
enum E_BLEND_FACTOR : u8
 | 
			
		||||
{
 | 
			
		||||
	EBF_ZERO = 0,            //!< src & dest	(0, 0, 0, 0)
 | 
			
		||||
	EBF_ONE,                 //!< src & dest	(1, 1, 1, 1)
 | 
			
		||||
@@ -36,7 +36,7 @@ enum E_BLEND_FACTOR
 | 
			
		||||
};
 | 
			
		||||
 | 
			
		||||
//! Values defining the blend operation
 | 
			
		||||
enum E_BLEND_OPERATION
 | 
			
		||||
enum E_BLEND_OPERATION : u8
 | 
			
		||||
{
 | 
			
		||||
	EBO_NONE = 0,    //!< No blending happens
 | 
			
		||||
	EBO_ADD,         //!< Default blending adds the color values
 | 
			
		||||
@@ -51,7 +51,7 @@ enum E_BLEND_OPERATION
 | 
			
		||||
};
 | 
			
		||||
 | 
			
		||||
//! MaterialTypeParam: e.g. DirectX: D3DTOP_MODULATE, D3DTOP_MODULATE2X, D3DTOP_MODULATE4X
 | 
			
		||||
enum E_MODULATE_FUNC
 | 
			
		||||
enum E_MODULATE_FUNC : u8
 | 
			
		||||
{
 | 
			
		||||
	EMFN_MODULATE_1X = 1,
 | 
			
		||||
	EMFN_MODULATE_2X = 2,
 | 
			
		||||
@@ -59,7 +59,7 @@ enum E_MODULATE_FUNC
 | 
			
		||||
};
 | 
			
		||||
 | 
			
		||||
//! Comparison function, e.g. for depth buffer test
 | 
			
		||||
enum E_COMPARISON_FUNC
 | 
			
		||||
enum E_COMPARISON_FUNC : u8
 | 
			
		||||
{
 | 
			
		||||
	//! Depth test disabled (disable also write to depth buffer)
 | 
			
		||||
	ECFN_DISABLED = 0,
 | 
			
		||||
@@ -82,7 +82,7 @@ enum E_COMPARISON_FUNC
 | 
			
		||||
};
 | 
			
		||||
 | 
			
		||||
//! Enum values for enabling/disabling color planes for rendering
 | 
			
		||||
enum E_COLOR_PLANE
 | 
			
		||||
enum E_COLOR_PLANE : u8
 | 
			
		||||
{
 | 
			
		||||
	//! No color enabled
 | 
			
		||||
	ECP_NONE = 0,
 | 
			
		||||
@@ -103,7 +103,7 @@ enum E_COLOR_PLANE
 | 
			
		||||
//! Source of the alpha value to take
 | 
			
		||||
/** This is currently only supported in EMT_ONETEXTURE_BLEND. You can use an
 | 
			
		||||
or'ed combination of values. Alpha values are modulated (multiplied). */
 | 
			
		||||
enum E_ALPHA_SOURCE
 | 
			
		||||
enum E_ALPHA_SOURCE : u8
 | 
			
		||||
{
 | 
			
		||||
	//! Use no alpha, somewhat redundant with other settings
 | 
			
		||||
	EAS_NONE = 0,
 | 
			
		||||
@@ -181,7 +181,7 @@ Some drivers don't support a per-material setting of the anti-aliasing
 | 
			
		||||
modes. In those cases, FSAA/multisampling is defined by the device mode
 | 
			
		||||
chosen upon creation via irr::SIrrCreationParameters.
 | 
			
		||||
*/
 | 
			
		||||
enum E_ANTI_ALIASING_MODE
 | 
			
		||||
enum E_ANTI_ALIASING_MODE : u8
 | 
			
		||||
{
 | 
			
		||||
	//! Use to turn off anti-aliasing for this material
 | 
			
		||||
	EAAM_OFF = 0,
 | 
			
		||||
@@ -202,7 +202,7 @@ const c8 *const PolygonOffsetDirectionNames[] = {
 | 
			
		||||
	};
 | 
			
		||||
 | 
			
		||||
//! For SMaterial.ZWriteEnable
 | 
			
		||||
enum E_ZWRITE
 | 
			
		||||
enum E_ZWRITE : u8
 | 
			
		||||
{
 | 
			
		||||
	//! zwrite always disabled for this material
 | 
			
		||||
	EZW_OFF = 0,
 | 
			
		||||
@@ -240,10 +240,10 @@ public:
 | 
			
		||||
	//! Default constructor. Creates a solid material
 | 
			
		||||
	SMaterial() :
 | 
			
		||||
			MaterialType(EMT_SOLID), ColorParam(0, 0, 0, 0),
 | 
			
		||||
			MaterialTypeParam(0.0f), Thickness(1.0f), ZBuffer(ECFN_LESSEQUAL),
 | 
			
		||||
			AntiAliasing(EAAM_SIMPLE), ColorMask(ECP_ALL),
 | 
			
		||||
			BlendOperation(EBO_NONE), BlendFactor(0.0f), PolygonOffsetDepthBias(0.f),
 | 
			
		||||
			PolygonOffsetSlopeScale(0.f), Wireframe(false), PointCloud(false),
 | 
			
		||||
			MaterialTypeParam(0.0f), Thickness(1.0f), BlendFactor(0.0f),
 | 
			
		||||
			PolygonOffsetDepthBias(0.f), PolygonOffsetSlopeScale(0.f),
 | 
			
		||||
			ZBuffer(ECFN_LESSEQUAL), AntiAliasing(EAAM_SIMPLE), ColorMask(ECP_ALL),
 | 
			
		||||
			BlendOperation(EBO_NONE), Wireframe(false), PointCloud(false),
 | 
			
		||||
			ZWriteEnable(EZW_AUTO),
 | 
			
		||||
			BackfaceCulling(true), FrontfaceCulling(false), FogEnable(false),
 | 
			
		||||
			UseMipMaps(true)
 | 
			
		||||
@@ -268,28 +268,6 @@ public:
 | 
			
		||||
	//! Thickness of non-3dimensional elements such as lines and points.
 | 
			
		||||
	f32 Thickness;
 | 
			
		||||
 | 
			
		||||
	//! Is the ZBuffer enabled? Default: ECFN_LESSEQUAL
 | 
			
		||||
	/** If you want to disable depth test for this material
 | 
			
		||||
	just set this parameter to ECFN_DISABLED.
 | 
			
		||||
	Values are from E_COMPARISON_FUNC. */
 | 
			
		||||
	u8 ZBuffer;
 | 
			
		||||
 | 
			
		||||
	//! Sets the antialiasing mode
 | 
			
		||||
	/** Values are chosen from E_ANTI_ALIASING_MODE. Default is
 | 
			
		||||
	EAAM_SIMPLE, i.e. simple multi-sample anti-aliasing. */
 | 
			
		||||
	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 : 4;
 | 
			
		||||
 | 
			
		||||
	//! Store the blend operation of choice
 | 
			
		||||
	/** Values to be chosen from E_BLEND_OPERATION. */
 | 
			
		||||
	E_BLEND_OPERATION BlendOperation : 4;
 | 
			
		||||
 | 
			
		||||
	//! Store the blend factors
 | 
			
		||||
	/** textureBlendFunc/textureBlendFuncSeparate functions should be used to write
 | 
			
		||||
	properly blending factors to this parameter.
 | 
			
		||||
@@ -316,6 +294,25 @@ public:
 | 
			
		||||
	and -1.f to pull them towards the camera.  */
 | 
			
		||||
	f32 PolygonOffsetSlopeScale;
 | 
			
		||||
 | 
			
		||||
	//! Is the ZBuffer enabled? Default: ECFN_LESSEQUAL
 | 
			
		||||
	/** If you want to disable depth test for this material
 | 
			
		||||
	just set this parameter to ECFN_DISABLED. */
 | 
			
		||||
	E_COMPARISON_FUNC ZBuffer : 4;
 | 
			
		||||
 | 
			
		||||
	//! Sets the antialiasing mode
 | 
			
		||||
	/** Default is EAAM_SIMPLE, i.e. simple multi-sample anti-aliasing. */
 | 
			
		||||
	E_ANTI_ALIASING_MODE AntiAliasing : 4;
 | 
			
		||||
 | 
			
		||||
	//! 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. */
 | 
			
		||||
	E_COLOR_PLANE ColorMask : 4;
 | 
			
		||||
 | 
			
		||||
	//! Store the blend operation of choice
 | 
			
		||||
	E_BLEND_OPERATION BlendOperation : 4;
 | 
			
		||||
 | 
			
		||||
	//! Draw as wireframe or filled triangles? Default: false
 | 
			
		||||
	bool Wireframe : 1;
 | 
			
		||||
 | 
			
		||||
 
 | 
			
		||||
@@ -45,7 +45,7 @@ static const char *const aTextureClampNames[] = {
 | 
			
		||||
//! Texture minification filter.
 | 
			
		||||
/** Used when scaling textures down. See the documentation on OpenGL's
 | 
			
		||||
`GL_TEXTURE_MIN_FILTER` for more information. */
 | 
			
		||||
enum E_TEXTURE_MIN_FILTER
 | 
			
		||||
enum E_TEXTURE_MIN_FILTER : u8
 | 
			
		||||
{
 | 
			
		||||
	//! Aka nearest-neighbor.
 | 
			
		||||
	ETMINF_NEAREST_MIPMAP_NEAREST = 0,
 | 
			
		||||
@@ -61,7 +61,7 @@ enum E_TEXTURE_MIN_FILTER
 | 
			
		||||
/** Used when scaling textures up. See the documentation on OpenGL's
 | 
			
		||||
`GL_TEXTURE_MAG_FILTER` for more information.
 | 
			
		||||
Note that mipmaps are only used for minification, not for magnification. */
 | 
			
		||||
enum E_TEXTURE_MAG_FILTER
 | 
			
		||||
enum E_TEXTURE_MAG_FILTER : u8
 | 
			
		||||
{
 | 
			
		||||
	//! Aka nearest-neighbor.
 | 
			
		||||
	ETMAGF_NEAREST = 0,
 | 
			
		||||
 
 | 
			
		||||
@@ -253,7 +253,7 @@ void CAnimatedMeshSceneNode::render()
 | 
			
		||||
	// for debug purposes only:
 | 
			
		||||
	if (DebugDataVisible && PassCount == 1) {
 | 
			
		||||
		video::SMaterial debug_mat;
 | 
			
		||||
		debug_mat.AntiAliasing = 0;
 | 
			
		||||
		debug_mat.AntiAliasing = video::EAAM_OFF;
 | 
			
		||||
		driver->setMaterial(debug_mat);
 | 
			
		||||
		// show normals
 | 
			
		||||
		if (DebugDataVisible & scene::EDS_NORMALS) {
 | 
			
		||||
 
 | 
			
		||||
@@ -109,7 +109,7 @@ void CMeshSceneNode::render()
 | 
			
		||||
	// for debug purposes only:
 | 
			
		||||
	if (DebugDataVisible && PassCount == 1) {
 | 
			
		||||
		video::SMaterial m;
 | 
			
		||||
		m.AntiAliasing = 0;
 | 
			
		||||
		m.AntiAliasing = video::EAAM_OFF;
 | 
			
		||||
		m.ZBuffer = video::ECFN_DISABLED;
 | 
			
		||||
		driver->setMaterial(m);
 | 
			
		||||
 | 
			
		||||
 
 | 
			
		||||
@@ -1311,7 +1311,7 @@ void CNullDriver::runOcclusionQuery(scene::ISceneNode *node, bool visible)
 | 
			
		||||
	OcclusionQueries[index].Run = 0;
 | 
			
		||||
	if (!visible) {
 | 
			
		||||
		SMaterial mat;
 | 
			
		||||
		mat.AntiAliasing = 0;
 | 
			
		||||
		mat.AntiAliasing = video::EAAM_OFF;
 | 
			
		||||
		mat.ColorMask = ECP_NONE;
 | 
			
		||||
		mat.ZWriteEnable = EZW_OFF;
 | 
			
		||||
		setMaterial(mat);
 | 
			
		||||
 
 | 
			
		||||
@@ -18,7 +18,7 @@ void SetColorMaskStep::run(PipelineContext &context)
 | 
			
		||||
{
 | 
			
		||||
	video::SOverrideMaterial &mat = context.device->getVideoDriver()->getOverrideMaterial();
 | 
			
		||||
	mat.reset();
 | 
			
		||||
	mat.Material.ColorMask = color_mask;
 | 
			
		||||
	mat.Material.ColorMask = static_cast<video::E_COLOR_PLANE>(color_mask);
 | 
			
		||||
	mat.EnableProps = video::EMP_COLOR_MASK;
 | 
			
		||||
	mat.EnablePasses = scene::ESNRP_SKY_BOX | scene::ESNRP_SOLID |
 | 
			
		||||
			   scene::ESNRP_TRANSPARENT | scene::ESNRP_TRANSPARENT_EFFECT;
 | 
			
		||||
 
 | 
			
		||||
@@ -21,7 +21,7 @@ PostProcessingStep::PostProcessingStep(u32 _shader_id, const std::vector<u8> &_t
 | 
			
		||||
void PostProcessingStep::configureMaterial()
 | 
			
		||||
{
 | 
			
		||||
	material.UseMipMaps = false;
 | 
			
		||||
	material.ZBuffer = true;
 | 
			
		||||
	material.ZBuffer = video::ECFN_LESSEQUAL;
 | 
			
		||||
	material.ZWriteEnable = video::EZW_ON;
 | 
			
		||||
	for (u32 k = 0; k < texture_map.size(); ++k) {
 | 
			
		||||
		material.TextureLayers[k].AnisotropicFilter = 0;
 | 
			
		||||
 
 | 
			
		||||
@@ -27,7 +27,7 @@ static video::SMaterial baseMaterial()
 | 
			
		||||
	video::SMaterial mat;
 | 
			
		||||
	mat.ZBuffer = video::ECFN_DISABLED;
 | 
			
		||||
	mat.ZWriteEnable = video::EZW_OFF;
 | 
			
		||||
	mat.AntiAliasing = 0;
 | 
			
		||||
	mat.AntiAliasing = video::EAAM_OFF;
 | 
			
		||||
	mat.TextureLayers[0].TextureWrapU = video::ETC_CLAMP_TO_EDGE;
 | 
			
		||||
	mat.TextureLayers[0].TextureWrapV = video::ETC_CLAMP_TO_EDGE;
 | 
			
		||||
	mat.BackfaceCulling = false;
 | 
			
		||||
 
 | 
			
		||||
		Reference in New Issue
	
	Block a user