浏览代码

Spherical Pivot Transformed Distribution initial commit.

/StackLit2
Stephane Laroche 7 年前
当前提交
6d2710d9
共有 9 个文件被更改,包括 1136 次插入0 次删除
  1. 3
      com.unity.render-pipelines.high-definition/HDRP/Material/StackLit/StackLit.cs
  2. 8
      com.unity.render-pipelines.high-definition/HDRP/Material/SphericalCapPivot.meta
  3. 1001
      com.unity.render-pipelines.high-definition/HDRP/Material/SphericalCapPivot/PivotData.GGX.cs
  4. 11
      com.unity.render-pipelines.high-definition/HDRP/Material/SphericalCapPivot/PivotData.GGX.cs.meta
  5. 86
      com.unity.render-pipelines.high-definition/HDRP/Material/SphericalCapPivot/SPTDistribution.cs
  6. 11
      com.unity.render-pipelines.high-definition/HDRP/Material/SphericalCapPivot/SPTDistribution.cs.meta
  7. 7
      com.unity.render-pipelines.high-definition/HDRP/Material/SphericalCapPivot/SPTDistribution.hlsl
  8. 9
      com.unity.render-pipelines.high-definition/HDRP/Material/SphericalCapPivot/SPTDistribution.hlsl.meta

3
com.unity.render-pipelines.high-definition/HDRP/Material/StackLit/StackLit.cs


{
PreIntegratedFGD.instance.Build(PreIntegratedFGD.FGDIndex.FGD_GGXAndDisneyDiffuse);
LTCAreaLight.instance.Build();
SPTDistribution.instance.Build();
m_isInit = false;
}

PreIntegratedFGD.instance.Cleanup(PreIntegratedFGD.FGDIndex.FGD_GGXAndDisneyDiffuse);
LTCAreaLight.instance.Cleanup();
SPTDistribution.instance.Cleanup();
m_isInit = false;
}

{
PreIntegratedFGD.instance.Bind(PreIntegratedFGD.FGDIndex.FGD_GGXAndDisneyDiffuse);
LTCAreaLight.instance.Bind();
SPTDistribution.instance.Bind();
}
}
}

8
com.unity.render-pipelines.high-definition/HDRP/Material/SphericalCapPivot.meta


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

1001
com.unity.render-pipelines.high-definition/HDRP/Material/SphericalCapPivot/PivotData.GGX.cs
文件差异内容过多而无法显示
查看文件

11
com.unity.render-pipelines.high-definition/HDRP/Material/SphericalCapPivot/PivotData.GGX.cs.meta


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

86
com.unity.render-pipelines.high-definition/HDRP/Material/SphericalCapPivot/SPTDistribution.cs


using System;
using UnityEngine.Rendering;
namespace UnityEngine.Experimental.Rendering.HDPipeline
{
public partial class SPTDistribution
{
static SPTDistribution s_Instance;
public static SPTDistribution instance
{
get
{
if (s_Instance == null)
s_Instance = new SPTDistribution();
return s_Instance;
}
}
int m_refCounting;
Texture2D m_PivotData;
const int k_PivotLUTResolution = 64;
const int k_PivotLUTEntryDim = 4; // the s_PivotLUTData array has 4 components for each entry, we only upload and use first 2
SPTDistribution()
{
m_refCounting = 0;
}
// Load LUT data in texture
void LoadLUT(Texture2D tex, double[,] PivotData)
{
const int count = k_PivotLUTResolution * k_PivotLUTResolution;
Color[] pixels = new Color[count];
for (int i = 0; i < count; i++)
{
pixels[i] = new Color((float)PivotData[i, 0], (float)PivotData[i, 1], 0.0f, 0.0f);
}
tex.SetPixels(pixels);
}
public void Build()
{
Debug.Assert(m_refCounting >= 0);
if (m_refCounting == 0)
{
m_PivotData = new Texture2D(k_PivotLUTResolution, k_PivotLUTResolution, TextureFormat.RGHalf, false /*mipmap*/, true /* linear */)
{
hideFlags = HideFlags.HideAndDontSave,
wrapMode = TextureWrapMode.Clamp,
filterMode = FilterMode.Bilinear,
name = CoreUtils.GetTextureAutoName(k_PivotLUTResolution, k_PivotLUTResolution, TextureFormat.RGHalf, depth: 0, dim: TextureDimension.Tex2D, name: "PIVOT_LUT")
};
LoadLUT(m_PivotData, s_PivotLUTData);
m_PivotData.Apply();
}
m_refCounting++;
}
public void Cleanup()
{
m_refCounting--;
if (m_refCounting == 0)
{
CoreUtils.Destroy(m_PivotData);
}
Debug.Assert(m_refCounting >= 0);
}
public void Bind()
{
Shader.SetGlobalTexture("_PivotData", m_PivotData);
}
}
}

11
com.unity.render-pipelines.high-definition/HDRP/Material/SphericalCapPivot/SPTDistribution.cs.meta


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

7
com.unity.render-pipelines.high-definition/HDRP/Material/SphericalCapPivot/SPTDistribution.hlsl


// SPTD: Spherical Pivot Transformed Distributions
// Keep in synch with the c# side (eg in Bind() and for dims)
TEXTURE2D_ARRAY(_PivotData);
#define PIVOT_LUT_SIZE 64
#define PIVOT_LUT_SCALE ((PIVOT_LUT_SIZE - 1) * rcp(PIVOT_LUT_SIZE))
#define PIVOT_LUT_OFFSET (0.5 * rcp(PIVOT_LUT_SIZE))

9
com.unity.render-pipelines.high-definition/HDRP/Material/SphericalCapPivot/SPTDistribution.hlsl.meta


fileFormatVersion: 2
guid: 5d1bd0ed16ace314dbbdaad05a6f6384
ShaderImporter:
externalObjects: {}
defaultTextures: []
nonModifiableTextures: []
userData:
assetBundleName:
assetBundleVariant:
正在加载...
取消
保存