浏览代码

Merge pull request #1268 from Unity-Technologies/volumetric-lighting-updates

Manager for the density volumes
/main
GitHub 7 年前
当前提交
3845c0cb
共有 4 个文件被更改,包括 70 次插入16 次删除
  1. 2
      ScriptableRenderPipeline/HDRenderPipeline/HDRP/Lighting/Volumetrics/HomogeneousDensityVolume.cs
  2. 28
      ScriptableRenderPipeline/HDRenderPipeline/HDRP/Lighting/Volumetrics/VolumetricLighting.cs
  3. 45
      ScriptableRenderPipeline/HDRenderPipeline/HDRP/Lighting/Volumetrics/DensityVolumeManager.cs
  4. 11
      ScriptableRenderPipeline/HDRenderPipeline/HDRP/Lighting/Volumetrics/DensityVolumeManager.cs.meta

2
ScriptableRenderPipeline/HDRenderPipeline/HDRP/Lighting/Volumetrics/HomogeneousDensityVolume.cs


private void OnEnable()
{
DensityVolumeManager.manager.RegisterVolume(this);
DensityVolumeManager.manager.DeRegisterVolume(this);
}
private void Update()

28
ScriptableRenderPipeline/HDRenderPipeline/HDRP/Lighting/Volumetrics/VolumetricLighting.cs


m_VisibleVolumeData.Clear();
// Collect all visible finite volume data, and upload it to the GPU.
HomogeneousDensityVolume[] volumes = Object.FindObjectsOfType(typeof(HomogeneousDensityVolume)) as HomogeneousDensityVolume[];
HomogeneousDensityVolume[] volumes = DensityVolumeManager.manager.GetAllVolumes();
// Only test active finite volumes.
if (volume.enabled)
{
// TODO: cache these?
var obb = OrientedBBox.Create(volume.transform);
// TODO: cache these?
var obb = OrientedBBox.Create(volume.transform);
// Handle camera-relative rendering.
obb.center -= camOffset;
// Handle camera-relative rendering.
obb.center -= camOffset;
// Frustum cull on the CPU for now. TODO: do it on the GPU.
if (GeometryUtils.Overlap(obb, camera.frustum, 6, 8))
{
// TODO: cache these?
var data = volume.parameters.GetData();
// Frustum cull on the CPU for now. TODO: do it on the GPU.
if (GeometryUtils.Overlap(obb, camera.frustum, 6, 8))
{
// TODO: cache these?
var data = volume.parameters.GetData();
m_VisibleVolumeBounds.Add(obb);
m_VisibleVolumeData.Add(data);
}
m_VisibleVolumeBounds.Add(obb);
m_VisibleVolumeData.Add(data);
}
}

45
ScriptableRenderPipeline/HDRenderPipeline/HDRP/Lighting/Volumetrics/DensityVolumeManager.cs


using System.Collections.Generic;
namespace UnityEngine.Experimental.Rendering.HDPipeline
{
public class DensityVolumeManager
{
static private DensityVolumeManager _instance = null;
private DensityVolumeManager()
{
volumes = new List<HomogeneousDensityVolume>();
}
public static DensityVolumeManager manager
{
get
{
if (_instance == null)
{
_instance = new DensityVolumeManager();
}
return _instance;
}
}
private List<HomogeneousDensityVolume> volumes = null;
public void RegisterVolume(HomogeneousDensityVolume volume)
{
volumes.Add(volume);
}
public void DeRegisterVolume(HomogeneousDensityVolume volume)
{
if (volumes.Contains(volume))
{
volumes.Remove(volume);
}
}
public HomogeneousDensityVolume[] GetAllVolumes()
{
return volumes.ToArray();
}
}
}

11
ScriptableRenderPipeline/HDRenderPipeline/HDRP/Lighting/Volumetrics/DensityVolumeManager.cs.meta


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