浏览代码

TextureRandomizer now works for tutorial's HueShift shader in HDRP

/0.8.0-preview.1_staging
sleal-unity 4 年前
当前提交
c27393c5
共有 2 个文件被更改,包括 15 次插入5 次删除
  1. 18
      com.unity.perception/Runtime/Randomization/Randomizers/RandomizerExamples/Randomizers/TextureRandomizer.cs
  2. 2
      com.unity.perception/Tests/Runtime/Randomization/ScenarioTests/TestFixedLengthScenario.cs

18
com.unity.perception/Runtime/Randomization/Randomizers/RandomizerExamples/Randomizers/TextureRandomizer.cs


[AddRandomizerMenu("Perception/Texture Randomizer")]
public class TextureRandomizer : Randomizer
{
static readonly int k_BaseMap = Shader.PropertyToID("_BaseMap");
static readonly int k_BaseTexture = Shader.PropertyToID("_BaseColorMap");
#else
static readonly int k_BaseTexture = Shader.PropertyToID("_BaseMap");
const string k_TutorialHueShaderName = "Shader Graphs/HueShiftOpaque";
static readonly int k_BaseColorMap = Shader.PropertyToID("_BaseColorMap");
#endif
/// <summary>

var tags = tagManager.Query<TextureRandomizerTag>();
foreach (var tag in tags)
{
var renderer = tag.GetComponent<MeshRenderer>();
renderer.material.SetTexture(k_BaseTexture, texture.Sample());
var renderer = tag.GetComponent<Renderer>();
#if HDRP_PRESENT
// Choose the appropriate shader texture property ID depending on whether the current material is
// using the default HDRP/lit shader or the Perception tutorial's HueShiftOpaque shader
var material = renderer.material;
var propertyId = material.shader.name == k_TutorialHueShaderName ? k_BaseMap : k_BaseColorMap;
material.SetTexture(propertyId, texture.Sample());
#else
renderer.material.SetTexture(k_BaseMap, texture.Sample());
#endif
}
}
}

2
com.unity.perception/Tests/Runtime/Randomization/ScenarioTests/TestFixedLengthScenario.cs


using System;
using UnityEngine;
[AddComponentMenu("")]
class TestFixedLengthScenario : FixedLengthScenario
{
protected override void OnComplete()

正在加载...
取消
保存