UE2 - UT2kX Color change from alpha

  • Two Factor Authentication is now available on BeyondUnreal Forums. To configure it, visit your Profile and look for the "Two Step Verification" option on the left side. We can send codes via email (may be slower) or you can set up any TOTP Authenticator app on your phone (Authy, Google Authenticator, etc) to deliver codes. It is highly recommended that you configure this to keep your account safe.

forrestmark9

New Member
Aug 6, 2009
56
0
0
Yes, I'm trying to get the color in a texture to change only within the alpha and leave everything else the same like how Halo does, I've tried most things but so far it seems impossible to use a ColorModifier with anything else, I can only add the shader, combiner, or etc to the ColorModifier

Here is the texture with it's alpha channel
https://dl.dropboxusercontent.com/u/52828637/cyborg.tif
 

VendorX

Member
Aug 2, 2010
231
6
18
BXL/Paris
You need two Combiners and ConstantColor - in the first Combiner add ConstantColor to original texture and in the second combine original texture with first Combiner by alpha blend with mask.

... or load this texture to the Photoshop, go to Select -> Load Selection ... and in the Channel select Alpha1. Now you can do what you want ...
 

forrestmark9

New Member
Aug 6, 2009
56
0
0
You need two Combiners and ConstantColor - in the first Combiner add ConstantColor to original texture and in the second combine original texture with first Combiner by alpha blend with mask.

... or load this texture to the Photoshop, go to Select -> Load Selection ... and in the Channel select Alpha1. Now you can do what you want ...

That doesn't seem to work, I can't change the texture itself unless I want the package to be huge as I want to replicate the custom color abilities in Free-For-All gametypes in Halo. I currently do this by creating a color-modifier in the code then change the color and material to what I need. This works for models with the armor and leather as separate textures but doesn't work for a few since the color change is 100% reliant on the alpha channel
 

forrestmark9

New Member
Aug 6, 2009
56
0
0
I got it to work now on to the code part, would this correctly do it?

Code:
	if (Controller != None && HaloPlayer(Controller) != none)
	{
		for (i=0;i<PawnModifier[j].Skins.Length;i++)
		{
			HaloConstantColor = ConstantColor(Level.ObjectPool.AllocateObject(class'ConstantColor'));
			if( HaloConstantColor != none )
			{
				if (Controller.PlayerReplicationInfo != None && Controller.PlayerReplicationInfo.Team != None)
				{
					if (Controller.PlayerReplicationInfo.Team.TeamIndex == 0)
						HaloConstantColor.Color = RedTeamColor;
					else
						HaloConstantColor.Color = BlueTeamColor;
				}
				else
					HaloConstantColor.Color = HaloPlayer(Controller).FFAColor;
				HaloCombiner[i] = Combiner(Level.ObjectPool.AllocateObject(class'Combiner'));
				if( HaloCombiner[i] != none )
				{
					HaloCombiner[i].CombineOperation = CO_Multiply;
					HaloCombiner[i].AlphaOperation = AO_Multiply;
					HaloCombiner[i].Material1 = PawnModifier[j].Skins[i].Material;
					HaloCombiner[i].Material2 = HaloConstantColor;
					FinalHaloCombiner[i] = Combiner(Level.ObjectPool.AllocateObject(class'Combiner'));
					if( FinalHaloCombiner[i] != none )
					{
						FinalHaloCombiner[i].CombineOperation = CO_AlphaBlend_With_Mask;
						FinalHaloCombiner[i].AlphaOperation = AO_Use_Mask;
						FinalHaloCombiner[i].Material1 = PawnModifier[j].FFASkins[i].Material;
						FinalHaloCombiner[i].Material2 = HaloCombiner[i];
					}
					FinalShader[i] = Shader(Level.ObjectPool.AllocateObject(class'Shader'));
					if( FinalShader[i] != none )
					{
						FinalShader[i].Diffuse = FinalHaloCombiner[i];
						for (k=0;k<PawnModifier[j].MaterialEnhancers.Length;k++)
						{
							FinalShader[i].Opacity = PawnModifier[j].MaterialEnhancers[k].OpacityMap;
							FinalShader[i].Specular = PawnModifier[j].MaterialEnhancers[k].SpecularMap;
							FinalShader[i].SpecularityMask = PawnModifier[j].MaterialEnhancers[k].SpecularityMask;
							FinalShader[i].SelfIllumination = PawnModifier[j].MaterialEnhancers[k].SelfIlluminationMap;
							FinalShader[i].SelfIlluminationMask = PawnModifier[j].MaterialEnhancers[k].SelfIlluminationMask;
							FinalShader[i].Detail = PawnModifier[j].MaterialEnhancers[k].DetailMap;
							FinalShader[i].DetailScale = PawnModifier[j].MaterialEnhancers[k].DetailScale;
						}
					}
				}
			}
			HaloSkins[i] = FinalShader[i];
			Controller.Pawn.Skins[PawnModifier[j].Skins[i].SkinNum] = HaloSkins[i];
		}
	}

simulated event Destroyed()
{
	local byte i;
	
	if( HaloConstantColor != none )
	{
		Level.ObjectPool.FreeObject(HaloConstantColor);
		HaloConstantColor = None;
	}
	
	for (i=0;i<FinalHaloCombiner.Length;i++)
	{
		if( FinalHaloCombiner[i] != none )
		{
			Level.ObjectPool.FreeObject(FinalHaloCombiner[i]);
			FinalHaloCombiner[i] = None;
		}
	}
	FinalHaloCombiner.Length = 0;

	for (i=0;i<HaloCombiner.Length;i++)
	{
		if( HaloCombiner[i] != none )
		{
			Level.ObjectPool.FreeObject(HaloCombiner[i]);
			HaloCombiner[i] = None;
		}
	}
	HaloCombiner.Length = 0;
	
	for (i=0;i<FinalShader.Length;i++)
	{
		if( FinalShader[i] != none )
		{
			Level.ObjectPool.FreeObject(FinalShader[i]);
			FinalShader[i] = None;
		}
	}
	FinalShader.Length = 0;
	
	for (i=0;i<HaloSkins.Length;i++)
	{
		if( HaloSkins != none )
			HaloSkins = None;
	}
	HaloSkins.Length = 0;
	
	Super.Destroyed();
}
 
Last edited by a moderator:

VendorX

Member
Aug 2, 2010
231
6
18
BXL/Paris
I highly recommend WotGreal - syntax, compiler, debugger etc. Your US learning will speed-up like hell ...

BTW: Bigger package bothers you , but the impact on performance not?
 
Last edited:

forrestmark9

New Member
Aug 6, 2009
56
0
0
I highly recommended WotGreal - syntax, compiler, debugger etc. Your US learning will speed-up like hell ...

I've tried using that and I could never figure it out, so I may just stick to Notepad++

I could never get it to show my packages and it does not support KF as far as I've seen least not in the Mod support area
 
Last edited by a moderator:

VendorX

Member
Aug 2, 2010
231
6
18
BXL/Paris
I've tried using that and I could never figure it out, so I may just stick to Notepad++

I could never get it to show my packages and it does not support KF as far as I've seen least not in the Mod support area

... it does ... Just you need to add your mod name to the UT2004 Mod Name
 

forrestmark9

New Member
Aug 6, 2009
56
0
0
... it does ... Just you need to add your mod name to the UT2004 Mod Name

KillingFloor does it's mod system different from what I've seen, it uses OfficialMod.ini instead of UT2K4Mod.ini

I also can never get it to find UCC.exe or anything else, it will always say that the file was not found
 
Last edited by a moderator:

forrestmark9

New Member
Aug 6, 2009
56
0
0
Here's the final bit of code that adds the combiner and shader and everything, unsure if it will work or if anyone here has a better idea to optimize this

Code:
var		array<Material>			HaloSkins;
var		ConstantColor			HaloConstantColor;
var		array<Combiner>			HaloCombiner,FinalHaloCombiner;
var		array<Shader>			FinalShader;
var()	Color					RedTeamColor,BlueTeamColor;

simulated function Setup(xUtil.PlayerRecord rec, optional bool bLoadNow)
{
	local byte i,j,k,l,m,n;
	
    if( Class<BaseHaloSpecies>(rec.Species)==None )
        rec = class'xUtil'.static.FindPlayerRecord(GetDefaultCharacter());
    Species = rec.Species;
    RagdollOverride = rec.Ragdoll;
    if ( Species!=None && !Species.static.Setup(self,rec) )
    {
        rec = class'xUtil'.static.FindPlayerRecord(GetDefaultCharacter());
        Species = rec.Species;
        RagdollOverride = rec.Ragdoll;
        if ( !Species.static.Setup(self,rec) )
            return;
    }
	
	ParentSpecies = Class<BaseHaloSpecies>(Species);
	
	if( ClassIsChildOf(ParentSpecies, class'SpartanSpecies') ){j=0;}
	else if( ClassIsChildOf(ParentSpecies, class'EliteSpecies') ){j=1;}

	for(k=0;k<Globals.default.CustomSpecies.Length;k++)
	{
		if( ClassIsChildOf(ParentSpecies, Globals.default.CustomSpecies[k].Species))
			j = k+2;
	}
	
	if (Controller != None && HaloPlayer(Controller) != none)
	{
		for (i=0;i<PawnModifier[j].Skins.Length;i++)
		{
			if (PawnModifier[j].Skins[i] == None)
				continue;
			
			HaloSkins[i] = PawnModifier[j].Skins[i].Material;
			
			if( PawnModifier[j].Skins[i].bChangeColors )
			{
				HaloConstantColor = ConstantColor(Level.ObjectPool.AllocateObject(class'ConstantColor'));
				if( HaloConstantColor != none )
				{
					if (Controller.PlayerReplicationInfo != None && Controller.PlayerReplicationInfo.Team != None)
					{
						if (Controller.PlayerReplicationInfo.Team.TeamIndex == 0)
							HaloConstantColor.Color = RedTeamColor;
						else
							HaloConstantColor.Color = BlueTeamColor;
					}
					else
						HaloConstantColor.Color = HaloPlayer(Controller).FFAColor;
					
					l = HaloCombiner.Length;
					m = FinalHaloCombiner.Length;
					n = FinalShader.Length;
				
					HaloCombiner[l] = Combiner(Level.ObjectPool.AllocateObject(class'Combiner'));
					if( HaloCombiner[l] != none )
					{
						HaloCombiner[l].CombineOperation = CO_Multiply;
						HaloCombiner[l].AlphaOperation = AO_Multiply;
						HaloCombiner[l].Material1 = PawnModifier[j].Skins[i].Material;
						HaloCombiner[l].Material2 = HaloConstantColor;
						FinalHaloCombiner[m] = Combiner(Level.ObjectPool.AllocateObject(class'Combiner'));
						if( FinalHaloCombiner[m] != none )
						{
							FinalHaloCombiner[m].CombineOperation = CO_AlphaBlend_With_Mask;
							FinalHaloCombiner[m].AlphaOperation = AO_Use_Mask;
							FinalHaloCombiner[m].Material1 = PawnModifier[j].Skins[i].Material;
							FinalHaloCombiner[m].Material2 = HaloCombiner[l];
							FinalHaloCombiner[m].Mask = PawnModifier[j].Skins[i].Material;
							if( PawnModifier[j].Skins[i].bUsesEnhancer )
							{
								FinalShader[n] = Shader(Level.ObjectPool.AllocateObject(class'Shader'));
								if( FinalShader[n] != none )
								{						
									k = PawnModifier[j].Skins[i].EnhancerNum;
									FinalShader[n].Diffuse = FinalHaloCombiner[m];
									FinalShader[n].Opacity = PawnModifier[j].MaterialEnhancers[k].OpacityMap;
									FinalShader[n].Specular = PawnModifier[j].MaterialEnhancers[k].SpecularMap;
									FinalShader[n].SpecularityMask = PawnModifier[j].MaterialEnhancers[k].SpecularityMask;
									FinalShader[n].SelfIllumination = PawnModifier[j].MaterialEnhancers[k].SelfIlluminationMap;
									FinalShader[n].SelfIlluminationMask = PawnModifier[j].MaterialEnhancers[k].SelfIlluminationMask;
									FinalShader[n].Detail = PawnModifier[j].MaterialEnhancers[k].DetailMap;
									FinalShader[n].DetailScale = PawnModifier[j].MaterialEnhancers[k].DetailScale;
									HaloSkins[i] = FinalShader[n];
								}
							}
							else
							{
								HaloSkins[i] = FinalHaloCombiner[m];
							}
						}
					}
				}
			}
			Controller.Pawn.Skins[PawnModifier[j].Skins[i].SkinNum] = HaloSkins[i];
		}
	}
	ResetPhysicsBasedAnim();
}

simulated event Destroyed()
{
	local byte i;
	
	if( HaloConstantColor != none )
	{
		Level.ObjectPool.FreeObject(HaloConstantColor);
		HaloConstantColor = None;
	}
	
	for (i=0;i<FinalHaloCombiner.Length;i++)
	{
		if( FinalHaloCombiner[i] != none )
		{
			Level.ObjectPool.FreeObject(FinalHaloCombiner[i]);
			FinalHaloCombiner[i] = None;
		}
	}
	FinalHaloCombiner.Length = 0;

	for (i=0;i<HaloCombiner.Length;i++)
	{
		if( HaloCombiner[i] != none )
		{
			Level.ObjectPool.FreeObject(HaloCombiner[i]);
			HaloCombiner[i] = None;
		}
	}
	HaloCombiner.Length = 0;
	
	for (i=0;i<FinalShader.Length;i++)
	{
		if( FinalShader[i] != none )
		{
			Level.ObjectPool.FreeObject(FinalShader[i]);
			FinalShader[i] = None;
		}
	}
	FinalShader.Length = 0;
	
	for (i=0;i<HaloSkins.Length;i++)
	{
		if( HaloSkins != none )
			HaloSkins = None;
	}
	HaloSkins.Length = 0;
	
	Super.Destroyed();
}

defaultproperties	
{
	Begin Object Class=HaloMeshModifier Name=PawnModifierSpartan
		Skins(0)=(Material=Texture'HaloTC_Textures.Cyborg.Cyborg',bChangeColors=True,bUsesEnhancer=True)
		MaterialEnhancers(0)=(SpecularMap=TexEnvMap'HaloTC_Textures.CubeMaps.cyborg_reflection_armor_envtex',SpecularityMask=Texture'HaloTC_Textures.Cyborg.cyborg_multipurpose',SelfIlluminationMap=Texture'HaloTC_Textures.Cyborg.Cyborg',SelfIlluminationMask=Texture'HaloTC_Textures.Cyborg.cyborg_selfillum',DetailMap=Texture'HaloTC_Textures.Detailmaps.detail_corroded_metal_light',DetailScale=10.000000)
		RightHandBoneName="#right hand"
		LeftHandBoneName="#left hand"
	End Object
	Begin Object Class=HaloMeshModifier Name=PawnModifierElite
		Skins(0)=(Material=Texture'HaloTC_Textures.Elite.Arms',bChangeColors=True,bUsesEnhancer=True)
		Skins(1)=(Material=Texture'HaloTC_Textures.Elite.head',bChangeColors=True,bUsesEnhancer=True,SkinNum=1,EnhancerNum=1)
		Skins(2)=(Material=Texture'HaloTC_Textures.Elite.legs',SkinNum=2)
		Skins(3)=(Material=Texture'HaloTC_Textures.Elite.Torso',bChangeColors=True,bUsesEnhancer=True,SkinNum=4,EnhancerNum=2)
		Skins(4)=(Material=Texture'HaloTC_Textures.Elite.Helmet',bChangeColors=True,SkinNum=5)
		MaterialEnhancers(0)=(SelfIlluminationMap=Texture'HaloTC_Textures.Elite.Arms',SelfIlluminationMask=Texture'HaloTC_Textures.Elite.arms_selfillum')
		MaterialEnhancers(1)=(SelfIlluminationMap=Texture'HaloTC_Textures.Elite.legs',SelfIlluminationMask=Texture'HaloTC_Textures.Elite.legs_selfillum')
		MaterialEnhancers(2)=(SelfIlluminationMap=Texture'HaloTC_Textures.Elite.Torso',SelfIlluminationMask=Texture'HaloTC_Textures.Elite.torso_selfillum')
		RightHandBoneName="#right hand elite"
		LeftHandBoneName="#left hand elite"
	End Object
}
 
Last edited by a moderator: