浏览代码

(wip) reflection probe editor

/feature-ReflectionProbeFit
Frédéric Vauchelles 7 年前
当前提交
fb318542
共有 12 个文件被更改,包括 1659 次插入0 次删除
  1. 72
      ScriptableRenderPipeline/HDRenderPipeline/Debug/ReflectionProbesPreview.shader
  2. 9
      ScriptableRenderPipeline/HDRenderPipeline/Debug/ReflectionProbesPreview.shader.meta
  3. 173
      ScriptableRenderPipeline/HDRenderPipeline/Editor/Lighting/HDCubemapInspector.cs
  4. 13
      ScriptableRenderPipeline/HDRenderPipeline/Editor/Lighting/HDCubemapInspector.cs.meta
  5. 116
      ScriptableRenderPipeline/HDRenderPipeline/Editor/Lighting/HDReflectionProbeEditor.cs
  6. 13
      ScriptableRenderPipeline/HDRenderPipeline/Editor/Lighting/HDReflectionProbeEditor.cs.meta
  7. 1001
      ScriptableRenderPipeline/HDRenderPipeline/Editor/Lighting/HDReflectionProbeEditorOld.cs
  8. 11
      ScriptableRenderPipeline/HDRenderPipeline/Editor/Lighting/HDReflectionProbeEditorOld.cs.meta
  9. 155
      ScriptableRenderPipeline/HDRenderPipeline/Editor/Lighting/PreviewCubemapMaterial.mat
  10. 10
      ScriptableRenderPipeline/HDRenderPipeline/Editor/Lighting/PreviewCubemapMaterial.mat.meta
  11. 73
      ScriptableRenderPipeline/HDRenderPipeline/Lighting/HDAdditionalReflectionData.cs
  12. 13
      ScriptableRenderPipeline/HDRenderPipeline/Lighting/HDAdditionalReflectionData.cs.meta

72
ScriptableRenderPipeline/HDRenderPipeline/Debug/ReflectionProbesPreview.shader


// Upgrade NOTE: replaced '_Object2World' with 'unity_ObjectToWorld'
Shader "Debug/ReflectionProbePreview"
{
Properties
{
_Cubemap("_Cubemap", Cube) = "white" {}
_CameraWorldPosition("_CameraWorldPosition", Vector) = (1,1,1,1)
_MipLevel("_MipLevel", Range(0.0,7.0)) = 0.0
_Exposure("_Exposure", Range(-10.0,10.0)) = 0.0
}
SubShader
{
Tags{ "RenderType" = "Opaque" "Queue" = "Transparent" }
LOD 100
ZWrite On
Cull Back
LOD 100
Pass
{
Name "ForwardUnlit"
Tags{ "LightMode" = "Forward" }
CGPROGRAM
#pragma vertex vert
#pragma fragment frag
#include "UnityCG.cginc"
struct appdata
{
float4 vertex : POSITION;
float3 normal : NORMAL;
};
struct v2f
{
float4 vertex : SV_POSITION;
float3 normal : NORMAL;
float3 worldpos : TEXCOORD0;
};
samplerCUBE _Cubemap;
float3 _CameraWorldPosition;
float _MipLevel;
float _Exposure;
v2f vert(appdata v)
{
v2f o;
o.vertex = UnityObjectToClipPos(v.vertex);
o.worldpos = mul(unity_ObjectToWorld, v.vertex);
o.normal = mul(unity_ObjectToWorld, float4(v.normal, 0)).xyz;
return o;
}
float4 frag(v2f i) : SV_Target
{
//float3 view = normalize(i.worldpos - _CameraWorldPosition);
float3 view = normalize(i.worldpos - _WorldSpaceCameraPos);
float3 reflected = reflect(view, i.normal);
float4 col = texCUBElod(_Cubemap,float4(reflected,_MipLevel));
col = col*exp2(_Exposure);
return col;
}
ENDCG
}
}
}

9
ScriptableRenderPipeline/HDRenderPipeline/Debug/ReflectionProbesPreview.shader.meta


fileFormatVersion: 2
guid: 73be0053604e1d54388db4f32739a92f
ShaderImporter:
externalObjects: {}
defaultTextures: []
nonModifiableTextures: []
userData:
assetBundleName:
assetBundleVariant:

173
ScriptableRenderPipeline/HDRenderPipeline/Editor/Lighting/HDCubemapInspector.cs


using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEditor;
using UnityEngine.Experimental.Rendering;
using UnityEngine.Experimental.Rendering.HDPipeline;
[CustomEditorForRenderPipeline(typeof(Cubemap), typeof(HDRenderPipelineAsset))]
class HDCubemapInspector : Editor
{
private enum NavMode
{
None = 0,
Zooming = 1,
Rotating = 2
}
private static Mesh s_SphereMesh;
private Material m_ReflectiveMaterial;
public float m_PreviewExposure = 0f;
public float m_MipLevelPreview = 0f;
private PreviewRenderUtility m_PreviewUtility;
private float m_CameraPhi = 0.75f;
private float m_CameraTheta = 0.5f;
private float m_CameraDistance = 2.0f;
private NavMode m_NavMode = NavMode.None;
private Vector2 m_PreviousMousePosition = Vector2.zero;
static GUIContent s_MipMapLow, s_MipMaipHigh, s_CurveKeyframeSelected, s_CurveKeyframeSemiSelectedOverlay, s_RGBMIcon;
static GUIStyle s_PreButton, s_PreSlider, s_PreSliderThumb, s_PreLabel;
private void OnEnable()
{
if (m_PreviewUtility == null)
{
InitPreview();
Debug.Log("created new");
}
//m_ReflectiveMaterial = Instantiate((Material)AssetDatabase.LoadAssetAtPath("Assets/ScriptableRenderPipeline/ScriptableRenderPipeline/HDRenderPipeline/Debug/PreviewCubemapMaterial.mat", typeof(Material)));
m_ReflectiveMaterial = new Material(Shader.Find("Debug/ReflectionProbePreview"));
m_ReflectiveMaterial.SetTexture("_Cubemap", target as Texture);
m_ReflectiveMaterial.hideFlags = HideFlags.HideAndDontSave;
}
private void OnDisable()
{
if (m_PreviewUtility != null)
{
m_PreviewUtility.Cleanup();
}
}
private static Mesh sphereMesh
{
get { return s_SphereMesh ?? (s_SphereMesh = Resources.GetBuiltinResource(typeof(Mesh), "New-Sphere.fbx") as Mesh); }
}
public override bool HasPreviewGUI()
{
return true;
}
public override void OnPreviewGUI(Rect r, GUIStyle background)
{
if(m_ReflectiveMaterial != null)
{
m_ReflectiveMaterial.SetFloat("_Exposure", m_PreviewExposure);
m_ReflectiveMaterial.SetFloat("_MipLevel", m_MipLevelPreview);
}
if(m_PreviewUtility == null)
InitPreview();
UpdateCamera();
m_PreviewUtility.BeginPreview(r, GUIStyle.none);
m_PreviewUtility.DrawMesh(sphereMesh, Matrix4x4.identity, m_ReflectiveMaterial, 0);
m_PreviewUtility.camera.Render();
m_PreviewUtility.EndAndDrawPreview(r);
if (Event.current.type != EventType.Repaint)
{
if (HandleMouse(r))
Repaint();
}
}
private void InitPreview()
{
m_PreviewUtility = new PreviewRenderUtility(false, true);
m_PreviewUtility.cameraFieldOfView = 50.0f;
m_PreviewUtility.camera.nearClipPlane = 0.01f;
m_PreviewUtility.camera.farClipPlane = 20.0f;
m_PreviewUtility.camera.transform.position = new Vector3(0, 0, 2);
m_PreviewUtility.camera.transform.LookAt(Vector3.zero);
//m_PreviewUtility.camera.clearFlags = CameraClearFlags.Skybox;
}
private void InitIcons()
{
s_MipMapLow = EditorGUIUtility.IconContent("PreTextureMipMapLow");
s_MipMaipHigh = EditorGUIUtility.IconContent("PreTextureMipMapHigh");
s_CurveKeyframeSelected = EditorGUIUtility.IconContent("d_curvekeyframeselected");
s_CurveKeyframeSemiSelectedOverlay = EditorGUIUtility.IconContent("d_curvekeyframesemiselectedoverlay");
s_RGBMIcon = EditorGUIUtility.IconContent("PreMatLight1"); // TODO: proper icon for RGBM preview mode
s_PreButton = "preButton";
s_PreSlider = "preSlider";
s_PreSliderThumb = "preSliderThumb";
s_PreLabel = "preLabel";
}
public override void OnPreviewSettings()
{
GUI.enabled = true;
InitIcons();
GUI.enabled = true;
GUILayout.Box(s_CurveKeyframeSemiSelectedOverlay, s_PreLabel,GUILayout.MaxWidth(20));
GUI.changed = false;
m_PreviewExposure = GUILayout.HorizontalSlider(m_PreviewExposure, -10f, 10f, GUILayout.MaxWidth(80));
GUILayout.Box(s_CurveKeyframeSelected, s_PreLabel, GUILayout.MaxWidth(20));
GUI.enabled = true;
}
public bool HandleMouse(Rect Viewport)
{
bool result = false;
if (Event.current.type == EventType.MouseDown)
{
if (Event.current.button == 0)
m_NavMode = NavMode.Rotating;
else if (Event.current.button == 1)
m_NavMode = NavMode.Zooming;
m_PreviousMousePosition = Event.current.mousePosition;
result = true;
}
if (Event.current.type == EventType.MouseUp || Event.current.rawType == EventType.MouseUp)
m_NavMode = NavMode.None;
if (m_NavMode != NavMode.None)
{
Vector2 mouseDelta = Event.current.mousePosition - m_PreviousMousePosition;
switch (m_NavMode)
{
case NavMode.Rotating:
m_CameraTheta = (m_CameraTheta - mouseDelta.x * 0.003f) % (Mathf.PI * 2);
m_CameraPhi = Mathf.Clamp(m_CameraPhi - mouseDelta.y * 0.003f, 0.2f, Mathf.PI - 0.2f);
break;
case NavMode.Zooming:
m_CameraDistance = Mathf.Clamp(mouseDelta.y * 0.01f + m_CameraDistance, 1, 10);
break;
}
result = true;
}
m_PreviousMousePosition = Event.current.mousePosition;
return result;
}
private void UpdateCamera()
{
Vector3 pos = new Vector3(Mathf.Sin(m_CameraPhi) * Mathf.Cos(m_CameraTheta), Mathf.Cos(m_CameraPhi), Mathf.Sin(m_CameraPhi) * Mathf.Sin(m_CameraTheta)) * m_CameraDistance;
m_PreviewUtility.camera.transform.position = pos;
m_PreviewUtility.camera.transform.LookAt(Vector3.zero);
}
}

13
ScriptableRenderPipeline/HDRenderPipeline/Editor/Lighting/HDCubemapInspector.cs.meta


fileFormatVersion: 2
guid: cdea3bc9038283a42ae5ca2c1956484d
timeCreated: 1507739065
licenseType: Pro
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

116
ScriptableRenderPipeline/HDRenderPipeline/Editor/Lighting/HDReflectionProbeEditor.cs


using System;
using UnityEditor.AnimatedValues;
using UnityEditor.Experimental.Rendering;
using UnityEngine;
using UnityEngine.Events;
using UnityEngine.Experimental.Rendering.HDPipeline;
using UnityEngine.Rendering;
namespace UnityEditor
{
[CustomEditorForRenderPipeline(typeof(ReflectionProbe), typeof(HDRenderPipelineAsset))]
[CanEditMultipleObjects]
class HDReflectionProbeEditor : Editor
{
class SerializedReflectionProbe
{
internal SerializedProperty mode;
internal SerializedProperty renderDynamicObjects;
public SerializedReflectionProbe(ReflectionProbe target, SerializedObject so)
{
mode = so.FindProperty("m_Mode");
renderDynamicObjects = so.FindProperty("m_RenderDynamicObjects");
}
}
class UIState
{
AnimBool[] m_ModeSettingsDisplays = new AnimBool[Enum.GetValues(typeof(ReflectionProbeMode)).Length];
internal UIState()
{
for (var i = 0; i < m_ModeSettingsDisplays.Length; i++)
m_ModeSettingsDisplays[i] = new AnimBool();
}
internal void Reset(UnityAction repaint, ReflectionProbeMode mode)
{
for (var i = 0; i < m_ModeSettingsDisplays.Length; i++)
{
m_ModeSettingsDisplays[i].valueChanged.RemoveAllListeners();
m_ModeSettingsDisplays[i].valueChanged.AddListener(repaint);
m_ModeSettingsDisplays[i].value = (int)mode == i;
}
}
public float GetModeFaded(ReflectionProbeMode mode)
{
return m_ModeSettingsDisplays[(int)mode].faded;
}
public void SetModeTarget(int value)
{
for (var i = 0; i < m_ModeSettingsDisplays.Length; i++)
m_ModeSettingsDisplays[i].target = i == value;
}
}
delegate void Drawer(UIState s, SerializedReflectionProbe p);
SerializedReflectionProbe m_SerializedReflectionProbe;
ReflectionProbe m_ReflectionProbe;
UIState m_UIState = new UIState();
void OnEnable()
{
m_ReflectionProbe = (ReflectionProbe)target;
m_SerializedReflectionProbe = new SerializedReflectionProbe(m_ReflectionProbe, serializedObject);
m_UIState.Reset(Repaint, m_ReflectionProbe.mode);
}
public override void OnInspectorGUI()
{
serializedObject.Update();
Drawer_ReflectionProbeMode(m_UIState, m_SerializedReflectionProbe);
Drawer_ModeSettings(m_UIState, m_SerializedReflectionProbe);
serializedObject.ApplyModifiedProperties();
}
static readonly GUIContent[] k_Content_ReflectionProbeMode = { new GUIContent("Baked"), new GUIContent("Custom"), new GUIContent("Realtime") };
static readonly int[] k_Content_ReflectionProbeModeValues = { (int)ReflectionProbeMode.Baked, (int)ReflectionProbeMode.Custom, (int)ReflectionProbeMode.Realtime };
static void Drawer_ReflectionProbeMode(UIState s, SerializedReflectionProbe p)
{
EditorGUILayout.IntPopup(p.mode, k_Content_ReflectionProbeMode, k_Content_ReflectionProbeModeValues, CoreEditorUtils.GetContent("Type|'Baked Cubemap' uses the 'Auto Baking' mode from the Lighting window. If it is enabled then baking is automatic otherwise manual bake is needed (use the bake button below). \n'Custom' can be used if a custom cubemap is wanted. \n'Realtime' can be used to dynamically re-render the cubemap during runtime (via scripting)."));
s.SetModeTarget(p.mode.intValue);
}
static void Drawer_NOOP(UIState s, SerializedReflectionProbe p) { }
static void Drawer_ModeSettings(UIState s, SerializedReflectionProbe p)
{
for (var i = 0; i < k_ModeDrawers.Length; ++i)
{
if (EditorGUILayout.BeginFadeGroup(s.GetModeFaded((ReflectionProbeMode)i)))
{
++EditorGUI.indentLevel;
k_ModeDrawers[i](s, p);
--EditorGUI.indentLevel;
}
EditorGUILayout.EndFadeGroup();
}
}
static readonly Drawer[] k_ModeDrawers = { Drawer_NOOP, Drawer_ModeRealtime , Drawer_ModeCustom };
static void Drawer_ModeCustom(UIState s, SerializedReflectionProbe p)
{
EditorGUILayout.PropertyField(p.renderDynamicObjects, CoreEditorUtils.GetContent("Dynamic Objects|If enabled dynamic objects are also rendered into the cubemap"));
}
static void Drawer_ModeRealtime(UIState s, SerializedReflectionProbe p) { }
}
}

13
ScriptableRenderPipeline/HDRenderPipeline/Editor/Lighting/HDReflectionProbeEditor.cs.meta


fileFormatVersion: 2
guid: ad7341012fc407341a64d703beefb011
timeCreated: 1507739065
licenseType: Pro
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

1001
ScriptableRenderPipeline/HDRenderPipeline/Editor/Lighting/HDReflectionProbeEditorOld.cs
文件差异内容过多而无法显示
查看文件

11
ScriptableRenderPipeline/HDRenderPipeline/Editor/Lighting/HDReflectionProbeEditorOld.cs.meta


fileFormatVersion: 2
guid: ef8853edf03920d48aa9c5814c08f41a
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

155
ScriptableRenderPipeline/HDRenderPipeline/Editor/Lighting/PreviewCubemapMaterial.mat


%YAML 1.1
%TAG !u! tag:unity3d.com,2011:
--- !u!21 &2100000
Material:
serializedVersion: 6
m_ObjectHideFlags: 0
m_PrefabParentObject: {fileID: 0}
m_PrefabInternal: {fileID: 0}
m_Name: PreviewCubemapMaterial
m_Shader: {fileID: 4800000, guid: dfb0f7452ff8af24da7ad152669043b1, type: 3}
m_ShaderKeywords: _ALBEDOAFFECTEMISSIVE_OFF _ALPHACUTOFFENABLE_OFF _DEPTHOFFSETENABLE_OFF
_DISTORTIONDEPTHTEST_OFF _DISTORTIONENABLE_OFF _DISTORTIONONLY_OFF _DOUBLESIDEDENABLE_OFF
_ENABLEPERPIXELDISPLACEMENT_OFF _ENABLESPECULAROCCLUSION_OFF _ENABLEWIND_OFF
m_LightmapFlags: 4
m_EnableInstancingVariants: 0
m_DoubleSidedGI: 0
m_CustomRenderQueue: -1
stringTagMap: {}
disabledShaderPasses: []
m_SavedProperties:
serializedVersion: 3
m_TexEnvs:
- _AnisotropyMap:
m_Texture: {fileID: 0}
m_Scale: {x: 1, y: 1}
m_Offset: {x: 0, y: 0}
- _BaseColorMap:
m_Texture: {fileID: 0}
m_Scale: {x: 1, y: 1}
m_Offset: {x: 0, y: 0}
- _BentNormalMap:
m_Texture: {fileID: 0}
m_Scale: {x: 1, y: 1}
m_Offset: {x: 0, y: 0}
- _BentNormalMapOS:
m_Texture: {fileID: 0}
m_Scale: {x: 1, y: 1}
m_Offset: {x: 0, y: 0}
- _Cubemap:
m_Texture: {fileID: 8900000, guid: 92b5e3ec0b8d42049a853f0f4f01e4a7, type: 3}
m_Scale: {x: 1, y: 1}
m_Offset: {x: 0, y: 0}
- _DetailMap:
m_Texture: {fileID: 0}
m_Scale: {x: 1, y: 1}
m_Offset: {x: 0, y: 0}
- _DistortionVectorMap:
m_Texture: {fileID: 0}
m_Scale: {x: 1, y: 1}
m_Offset: {x: 0, y: 0}
- _EmissiveColorMap:
m_Texture: {fileID: 0}
m_Scale: {x: 1, y: 1}
m_Offset: {x: 0, y: 0}
- _HeightMap:
m_Texture: {fileID: 0}
m_Scale: {x: 1, y: 1}
m_Offset: {x: 0, y: 0}
- _MaskMap:
m_Texture: {fileID: 0}
m_Scale: {x: 1, y: 1}
m_Offset: {x: 0, y: 0}
- _NormalMap:
m_Texture: {fileID: 0}
m_Scale: {x: 1, y: 1}
m_Offset: {x: 0, y: 0}
- _NormalMapOS:
m_Texture: {fileID: 0}
m_Scale: {x: 1, y: 1}
m_Offset: {x: 0, y: 0}
- _SpecularColorMap:
m_Texture: {fileID: 0}
m_Scale: {x: 1, y: 1}
m_Offset: {x: 0, y: 0}
- _SubsurfaceRadiusMap:
m_Texture: {fileID: 0}
m_Scale: {x: 1, y: 1}
m_Offset: {x: 0, y: 0}
- _TangentMap:
m_Texture: {fileID: 0}
m_Scale: {x: 1, y: 1}
m_Offset: {x: 0, y: 0}
- _TangentMapOS:
m_Texture: {fileID: 0}
m_Scale: {x: 1, y: 1}
m_Offset: {x: 0, y: 0}
- _ThicknessMap:
m_Texture: {fileID: 0}
m_Scale: {x: 1, y: 1}
m_Offset: {x: 0, y: 0}
m_Floats:
- _AlbedoAffectEmissive: 0
- _AlphaCutoff: 0.5
- _AlphaCutoffEnable: 0
- _Anisotropy: 0
- _BlendMode: 0
- _CoatCoverage: 1
- _CoatIOR: 0.5
- _CullMode: 2
- _DepthOffsetEnable: 0
- _DetailAlbedoScale: 1
- _DetailNormalScale: 1
- _DetailSmoothnessScale: 1
- _DistortionDepthTest: 0
- _DistortionEnable: 0
- _DistortionOnly: 0
- _DoubleSidedEnable: 0
- _DoubleSidedNormalMode: 1
- _Drag: 1
- _DstBlend: 0
- _EmissiveColorMode: 1
- _EmissiveIntensity: 0
- _EnablePerPixelDisplacement: 0
- _EnableSpecularOcclusion: 0
- _EnableWind: 0
- _Exposure: 0
- _HeightAmplitude: 0.01
- _HeightCenter: 0.5
- _HeightMax: 1
- _HeightMin: -1
- _InitialBend: 1
- _MaterialID: 1
- _Metallic: 0
- _MipLevel: 0
- _NormalMapSpace: 0
- _NormalScale: 1
- _PPDLodThreshold: 5
- _PPDMaxSamples: 15
- _PPDMinSamples: 5
- _ShiverDirectionality: 0.5
- _ShiverDrag: 0.2
- _Smoothness: 1
- _SmoothnessRemapMax: 1
- _SmoothnessRemapMin: 0
- _SrcBlend: 1
- _StencilRef: 2
- _Stiffness: 1
- _SubsurfaceProfile: 0
- _SubsurfaceRadius: 1
- _SurfaceType: 0
- _TexWorldScale: 1
- _Thickness: 1
- _UVBase: 0
- _UVDetail: 0
- _ZTestMode: 8
- _ZWrite: 1
m_Colors:
- _BaseColor: {r: 1, g: 1, b: 1, a: 1}
- _CameraWorldPosition: {r: 1, g: 1, b: 1, a: 1}
- _DoubleSidedConstants: {r: 1, g: 1, b: -1, a: 0}
- _EmissionColor: {r: 1, g: 1, b: 1, a: 1}
- _EmissiveColor: {r: 0, g: 0, b: 0, a: 1}
- _SpecularColor: {r: 1, g: 1, b: 1, a: 1}
- _UVDetailsMappingMask: {r: 1, g: 0, b: 0, a: 0}
- _UVMappingMask: {r: 1, g: 0, b: 0, a: 0}

10
ScriptableRenderPipeline/HDRenderPipeline/Editor/Lighting/PreviewCubemapMaterial.mat.meta


fileFormatVersion: 2
guid: 2d429e5e71c1df34791a7779fdf54dc8
timeCreated: 1507739089
licenseType: Pro
NativeFormatImporter:
externalObjects: {}
mainObjectFileID: 0
userData:
assetBundleName:
assetBundleVariant:

73
ScriptableRenderPipeline/HDRenderPipeline/Lighting/HDAdditionalReflectionData.cs


#if UNITY_EDITOR
using UnityEditor;
#endif
namespace UnityEngine.Experimental.Rendering
{
public enum ReflectionInfluenceShape { Box, Sphere };
[ExecuteInEditMode]
[RequireComponent(typeof(ReflectionProbe), typeof(MeshFilter), typeof(MeshRenderer))]
public class HDAdditionalReflectionData : MonoBehaviour
{
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;
#if UNITY_EDITOR
private static Mesh sphereMesh
{
get { return m_SphereMesh ?? (m_SphereMesh = Resources.GetBuiltinResource(typeof(Mesh), "New-Sphere.fbx") as Mesh); }
}
public Material previewMaterial
{
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;
}
}
private 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;
}
public void ChangeVisibility(bool visible)
{
if(visible != m_Visible)
{
m_PreviewMeshRenderer.sharedMaterial = previewMaterial;
m_PreviewMeshRenderer.enabled = visible ? true : false;
m_Visible = visible;
}
}
#endif
}
}

13
ScriptableRenderPipeline/HDRenderPipeline/Lighting/HDAdditionalReflectionData.cs.meta


fileFormatVersion: 2
guid: d0ef8dc2c2eabfa4e8cb77be57a837c0
timeCreated: 1507739066
licenseType: Pro
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:
正在加载...
取消
保存