浏览代码

Factor PreIntegratedFGD

/main
sebastienlagarde 7 年前
当前提交
a7a14891
共有 12 个文件被更改,包括 150 次插入50 次删除
  1. 35
      ScriptableRenderPipeline/HDRenderPipeline/HDRP/Material/LTCAreaLight/LTCAreaLight.cs
  2. 26
      ScriptableRenderPipeline/HDRenderPipeline/HDRP/Material/Lit/Lit.cs
  3. 3
      ScriptableRenderPipeline/HDRenderPipeline/HDRP/Material/Lit/Lit.hlsl
  4. 8
      ScriptableRenderPipeline/HDRenderPipeline/HDRP/Material/PreIntegratedFGD.meta
  5. 90
      ScriptableRenderPipeline/HDRenderPipeline/HDRP/Material/PreIntegratedFGD/PreIntegratedFGD.cs
  6. 11
      ScriptableRenderPipeline/HDRenderPipeline/HDRP/Material/PreIntegratedFGD/PreIntegratedFGD.cs.meta
  7. 1
      ScriptableRenderPipeline/HDRenderPipeline/HDRP/Material/PreIntegratedFGD/PreIntegratedFGD.hlsl
  8. 9
      ScriptableRenderPipeline/HDRenderPipeline/HDRP/Material/PreIntegratedFGD/PreIntegratedFGD.hlsl.meta
  9. 8
      ScriptableRenderPipeline/HDRenderPipeline/HDRP/Material/PreIntegratedFGD/Resources.meta
  10. 9
      ScriptableRenderPipeline/HDRenderPipeline/HDRP/Material/Lit/Resources.meta
  11. 0
      /ScriptableRenderPipeline/HDRenderPipeline/HDRP/Material/PreIntegratedFGD/Resources

35
ScriptableRenderPipeline/HDRenderPipeline/HDRP/Material/LTCAreaLight/LTCAreaLight.cs


}
}
bool m_isInit;
int m_refCounting;
// For area lighting - We pack all texture inside a texture array to reduce the number of resource required

LTCAreaLight()
{
m_isInit = false;
m_refCounting = 0;
}

public void Build()
{
m_refCounting++;
Debug.Assert(m_refCounting >= 0);
m_LtcData = new Texture2DArray(k_LtcLUTResolution, k_LtcLUTResolution, 3, TextureFormat.RGBAHalf, false /*mipmap*/, true /* linear */)
if (m_refCounting == 0)
hideFlags = HideFlags.HideAndDontSave,
wrapMode = TextureWrapMode.Clamp,
filterMode = FilterMode.Bilinear,
name = CoreUtils.GetTextureAutoName(k_LtcLUTResolution, k_LtcLUTResolution, TextureFormat.RGBAHalf, depth: 3, dim: TextureDimension.Tex2DArray, name: "LTC_LUT")
};
m_LtcData = new Texture2DArray(k_LtcLUTResolution, k_LtcLUTResolution, 3, TextureFormat.RGBAHalf, false /*mipmap*/, true /* linear */)
{
hideFlags = HideFlags.HideAndDontSave,
wrapMode = TextureWrapMode.Clamp,
filterMode = FilterMode.Bilinear,
name = CoreUtils.GetTextureAutoName(k_LtcLUTResolution, k_LtcLUTResolution, TextureFormat.RGBAHalf, depth: 3, dim: TextureDimension.Tex2DArray, name: "LTC_LUT")
};
LoadLUT(m_LtcData, 0, TextureFormat.RGBAHalf, s_LtcGGXMatrixData);
LoadLUT(m_LtcData, 1, TextureFormat.RGBAHalf, s_LtcDisneyDiffuseMatrixData);
// TODO: switch to RGBA64 when it becomes available.
LoadLUT(m_LtcData, 2, TextureFormat.RGBAHalf, s_LtcGGXMagnitudeData, s_LtcGGXFresnelData, s_LtcDisneyDiffuseMagnitudeData);
LoadLUT(m_LtcData, 0, TextureFormat.RGBAHalf, s_LtcGGXMatrixData);
LoadLUT(m_LtcData, 1, TextureFormat.RGBAHalf, s_LtcDisneyDiffuseMatrixData);
// TODO: switch to RGBA64 when it becomes available.
LoadLUT(m_LtcData, 2, TextureFormat.RGBAHalf, s_LtcGGXMagnitudeData, s_LtcGGXFresnelData, s_LtcDisneyDiffuseMagnitudeData);
m_LtcData.Apply();
m_LtcData.Apply();
}
m_isInit = true;
m_refCounting++;
}
public void Cleanup()

if (m_refCounting <= 0)
if (m_refCounting == 0)
m_isInit = false;
Debug.Assert(m_refCounting >= 0);
}
public void Bind()

26
ScriptableRenderPipeline/HDRenderPipeline/HDRP/Material/Lit/Lit.cs


bool m_isInit;
// For image based lighting
Material m_InitPreFGD;
RenderTexture m_PreIntegratedFGD;
m_InitPreFGD = CoreUtils.CreateEngineMaterial("Hidden/HDRenderPipeline/PreIntegratedFGD");
m_PreIntegratedFGD = new RenderTexture(128, 128, 0, RenderTextureFormat.ARGB2101010, RenderTextureReadWrite.Linear);
m_PreIntegratedFGD.hideFlags = HideFlags.HideAndDontSave;
m_PreIntegratedFGD.filterMode = FilterMode.Bilinear;
m_PreIntegratedFGD.wrapMode = TextureWrapMode.Clamp;
m_PreIntegratedFGD.hideFlags = HideFlags.DontSave;
m_PreIntegratedFGD.name = CoreUtils.GetRenderTargetAutoName(128, 128, RenderTextureFormat.ARGB2101010, "PreIntegratedFGD");
m_PreIntegratedFGD.Create();
PreIntegratedFGD.instance.Build();
LTCAreaLight.instance.Build();
m_isInit = false;

{
CoreUtils.Destroy(m_InitPreFGD);
CoreUtils.Destroy(m_PreIntegratedFGD);
PreIntegratedFGD.instance.Cleanup();
LTCAreaLight.instance.Cleanup();
m_isInit = false;

if (m_isInit)
return;
using (new ProfilingSample(cmd, "Init PreFGD"))
{
CoreUtils.DrawFullScreen(cmd, m_InitPreFGD, new RenderTargetIdentifier(m_PreIntegratedFGD));
}
PreIntegratedFGD.instance.RenderInit(cmd);
m_isInit = true;
}

Shader.SetGlobalTexture("_PreIntegratedFGD", m_PreIntegratedFGD);
PreIntegratedFGD.instance.Bind();
LTCAreaLight.instance.Bind();
}
}

3
ScriptableRenderPipeline/HDRenderPipeline/HDRP/Material/Lit/Lit.hlsl


TEXTURE2D(_GBufferTexture3);
#include "../LTCAreaLight/LTCAreaLight.hlsl"
TEXTURE2D(_PreIntegratedFGD);
#include "../PreIntegratedFGD/PreIntegratedFGD.hlsl"
//-----------------------------------------------------------------------------
// Definition

8
ScriptableRenderPipeline/HDRenderPipeline/HDRP/Material/PreIntegratedFGD.meta


fileFormatVersion: 2
guid: d67850515da2e0844bf387a58fa11fac
folderAsset: yes
DefaultImporter:
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant:

90
ScriptableRenderPipeline/HDRenderPipeline/HDRP/Material/PreIntegratedFGD/PreIntegratedFGD.cs


using System;
using UnityEngine.Rendering;
namespace UnityEngine.Experimental.Rendering.HDPipeline
{
// Currently PreIntegratedFGD only have GGX, if we add another case convert it to a textureArray (like LTCArea)
public partial class PreIntegratedFGD
{
static PreIntegratedFGD s_Instance;
public static PreIntegratedFGD instance
{
get
{
if (s_Instance == null)
s_Instance = new PreIntegratedFGD();
return s_Instance;
}
}
bool m_isInit;
int m_refCounting;
// For image based lighting
Material m_InitPreFGD;
RenderTexture m_PreIntegratedFGD;
PreIntegratedFGD()
{
m_isInit = false;
m_refCounting = 0;
}
public void Build()
{
Debug.Assert(m_refCounting >= 0);
if (m_refCounting == 0)
{
m_InitPreFGD = CoreUtils.CreateEngineMaterial("Hidden/HDRenderPipeline/PreIntegratedFGD");
m_PreIntegratedFGD = new RenderTexture(128, 128, 0, RenderTextureFormat.ARGB2101010, RenderTextureReadWrite.Linear);
m_PreIntegratedFGD.hideFlags = HideFlags.HideAndDontSave;
m_PreIntegratedFGD.filterMode = FilterMode.Bilinear;
m_PreIntegratedFGD.wrapMode = TextureWrapMode.Clamp;
m_PreIntegratedFGD.hideFlags = HideFlags.DontSave;
m_PreIntegratedFGD.name = CoreUtils.GetRenderTargetAutoName(128, 128, RenderTextureFormat.ARGB2101010, "PreIntegratedFGD");
m_PreIntegratedFGD.Create();
m_isInit = false;
}
m_refCounting++;
}
public void RenderInit(CommandBuffer cmd)
{
if (m_isInit)
return;
using (new ProfilingSample(cmd, "Init PreFGD"))
{
CoreUtils.DrawFullScreen(cmd, m_InitPreFGD, new RenderTargetIdentifier(m_PreIntegratedFGD));
}
m_isInit = true;
}
public void Cleanup()
{
m_refCounting--;
if (m_refCounting == 0)
{
CoreUtils.Destroy(m_InitPreFGD);
CoreUtils.Destroy(m_PreIntegratedFGD);
m_isInit = false;
}
Debug.Assert(m_refCounting >= 0);
}
public void Bind()
{
Shader.SetGlobalTexture("_PreIntegratedFGD", m_PreIntegratedFGD);
}
}
}

11
ScriptableRenderPipeline/HDRenderPipeline/HDRP/Material/PreIntegratedFGD/PreIntegratedFGD.cs.meta


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

1
ScriptableRenderPipeline/HDRenderPipeline/HDRP/Material/PreIntegratedFGD/PreIntegratedFGD.hlsl


TEXTURE2D(_PreIntegratedFGD);

9
ScriptableRenderPipeline/HDRenderPipeline/HDRP/Material/PreIntegratedFGD/PreIntegratedFGD.hlsl.meta


fileFormatVersion: 2
guid: 4ca702b62d480a040a08b750920b6b55
ShaderImporter:
externalObjects: {}
defaultTextures: []
nonModifiableTextures: []
userData:
assetBundleName:
assetBundleVariant:

8
ScriptableRenderPipeline/HDRenderPipeline/HDRP/Material/PreIntegratedFGD/Resources.meta


fileFormatVersion: 2
guid: ce581725fe970e14abbd599942a16779
folderAsset: yes
DefaultImporter:
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant:

9
ScriptableRenderPipeline/HDRenderPipeline/HDRP/Material/Lit/Resources.meta


fileFormatVersion: 2
guid: 0c490c1afeb26224c910524c2a5f08c6
folderAsset: yes
timeCreated: 1479130495
licenseType: Pro
DefaultImporter:
userData:
assetBundleName:
assetBundleVariant:

/ScriptableRenderPipeline/HDRenderPipeline/HDRP/Material/Lit/Resources → /ScriptableRenderPipeline/HDRenderPipeline/HDRP/Material/PreIntegratedFGD/Resources

正在加载...
取消
保存