Day cycle

Hi guys… I’ve made an animated sky cycle as an exercise in getting my feet wet with Kismet. It looks ok apart from one thing that’s really apparent, the foliage which uses an unlit material never changes and stands out like day glow when it gets darker. How much of a performance hit would I take if I changed the Master material to phong? The other option is to animate the materials to suit and if that is the better option, can I make a Master Instance material so I only have to animate the one instance for everything else to follow? (IGNORE I HAVE GONE FOR THE SECOND OPTION)

i will share you my day night cycle code in the future now I GTG wait on.


//-----------------------------------------------------------
//By Neongho
//Description applies day night ingame
//credits to tutorial of day nihgth system, of UDK " write name when you has time"
//-----------------------------------------------------------
class GOTADayNightDominantLight extends DominantDirectionalLightMovable
ClassGroup(Lights,DirectionalLights)
placeable;

var () float DayNightFreq;
var () int DayNightStep;
var () float Correction;
var () int TurnOffHour;
var () int TurnOnHour;

//for rotation purposes
var rotator R;
var rotator SunRotation;

//Time vars
var int Days;
var int Hours;
var int Minutes;

//assets to modify for lighting
var() InterpActor SkyActor;
var() SkyLightToggleable SkyLight;
var() exponentialheightFog FogAsset;

//Basic colors of the MIC of the Sky
var() const linearColor HorizonColor[6], ZenithColor[6], SunColor[6], RimColor[6];

//other miscellenous values of the MIC
var() const float skyBrightness[6], CloudOpacity[6], CloudDarkness[6], CloudBrightness[6], Desaturation[6], RimBrightness[6];

//Directional, fog , skylight , directional light colours
var() const color DirectionalLightColor[6], FogOppositeColor[6], FogInscatteringColor[6], SkyLightColor[6];


//Brigthnesses and scales of the 6 stages for SKY LIGHT AND DIRECTIONAL LIght
var() const float DirectionalLightBrigthnesses[6], SkyLightBrightnesses[6], SkyLightLowerBrightnesses[6];

//ShaftsVariablesvariables
var() const float BloomScale[5], RadialBlurrPercent[5], OcclusionBloomDarkness[5], OcculusionDepthRange[5];
var() const color BloomTint[5];

//Fog variables
var() const float Density[6], FogMaxFallOf[6], FogAngle[6], FogOppositeBrightness[6], FogInscatteringBrightness[6];

var() const int StagesTimes[6], StagesEnds[6];

var() bool bIsInMorningHori, bIsInMorningToMid, bIsInMidday, bIsInAfternoonToLate, bIsInAfternoonToHori, bIsInAfternoonToNight;

//Dyamic variables**********************
//Horizon zenith sun
var linearColor ActualColourHorizon;
var linearColor ActualColourZenith;
var linearColor ActualColourSun;
var linearColor ActualColourCloudSide;

//float variables from the day night system
var float ActualCloudBrightness;
var float ActualCloudOpacity;
var float ActualDesaturation;
var float ActualCloudDarkness;
var float ActualRimBrightness;
var float ActualSkyBrightness;

//Dirlight color , fog color
Var color ActualDirColor;
var float ActualDirColorX, ActualDirColorY, ActualDirColorZ;
Var color ActualFogColor;
var float ActualFogColorX, ActualFogColorY, ActualFogColorZ;
Var color ActualFogInscatteringColor;
var float ActualFogInscatteringColorX, ActualFogInscatteringColorY, ActualFogInscatteringColorZ;
Var color ActualSkyLightColor;
var float ActualSkyLightColorX, ActualSkyLightColorY, ActualSkyLightColorZ;
Var color ActualSkyLowLightColor;
var float ActualSkyLowLightColorX, ActualSkyLowLightColorY, ActualSkyLowLightColorZ;

//Fog properties
var float ActualFogInscaBrighness;
var float ActualFogOppositeBrighness;
var float ActualFogDensity;
var float ActualFogMaxFellOff;
var float ActualFogAngle;


//Shaft Bloom properties
var float ActualBloomScale;
var color ActualBloomColor;
var float ActualBloomColorX, ActualBloomColorY, ActualBloomColorZ;
var float ActualRadialBlurrPercent;
var float ActualMaskOcclusion;
var float ActualOcclusionBloomDarkness;
var float ActualOcculusionDepthRange;
var float ActualstarBrightness;

//Lighting vars " Sky light and DomDir"
var float SLBrigthness;
var float SLLBrigthness;
var float DLBrigthness;

//material instance information
var float TimeStamp;
var bool MatInstanced;

var int ActualStage; //0 Mroning Hori //1 Morning

simulated event PostBeginPlay()
{
	super.PostBeginPlay();

	//TimeStamp = WorldInfo.TimeSeconds;
  	SetTimer(DayNightFreq, true, 'DayNightTimer');

   	GOTAGameInfo(WorldInfo.game).TheDayNightLight = self;
}



simulated function DayNightTimer()
{
	local MaterialInstance CurrentMaterial;
    //local float deltaTime;

    //DeltaTime=WorldInfo.TimeSeconds-TimeStamp;
	TimeStamp = WorldInfo.TimeSeconds;

	R=self.rotation;
	R.Pitch += DayNightStep;
	SunRotation=R;
	if (Role == Role_Authority){
		SunRotation=R;
	}

      //Instance the mateiral
      if (!MatInstanced){
      CurrentMaterial=SkyActor.StaticMeshComponent.CreateAndSetMaterialInstanceConstant(0);
      MatInstanced=true;
			}
      else
      CurrentMaterial=MaterialInstance(SkyActor.StaticMeshComponent.GetMaterial(0));

	Days = (Rotation.Pitch + Correction*(65536/24)) / 65536 ;
	Hours = ( ( (Rotation.Pitch - (Days*65536) ) / 65536.) * 24.)+Correction ;
	Minutes = ( ( (Rotation.Pitch+(Correction*(65536/24)) - (Days*65536) ) ) - (Hours*(65536/24) ) ) / 45.51 ;


	self.SetRotation(R);



   //Change colours change environment***********************

   //Interpolations /////////////////////////////////////////////////

   ActualColourZenith.R = lerp(ActualColourZenith.R, ZenithColor[ActualStage].R ,0.003);     ActualColourZenith.B = lerp(ActualColourZenith.B, ZenithColor[ActualStage].B,0.003);     ActualColourZenith.G = lerp(ActualColourZenith.G, ZenithColor[ActualStage].G, 0.003);
   ActualColourHorizon.R = lerp(ActualColourHorizon.R, HorizonColor[ActualStage].R ,0.003);     ActualColourHorizon.B = lerp(ActualColourHorizon.B, HorizonColor[ActualStage].B, 0.003);     ActualColourHorizon.G = lerp(ActualColourHorizon.G, HorizonColor[ActualStage].G, 0.003);
   ActualColourCloudSide.R = lerp(ActualColourCloudSide.R, RimColor[ActualStage].R ,0.01);     ActualColourCloudSide.B = lerp(ActualColourCloudSide.B, RimColor[ActualStage].B,0.01);     ActualColourCloudSide.G = lerp(ActualColourCloudSide.G, RimColor[ActualStage].G, 0.01);  ActualColourCloudSide.A = lerp(ActualColourCloudSide.A, RimColor[ActualStage].A, 0.1);
   ActualColourSun.R = lerp(ActualColoursun.R, SunColor[ActualStage].R ,0.01);     ActualColourSun.B = lerp(ActualColoursun.B, SunColor[ActualStage].B, 0.01);     ActualColourSun.G = lerp(ActualColourSun.G, SunColor[ActualStage].G, 0.01);   ActualColourSun.A = lerp(ActualColourSun.A, SunColor[ActualStage].A, 0.1);

   ActualSkyBrightness = lerp(ActualSkyBrightness, skyBrightness[ActualStage] , 0.0025);
   ActualRimBrightness = lerp(ActualRimBrightness, RimBrightness[ActualStage] , 0.0025);
   ActualCloudDarkness = lerp(ActualCloudDarkness, CloudDarkness[ActualStage] , 0.0025);
   ActualDesaturation = lerp(ActualDesaturation, Desaturation[ActualStage] , 0.0025);
   ActualCloudOpacity = lerp(ActualCloudOpacity, CloudOpacity[ActualStage] , 0.0025);
   ActualCloudBrightness = lerp(ActualCloudBrightness, CloudBrightness[ActualStage] , 0.0025);

   //Lights interpolating
   SLBrigthness = lerp(SLBrigthness, SkyLightBrightnesses[ActualStage] , 0.0005);
   SLLBrigthness = lerp(SLLBrigthness, SkyLightLowerBrightnesses[ActualStage] , 0.005);
   DLBrigthness = lerp(DLBrigthness, DirectionalLightBrigthnesses[ActualStage] , 0.0005);

   //Directional light color and brightness
   ActualDirColorX = Lerp(ActualDirColorX, DirectionalLightColor[ActualStage].R, 0.005);   ActualDirColorY = Lerp(ActualDirColorY, DirectionalLightColor[ActualStage].G, 0.005);  ActualDirColorZ = Lerp(ActualDirColorZ, DirectionalLightColor[ActualStage].B, 0.005);
   ActualDirColor.R = ActualDirColorX;  ActualDirColor.G = ActualDirColorY; ActualDirColor.B = ActualDirColorZ;
   ActualSkyLightColorX = Lerp(ActualSkyLightColorX, SkyLightColor[ActualStage].R, 0.005);   ActualSkyLightColorY = Lerp(ActualSkyLightColorY, SkyLightColor[ActualStage].G, 0.005);  ActualSkyLightColorZ = Lerp(ActualSkyLightColorZ, SkyLightColor[ActualStage].B, 0.005);
   ActualSkyLightColor.R = ActualSkyLightColorX;  ActualSkyLightColor.G = ActualSkyLightColorY;      ActualSkyLightColor.B = ActualSkyLightColorZ;
   ActualFogColorX = Lerp(ActualFogColorX, FogOppositeColor[ActualStage].R, 0.002) ;   ActualFogColorY = Lerp(ActualFogColorY, FogOppositeColor[ActualStage].G, 0.002);  ActualFogColorZ = Lerp(ActualFogColorZ, FogOppositeColor[ActualStage].B, 0.002);
   ActualFogColor.R = ActualFogColorX;   ActualFogColor.G = ActualFogColorY; ActualFogColor.B = ActualFogColorZ;
   ActualFogInscatteringColorX = Lerp(ActualFogInscatteringColorX, FogInscatteringColor[ActualStage].R, 0.002) ;   ActualFogInscatteringColorY = Lerp(ActualFogInscatteringColorY, FogInscatteringColor[ActualStage].G, 0.002);  ActualFogInscatteringColorZ = Lerp(ActualFogInscatteringColorZ, FogInscatteringColor[ActualStage].B, 0.002);
   ActualFogInscatteringColor.R = ActualFogInscatteringColorX;  ActualFogInscatteringColor.G = ActualFogInscatteringColorY;  ActualFogInscatteringColor.B = ActualFogInscatteringColorZ;


    ActualFogInscaBrighness = Lerp(ActualFogInscaBrighness, FogInscatteringBrightness[ActualStage], 0.002) ;
    ActualFogOppositeBrighness = Lerp(ActualFogOppositeBrighness, FogOppositeBrightness[ActualStage] , 0.002) ;  //Opposite fog bright...
    ActualFogDensity = Lerp(ActualFogDensity, Density[ActualStage], 0.001) ;
    ActualFogMaxFellOff = Lerp(ActualFogMaxFellOff, FogMaxFallOf[ActualStage], 0.004) ;
    ActualFogAngle = Lerp(ActualFogAngle ,FogAngle[ActualStage] , 0.05) ;

    ActualBloomScale = Lerp(ActualBloomScale, BloomScale[ActualStage], 0.005);
    ActualBloomColorX = Lerp(ActualBloomColorX, BloomTint[ActualStage].R, 0.002) ; ActualBloomColorY = Lerp(ActualBloomColorY, BloomTint[ActualStage].G, 0.002); ActualBloomColorZ = Lerp(ActualBloomColorZ, BloomTint[ActualStage].B, 0.002);
    ActualBloomColor.R = ActualBloomColorX; ActualBloomColor.G = ActualBloomColorY; ActualBloomColor.B = ActualBloomColorZ;
    ActualRadialBlurrPercent =  Lerp(ActualRadialBlurrPercent, RadialBlurrPercent[ActualStage], 0.005);
    ActualMaskOcclusion = Lerp(ActualMaskOcclusion, RadialBlurrPercent[ActualStage], 0.005);
    ActualOcclusionBloomDarkness = Lerp(ActualOcclusionBloomDarkness, OcclusionBloomDarkness[ActualStage], 0.005);
    ActualOcculusionDepthRange = Lerp(ActualOcculusionDepthRange, OcculusionDepthRange[ActualStage], 0.005);


   //Setters ////////////////////////////////////////////***********

   //4 colours of sky
   CurrentMaterial.SetVectorParameterValue('ZenithColor',ActualColourZenith);
   CurrentMaterial.SetVectorParameterValue('HorizonColor',ActualColourHorizon);
   CurrentMaterial.SetVectorParameterValue('Sun',ActualColourSun);
   CurrentMaterial.SetVectorParameterValue('RimColor',ActualColourCloudSide);

   CurrentMaterial.SetScalarParameterValue('CloudBrightness',ActualCloudBrightness);
   CurrentMaterial.SetScalarParameterValue('CloudOpacity',ActualCloudOpacity);
   CurrentMaterial.SetScalarParameterValue('Desaturation',ActualDesaturation);
   CurrentMaterial.SetScalarParameterValue('CloudDarkness',ActualCloudDarkness);
   CurrentMaterial.SetScalarParameterValue('RimBrightness',ActualRimBrightness);
   CurrentMaterial.SetScalarParameterValue('SkyBrightness',ActualSkyBrightness);

   LightComponent.SetLightProperties(DLBrigthness, ActualDirColor );
   //SkyLightComponent ( SkyLight.LightComponent ).LowerBrightness = SLLBrigthness;  //So no need for to change engine classes
   SkyLight.LightComponent.SetLightProperties(SLBrigthness, ActualSkyLightColor);


   //DominantDirectionalLightMovable

   //Shaft updating
   LightComponent.BloomScale = ActualBloomScale;
   LightComponent.OcclusionDepthRange = ActualOcculusionDepthRange;
   LightComponent.BloomTint = ActualBloomColor;
   LightComponent.RadialBlurPercent = ActualRadialBlurrPercent;
   LightComponent.OcclusionMaskDarkness = ActualOcclusionBloomDarkness;

   LightComponent.UpdateLightShaftParameters();
   LightComponent.UpdateColorAndBrightness();

   //Fog asset
   //FogAsset.Component.LightInscatteringColor = ActualFogInscatteringColor;
   //FogAsset.Component.OppositeLightColor = ActualFogColor;
   //Non color fog properties
   //FogAsset.Component.LightInscatteringBrightness = ActualFogInscaBrighness;
   //FogAsset.Component.OppositeLightBrightness = ActualFogOppositeBrighness;
   //FogAsset.Component.FogDensity = ActualFogDensity;
   //FogAsset.Component.FogHeightFalloff = ActualFogMaxFellOff;
   //FogAsset.Component.LightTerminatorAngle = ActualFogAngle;

   FogAsset.Component.ForceUpdate(false);


   //Morning horizon
   if(Hours >= StagesTimes[0] && Hours < StagesEnds[0] )
   {

     if(!bIsInMorningHori)
     {
     ActualStage = 0;
     bIsInMorningHori = true;  bIsInMorningToMid = false; bIsInMidday = false; bIsInAfternoonToLate = false; bIsInAfternoonToHori = false; bIsInAfternoonToNight = false;
     }

   }


   //Morning transition to midday
   if(Hours >= StagesTimes[1] && Hours < StagesEnds[1] )
   {

     if(!bIsInMorningToMid)
     {
     ActualStage = 1;
     bIsInMorningHori = false;  bIsInMorningToMid = true; bIsInMidday = false; bIsInAfternoonToLate = false; bIsInAfternoonToHori = false; bIsInAfternoonToNight = false;
     }

   }

   //midday
   if(Hours >= StagesTimes[2] && Hours < StagesEnds[2] )
   {

     if(!bIsInMidday)
     {
     ActualStage = 2;
     bIsInMorningHori = false;  bIsInMorningToMid = false; bIsInMidday = true; bIsInAfternoonToLate = false; bIsInAfternoonToHori = false; bIsInAfternoonToNight = false;
     }

   }




   //midday to aftrnoon late
   if(Hours >= StagesTimes[3] && Hours < StagesEnds[3] )
   {

     if(!bIsInAfternoonToLate)
     {
     ActualStage = 3;
     bIsInMorningHori = false;  bIsInMorningToMid = false; bIsInMidday = false; bIsInAfternoonToLate = true; bIsInAfternoonToHori = false; bIsInAfternoonToNight = false;
     }

   }

   // Aftrnoon to hori
   if(Hours >= StagesTimes[4] && Hours < StagesEnds[4] )
   {

     if(!bIsInAfternoonToHori)
     {
     ActualStage = 4;
     bIsInMorningHori = false;  bIsInMorningToMid = false; bIsInMidday = false; bIsInAfternoonToLate = false; bIsInAfternoonToHori = true; bIsInAfternoonToNight = false;
     }

   }

   //night
   if(Hours >= StagesTimes[5] && Hours < StagesEnds[5] )
   {

     if(!bIsInAfternoonToNight)
     {
     ActualStage = 5;
     bIsInMorningHori = false;  bIsInMorningToMid = false; bIsInMidday = false; bIsInAfternoonToLate = false; bIsInAfternoonToHori = false; bIsInAfternoonToNight = true;
     }

   }



}


//set time specific of the sun

function SetNewTime(int NewHour, int NewMinute)
{
local float FloatMinutesAddition;
local float FloatHours;
local float ConstantHourRota;

FloatMinutesAddition =( ( (NewMinute*100) / 60  ) /100);
FloatHours = NewHour + FloatMinutesAddition;
ConstantHourRota = 65536/24;
R.pitch = (FloatHours+3)*ConstantHourRota;
self.SetRotation(R);




}






DefaultProperties
{


	bHidden=FALSE //REPLICATION NEEDS THIS
	bNoDelete=TRUE

	bRouteBeginPlayEvenIfStatic=FALSE
	bEdShouldSnap=FALSE


	Begin Object name=DominantDirectionalLightComponent0


		ModShadowFadeoutExponent=3.0

		bRenderLightShafts=True

		LightAffectsClassification=LAC_DYNAMIC_AND_STATIC_AFFECTING

	    CastShadows=TRUE
	    CastStaticShadows=TRUE
	    CastDynamicShadows=TRUE
	    bForceDynamicLight=FALSE
	    UseDirectLightMap=FALSE
        bAllowPreShadow=TRUE

	    LightingChannels=(BSP=TRUE,Static=TRUE,Dynamic=TRUE,bInitialized=TRUE)
        LightmassSettings=(LightSourceAngle=.2)

	End Object

	bStatic=FALSE
	bHardAttach=TRUE
	bMovable=TRUE
	Physics=PHYS_Interpolating

	RemoteRole=ROLE_SimulatedProxy
	Role=ROLE_Authority
	bNetInitialRotation=TRUE
	bUpdateSimulatedPosition=TRUE
	bReplicateMovement=TRUE



}

This is basically a dominant map you drop on the map.