浏览代码

Added the possibility to setup an override transform for volume interpolation.

/main
Julien Ignace 7 年前
当前提交
057e32db
共有 6 个文件被更改,包括 69 次插入43 次删除
  1. 3
      com.unity.render-pipelines.high-definition/HDRP/Camera/HDAdditionalCameraData.cs
  2. 52
      com.unity.render-pipelines.high-definition/HDRP/Camera/HDCamera.cs
  3. 5
      com.unity.render-pipelines.high-definition/HDRP/Editor/Camera/HDCameraUI.cs
  4. 2
      com.unity.render-pipelines.high-definition/HDRP/Editor/Camera/SerializedHDCamera.cs
  5. 48
      com.unity.render-pipelines.high-definition/HDRP/RenderPipeline/HDRenderPipeline.cs
  6. 2
      com.unity.render-pipelines.high-definition/HDRP/Sky/SkyManager.cs

3
com.unity.render-pipelines.high-definition/HDRP/Camera/HDAdditionalCameraData.cs


public RenderingPath renderingPath = RenderingPath.Default;
[Tooltip("Layer Mask used for the volume interpolation for this camera.")]
public LayerMask volumeLayerMask = -1;
[Tooltip("Transform used for the volume interpolation for this camera.")]
public Transform volumeAnchorOverride;
// Physical parameters
public float aperture = 8f;

data.clearDepth = clearDepth;
data.renderingPath = renderingPath;
data.volumeLayerMask = volumeLayerMask;
data.volumeAnchorOverride = volumeAnchorOverride;
data.aperture = aperture;
data.shutterSpeed = shutterSpeed;
data.iso = iso;

52
com.unity.render-pipelines.high-definition/HDRP/Camera/HDCamera.cs


public Vector4 unity_OrthoParams;
public Vector4 projectionParams;
public Vector4 screenParams;
public int volumeLayerMask;
public Transform volumeAnchor;
public VolumetricLightingSystem.VBufferParameters[] vBufferParams; // Double-buffered

{
vlSys.UpdatePerCameraData(this);
}
UpdateVolumeParameters();
}
void UpdateVolumeParameters()
{
volumeAnchor = null;
volumeLayerMask = -1;
if (m_AdditionalCameraData != null)
{
volumeLayerMask = m_AdditionalCameraData.volumeLayerMask;
volumeAnchor = m_AdditionalCameraData.volumeAnchorOverride;
}
else
{
// Temporary hack:
// For scene view, by default, we use the "main" camera volume layer mask if it exists
// Otherwise we just remove the lighting override layers in the current sky to avoid conflicts
// This is arbitrary and should be editable in the scene view somehow.
if (camera.cameraType == CameraType.SceneView)
{
var mainCamera = Camera.main;
bool needFallback = true;
if (mainCamera != null)
{
var mainCamAdditionalData = mainCamera.GetComponent<HDAdditionalCameraData>();
if (mainCamAdditionalData != null)
{
volumeLayerMask = mainCamAdditionalData.volumeLayerMask;
volumeAnchor = mainCamAdditionalData.volumeAnchorOverride;
needFallback = false;
}
}
if (needFallback)
{
HDRenderPipeline hdPipeline = RenderPipelineManager.currentPipeline as HDRenderPipeline;
// If the override layer is "Everything", we fall-back to "Everything" for the current layer mask to avoid issues by having no current layer
// In practice we should never have "Everything" as an override mask as it does not make sense (a warning is issued in the UI)
if (hdPipeline.asset.renderPipelineSettings.lightLoopSettings.skyLightingOverrideLayerMask == -1)
volumeLayerMask = -1;
else
volumeLayerMask = (-1 & ~hdPipeline.asset.renderPipelineSettings.lightLoopSettings.skyLightingOverrideLayerMask);
}
}
}
// If no override is provided, use the camera transform.
if (volumeAnchor == null)
volumeAnchor = camera.transform;
}
// Stopgap method used to extract stereo combined matrix state.

5
com.unity.render-pipelines.high-definition/HDRP/Editor/Camera/HDCameraUI.cs


CED.Action(Drawer_FieldClearDepth),
CED.Action(Drawer_FieldCullingMask),
CED.Action(Drawer_FieldVolumeLayerMask),
CED.Action(Drawer_FieldVolumeAnchorOverride),
CED.space,
CED.Action(Drawer_Projection),
CED.Action(Drawer_FieldClippingPlanes),

static void Drawer_FieldVolumeLayerMask(HDCameraUI s, SerializedHDCamera p, Editor owner)
{
EditorGUILayout.PropertyField(p.volumeLayerMask, _.GetContent("Volume Layer Mask"));
}
static void Drawer_FieldVolumeAnchorOverride(HDCameraUI s, SerializedHDCamera p, Editor owner)
{
EditorGUILayout.PropertyField(p.volumeAnchorOverride, _.GetContent("Volume Anchor Override"));
}
static void Drawer_FieldCullingMask(HDCameraUI s, SerializedHDCamera p, Editor owner)

2
com.unity.render-pipelines.high-definition/HDRP/Editor/Camera/SerializedHDCamera.cs


public SerializedProperty renderingPath;
public SerializedProperty clearDepth;
public SerializedProperty volumeLayerMask;
public SerializedProperty volumeAnchorOverride;
public SerializedFrameSettings frameSettings;

renderingPath = serializedAdditionalDataObject.Find((HDAdditionalCameraData d) => d.renderingPath);
clearDepth = serializedAdditionalDataObject.Find((HDAdditionalCameraData d) => d.clearDepth);
volumeLayerMask = serializedAdditionalDataObject.Find((HDAdditionalCameraData d) => d.volumeLayerMask);
volumeAnchorOverride = serializedAdditionalDataObject.Find((HDAdditionalCameraData d) => d.volumeAnchorOverride);
frameSettings = new SerializedFrameSettings(serializedAdditionalDataObject.FindProperty("m_FrameSettings"));
}

48
com.unity.render-pipelines.high-definition/HDRP/RenderPipeline/HDRenderPipeline.cs


{
CoreUtils.SetKeyword(cmd, "LIGHT_LAYERS", enableLightLayers);
cmd.SetGlobalInt(HDShaderIDs._EnableLightLayers, enableLightLayers ? 1 : 0);
}
}
public void ConfigureForDecal(CommandBuffer cmd)
{

m_CurrentDebugDisplaySettings = m_DebugDisplaySettings;
}
using (new ProfilingSample(cmd, "Volume Update", CustomSamplerId.VolumeUpdate.GetSampler()))
{
LayerMask layerMask = -1;
if (additionalCameraData != null)
{
layerMask = additionalCameraData.volumeLayerMask;
}
else
{
// Temporary hack:
// For scene view, by default, we use the "main" camera volume layer mask if it exists
// Otherwise we just remove the lighting override layers in the current sky to avoid conflicts
// This is arbitrary and should be editable in the scene view somehow.
if (camera.cameraType == CameraType.SceneView)
{
var mainCamera = Camera.main;
bool needFallback = true;
if (mainCamera != null)
{
var mainCamAdditionalData = mainCamera.GetComponent<HDAdditionalCameraData>();
if (mainCamAdditionalData != null)
{
layerMask = mainCamAdditionalData.volumeLayerMask;
needFallback = false;
}
}
if (needFallback)
{
// If the override layer is "Everything", we fall-back to "Everything" for the current layer mask to avoid issues by having no current layer
// In practice we should never have "Everything" as an override mask as it does not make sense (a warning is issued in the UI)
if (m_Asset.renderPipelineSettings.lightLoopSettings.skyLightingOverrideLayerMask == -1)
layerMask = -1;
else
layerMask = (-1 & ~m_Asset.renderPipelineSettings.lightLoopSettings.skyLightingOverrideLayerMask);
}
}
}
VolumeManager.instance.Update(camera.transform, layerMask);
}
var postProcessLayer = camera.GetComponent<PostProcessLayer>();
// Disable post process if we enable debug mode or if the post process layer is disabled

// From this point, we should only use frame settings from the camera
hdCamera.Update(currentFrameSettings, postProcessLayer, m_VolumetricLightingSystem);
using (new ProfilingSample(cmd, "Volume Update", CustomSamplerId.VolumeUpdate.GetSampler()))
{
VolumeManager.instance.Update(hdCamera.volumeAnchor, hdCamera.volumeLayerMask);
}
Resize(hdCamera);

2
com.unity.render-pipelines.high-definition/HDRP/Sky/SkyManager.cs


m_BakingSky.skySettings = SkyManager.GetBakingSkySettings();
// Update needs to happen before testing if the component is active other internal data structure are not properly updated yet.
VolumeManager.instance.Update(m_LightingOverrideVolumeStack, hdCamera.camera.transform, m_LightingOverrideLayerMask);
VolumeManager.instance.Update(m_LightingOverrideVolumeStack, hdCamera.volumeAnchor, m_LightingOverrideLayerMask);
if (VolumeManager.instance.IsComponentActiveInMask<VisualEnvironment>(m_LightingOverrideLayerMask))
{
SkySettings newSkyOverride = GetSkySetting(m_LightingOverrideVolumeStack);

正在加载...
取消
保存