浏览代码

Merge branch 'master' into feature/SSR

/main
Frédéric Vauchelles 7 年前
当前提交
0ade2a97
共有 9 个文件被更改,包括 52 次插入30 次删除
  1. 1
      ScriptableRenderPipeline/Core/CoreRP/CoreResources/GPUCopy.compute
  2. 1
      ScriptableRenderPipeline/Core/CoreRP/CoreResources/GPUCopyAsset.cs
  3. 4
      ScriptableRenderPipeline/Core/CoreRP/CoreResources/TexturePadding.compute
  4. 10
      ScriptableRenderPipeline/Core/CoreRP/CoreResources/TexturePadding.cs
  5. 35
      ScriptableRenderPipeline/HDRenderPipeline/HDRP/HDRenderPipeline.cs
  6. 4
      ScriptableRenderPipeline/HDRenderPipeline/HDRP/Material/SubsurfaceScattering/SubsurfaceScatteringManager.cs
  7. 24
      ScriptableRenderPipeline/HDRenderPipeline/HDRP/RenderPipelineResources/BufferPyramidProcessor.cs
  8. 1
      ScriptableRenderPipeline/HDRenderPipeline/HDRP/RenderPipelineResources/CopyDepthBuffer.shader
  9. 2
      ScriptableRenderPipeline/LightweightPipeline/LWRP/LightweightPipeline.cs

1
ScriptableRenderPipeline/Core/CoreRP/CoreResources/GPUCopy.compute


// Autogenerated file. Do not edit by hand
#pragma only_renderers d3d11 ps4 xboxone vulkan metal
#include "../ShaderLibrary/Common.hlsl"
CBUFFER_START (UnityCBuffer)

1
ScriptableRenderPipeline/Core/CoreRP/CoreResources/GPUCopyAsset.cs


// Compute Shader
cc.AppendLine(@"// Autogenerated file. Do not edit by hand");
cc.AppendLine();
cc.AppendLine("#pragma only_renderers d3d11 ps4 xboxone vulkan metal");
cc.AppendLine(@"#include ""../ShaderLibrary/Common.hlsl""");
cc.AppendLine(ccp.ToString()); // Properties
cc.AppendLine(cck.ToString()); // Kernels

4
ScriptableRenderPipeline/Core/CoreRP/CoreResources/TexturePadding.compute


// Texture buffers
// ------------------------------------------------
RW_TEXTURE2D(float4, _Source);
RW_TEXTURE2D(float4, _InOutTexture);
// ------------------------------------------------
// Constant buffers

const int2 loadId = targetId - int2(1 + dispatchThreadId.x, 0);
#endif
_Source[targetId] = _Source[loadId];
_InOutTexture[targetId] = _InOutTexture[loadId];
}

10
ScriptableRenderPipeline/Core/CoreRP/CoreResources/TexturePadding.cs


public class TexturePadding
{
static readonly int _RectOffset = Shader.PropertyToID("_RectOffset");
static readonly int _Source = Shader.PropertyToID("_Source");
static readonly int _InOutTexture = Shader.PropertyToID("_InOutTexture");
ComputeShader m_CS;
int m_KMainTopRight;

m_KMainTop = m_CS.FindKernel("KMainTop");
m_KMainRight = m_CS.FindKernel("KMainRight");
}
public void Pad(CommandBuffer cmd, RenderTexture source, RectInt from, RectInt to)
public void Pad(CommandBuffer cmd, RenderTexture inOutTexture, RectInt from, RectInt to)
cmd.SetComputeTextureParam(m_CS, m_KMainRight, _Source, source);
cmd.SetComputeTextureParam(m_CS, m_KMainRight, _InOutTexture, inOutTexture);
cmd.SetComputeTextureParam(m_CS, m_KMainTop, _Source, source);
cmd.SetComputeTextureParam(m_CS, m_KMainTop, _InOutTexture, inOutTexture);
cmd.SetComputeTextureParam(m_CS, m_KMainTopRight, _Source, source);
cmd.SetComputeTextureParam(m_CS, m_KMainTopRight, _InOutTexture, inOutTexture);
cmd.DispatchCompute(m_CS, m_KMainTopRight, to.width - from.width, to.height - from.height, 1);
}
}

35
ScriptableRenderPipeline/HDRenderPipeline/HDRP/HDRenderPipeline.cs


RTHandle m_DebugColorPickerBuffer;
RTHandle m_DebugFullScreenTempBuffer;
bool m_FullScreenDebugPushed;
bool m_NoRendering; // False by default mean we render normally, true mean we don't render anything
bool m_ValidAPI; // False by default mean we render normally, true mean we don't render anything
public Material GetBlitMaterial() { return m_Blit; }

public HDRenderPipeline(HDRenderPipelineAsset asset)
{
SetRenderingFeatures();
m_ValidAPI = true;
if (!SetRenderingFeatures())
{
m_ValidAPI = false;
return ;
}
m_Asset = asset;
m_GPUCopy = new GPUCopy(asset.renderPipelineResources.copyChannelCS);

}
void SetRenderingFeatures()
bool SetRenderingFeatures()
{
// Set subshader pipeline tag
Shader.globalRenderPipeline = "HDRenderPipeline";

Debug.LogError("High Definition Render Pipeline doesn't support Gamma mode, change to Linear mode");
}
#endif
m_NoRendering = false;
m_NoRendering = true;
#if UNITY_EDITOR
foreach (UnityEditor.SceneView sv in Resources.FindObjectsOfTypeAll(typeof(UnityEditor.SceneView)))
sv.ShowNotification(new GUIContent("Platform " + SystemInfo.operatingSystem + " with device " + SystemInfo.graphicsDeviceType.ToString() + " is not supported, no rendering will occur"));
#endif
return false;
return true;
}
bool IsSupportedPlatform()

public override void Dispose()
{
UnsetRenderingFeatures();
if (!m_ValidAPI)
return ;
base.Dispose();
m_DebugDisplaySettings.UnregisterDebug();

m_IBLFilterGGX.Cleanup();
DestroyRenderTextures();
UnsetRenderingFeatures();
#if UNITY_EDITOR
SceneViewDrawMode.ResetDrawMode();

ReflectionProbeCullResults m_ReflectionProbeCullResults;
public override void Render(ScriptableRenderContext renderContext, Camera[] cameras)
{
if (m_NoRendering)
if (!m_ValidAPI)
return;
base.Render(renderContext, cameras);

context.command = cmd;
context.camera = hdcamera.camera;
context.sourceFormat = RenderTextureFormat.ARGBHalf;
context.flip = true;
context.flip = hdcamera.camera.targetTexture == null;
layer.Render(context);
}

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


{
// Currently, Unity does not offer a way to access the GCN HTile even on PS4 and Xbox One.
// Therefore, it's computed in a pixel shader, and optimized to only contain the SSS bit.
// Clear the HTile texture. TODO: move this to ClearBuffers(). Clear operations must be batched!
HDUtils.SetRenderTarget(cmd, hdCamera, depthStencilBufferRT); // No need for color buffer here
HDUtils.SetRenderTarget(cmd, hdCamera, depthStencilBufferRT); // No need for color buffer here
CoreUtils.DrawFullScreen(cmd, m_CopyStencilForSplitLighting, null, 2);
cmd.ClearRandomWriteTargets();
}

24
ScriptableRenderPipeline/HDRenderPipeline/HDRP/RenderPipelineResources/BufferPyramidProcessor.cs


public BufferPyramidProcessor(
ComputeShader colorPyramidCS,
ComputeShader depthPyramidCS,
ComputeShader depthPyramidCS,
GPUCopy gpuCopy,
TexturePadding texturePadding
)

cmd.SetComputeTextureParam(m_DepthPyramidCS, kernel, _Source, src);
cmd.SetComputeTextureParam(m_DepthPyramidCS, kernel, _Result, dest);
cmd.SetComputeVectorParam(m_DepthPyramidCS, _SrcSize, new Vector4(
srcWorkMip.width, srcWorkMip.height,
srcWorkMip.width, srcWorkMip.height,
(1.0f / srcWorkMip.width) * scale.x, (1.0f / srcWorkMip.height) * scale.y)
);

public void RenderColorPyramid(
HDCamera hdCamera,
CommandBuffer cmd,
CommandBuffer cmd,
RTHandle sourceTexture,
RTHandle targetTexture,
List<RTHandle> mips,

public void RenderColorPyramid(
RectInt srcRect,
CommandBuffer cmd,
CommandBuffer cmd,
Texture sourceTexture,
RenderTexture targetTexture,
List<RenderTexture> mips,

void RenderColorPyramidMips(
RectInt srcRect,
CommandBuffer cmd,
CommandBuffer cmd,
RenderTexture targetTexture,
List<RenderTexture> mips,
int lodCount,

var dest = mips[i];
var srcMip = new RectInt(0, 0, srcRect.width >> i, srcRect.height >> i);
var dstMip = new RectInt(0, 0, srcMip.width >> 1, srcMip.height >> 1);
//var dstMip = new RectInt(0, 0, srcMip.width >> 1, srcMip.height >> 1);
0,
0,
0,
0,
Mathf.CeilToInt(srcMip.width / 16.0f) * 16,
Mathf.CeilToInt(srcMip.height / 16.0f) * 16
);

cmd.SetComputeTextureParam(m_ColorPyramidCS, m_ColorPyramidKernel, _Result, dest);
// _Size is used as a scale inside the whole render target so here we need to keep the full size (and not the scaled size depending on the current camera)
cmd.SetComputeVectorParam(
m_ColorPyramidCS,
_Size,
m_ColorPyramidCS,
_Size,
new Vector4(dest.width, dest.height, 1f / dest.width, 1f / dest.height)
);
cmd.DispatchCompute(

// If we could bind texture mips as UAV we could avoid this copy...(which moreover copies more than the needed viewport if not fullscreen)
cmd.CopyTexture(
mips[i],
0, 0, 0, 0,
mips[i],
0, 0, 0, 0,
dstMipWidthToCopy, dstMipHeightToCopy, targetTexture, 0, i + 1, 0, 0
);

1
ScriptableRenderPipeline/HDRenderPipeline/HDRP/RenderPipelineResources/CopyDepthBuffer.shader


ZTest Always
ZWrite On
Blend Off
ColorMask 0
HLSLPROGRAM
#pragma target 4.5

2
ScriptableRenderPipeline/LightweightPipeline/LWRP/LightweightPipeline.cs


m_PostProcessRenderContext.sourceFormat = m_ColorFormat;
m_PostProcessRenderContext.destination = dest;
m_PostProcessRenderContext.command = cmd;
m_PostProcessRenderContext.flip = true;
m_PostProcessRenderContext.flip = m_CurrCamera.targetTexture == null;
if (opaqueOnly)
{

正在加载...
取消
保存