浏览代码

Intermediate commit

/main
Paul Melamed 7 年前
当前提交
163fdc44
共有 5 个文件被更改,包括 37 次插入13 次删除
  1. 13
      ScriptableRenderPipeline/Core/CoreRP/CoreUtils.cs
  2. 22
      ScriptableRenderPipeline/HDRenderPipeline/HDRP/HDRenderPipeline.cs
  3. 2
      ScriptableRenderPipeline/HDRenderPipeline/HDRP/Material/Decal/DecalProperties.hlsl
  4. 11
      ScriptableRenderPipeline/HDRenderPipeline/HDRP/Material/SubsurfaceScattering/SubsurfaceScatteringManager.cs
  5. 2
      ScriptableRenderPipeline/HDRenderPipeline/HDRP/ShaderPass/ShaderPassDBuffer.hlsl

13
ScriptableRenderPipeline/Core/CoreRP/CoreUtils.cs


mesh.triangles = triangles;
return mesh;
}
public static void ResizeHTile(RenderTexture hTile, ref RenderTargetIdentifier hTileRT, RenderTextureDescriptor desc)
{
// We must use a RenderTexture and not GetTemporaryRT() as currently Unity only aloow to bind a RenderTexture for a UAV in a pixel shader
// We use 8x8 tiles in order to match the native GCN HTile as closely as possible.
desc.width = (desc.width + 7) / 8;
desc.height = (desc.height + 7) / 8;
hTile = CreateRenderTexture(desc, 0, RenderTextureFormat.R8, RenderTextureReadWrite.Linear); // DXGI_FORMAT_R8_UINT is not supported by Unity
hTile.filterMode = FilterMode.Point;
hTile.enableRandomWrite = true;
hTile.Create();
hTileRT = new RenderTargetIdentifier(hTile);
}
}
}

22
ScriptableRenderPipeline/HDRenderPipeline/HDRP/HDRenderPipeline.cs


RenderTargetIdentifier[] m_ColorMRTs;
RenderTargetIdentifier[] m_RTIDs = new RenderTargetIdentifier[k_MaxDbuffer];
RenderTexture m_HTile;
RenderTargetIdentifier m_HTileRT;
public void InitDBuffers(RenderTextureDescriptor rtDesc, CommandBuffer cmd)
{
dbufferCount = Decal.GetMaterialDBufferCount();

return m_ColorMRTs;
}
public void ClearNormalTarget(Color clearColor, CommandBuffer cmd)
public void ClearNormalTargetAndHTile(Color clearColor, CommandBuffer cmd)
CoreUtils.SetRenderTarget(cmd, m_HTileRT, ClearFlag.Color, CoreUtils.clearColorAllBlack);
public void SetHTile(CommandBuffer cmd)
{
cmd.SetRandomWriteTarget(3, m_HTile);
}
}
public void Resize(HDCamera camera)
{
CoreUtils.ResizeHTile(m_HTile, ref m_HTileRT, camera.renderTextureDesc);
}
}

{
CreateDepthStencilBuffer(hdCamera);
m_SSSBufferManager.Resize(hdCamera);
m_DbufferManager.Resize(hdCamera);
}
if (resolutionChanged || m_LightLoop.NeedResize())

// we need to do a separate clear for normals, because they are cleared to a different color
Color clearColorNormal = new Color(0.5f, 0.5f, 0.5f, 1.0f); // for normals 0.5 is neutral
m_DbufferManager.ClearNormalTarget(clearColorNormal, cmd);
m_DbufferManager.ClearNormalTargetAndHTile(clearColorNormal, cmd);
m_DbufferManager.SetHTile(cmd);
cmd.ClearRandomWriteTargets();
}
}

2
ScriptableRenderPipeline/HDRenderPipeline/HDRP/Material/Decal/DecalProperties.hlsl


float _DecalBlend;
RW_TEXTURE2D(float, _DecalHTile); // DXGI_FORMAT_R8_UINT is not supported by Unity
#endif

11
ScriptableRenderPipeline/HDRenderPipeline/HDRP/Material/SubsurfaceScattering/SubsurfaceScatteringManager.cs


public void Resize(HDCamera hdCamera)
{
// We must use a RenderTexture and not GetTemporaryRT() as currently Unity only aloow to bind a RenderTexture for a UAV in a pixel shader
// We use 8x8 tiles in order to match the native GCN HTile as closely as possible.
var desc = hdCamera.renderTextureDesc;
desc.width = (desc.width + 7) / 8;
desc.height = (desc.height + 7) / 8;
m_HTile = CoreUtils.CreateRenderTexture(desc, 0, RenderTextureFormat.R8, RenderTextureReadWrite.Linear); // DXGI_FORMAT_R8_UINT is not supported by Unity
m_HTile.filterMode = FilterMode.Point;
m_HTile.enableRandomWrite = true;
m_HTile.Create();
m_HTileRT = new RenderTargetIdentifier(m_HTile);
CoreUtils.ResizeHTile(m_HTile, ref m_HTileRT, hdCamera.renderTextureDesc);
}
public void PushGlobalParams(CommandBuffer cmd, DiffusionProfileSettings sssParameters, FrameSettings frameSettings)

2
ScriptableRenderPipeline/HDRenderPipeline/HDRP/ShaderPass/ShaderPassDBuffer.hlsl


DecalSurfaceData surfaceData;
float3x3 decalToWorld = (float3x3)UNITY_ACCESS_INSTANCED_PROP(matrix, normalToWorld);
GetSurfaceData(positionDS.xz, decalToWorld, surfaceData);
_DecalHTile[posInput.positionSS / 8] = 1.0f;
ENCODE_INTO_DBUFFER(surfaceData, outDBuffer);
}
正在加载...
取消
保存