浏览代码

workaround to enable renderpasses without latest changes from graphics/renderpass on graphics/srp

/main
Filip Iliescu 8 年前
当前提交
46f3b214
共有 2 个文件被更改,包括 16 次插入4 次删除
  1. 15
      Assets/ScriptableRenderPipeline/MobileRenderPipeline/OnTileDeferredRenderPipeline.cs
  2. 5
      Assets/ScriptableRenderPipeline/MobileRenderPipeline/Shaders/UnityStandardCore.cginc

15
Assets/ScriptableRenderPipeline/MobileRenderPipeline/OnTileDeferredRenderPipeline.cs


// cannot read depth buffer directly in shader on iOS
private RenderPassAttachment s_GBufferRedF32;
// TODO: When graphics/renderpass lands, replace code that uses boolean below with SystemInfo.supportsReadOnlyDepth
#if UNITY_EDITOR || UNITY_STANDALONE
static bool s_SupportsReadOnlyDepth = true;
#else
static bool s_SupportsReadOnlyDepth = false;
#endif
private static int _sceneViewBlitId;
private static int _sceneViewDepthId;
private static Material _blitDepthMaterial;

s_GBufferEmission.Clear(new Color(0.0f, 0.0f, 0.0f, 0.0f), 1.0f, 0);
s_Depth.Clear(new Color(), 1.0f, 0);
if (SystemInfo.supportsReadOnlyDepth)
if (s_SupportsReadOnlyDepth)
{
s_GBufferRedF32 = null;
}

void ExecuteRenderLoop(Camera camera, CullResults cullResults, ScriptableRenderContext loop)
{
using (RenderPass rp = new RenderPass (loop, camera.pixelWidth, camera.pixelHeight, 1, SystemInfo.supportsReadOnlyDepth ?
using (RenderPass rp = new RenderPass (loop, camera.pixelWidth, camera.pixelHeight, 1, s_SupportsReadOnlyDepth ?
using (new RenderPass.SubPass (rp, SystemInfo.supportsReadOnlyDepth ?
using (new RenderPass.SubPass (rp, s_SupportsReadOnlyDepth ?
new[] { s_GBufferAlbedo, s_GBufferSpecRough, s_GBufferNormal, s_GBufferEmission } :
new[] { s_GBufferAlbedo, s_GBufferSpecRough, s_GBufferNormal, s_GBufferEmission, s_GBufferRedF32 }, null)) {
using (var cmd = new CommandBuffer { name = "Create G-Buffer" }) {

//Lighting Pass
using (new RenderPass.SubPass(rp, new[] { s_GBufferEmission },
new[] { s_GBufferAlbedo, s_GBufferSpecRough, s_GBufferNormal, SystemInfo.supportsReadOnlyDepth ? s_Depth : s_GBufferRedF32 }, true))
new[] { s_GBufferAlbedo, s_GBufferSpecRough, s_GBufferNormal, s_SupportsReadOnlyDepth ? s_Depth : s_GBufferRedF32 }, true))
{
using (var cmd = new CommandBuffer { name = "Deferred Lighting and Reflections Pass"} )
{

5
Assets/ScriptableRenderPipeline/MobileRenderPipeline/Shaders/UnityStandardCore.cginc


return o;
}
// TODO: Remove this after merging in graphics/renderpass branch. This should be defined in hlslSupport.cginc
#if defined(SHADER_API_D3D11) || defined(SHADER_API_GLCORE) || defined(SHADER_API_GLES3) || defined(SHADER_API_VULKAN) || (defined(SHADER_API_METAL) && !defined(SHADER_API_MOBILE))
#define UNITY_SUPPORT_DEPTH_FETCH 1
#endif
void fragDeferred (
VertexOutputDeferred i,
//in float inDepth : SV_Depth,

正在加载...
取消
保存