浏览代码

Merge remote-tracking branch 'refs/remotes/origin/master' into Update-ClearCoat

/feature-ReflectionProbeFit
sebastienlagarde 7 年前
当前提交
e9e58a8b
共有 3 个文件被更改,包括 32 次插入33 次删除
  1. 33
      ScriptableRenderPipeline/Core/CoreRP/CoreUtils.cs
  2. 2
      ScriptableRenderPipeline/HDRenderPipeline/HDRP/Decal/DecalProjectorComponent.cs
  3. 30
      ScriptableRenderPipeline/HDRenderPipeline/HDRP/Decal/DecalSystem.cs

33
ScriptableRenderPipeline/Core/CoreRP/CoreUtils.cs


public static void QuickSort(uint[] arr, int left, int right)
{
// For Recusrion
// For Recursion
if (left < right)
{
int pivot = Partition(arr, left, right);

}
}
public static Mesh CreateDecalMesh()
public static Mesh CreateCubeMesh(Vector3 min, Vector3 max)
vertices[0] = new Vector3(-0.5f, -1.0f, -0.5f);
vertices[1] = new Vector3(0.5f, -1.0f, -0.5f);
vertices[2] = new Vector3(0.5f, 0.0f, -0.5f);
vertices[3] = new Vector3(-0.5f, 0.0f, -0.5f);
vertices[4] = new Vector3(-0.5f, -1.0f, 0.5f);
vertices[5] = new Vector3(0.5f, -1.0f, 0.5f);
vertices[6] = new Vector3(0.5f, 0.0f, 0.5f);
vertices[7] = new Vector3(-0.5f, 0.0f, 0.5f);
vertices[0] = new Vector3(min.x, min.y, min.z);
vertices[1] = new Vector3(max.x, min.y, min.z);
vertices[2] = new Vector3(max.x, max.y, min.z);
vertices[3] = new Vector3(min.x, max.y, min.z);
vertices[4] = new Vector3(min.x, min.y, max.z);
vertices[5] = new Vector3(max.x, min.y, max.z);
vertices[6] = new Vector3(max.x, max.y, max.z);
vertices[7] = new Vector3(min.x, max.y, max.z);
mesh.vertices = vertices;

mesh.triangles = triangles;
return mesh;
}
public static BoundingSphere GetDecalMeshBoundingSphere(Matrix4x4 decalToWorld)
{
Vector4 min = new Vector4(-0.5f, -1.0f, -0.5f, 1.0f);
Vector4 max = new Vector4(0.5f, 0.0f, 0.5f, 1.0f);
min = decalToWorld * min;
max = decalToWorld * max;
BoundingSphere res = new BoundingSphere();
res.position = (max + min) / 2;
res.radius = ((Vector3)(max - min)).magnitude / 2;
return res;
}
}
}

2
ScriptableRenderPipeline/HDRenderPipeline/HDRP/Decal/DecalProjectorComponent.cs


public void OnValidate()
{
BoundingSphere sphere = CoreUtils.GetDecalMeshBoundingSphere(transform.localToWorldMatrix);
BoundingSphere sphere = DecalSystem.instance.GetDecalProjectBoundingSphere(transform.localToWorldMatrix);
if (m_Material != null)
{
Shader shader = m_Material.shader;

30
ScriptableRenderPipeline/HDRenderPipeline/HDRP/Decal/DecalSystem.cs


return m_Instance;
}
}
private Mesh m_DecalMesh = null;
private CullingGroup m_CullingGroup = null;
private const int kDecalBlockSize = 128;

private int m_NumResults = 0;
private int m_DecalsCount = 0;
m_DecalMesh = CoreUtils.CreateDecalMesh();
m_BoundingSpheres[decal.CullIndex] = CoreUtils.GetDecalMeshBoundingSphere(decal.transform.localToWorldMatrix);
m_BoundingSpheres[decal.CullIndex] = GetDecalProjectBoundingSphere(decal.transform.localToWorldMatrix);
}
public void AddDecal(DecalProjectorComponent decal)

m_Decals[m_DecalsCount] = decal;
m_Decals[m_DecalsCount].CullIndex = m_DecalsCount;
UpdateBoundingSphere(m_Decals[m_DecalsCount]);
m_DecalsCount++;
m_DecalsCount++;
}
public void RemoveDecal(DecalProjectorComponent decal)

int removeAtIndex = decal.CullIndex;
// replace with last decal in the list and update index
m_Decals[removeAtIndex] = m_Decals[m_DecalsCount - 1]; // move the last decal in list
m_Decals[removeAtIndex] = m_Decals[m_DecalsCount - 1]; // move the last decal in list
m_Decals[removeAtIndex].CullIndex = removeAtIndex;
m_Decals[m_DecalsCount - 1] = null;

{
if (m_CullingGroup != null)
{
Debug.LogError("Begin/EndCull() called out of sequence for decal projectors.");
Debug.LogError("Begin/EndCull() called out of sequence for decal projectors.");
}
m_NumResults = 0;
m_CullingGroup = new CullingGroup();

public void Render(ScriptableRenderContext renderContext, HDCamera camera, CommandBuffer cmd)
{
if (m_DecalMesh == null)
m_DecalMesh = CoreUtils.CreateDecalMesh();
m_DecalMesh = CoreUtils.CreateCubeMesh(new Vector3(-0.5f, -1.0f, -0.5f), new Vector3(0.5f, 0.0f, 0.5f));
for (int resultIndex = 0; resultIndex < m_NumResults; resultIndex++)
{

else
{
m_CullingGroup.Dispose();
m_CullingGroup = null;
m_CullingGroup = null;
}
// Decal are assume to use a CubeMesh with bounds min(-0.5f, -1.0f, -0.5f) max(0.5f, 0.0f, 0.5f)
public BoundingSphere GetDecalProjectBoundingSphere(Matrix4x4 decalToWorld)
{
Vector4 min = new Vector4(-0.5f, -1.0f, -0.5f, 1.0f);
Vector4 max = new Vector4(0.5f, 0.0f, 0.5f, 1.0f);
min = decalToWorld * min;
max = decalToWorld * max;
BoundingSphere res = new BoundingSphere();
res.position = (max + min) / 2;
res.radius = ((Vector3)(max - min)).magnitude / 2;
return res;
}
}
}
正在加载...
取消
保存