浏览代码

ibeforerender changes - background rendering works, but the rest of the shaders don't work with this change

/lwrp-support-2018.3-with-1.5
Jimmy Alamparambil 6 年前
当前提交
1e4a9806
共有 18 个文件被更改,包括 316 次插入144 次删除
  1. 2
      Assets/LWRPSupport/ARKitLWRPShader.shader
  2. 2
      Assets/LWRPSupport/LWRPBackgroundRendererAsset.asset
  3. 31
      Assets/LWRPSupport/LWRPBeforeCameraRender.cs
  4. 6
      Assets/LWRPSupport/Unity.XR.ARFoundation.LWRPSupport.asmdef
  5. 7
      Assets/Materials/LWRPCube.mat
  6. 7
      Assets/Materials/LWRPPlane.mat
  7. 116
      Assets/Scenes/SampleLWRPScene.unity
  8. 11
      Packages/manifest.json
  9. 44
      ProjectSettings/EditorSettings.asset
  10. 9
      ProjectSettings/GraphicsSettings.asset
  11. 13
      ProjectSettings/ProjectSettings.asset
  12. 2
      ProjectSettings/ProjectVersion.txt
  13. 1
      ProjectSettings/UnityConnectSettings.asset
  14. 63
      Assets/LWRPSupport/LWRPBackgroundRenderPass.cs
  15. 11
      Assets/LWRPSupport/LWRPBackgroundRenderPass.cs.meta
  16. 61
      Assets/LWRPSupport/LWRPBackgroundRendererAsset.cs
  17. 74
      Assets/LWRPSupport/LWRPBackroundRendererAsset.cs
  18. 0
      /Assets/LWRPSupport/LWRPBackgroundRendererAsset.cs.meta

2
Assets/LWRPSupport/ARKitLWRPShader.shader


#pragma vertex Vertex
#pragma fragment Fragment
#include "LWRP/ShaderLibrary/Core.hlsl"
#include "Packages/com.unity.render-pipelines.lightweight/ShaderLibrary/Core.hlsl"
float4x4 _UnityDisplayTransform;

2
Assets/LWRPSupport/LWRPBackgroundRendererAsset.asset


m_Enabled: 1
m_EditorHideFlags: 0
m_Script: {fileID: 11500000, guid: 3974c4b6d5b67422c935da45b02d23f2, type: 3}
m_Name: LWRPBackroundRendererAsset
m_Name: LWRPBackgroundRendererAsset
m_EditorClassIdentifier:
m_MaterialsUsed:
- {fileID: 2100000, guid: 91c809f5df4d84941a85f4cd21a290f7, type: 2}

31
Assets/LWRPSupport/LWRPBeforeCameraRender.cs


using UnityEngine.Experimental.Rendering;
using UnityEngine.Rendering;
using UnityEngine.Experimental.Rendering.LWRP;
namespace UnityEngine.XR.ARFoundation
namespace UnityEngine.XR.ARFoundation.LWRPSupport
public class LWRPBeforeCameraRender : MonoBehaviour, LightweightPipeline.IBeforeCameraRender
public class LWRPBeforeCameraRender : MonoBehaviour, IBeforeRender
public void ExecuteBeforeCameraRender(ScriptableRenderContext context, Camera currentCamera, LightweightPipeline.PipelineSettings pipelineSettings,
ScriptableRenderer currentRenderer)
/// <summary>
/// Create, setup and return a ScriptableRenderPass that will blit the pass-thru video when this GameObject is rendered.
/// </summary>
/// <param name="baseDescriptor">RenderTextureDescriptor for this pass. </param>
/// <param name="colorHandle">RenderTargetHandle for color buffer.</param>
/// <param name="depthHandle">RenderTargetHandle for depth buffer.</param>
/// <param name="clearFlag">ClearFlag used for rendering.</param>
/// <returns></returns>
public ScriptableRenderPass GetPassToEnqueue(RenderTextureDescriptor baseDescriptor, RenderTargetHandle colorHandle,
RenderTargetHandle depthHandle, ClearFlag clearFlag)
if (blitMaterial == null)
return;
var cmd = CommandBufferPool.Get(k_ARBlitTag);
cmd.Blit(null, BuiltinRenderTextureType.CameraTarget, blitMaterial);
context.ExecuteCommandBuffer(cmd);
CommandBufferPool.Release(cmd);
LWRPBackgroundRenderPass lwrpBackgroundRenderPass = new LWRPBackgroundRenderPass();
lwrpBackgroundRenderPass.Setup(blitMaterial, colorHandle.Identifier(), depthHandle.Identifier(),
baseDescriptor);
return lwrpBackgroundRenderPass;
}
}
}

6
Assets/LWRPSupport/Unity.XR.ARFoundation.LWRPSupport.asmdef


"name": "Unity.XR.ARFoundation.LWRPSupport",
"references": [
"Unity.XR.ARFoundation",
"Unity.RenderPipelines.Lightweight.Runtime",
"Unity.RenderPipelines.Core.Runtime"
],
"Unity.RenderPipelines.Core.Runtime",
"Unity.RenderPipelines.Lightweight.Runtime"
],
"optionalUnityReferences": [],
"includePlatforms": [],
"excludePlatforms": [],

7
Assets/Materials/LWRPCube.mat


m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_Name: LWRPCube
m_Shader: {fileID: 4800000, guid: 8d2bb70cbf9db8d4da26e15b26e74248, type: 3}
m_ShaderKeywords: _GLOSSINESS_FROM_BASE_ALPHA _SPECULAR_COLOR
m_Shader: {fileID: 4800000, guid: 650dd9526735d5b46b79224bc6e94025, type: 3}
m_ShaderKeywords:
m_LightmapFlags: 4
m_EnableInstancingVariants: 0
m_DoubleSidedGI: 0

- _AlphaClip: 0
- _Blend: 0
- _BumpScale: 1
- _Cull: 2
- _Cull: 0
- _Cutoff: 0.5
- _DetailNormalMapScale: 1
- _DstBlend: 0

- _OcclusionStrength: 1
- _Parallax: 0.02
- _ReceiveShadows: 1
- _SampleGI: 0
- _Shininess: 0.5
- _SmoothnessTextureChannel: 0
- _SpecSource: 0

7
Assets/Materials/LWRPPlane.mat


m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_Name: LWRPPlane
m_Shader: {fileID: 4800000, guid: 8d2bb70cbf9db8d4da26e15b26e74248, type: 3}
m_ShaderKeywords: _SPECULAR_COLOR
m_Shader: {fileID: 4800000, guid: 650dd9526735d5b46b79224bc6e94025, type: 3}
m_ShaderKeywords:
m_LightmapFlags: 4
m_EnableInstancingVariants: 0
m_DoubleSidedGI: 0

- _AlphaClip: 0
- _Blend: 0
- _BumpScale: 1
- _Cull: 2
- _Cull: 0
- _Cutoff: 0.5
- _DetailNormalMapScale: 1
- _DstBlend: 10

- _OcclusionStrength: 1
- _Parallax: 0.02
- _ReceiveShadows: 1
- _SampleGI: 0
- _Shininess: 0.5
- _SmoothnessTextureChannel: 0
- _SpecSource: 0

116
Assets/Scenes/SampleLWRPScene.unity


m_ReflectionIntensity: 1
m_CustomReflection: {fileID: 0}
m_Sun: {fileID: 0}
m_IndirectSpecularColor: {r: 0.44657898, g: 0.49641275, b: 0.57481736, a: 1}
m_IndirectSpecularColor: {r: 0.44657898, g: 0.496413, b: 0.5748175, a: 1}
m_UseRadianceAmbientProbe: 0
--- !u!157 &3
LightmapSettings:

m_BounceScale: 1
m_IndirectOutputScale: 1
m_AlbedoBoost: 1
m_TemporalCoherenceThreshold: 1
m_EnvironmentLightingMode: 0
m_EnableBakedLightmaps: 1
m_EnableRealtimeLightmaps: 0

m_UseCustomMaterial: 0
m_CustomMaterial: {fileID: 2100000, guid: e77eba92b3f8949a8ba25b8d98a8f694, type: 2}
m_UseCustomRendererAsset: 1
m_CustomRendererAsset: {fileID: 11400000, guid: 2310b94e2d8f5463ab592fa99eefbe6f, type: 2}
m_CustomRendererAsset: {fileID: 11400000, guid: 2310b94e2d8f5463ab592fa99eefbe6f,
type: 2}
--- !u!20 &282840813
Camera:
m_ObjectHideFlags: 0

y: 0
width: 1
height: 1
near clip plane: 0.1
far clip plane: 20
near clip plane: 0.01
far clip plane: 1000
field of view: 60
orthographic: 0
orthographic size: 5

m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 282840810}
m_LocalRotation: {x: 0, y: 0.38268343, z: 0, w: 0.92387956}
m_LocalPosition: {x: 0, y: -0.46, z: 3.16}
m_LocalRotation: {x: 0, y: 0, z: 0, w: 1}
m_LocalPosition: {x: 0, y: 0, z: 0}
m_LocalEulerAnglesHint: {x: 0, y: 45, z: 0}
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
--- !u!114 &282840815
MonoBehaviour:
m_ObjectHideFlags: 0

m_Father: {fileID: 0}
m_RootOrder: 1
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
--- !u!1 &518872366
GameObject:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
serializedVersion: 6
m_Component:
- component: {fileID: 518872370}
- component: {fileID: 518872369}
- component: {fileID: 518872368}
- component: {fileID: 518872367}
m_Layer: 0
m_Name: Cube
m_TagString: Untagged
m_Icon: {fileID: 0}
m_NavMeshLayer: 0
m_StaticEditorFlags: 0
m_IsActive: 1
--- !u!65 &518872367
BoxCollider:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 518872366}
m_Material: {fileID: 0}
m_IsTrigger: 0
m_Enabled: 1
serializedVersion: 2
m_Size: {x: 1, y: 1, z: 1}
m_Center: {x: 0, y: 0, z: 0}
--- !u!23 &518872368
MeshRenderer:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 518872366}
m_Enabled: 1
m_CastShadows: 1
m_ReceiveShadows: 1
m_DynamicOccludee: 1
m_MotionVectors: 1
m_LightProbeUsage: 1
m_ReflectionProbeUsage: 1
m_RenderingLayerMask: 1
m_RendererPriority: 0
m_Materials:
- {fileID: 2100000, guid: 31321ba15b8f8eb4c954353edc038b1d, type: 2}
m_StaticBatchInfo:
firstSubMesh: 0
subMeshCount: 0
m_StaticBatchRoot: {fileID: 0}
m_ProbeAnchor: {fileID: 0}
m_LightProbeVolumeOverride: {fileID: 0}
m_ScaleInLightmap: 1
m_PreserveUVs: 0
m_IgnoreNormalsForChartDetection: 0
m_ImportantGI: 0
m_StitchLightmapSeams: 0
m_SelectedEditorRenderState: 3
m_MinimumChartSize: 4
m_AutoUVMaxDistance: 0.5
m_AutoUVMaxAngle: 89
m_LightmapParameters: {fileID: 0}
m_SortingLayerID: 0
m_SortingLayer: 0
m_SortingOrder: 0
--- !u!33 &518872369
MeshFilter:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 518872366}
m_Mesh: {fileID: 10202, guid: 0000000000000000e000000000000000, type: 0}
--- !u!4 &518872370
Transform:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 518872366}
m_LocalRotation: {x: 0, y: 0, z: 0, w: 1}
m_LocalPosition: {x: 0, y: 0, z: 0}
m_LocalScale: {x: 1, y: 1, z: 1}
m_Children: []
m_Father: {fileID: 0}
m_RootOrder: 3
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
--- !u!1 &1015722065
GameObject:
m_ObjectHideFlags: 0

m_Script: {fileID: 11500000, guid: 7ab0e80cee9cc1d44928bfe488dd1e2d, type: 3}
m_Name:
m_EditorClassIdentifier:
m_PointCloudPrefab: {fileID: 1854016325464908, guid: 0d4f49e744bffd14eb527ba76c9bba12, type: 2}
m_PointCloudPrefab: {fileID: 1854016325464908, guid: 0d4f49e744bffd14eb527ba76c9bba12,
type: 3}
--- !u!114 &1335839537
MonoBehaviour:
m_ObjectHideFlags: 0

m_Script: {fileID: 11500000, guid: e1760703bbd54c04488a8d10600262ab, type: 3}
m_Name:
m_EditorClassIdentifier:
m_PlanePrefab: {fileID: 1568414836858200, guid: b588636d005074635b1c79eb606780fa, type: 3}
m_PlanePrefab: {fileID: 1568414836858200, guid: b588636d005074635b1c79eb606780fa,
type: 3}
--- !u!114 &1335839538
MonoBehaviour:
m_ObjectHideFlags: 0

m_Script: {fileID: 11500000, guid: 7d5359d5f13250e4485741ed685a32be, type: 3}
m_Name:
m_EditorClassIdentifier:
m_PlacedPrefab: {fileID: 1934569588295450, guid: 1ce7552d1af24499c9d1092090d6fb40, type: 3}
m_PlacedPrefab: {fileID: 1934569588295450, guid: 1ce7552d1af24499c9d1092090d6fb40,
type: 3}

11
Packages/manifest.json


{
"dependencies": {
"com.unity.collab-proxy": "1.2.9",
"com.unity.package-manager-ui": "2.0.0-preview.7",
"com.unity.render-pipelines.lightweight": "3.3.0-preview",
"com.unity.collab-proxy": "1.2.15",
"com.unity.package-manager-ui": "2.0.3",
"com.unity.shadergraph": "file:/Users/jimmy/Documents/Projects/DevUnity/Packages/ScriptableRenderPipeline/com.unity.shadergraph",
"com.unity.render-pipelines.core": "file:/Users/jimmy/Documents/Projects/DevUnity/Packages/ScriptableRenderPipeline/com.unity.render-pipelines.core",
"com.unity.render-pipelines.lightweight": "file:/Users/jimmy/Documents/Projects/DevUnity/Packages/ScriptableRenderPipeline/com.unity.render-pipelines.lightweight",
"com.unity.modules.jsonserialize": "1.0.0",
"com.unity.modules.unityanalytics": "1.0.0",
"com.unity.modules.unitywebrequest": "1.0.0",
"com.unity.modules.vr": "1.0.0",
"com.unity.modules.xr": "1.0.0"
}

44
ProjectSettings/EditorSettings.asset


%YAML 1.1
%TAG !u! tag:unity3d.com,2011:
--- !u!159 &1
EditorSettings:
m_ObjectHideFlags: 0
serializedVersion: 7
m_ExternalVersionControlSupport: Visible Meta Files
m_SerializationMode: 2
m_LineEndingsForNewScripts: 2
m_DefaultBehaviorMode: 0
m_SpritePackerMode: 0
m_SpritePackerPaddingPower: 1
m_EtcTextureCompressorBehavior: 1
m_EtcTextureFastCompressor: 1
m_EtcTextureNormalCompressor: 2
m_EtcTextureBestCompressor: 4
m_ProjectGenerationIncludedExtensions: txt;xml;fnt;cd
m_ProjectGenerationRootNamespace:
m_UserGeneratedProjectSuffix:
m_CollabEditorSettings:
inProgressEnabled: 1
%YAML 1.1
%TAG !u! tag:unity3d.com,2011:
--- !u!159 &1
EditorSettings:
m_ObjectHideFlags: 0
serializedVersion: 7
m_ExternalVersionControlSupport: Visible Meta Files
m_SerializationMode: 2
m_LineEndingsForNewScripts: 2
m_DefaultBehaviorMode: 0
m_PrefabRegularEnvironment: {fileID: 0}
m_PrefabUIEnvironment: {fileID: 0}
m_SpritePackerMode: 0
m_SpritePackerPaddingPower: 1
m_EtcTextureCompressorBehavior: 1
m_EtcTextureFastCompressor: 1
m_EtcTextureNormalCompressor: 2
m_EtcTextureBestCompressor: 4
m_ProjectGenerationIncludedExtensions: txt;xml;fnt;cd;asmdef
m_ProjectGenerationRootNamespace:
m_CollabEditorSettings:
inProgressEnabled: 1
m_EnableTextureStreamingInPlayMode: 1

9
ProjectSettings/GraphicsSettings.asset


- {fileID: 10770, guid: 0000000000000000f000000000000000, type: 0}
- {fileID: 17000, guid: 0000000000000000f000000000000000, type: 0}
- {fileID: 16000, guid: 0000000000000000f000000000000000, type: 0}
- {fileID: 16002, guid: 0000000000000000f000000000000000, type: 0}
m_SpritesDefaultMaterial: {fileID: 10754, guid: 0000000000000000f000000000000000, type: 0}
m_CustomRenderPipeline: {fileID: 11400000, guid: b01a4952003554c0191ed57356e5830a, type: 2}
m_SpritesDefaultMaterial: {fileID: 10754, guid: 0000000000000000f000000000000000,
type: 0}
m_CustomRenderPipeline: {fileID: 11400000, guid: b01a4952003554c0191ed57356e5830a,
type: 2}
m_TransparencySortMode: 0
m_TransparencySortAxis: {x: 0, y: 0, z: 1}
m_DefaultRenderingPath: 1

m_FogStripping: 0
m_InstancingStripping: 0
m_InstancingStripping: 2
m_LightmapKeepPlain: 1
m_LightmapKeepDirCombined: 1
m_LightmapKeepDynamicPlain: 1

13
ProjectSettings/ProjectSettings.asset


preserveFramebufferAlpha: 0
disableDepthAndStencilBuffers: 0
androidStartInFullscreen: 1
androidRenderOutsideSafeArea: 0
androidBlitType: 0
defaultIsNativeResolution: 1
macRetinaSupport: 1

m_HolographicPauseOnTrackingLoss: 1
xboxOneDisableKinectGpuReservation: 0
xboxOneEnable7thCore: 0
isWsaHolographicRemotingEnabled: 0
vrSettings:
cardboard:
depthFormat: 0

StripUnusedMeshComponents: 1
VertexChannelCompressionMask: 4054
iPhoneSdkVersion: 988
iOSTargetOSVersionString: 8.0
iOSTargetOSVersionString: 9.0
tvOSSdkVersion: 0
tvOSRequireExtendedGameController: 0
tvOSTargetOSVersionString: 9.0

height: 180
banner: {fileID: 0}
androidGamepadSupportLevel: 0
AndroidJvmMaxHeapSize: 4096
resolutionDialogBanner: {fileID: 0}
m_BuildTargetIcons: []
m_BuildTargetPlatformIcons:

switchAllowsVideoCapturing: 1
switchAllowsRuntimeAddOnContentInstall: 0
switchDataLossConfirmation: 0
switchUserAccountLockEnabled: 0
switchSupportedNpadStyles: 3
switchNativeFsCacheSize: 32
switchIsHoldTypeHorizontal: 0

incrementalIl2cppBuild: {}
allowUnsafeCode: 0
additionalIl2CppArgs:
scriptingRuntimeVersion: 0
scriptingRuntimeVersion: 1
apiCompatibilityLevelPerPlatform: {}
m_RenderingPath: 1
m_MobileRenderingPath: 1

metroDefaultTileSize: 1
metroTileForegroundText: 2
metroTileBackgroundColor: {r: 0.13333334, g: 0.17254902, b: 0.21568628, a: 0}
metroSplashScreenBackgroundColor: {r: 0.12941177, g: 0.17254902, b: 0.21568628, a: 1}
metroSplashScreenBackgroundColor: {r: 0.12941177, g: 0.17254902, b: 0.21568628,
a: 1}
metroSplashScreenUseBackgroundColor: 0
platformCapabilities: {}
metroTargetDeviceFamilies: {}

facebookStatus: 1
facebookXfbml: 0
facebookFrictionlessRequests: 1
apiCompatibilityLevel: 2
apiCompatibilityLevel: 6
cloudProjectId:
framebufferDepthMemorylessMode: 0
projectName: Template_3D

2
ProjectSettings/ProjectVersion.txt


m_EditorVersion: 2018.3.0b2
m_EditorVersion: 2018.3.0f2

1
ProjectSettings/UnityConnectSettings.asset


UnityAnalyticsSettings:
m_Enabled: 1
m_TestMode: 0
m_InitializeOnStartup: 1
UnityAdsSettings:
m_Enabled: 0
m_InitializeOnStartup: 1

63
Assets/LWRPSupport/LWRPBackgroundRenderPass.cs


using System;
using UnityEngine.Experimental.Rendering;
using UnityEngine.Experimental.Rendering.LightweightPipeline;
using UnityEngine.Rendering;
namespace UnityEngine.XR.ARFoundation.LWRPSupport
{
public class LWRPBackgroundRenderPass : ScriptableRenderPass
{
Material m_BlitMaterial;
RenderTargetIdentifier m_DepthIdentifier;
RenderTargetIdentifier m_TargetIdentifier;
RenderTextureDescriptor m_Descriptor;
const string k_ARBlitTag = "ARBackground Blit Pass";
/// <summary>
/// This render pass will need to be setup with the following parameters to be able to execute when called to do so.
/// In this case, this method is called from GetPassToEnqueue in IBeforeRender interface.
/// </summary>
/// <param name="mat"> Material to be used to clear the screen. </param>
/// <param name="ident"> RenderTargetIdentifier for the color buffer. </param>
/// <param name="depthIdent"> RenderTargetIdentifier for the depth buffer.</param>
/// <param name="descript"> RenderTextureDescriptor for the target RenderTexture. </param>
/// <returns> True if the material set is not null. </returns>
public bool Setup(Material mat, RenderTargetIdentifier ident, RenderTargetIdentifier depthIdent, RenderTextureDescriptor descript)
{
m_BlitMaterial = mat;
m_TargetIdentifier = ident;
m_DepthIdentifier = depthIdent;
m_Descriptor = descript;
return m_BlitMaterial != null;
}
/// <summary>
/// Custom rendering for clearing the background with the pass-thru video for AR happens here. We use the parameters passed in via setup
/// to create command buffer that clears the render target and blits to it using the clear material.
/// </summary>
/// <param name="renderer"> The ScriptableRenderer that is being used. </param>
/// <param name="context"> The ScriptableRenderContext used to execute the command buffer that we create. </param>
/// <param name="renderingData"> RenderingData (unused here). </param>
/// <exception cref="ArgumentNullException"> Throw this exception if the renderer is null. </exception>
public override void Execute(ScriptableRenderer renderer, ScriptableRenderContext context, ref RenderingData renderingData)
{
if (renderer == null)
throw new ArgumentNullException("renderer");
var cmd = CommandBufferPool.Get(k_ARBlitTag);
RenderBufferLoadAction colorLoadOp = RenderBufferLoadAction.DontCare;
RenderBufferStoreAction colorStoreOp = RenderBufferStoreAction.Store;
RenderBufferLoadAction depthLoadOp = RenderBufferLoadAction.DontCare;
RenderBufferStoreAction depthStoreOp = RenderBufferStoreAction.Store;
SetRenderTarget(cmd, m_TargetIdentifier, colorLoadOp, colorStoreOp,
m_DepthIdentifier, depthLoadOp, depthStoreOp, ClearFlag.All, Color.clear, m_Descriptor.dimension);
cmd.Blit(null, m_TargetIdentifier, m_BlitMaterial);
context.ExecuteCommandBuffer(cmd);
CommandBufferPool.Release(cmd);
}
}
}

11
Assets/LWRPSupport/LWRPBackgroundRenderPass.cs.meta


fileFormatVersion: 2
guid: 566adfba2b318447fb941a2ea4f3f84f
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

61
Assets/LWRPSupport/LWRPBackgroundRendererAsset.cs



using System;
using UnityEngine.Rendering;
namespace UnityEngine.XR.ARFoundation.LWRPSupport
{
[CreateAssetMenu(fileName = "LWRPBackgroundRendererAsset", menuName = "XR/LWRPBackgroundRendererAsset")]
public class LWRPBackgroundRendererAsset : ARBackgroundRendererAsset
{
/// <summary>
/// we're going to reference all materials that we want to use so that they get built into the project
/// </summary>
[SerializeField]
Material[] m_MaterialsUsed;
static bool useRenderPipeline { get { return GraphicsSettings.renderPipelineAsset != null; } }
public override ARFoundationBackgroundRenderer CreateARBackgroundRenderer()
{
return useRenderPipeline ? new LWRPBackgroundRenderer() : new ARFoundationBackgroundRenderer();
}
public override void CreateHelperComponents(GameObject cameraGameObject)
{
if (useRenderPipeline)
{
var lwrpBeforeCameraRender = cameraGameObject.GetComponent<LWRPBeforeCameraRender>();
if (lwrpBeforeCameraRender == null)
{
cameraGameObject.AddComponent<LWRPBeforeCameraRender>();
}
}
}
public override Material CreateCustomMaterial()
{
var cameraSubsystem = ARSubsystemManager.cameraSubsystem;
if (cameraSubsystem == null)
return null;
// Try to create a material from the plugin's provided shader.
var shaderName = "";
if (!cameraSubsystem.TryGetShaderName(ref shaderName))
return null;
shaderName = shaderName + "LWRP";
var shader = Shader.Find(shaderName);
if (shader == null)
{
throw new InvalidOperationException(string.Format(
"Could not find shader named \"{0}\" required for LWRP video overlay on camera subsystem named \"{1}\".",
shaderName,
cameraSubsystem.SubsystemDescriptor.id));
}
return new Material(shader);
}
}
}

74
Assets/LWRPSupport/LWRPBackroundRendererAsset.cs



using System;
using UnityEngine.Experimental.Rendering.LightweightPipeline;
using UnityEngine.Rendering;
using UnityEngine.Serialization;
namespace UnityEngine.XR.ARFoundation.LWRPSupport
{
[CreateAssetMenu(fileName = "LWRPBackroundRendererAsset", menuName = "XR/LWRPBackroundRendererAsset")]
public class LWRPBackroundRendererAsset : ARBackgroundRendererAsset
{
/// <summary>
/// we're going to reference all materials that we want to use so that they get built into the project
/// </summary>
[SerializeField]
Material[] m_MaterialsUsed;
static bool useRenderPipeline { get { return GraphicsSettings.renderPipelineAsset != null; } }
public override ARFoundationBackgroundRenderer CreateARBackgroundRenderer()
{
return useRenderPipeline ? new LWRPBackgroundRenderer() : new ARFoundationBackgroundRenderer();
}
public override void CreateHelperComponents(GameObject cameraGameObject)
{
if (useRenderPipeline)
{
var lwrpBeforeCameraRender = cameraGameObject.GetComponent<LWRPBeforeCameraRender>();
if (lwrpBeforeCameraRender == null)
{
cameraGameObject.AddComponent<LWRPBeforeCameraRender>();
}
var lightweightAdditionalCameraData = cameraGameObject.GetComponent<LightweightAdditionalCameraData>();
if (lightweightAdditionalCameraData == null)
{
lightweightAdditionalCameraData = cameraGameObject.AddComponent<LightweightAdditionalCameraData>();
}
lightweightAdditionalCameraData.renderShadows = false;
lightweightAdditionalCameraData.requiresColorTexture = false;
lightweightAdditionalCameraData.requiresDepthTexture = false;
}
}
public override Material CreateCustomMaterial()
{
var cameraSubsystem = ARSubsystemManager.cameraSubsystem;
if (cameraSubsystem == null)
return null;
// Try to create a material from the plugin's provided shader.
var shaderName = "";
if (!cameraSubsystem.TryGetShaderName(ref shaderName))
return null;
shaderName = shaderName + "LWRP";
var shader = Shader.Find(shaderName);
if (shader == null)
{
throw new InvalidOperationException(string.Format(
"Could not find shader named \"{0}\" required for LWRP video overlay on camera subsystem named \"{1}\".",
shaderName,
cameraSubsystem.SubsystemDescriptor.id));
}
return new Material(shader);
}
}
}

/Assets/LWRPSupport/LWRPBackroundRendererAsset.cs.meta → /Assets/LWRPSupport/LWRPBackgroundRendererAsset.cs.meta

正在加载...
取消
保存