Frédéric Vauchelles
7 年前
当前提交
cd1edff6
共有 8 个文件被更改,包括 226 次插入 和 150 次删除
-
14ScriptableRenderPipeline/HDRenderPipeline/Editor/Lighting/HDReflectionProbeEditor.Data.cs
-
16ScriptableRenderPipeline/HDRenderPipeline/Editor/Lighting/HDReflectionProbeEditor.Drawers.cs
-
60ScriptableRenderPipeline/HDRenderPipeline/Editor/Lighting/HDReflectionProbeEditor.Handles.cs
-
71ScriptableRenderPipeline/HDRenderPipeline/Editor/Lighting/HDReflectionProbeEditor.cs
-
66ScriptableRenderPipeline/HDRenderPipeline/Editor/Lighting/HDReflectionProbeEditorOld.cs
-
82ScriptableRenderPipeline/HDRenderPipeline/Lighting/HDAdditionalReflectionData.cs
-
56ScriptableRenderPipeline/HDRenderPipeline/Editor/Lighting/HDReflectionProbeEditor.ProbeUtility.cs
-
11ScriptableRenderPipeline/HDRenderPipeline/Editor/Lighting/HDReflectionProbeEditor.ProbeUtility.cs.meta
|
|||
#if UNITY_EDITOR
|
|||
using UnityEditor; |
|||
#endif
|
|||
using System; |
|||
using System.Collections.Generic; |
|||
|
|||
public ReflectionInfluenceShape m_InfluenceShape; |
|||
[Range(0.0f,1.0f)] |
|||
public float m_Dimmer = 1.0f; |
|||
public float m_InfluenceSphereRadius = 3.0f; |
|||
public float m_SphereReprojectionVolumeRadius = 1.0f; |
|||
public bool m_UseSeparateProjectionVolume = false; |
|||
public Vector3 m_BoxReprojectionVolumeSize = Vector3.one; |
|||
public Vector3 m_BoxReprojectionVolumeCenter = Vector3.zero; |
|||
public float m_MaxSearchDistance = 8.0f; |
|||
private MeshRenderer m_PreviewMeshRenderer; |
|||
public Texture m_PreviewCubemap; |
|||
private MeshFilter m_PreviewMeshFilter; |
|||
private static Mesh m_SphereMesh; |
|||
private static Material m_PreviewMaterial; |
|||
private bool m_Visible; |
|||
#region Registration
|
|||
// We need to notify when a data is enabled
|
|||
// So it can be properly initialized in the editor
|
|||
public static event Action<HDAdditionalReflectionData> OnNewItem; |
|||
static List<HDAdditionalReflectionData> s_AllDatas = new List<HDAdditionalReflectionData>(); |
|||
public static IEnumerable<HDAdditionalReflectionData> AllDatas { get { return s_AllDatas; } } |
|||
|
|||
#if UNITY_EDITOR
|
|||
private static Mesh sphereMesh |
|||
static void AddData(HDAdditionalReflectionData value) |
|||
get { return m_SphereMesh ?? (m_SphereMesh = Resources.GetBuiltinResource(typeof(Mesh), "New-Sphere.fbx") as Mesh); } |
|||
s_AllDatas.Add(value); |
|||
if (OnNewItem != null) |
|||
OnNewItem(value); |
|||
public Material previewMaterial |
|||
static void RemoveData(HDAdditionalReflectionData value) |
|||
get |
|||
{ |
|||
if (m_PreviewMaterial == null ) |
|||
{ |
|||
//m_PreviewMaterial = (Material)Instantiate(AssetDatabase.LoadAssetAtPath("Assets/ScriptableRenderPipeline/ScriptableRenderPipeline/HDRenderPipeline/Debug/PreviewCubemapMaterial.mat", typeof(Material)));
|
|||
m_PreviewMaterial = new Material(Shader.Find("Debug/ReflectionProbePreview")); |
|||
} |
|||
if(m_PreviewCubemap != null) |
|||
m_PreviewMaterial.SetTexture("_Cubemap", m_PreviewCubemap); |
|||
m_PreviewMaterial.hideFlags = HideFlags.HideAndDontSave; |
|||
return m_PreviewMaterial; |
|||
} |
|||
s_AllDatas.Remove(value); |
|||
#endregion
|
|||
|
|||
public ReflectionInfluenceShape influenceShape; |
|||
[Range(0.0f,1.0f)] |
|||
public float dimmer = 1.0f; |
|||
public float influenceSphereRadius = 3.0f; |
|||
public float sphereReprojectionVolumeRadius = 1.0f; |
|||
public bool useSeparateProjectionVolume = false; |
|||
public Vector3 boxReprojectionVolumeSize = Vector3.one; |
|||
public Vector3 boxReprojectionVolumeCenter = Vector3.zero; |
|||
public float maxSearchDistance = 8.0f; |
|||
public Texture previewCubemap; |
|||
private void OnEnable() |
|||
void OnEnable() |
|||
m_PreviewMeshFilter = gameObject.GetComponent<MeshFilter>() != null ? gameObject.GetComponent<MeshFilter>() : gameObject.AddComponent<MeshFilter>(); |
|||
m_PreviewMeshRenderer = gameObject.GetComponent<MeshRenderer>() != null ? gameObject.GetComponent<MeshRenderer>() : gameObject.AddComponent<MeshRenderer>(); |
|||
m_PreviewMeshFilter.sharedMesh = sphereMesh; |
|||
//m_PreviewMeshRenderer.sharedMaterial = previewMaterial;
|
|||
m_PreviewMeshRenderer.lightProbeUsage = UnityEngine.Rendering.LightProbeUsage.Off; |
|||
m_PreviewMeshRenderer.shadowCastingMode = UnityEngine.Rendering.ShadowCastingMode.Off; |
|||
m_PreviewMeshRenderer.motionVectorGenerationMode = MotionVectorGenerationMode.ForceNoMotion; |
|||
AddData(this); |
|||
public void ChangeVisibility(bool visible) |
|||
void OnDisable() |
|||
if(visible != m_Visible) |
|||
{ |
|||
m_PreviewMeshRenderer.sharedMaterial = previewMaterial; |
|||
m_PreviewMeshRenderer.enabled = visible ? true : false; |
|||
m_Visible = visible; |
|||
} |
|||
RemoveData(this); |
|||
#endif
|
|||
} |
|||
} |
|
|||
using UnityEngine; |
|||
using UnityEngine.Experimental.Rendering; |
|||
using Object = UnityEngine.Object; |
|||
|
|||
namespace UnityEditor.Experimental.Rendering |
|||
{ |
|||
partial class HDReflectionProbeEditor |
|||
{ |
|||
static Material s_PreviewMaterial; |
|||
static Mesh s_SphereMesh; |
|||
static int _Cubemap = Shader.PropertyToID("_Cubemap"); |
|||
|
|||
|
|||
[InitializeOnLoadMethod] |
|||
static void Initialize() |
|||
{ |
|||
s_PreviewMaterial = new Material(Shader.Find("Debug/ReflectionProbePreview")) |
|||
{ |
|||
hideFlags = HideFlags.HideAndDontSave |
|||
}; |
|||
s_SphereMesh = Resources.GetBuiltinResource(typeof(Mesh), "New-Sphere.fbx") as Mesh; |
|||
|
|||
HDAdditionalReflectionData.OnNewItem += OnNewProbe; |
|||
foreach (var data in HDAdditionalReflectionData.AllDatas) |
|||
OnNewProbe(data); |
|||
} |
|||
|
|||
static void OnNewProbe(HDAdditionalReflectionData value) |
|||
{ |
|||
InitializeProbe(value.GetComponent<ReflectionProbe>(), value); |
|||
} |
|||
|
|||
static void InitializeProbe(ReflectionProbe p, HDAdditionalReflectionData data) |
|||
{ |
|||
var meshFilter = p.GetComponent<MeshFilter>() ?? p.gameObject.AddComponent<MeshFilter>(); |
|||
var meshRenderer = p.GetComponent<MeshRenderer>() ?? p.gameObject.AddComponent<MeshRenderer>(); |
|||
|
|||
meshFilter.sharedMesh = s_SphereMesh; |
|||
|
|||
var material = Object.Instantiate(s_PreviewMaterial); |
|||
material.SetTexture(_Cubemap, p.texture); |
|||
material.hideFlags = HideFlags.HideAndDontSave; |
|||
meshRenderer.material = material; |
|||
|
|||
meshRenderer.lightProbeUsage = UnityEngine.Rendering.LightProbeUsage.Off; |
|||
meshRenderer.shadowCastingMode = UnityEngine.Rendering.ShadowCastingMode.Off; |
|||
meshRenderer.motionVectorGenerationMode = MotionVectorGenerationMode.ForceNoMotion; |
|||
} |
|||
|
|||
static void ChangeVisibility(ReflectionProbe p, bool visible) |
|||
{ |
|||
var meshRenderer = p.GetComponent<MeshRenderer>() ?? p.gameObject.AddComponent<MeshRenderer>(); |
|||
meshRenderer.enabled = visible; |
|||
} |
|||
} |
|||
} |
|
|||
fileFormatVersion: 2 |
|||
guid: f6273acc6af56c2469971f9fd835884c |
|||
MonoImporter: |
|||
externalObjects: {} |
|||
serializedVersion: 2 |
|||
defaultReferences: [] |
|||
executionOrder: 0 |
|||
icon: {instanceID: 0} |
|||
userData: |
|||
assetBundleName: |
|||
assetBundleVariant: |
撰写
预览
正在加载...
取消
保存
Reference in new issue