Skip to content

Commit

Permalink
Merge pull request #263 from tier4/feature/improve-pedestrian-light
Browse files Browse the repository at this point in the history
Added LightOn Shader Properties to Traffic Light
  • Loading branch information
mackierx111 authored Feb 19, 2024
2 parents bd14119 + 6973645 commit 8408a68
Showing 1 changed file with 9 additions and 0 deletions.
9 changes: 9 additions & 0 deletions Assets/AWSIM/Scripts/Environments/TrafficLight.cs
Original file line number Diff line number Diff line change
Expand Up @@ -105,6 +105,7 @@ public class EmissionConfig
const string EmissiveColor = "_EmissiveColor";
const string EmissiveIntensity = "_EmissiveIntensity";
const string EmissiveExposureWeight = "_EmissiveExposureWeight";
const string LightOnFlag = "_LightOn";
const float flashIntervalSec = 0.5f; // flash bulb lighting interval(sec).

float timer = 0; // used for flashing status. NOTE: Might as well make it static and refer to the same time.
Expand Down Expand Up @@ -210,13 +211,21 @@ void Set(bool isLightOn)
var config = bulbColorConfigPairs[color];
material.SetColor(EmissiveColor, config.Color * config.Intensity);
material.SetFloat(EmissiveExposureWeight, config.ExposureWeight);
if(material.HasProperty(LightOnFlag))
{
material.SetInt(LightOnFlag, 1);
}
this.isLightOn = true;
timer = 0;
}
else
{
material.SetColor(EmissiveColor, defaultEmissiveColor);
material.SetFloat(EmissiveExposureWeight, defaultEmissiveExposureWeight);
if(material.HasProperty(LightOnFlag))
{
material.SetInt(LightOnFlag, 0);
}
this.isLightOn = false;
timer = 0;
}
Expand Down

0 comments on commit 8408a68

Please sign in to comment.