浏览代码

added hue randomizer

/main
Steven Leal 4 年前
当前提交
7cd5e8d4
共有 4 个文件被更改,包括 48 次插入0 次删除
  1. 34
      com.unity.perception/Runtime/Randomization/Randomizers/SampleRandomizers/Randomizers/HueOffsetRandomizer.cs
  2. 3
      com.unity.perception/Runtime/Randomization/Randomizers/SampleRandomizers/Randomizers/HueOffsetRandomizer.cs.meta
  3. 8
      com.unity.perception/Runtime/Randomization/Randomizers/SampleRandomizers/Tags/HueOffsetRandomizerTag.cs
  4. 3
      com.unity.perception/Runtime/Randomization/Randomizers/SampleRandomizers/Tags/HueOffsetRandomizerTag.cs.meta

34
com.unity.perception/Runtime/Randomization/Randomizers/SampleRandomizers/Randomizers/HueOffsetRandomizer.cs


using System;
using UnityEngine.Experimental.Perception.Randomization.Parameters;
using UnityEngine.Experimental.Perception.Randomization.Randomizers.SampleRandomizers.Tags;
using UnityEngine.Experimental.Perception.Randomization.Samplers;
namespace UnityEngine.Experimental.Perception.Randomization.Randomizers.SampleRandomizers
{
/// <summary>
/// Randomly offsets the hue of objects tagged with a ColorRandomizerTag
/// </summary>
[Serializable]
public class HueOffsetRandomizer : Randomizer
{
static readonly int k_HueOffsetShaderProperty = Shader.PropertyToID("_HueOffset");
/// <summary>
/// The range of hue offsets to assign to tagged objects
/// </summary>
public FloatParameter hueOffset = new FloatParameter { value = new UniformSampler(-180f, 180f) };
/// <summary>
/// Randomizes the hue offset of tagged objects at the start of each scenario iteration
/// </summary>
protected override void OnIterationStart()
{
var taggedObjects = tagManager.Query<HueOffsetRandomizerTag>();
foreach (var taggedObject in taggedObjects)
{
var renderer = taggedObject.GetComponent<MeshRenderer>();
renderer.material.SetFloat(k_HueOffsetShaderProperty, hueOffset.Sample());
}
}
}
}

3
com.unity.perception/Runtime/Randomization/Randomizers/SampleRandomizers/Randomizers/HueOffsetRandomizer.cs.meta


fileFormatVersion: 2
guid: cc39dc130de74dd2956d0c35cfdc0353
timeCreated: 1600902527

8
com.unity.perception/Runtime/Randomization/Randomizers/SampleRandomizers/Tags/HueOffsetRandomizerTag.cs


namespace UnityEngine.Experimental.Perception.Randomization.Randomizers.SampleRandomizers.Tags
{
/// <summary>
/// Used in conjunction with a HueOffsetRandomizer to vary the hue of GameObjects
/// </summary>
[AddComponentMenu("Perception/RandomizerTags/HueOffsetRandomizerTag")]
public class HueOffsetRandomizerTag : RandomizerTag { }
}

3
com.unity.perception/Runtime/Randomization/Randomizers/SampleRandomizers/Tags/HueOffsetRandomizerTag.cs.meta


fileFormatVersion: 2
guid: 15d8103dbb8346ad8a6cf5bcf723c188
timeCreated: 1600902591
正在加载...
取消
保存