浏览代码

code style, reference ARFoundation with LWRP support (backgroundrenderer replacement)

/1.5-preview
Jimmy Alamparambil 6 年前
当前提交
8cfccd21
共有 4 个文件被更改,包括 25 次插入29 次删除
  1. 20
      Assets/LWRPSupport/LWRPBackgroundRenderer.cs
  2. 18
      Assets/LWRPSupport/LWRPBackroundRendererAsset.cs
  3. 12
      Assets/LWRPSupport/LWRPBeforeCameraRender.cs
  4. 4
      Packages/manifest.json

20
Assets/LWRPSupport/LWRPBackgroundRenderer.cs


public class LWRPBackgroundRenderer : ARFoundationBackgroundRenderer
{
CameraClearFlags _savedClearFlags;
LWRPBeforeCameraRender _lwrpBeforeCameraRender;
CameraClearFlags m_SavedClearFlags;
LWRPBeforeCameraRender m_LWRPBeforeCameraRender;
protected override bool EnableARBackgroundRendering()
{

return false;
// Clear flags
_savedClearFlags = camera.clearFlags;
m_SavedClearFlags = camera.clearFlags;
if (_lwrpBeforeCameraRender == null)
if (m_LWRPBeforeCameraRender == null)
_lwrpBeforeCameraRender = camera.gameObject.GetComponent<LWRPBeforeCameraRender>();
m_LWRPBeforeCameraRender = camera.gameObject.GetComponent<LWRPBeforeCameraRender>();
_lwrpBeforeCameraRender.SetupBlitMaterial(m_BackgroundMaterial);
m_LWRPBeforeCameraRender.SetupBlitMaterial(m_BackgroundMaterial);
return true;

camera = m_Camera ? m_Camera : Camera.main;
if (camera == null)
return;
camera.clearFlags = _savedClearFlags;
camera.clearFlags = m_SavedClearFlags;
if (_lwrpBeforeCameraRender != null)
if (m_LWRPBeforeCameraRender != null)
_lwrpBeforeCameraRender.SetupBlitMaterial(null);
_lwrpBeforeCameraRender = null;
m_LWRPBeforeCameraRender.SetupBlitMaterial(null);
m_LWRPBeforeCameraRender = null;
}
}

18
Assets/LWRPSupport/LWRPBackroundRendererAsset.cs


if (bUseRenderPipeline)
{
var lbcr = cameraGameObject.GetComponent<LWRPBeforeCameraRender>();
if (lbcr == null)
var lwrpBeforeCameraRender = cameraGameObject.GetComponent<LWRPBeforeCameraRender>();
if (lwrpBeforeCameraRender == null)
var lacd = cameraGameObject.GetComponent<LightweightAdditionalCameraData>();
if (lacd == null)
var lightweightAdditionalCameraData = cameraGameObject.GetComponent<LightweightAdditionalCameraData>();
if (lightweightAdditionalCameraData == null)
lacd = cameraGameObject.AddComponent<LightweightAdditionalCameraData>();
lightweightAdditionalCameraData = cameraGameObject.AddComponent<LightweightAdditionalCameraData>();
lacd.renderShadows = false;
lacd.requiresColorTexture = false;
lacd.requiresDepthTexture = false;
lightweightAdditionalCameraData.renderShadows = false;
lightweightAdditionalCameraData.requiresColorTexture = false;
lightweightAdditionalCameraData.requiresDepthTexture = false;
}
}

return null;
// Try to create a material from the plugin's provided shader.
string shaderName = "";
var shaderName = "";
if (!cameraSubsystem.TryGetShaderName(ref shaderName))
return null;

12
Assets/LWRPSupport/LWRPBeforeCameraRender.cs



using UnityEngine.Experimental.Rendering;
using UnityEngine.Experimental.Rendering;
public class LWRPBeforeCameraRender : MonoBehaviour, LightweightPipeline.IBeforeCameraRender
{
const string k_ARBlitTag = "ARBackground Blit Pass";

this.BlitMaterial = material;
}
public void ExecuteBeforeCameraRender(ScriptableRenderContext context, Camera camera, LightweightPipeline.PipelineSettings pipelineSettings,
ScriptableRenderer renderer)
public void ExecuteBeforeCameraRender(ScriptableRenderContext context, Camera currentCamera, LightweightPipeline.PipelineSettings pipelineSettings,
ScriptableRenderer currentRenderer)
CommandBuffer cmd = CommandBufferPool.Get(k_ARBlitTag);
var cmd = CommandBufferPool.Get(k_ARBlitTag);
}
}
}

4
Packages/manifest.json


"com.unity.purchasing": "2.0.1",
"com.unity.render-pipelines.lightweight": "3.3.0-preview",
"com.unity.textmeshpro": "1.2.4",
"com.unity.xr.arcore": "1.0.0-preview.18",
"com.unity.xr.arfoundation": "1.0.0-preview.17",
"com.unity.xr.arcore": "1.0.0-preview.19",
"com.unity.xr.arfoundation": "1.0.0-preview.18",
"com.unity.xr.arkit": "1.0.0-preview.14",
"com.unity.modules.ai": "1.0.0",
"com.unity.modules.animation": "1.0.0",

正在加载...
取消
保存