浏览代码

get renderpass to work on iOS by removing the extra camera setup before the final blit and setting up the render attachments exactly how i expect them to be processed.

/main
Filip Iliescu 7 年前
当前提交
ac0dbace
共有 5 个文件被更改,包括 21 次插入31 次删除
  1. 29
      Assets/ScriptableRenderPipeline/MobileRenderPipeline/OnTileDeferredRenderPipeline.cs
  2. 4
      Assets/ScriptableRenderPipeline/MobileRenderPipeline/Shaders/FinalPass.shader
  3. 2
      Assets/ScriptableRenderPipeline/MobileRenderPipeline/Shaders/Internal-DeferredReflections.shader
  4. 13
      Assets/ScriptableRenderPipeline/MobileRenderPipeline/Shaders/LightingTemplate.hlsl
  5. 4
      Assets/ScriptableRenderPipeline/MobileRenderPipeline/Shaders/UnityStandardCore.cginc

29
Assets/ScriptableRenderPipeline/MobileRenderPipeline/OnTileDeferredRenderPipeline.cs


private RenderPassAttachment s_GBufferSpecRough;
private RenderPassAttachment s_GBufferNormal;
private RenderPassAttachment s_GBufferEmission;
private RenderPassAttachment s_GBufferZ;
private RenderPassAttachment s_CameraTarget;
private RenderPassAttachment s_Depth;

public void Build()
{
s_GBufferAlbedo = new RenderPassAttachment(RenderTextureFormat.ARGB32);
s_GBufferSpecRough = new RenderPassAttachment(RenderTextureFormat.ARGB32);
s_GBufferNormal = new RenderPassAttachment(RenderTextureFormat.ARGB2101010);
s_GBufferEmission = new RenderPassAttachment(RenderTextureFormat.ARGBHalf);
s_GBufferZ = new RenderPassAttachment(RenderTextureFormat.Depth);
s_GBufferAlbedo = new RenderPassAttachment(RenderTextureFormat.ARGB32) { hideFlags = HideFlags.HideAndDontSave };
s_GBufferSpecRough = new RenderPassAttachment(RenderTextureFormat.ARGB32) { hideFlags = HideFlags.HideAndDontSave };
s_GBufferNormal = new RenderPassAttachment(RenderTextureFormat.ARGB2101010) { hideFlags = HideFlags.HideAndDontSave };
s_GBufferEmission = new RenderPassAttachment(RenderTextureFormat.ARGBHalf) { hideFlags = HideFlags.HideAndDontSave };
s_Depth = new RenderPassAttachment(RenderTextureFormat.Depth) { hideFlags = HideFlags.HideAndDontSave };
s_Depth = new RenderPassAttachment(RenderTextureFormat.Depth);
s_GBufferZ.Clear(new Color(), 1.0f, 0);
s_Depth.Clear(new Color(), 1.0f, 0);
if (SystemInfo.supportsReadOnlyDepth)
{

{
s_GBufferRedF32 = new RenderPassAttachment(RenderTextureFormat.RFloat);
s_GBufferRedF32 = new RenderPassAttachment(RenderTextureFormat.RFloat) { hideFlags = HideFlags.HideAndDontSave };
s_GBufferRedF32.Clear(new Color(), 1.0f, 0);
}

context.ExecuteCommandBuffer(cmd);
}
s_CameraTarget.BindSurface(new RenderTargetIdentifier(_sceneViewBlitId), false, true);
s_Depth.BindSurface(new RenderTargetIdentifier(_sceneViewDepthId), false, true);
s_Depth.BindSurface(new RenderTargetIdentifier(_sceneViewDepthId), false, false);
}
else
{

}
}
context.Submit ();
context.Submit ();
}
void ExecuteRenderLoop(Camera camera, CullResults cullResults, ScriptableRenderContext loop)

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

}
//Single Pass Forward Transparencies
using (new RenderPass.SubPass(rp, new[] { s_GBufferEmission }, new[] { s_GBufferAlbedo, s_GBufferSpecRough, s_GBufferNormal, s_GBufferEmission }))
using (new RenderPass.SubPass(rp, new[] { s_GBufferEmission }, null))
{
using (var cmd = new CommandBuffer { name = "Forwward Lighting Setup"} )
{

}
//Final pass
loop.SetupCameraProperties (camera);
using (new RenderPass.SubPass(rp, new[] { s_CameraTarget }, new[] { s_GBufferEmission }))
{
var cmd = new CommandBuffer { name = "FinalPass" };

4
Assets/ScriptableRenderPipeline/MobileRenderPipeline/Shaders/FinalPass.shader


#include "UnityCG.cginc"
struct v2f {
float4 vertex : SV_POSITION;
float4 vertex : SV_Position;
};
UNITY_DECLARE_FRAMEBUFFER_INPUT_HALF(0);

v2f o;
o.vertex.x = (id & 1) != 0 ? 3 : -1;
o.vertex.y = (id & 2) != 0 ? -3 : 1;
o.vertex.y = (id & 2) != 0 ? -5 : 1;
o.vertex.z = 0;
o.vertex.w = 1;
return o;

2
Assets/ScriptableRenderPipeline/MobileRenderPipeline/Shaders/Internal-DeferredReflections.shader


float4 viewPos;
float3 worldPos;
float depth = UNITY_READ_FRAMEBUFFER_INPUT(4, i.pos);
float depth = UNITY_READ_FRAMEBUFFER_INPUT(3, i.pos);
OnChipDeferredFragSetup(i, uv, viewPos, worldPos, depth);
half4 gbuffer0 = UNITY_READ_FRAMEBUFFER_INPUT(0, i.pos);

13
Assets/ScriptableRenderPipeline/MobileRenderPipeline/Shaders/LightingTemplate.hlsl


UNITY_DECLARE_FRAMEBUFFER_INPUT_HALF(0);
UNITY_DECLARE_FRAMEBUFFER_INPUT_HALF(1);
UNITY_DECLARE_FRAMEBUFFER_INPUT_HALF(2);
UNITY_DECLARE_FRAMEBUFFER_INPUT_HALF(3);
UNITY_DECLARE_FRAMEBUFFER_INPUT_FLOAT(4);
UNITY_DECLARE_FRAMEBUFFER_INPUT_FLOAT(3);
// from LightDefinitions.cs.hlsl
#define SPOT_LIGHT (0)

out float2 outUV,
out half3 outLightDir,
out float outAtten,
out float outFadeDist,
out float4 outCookieColor,
float depth
)

OnChipDeferredFragSetup(i, uv, vpos, wpos, depth);
float fadeDist = UnityComputeShadowFadeDistance(wpos, vpos.z);
// spot light case
#if defined (SPOT)
float3 tolight = _LightPos.xyz - wpos;

outUV = uv;
outLightDir = lightDir;
outAtten = atten;
outFadeDist = fadeDist;
outCookieColor = colorCookie;
}

float3 wpos;
float2 uv;
float atten, fadeDist;
float atten;
float depth = UNITY_READ_FRAMEBUFFER_INPUT(4, i.pos);
OnChipDeferredCalculateLightParams (i, wpos, uv, light.dir, atten, fadeDist, colorCookie, depth);
float depth = UNITY_READ_FRAMEBUFFER_INPUT(3, i.pos);
OnChipDeferredCalculateLightParams (i, wpos, uv, light.dir, atten, colorCookie, depth);
#if defined (POINT_COOKIE) || defined (DIRECTIONAL_COOKIE) || defined (SPOT)
light.color = _LightColor.rgb * colorCookie.rgb * atten;

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


out half4 outGBuffer2 : SV_Target2,
out half4 outEmission : SV_Target3 // RT3: emission (rgb), --unused-- (a)
#if (UNITY_ALLOWED_MRT_COUNT > 4)
#if defined(UNITY_SUPPORT_DEPTH_FETCH)
#if !defined(UNITY_SUPPORT_DEPTH_FETCH)
,out float outDepth : SV_Target4 // RT4: zData (F32)
#elif defined(SHADOWS_SHADOWMASK)
,out half4 outShadowMask : SV_Target4 // RT4: shadowmask (rgba)

// Baked direct lighting occlusion if any
#if (UNITY_ALLOWED_MRT_COUNT > 4)
#if defined(UNITY_SUPPORT_DEPTH_FETCH)
#if !defined(UNITY_SUPPORT_DEPTH_FETCH)
outDepth = i.pos.z;
#elif defined(SHADOWS_SHADOWMASK)
outShadowMask = UnityGetRawBakedOcclusions(i.ambientOrLightmapUV.xy, IN_WORLDPOS(i));

正在加载...
取消
保存