浏览代码

various changes to the HD renderloop to match the preview camera changes

/main
vlad-andreev 8 年前
当前提交
367260ce
共有 9 个文件被更改,包括 157 次插入16 次删除
  1. 1
      Assets/ScriptableRenderLoop/HDRenderPipeline/HDRenderPipeline.asset
  2. 31
      Assets/ScriptableRenderLoop/HDRenderPipeline/HDRenderPipeline.cs
  3. 52
      Assets/ScriptableRenderLoop/HDRenderPipeline/Lighting/TilePass/TilePass.cs
  4. 2
      ProjectSettings/ProjectVersion.txt
  5. 25
      Assets/HDRenderPipelineSetup.asset
  6. 9
      Assets/HDRenderPipelineSetup.asset.meta
  7. 32
      Assets/ScriptableRenderLoop/HDRenderPipeline/HDRenderPipelineSetup.cs
  8. 12
      Assets/ScriptableRenderLoop/HDRenderPipeline/HDRenderPipelineSetup.cs.meta
  9. 9
      Assets/TestScenes/HDTest/HDRenderLoopTest.meta

1
Assets/ScriptableRenderLoop/HDRenderPipeline/HDRenderPipeline.asset


m_Script: {fileID: 11500000, guid: d440c0deec24a2f478b3e9021cb66c29, type: 3}
m_Name: HDRenderPipeline
m_EditorClassIdentifier:
m_setup: {fileID: 11400000, guid: c90ada6c2ed7b4e4b85a303678826111, type: 2}
m_ShadowSettings:
enabled: 1
shadowAtlasWidth: 4096

31
Assets/ScriptableRenderLoop/HDRenderPipeline/HDRenderPipeline.cs


using UnityEngine.Rendering;
using System.Collections.Generic;
using System;
using Assets.ScriptableRenderLoop.HDRenderPipeline;
using UnityEditor;
namespace UnityEngine.Experimental.Rendering.HDPipeline
{

{
var instance = ScriptableObject.CreateInstance<HDRenderPipeline>();
UnityEditor.AssetDatabase.CreateAsset(instance, k_HDRenderPipelinePath);
instance.m_setup = UnityEditor.AssetDatabase.LoadAssetAtPath<HDRenderPipelineSetup>("Assets/HDRenderPipelineSetup.asset");
}
[UnityEditor.MenuItem("RenderPipeline/UpdateHDLoop")]
static void UpdateHDLoop()
{
var guids = AssetDatabase.FindAssets("t:HDRenderPipeline");
foreach (var guid in guids)
{
string path = AssetDatabase.GUIDToAssetPath(guid);
var loop = AssetDatabase.LoadAssetAtPath<HDRenderPipeline>(path);
loop.m_setup = AssetDatabase.LoadAssetAtPath<HDRenderPipelineSetup>("Assets/HDRenderPipelineSetup.asset");
EditorUtility.SetDirty(loop);
}
}
[UnityEditor.MenuItem("HDRenderPipeline/Add \"Additional Light Data\" (if not present)")]

}
#endif
HDRenderPipeline()
{
m_lightLoop = new TilePass.LightLoop(this);
}
[SerializeField]
private HDRenderPipelineSetup m_setup;
public Assets.ScriptableRenderLoop.HDRenderPipeline.HDRenderPipelineSetup renderPipelineSetup
{
get { return m_setup; }
}
protected override IRenderPipeline InternalCreatePipeline()
{
return new HDRenderPipelineInstance(this);

bool previousLightsUseCCT;
// This must be allocate outside of Build() else the option in the class can't be set in the inspector (as it will in this case recreate the class with default value)
BaseLightLoop m_lightLoop = new TilePass.LightLoop();
BaseLightLoop m_lightLoop;
public BaseLightLoop lightLoop
{

52
Assets/ScriptableRenderLoop/HDRenderPipeline/Lighting/TilePass/TilePass.cs


using UnityEngine.Rendering;
using System.Collections.Generic;
using System;
using Assets.ScriptableRenderLoop.HDRenderPipeline;
using UnityEditor;
namespace UnityEngine.Experimental.Rendering.HDPipeline
{

int m_areaLightCount = 0;
int m_lightCount = 0;
static ComputeShader buildScreenAABBShader = null;
static ComputeShader buildPerTileLightListShader = null; // FPTL
static ComputeShader buildPerBigTileLightListShader = null;
static ComputeShader buildPerVoxelLightListShader = null; // clustered
static ComputeShader shadeOpaqueShader = null;
private ComputeShader buildScreenAABBShader { get { return m_Parent.renderPipelineSetup.buildScreenAABBShader; } }
private ComputeShader buildPerTileLightListShader { get { return m_Parent.renderPipelineSetup.buildPerTileLightListShader; } }
private ComputeShader buildPerBigTileLightListShader { get { return m_Parent.renderPipelineSetup.buildPerBigTileLightListShader; } }
private ComputeShader buildPerVoxelLightListShader { get { return m_Parent.renderPipelineSetup.buildPerVoxelLightListShader; } }
private ComputeShader shadeOpaqueShader { get { return m_Parent.renderPipelineSetup.shadeOpaqueShader; } }
static int s_GenAABBKernel;
static int s_GenListPerTileKernel;

static ComputeBuffer s_GlobalLightListAtomic = null;
// clustered light list specific buffers and data end
private static GameObject s_DefaultAdditionalLightDataGameObject;
private static AdditionalLightData s_DefaultAdditionalLightData;
bool usingFptl
{
get

Material m_SingleDeferredMaterial = null;
const int k_TileSize = 16;
private readonly HDRenderPipeline m_Parent;
int GetNumTileX(Camera camera)
{

return (camera.pixelHeight + (k_TileSize - 1)) / k_TileSize;
}
public LightLoop(HDRenderPipeline hdRenderPipeline)
{
m_Parent = hdRenderPipeline;
}
public override void Build(TextureSettings textureSettings)
{
m_lightList = new LightList();

m_CubeReflTexArray = new TextureCacheCubemap();
m_CubeReflTexArray.AllocTextureArray(32, textureSettings.reflectionCubemapSize, TextureFormat.BC6H, true);
buildScreenAABBShader = Resources.Load<ComputeShader>("scrbound");
buildPerTileLightListShader = Resources.Load<ComputeShader>("lightlistbuild");
buildPerBigTileLightListShader = Resources.Load<ComputeShader>("lightlistbuild-bigtile");
buildPerVoxelLightListShader = Resources.Load<ComputeShader>("lightlistbuild-clustered");
shadeOpaqueShader = Resources.Load<ComputeShader>("shadeopaque");
s_GenAABBKernel = buildScreenAABBShader.FindKernel("ScreenBoundsAABB");
s_GenListPerTileKernel = buildPerTileLightListShader.FindKernel(enableBigTilePrepass ? "TileLightListGen_SrcBigTile" : "TileLightListGen");
s_AABBBoundsBuffer = new ComputeBuffer(2 * k_MaxLightsOnScreen, 3 * sizeof(float));

UnityEditor.SceneView.onSceneGUIDelegate -= OnSceneGUI;
UnityEditor.SceneView.onSceneGUIDelegate += OnSceneGUI;
#endif
s_DefaultAdditionalLightDataGameObject = new GameObject("Default Light Data");
s_DefaultAdditionalLightDataGameObject.hideFlags = HideFlags.HideAndDontSave;
s_DefaultAdditionalLightData = s_DefaultAdditionalLightDataGameObject.AddComponent<AdditionalLightData>();
}
public override void Cleanup()

Utilities.Destroy(m_DebugViewTilesMaterial);
Utilities.Destroy(m_SingleDeferredMaterial);
GameObject.DestroyImmediate(s_DefaultAdditionalLightDataGameObject);
s_DefaultAdditionalLightDataGameObject = null;
s_DefaultAdditionalLightData = null;
}
public override void NewFrame()

public void GetDirectionalLightData(ShadowSettings shadowSettings, GPULightType gpuLightType, VisibleLight light, AdditionalLightData additionalData, int lightIndex, ref ShadowOutput shadowOutput, ref int directionalShadowcount)
{
var directionalLightData = new DirectionalLightData();
if (additionalData == null)
additionalData = s_DefaultAdditionalLightData;
// Light direction for directional is opposite to the forward direction
directionalLightData.forward = light.light.transform.forward;

{
var lightData = new LightData();
if (additionalData == null)
additionalData = s_DefaultAdditionalLightData;
lightData.lightType = gpuLightType;
lightData.positionWS = light.light.transform.position;

if (additionalData == null)
{
Debug.LogWarning("Light entity detected without additional data, will not be taken into account " + light.light.name);
continue;
Debug.LogWarningFormat("Light entity {0} has no additional data, will be rendered using default values.", light.light.name);
additionalData = s_DefaultAdditionalLightData;
}
LightCategory lightCategory = LightCategory.Count;

var light = cullResults.visibleLights[lightIndex];
var additionalData = light.light.GetComponent<AdditionalLightData>();
if (additionalData == null)
additionalData = s_DefaultAdditionalLightData;
// Directional rendering side, it is separated as it is always visible so no volume to handle here
if (gpuLightType == GPULightType.Directional)
{

for (int n = 0; n < numVectors; n++)
{
for (int i = 0; i < 4; i++)
{
{
data[4 * n + i] = values[n][i];
}
}

#if UNITY_EDITOR
private Vector2 m_mousePosition = Vector2.zero;
private void OnSceneGUI(UnityEditor.SceneView sceneview)
{
m_mousePosition = Event.current.mousePosition;

2
ProjectSettings/ProjectVersion.txt


m_EditorVersion: 5.6.0b3
m_EditorVersion: 5.6.0b5

25
Assets/HDRenderPipelineSetup.asset


%YAML 1.1
%TAG !u! tag:unity3d.com,2011:
--- !u!114 &11400000
MonoBehaviour:
m_ObjectHideFlags: 0
m_PrefabParentObject: {fileID: 0}
m_PrefabInternal: {fileID: 0}
m_GameObject: {fileID: 0}
m_Enabled: 1
m_EditorHideFlags: 0
m_Script: {fileID: 11500000, guid: 8b6f86e1523e69a4282e92d393be89a4, type: 3}
m_Name: HDRenderPipelineSetup
m_EditorClassIdentifier:
buildScreenAABBShader: {fileID: 7200000, guid: 728dce960f8a9c44bbc3abb3b851d8f6,
type: 3}
buildPerTileLightListShader: {fileID: 7200000, guid: 65af3444cbf4b3747a4dead7ee00cfee,
type: 3}
buildPerBigTileLightListShader: {fileID: 7200000, guid: 5ee1f9d6e09abe045b2f5e0b784b9072,
type: 3}
buildPerVoxelLightListShader: {fileID: 7200000, guid: 4c2d6eb0553e2514bba3ea9a85d8c53c,
type: 3}
shadeOpaqueShader: {fileID: 7200000, guid: 0b64f79746d2daf4198eaf6eab9af259, type: 3}
m_DebugViewMaterialGBuffer: {fileID: 4800000, guid: 439949ea1bfa91b4ba0d04269fcde33d,
type: 3}
m_InitPreFGD: {fileID: 4800000, guid: 123f13d52852ef547b2962de4bd9eaad, type: 3}

9
Assets/HDRenderPipelineSetup.asset.meta


fileFormatVersion: 2
guid: c90ada6c2ed7b4e4b85a303678826111
timeCreated: 1484737584
licenseType: Pro
NativeFormatImporter:
mainObjectFileID: 11400000
userData:
assetBundleName:
assetBundleVariant:

32
Assets/ScriptableRenderLoop/HDRenderPipeline/HDRenderPipelineSetup.cs


using System;
using System.Collections.Generic;
using UnityEditor;
using UnityEngine;
using UnityEngine.Rendering;
namespace Assets.ScriptableRenderLoop.HDRenderPipeline
{
public class HDRenderPipelineSetup : ScriptableObject
{
#if UNITY_EDITOR
[UnityEditor.MenuItem("RenderPipeline/CreateHDPipelineSetup")]
static void CreateHDRenderPipelineSetup()
{
var instance = ScriptableObject.CreateInstance<HDRenderPipelineSetup>();
UnityEditor.AssetDatabase.CreateAsset(instance, "Assets/HDRenderPipelineSetup.asset");
}
#endif
public ComputeShader buildScreenAABBShader = null;
public ComputeShader buildPerTileLightListShader = null; // FPTL
public ComputeShader buildPerBigTileLightListShader = null;
public ComputeShader buildPerVoxelLightListShader = null; // clustered
public ComputeShader shadeOpaqueShader = null;
// Various set of material use in render loop
public Shader m_DebugViewMaterialGBuffer;
// For image based lighting
public Shader m_InitPreFGD;
}
}

12
Assets/ScriptableRenderLoop/HDRenderPipeline/HDRenderPipelineSetup.cs.meta


fileFormatVersion: 2
guid: 8b6f86e1523e69a4282e92d393be89a4
timeCreated: 1484737533
licenseType: Pro
MonoImporter:
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

9
Assets/TestScenes/HDTest/HDRenderLoopTest.meta


fileFormatVersion: 2
guid: 276e673c84b003b4dba1783ac6567cf9
folderAsset: yes
timeCreated: 1484061606
licenseType: Pro
DefaultImporter:
userData:
assetBundleName:
assetBundleVariant:
正在加载...
取消
保存