浏览代码

allow arfoundation-samples to support LWRP, with a little help from ARFoundation. we could take the changes in the LWRPSupport folder and make them into a separate package (they already have their own assembly). The main idea is when you upgrade to LWRP (by setting up a LWRP settings asset in the graphics settings), you will at the same time, create a LWRPBackgroundRendererAsset, add the two materials in the folder to it, and set it as Custom Renderer Asset on your CameraBackground component on ARCamera.

/1.5-preview
Jimmy Alamparambil 6 年前
当前提交
2c980b8d
共有 24 个文件被更改,包括 718 次插入56 次删除
  1. 128
      Assets/Scenes/SampleScene.unity
  2. 7
      ProjectSettings/GraphicsSettings.asset
  3. 8
      Assets/LWRPSupport.meta
  4. 29
      Assets/Prefabs/LightweightRP.asset
  5. 8
      Assets/Prefabs/LightweightRP.asset.meta
  6. 56
      Assets/LWRPSupport/ARCoreBackgroundLWRP.shader
  7. 9
      Assets/LWRPSupport/ARCoreBackgroundLWRP.shader.meta
  8. 87
      Assets/LWRPSupport/ARCoreBackgroundLWRPMaterial.mat
  9. 8
      Assets/LWRPSupport/ARCoreBackgroundLWRPMaterial.mat.meta
  10. 95
      Assets/LWRPSupport/ARKitLWRPMaterial.mat
  11. 8
      Assets/LWRPSupport/ARKitLWRPMaterial.mat.meta
  12. 77
      Assets/LWRPSupport/ARKitLWRPShader.shader
  13. 9
      Assets/LWRPSupport/ARKitLWRPShader.shader.meta
  14. 56
      Assets/LWRPSupport/LWRPBackgroundRenderer.cs
  15. 11
      Assets/LWRPSupport/LWRPBackgroundRenderer.cs.meta
  16. 17
      Assets/LWRPSupport/LWRPBackroundRendererAsset.asset
  17. 8
      Assets/LWRPSupport/LWRPBackroundRendererAsset.asset.meta
  18. 73
      Assets/LWRPSupport/LWRPBackroundRendererAsset.cs
  19. 11
      Assets/LWRPSupport/LWRPBackroundRendererAsset.cs.meta
  20. 35
      Assets/LWRPSupport/LWRPBeforeCameraRender.cs
  21. 11
      Assets/LWRPSupport/LWRPBeforeCameraRender.cs.meta
  22. 16
      Assets/LWRPSupport/Unity.XR.ARFoundation.LWRPSupport.asmdef
  23. 7
      Assets/LWRPSupport/Unity.XR.ARFoundation.LWRPSupport.asmdef.meta

128
Assets/Scenes/SampleScene.unity


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

--- !u!1 &282840810
GameObject:
m_ObjectHideFlags: 0
m_PrefabParentObject: {fileID: 0}
m_PrefabInternal: {fileID: 0}
serializedVersion: 5
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
serializedVersion: 6
m_Component:
- component: {fileID: 282840814}
- component: {fileID: 282840813}

--- !u!81 &282840811
AudioListener:
m_ObjectHideFlags: 0
m_PrefabParentObject: {fileID: 0}
m_PrefabInternal: {fileID: 0}
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_PrefabParentObject: {fileID: 0}
m_PrefabInternal: {fileID: 0}
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 282840810}
m_Enabled: 1
m_EditorHideFlags: 0

m_OverrideMaterial: 0
m_Material: {fileID: 0}
m_UseCustomMaterial: 0
m_CustomMaterial: {fileID: 2100000, guid: e77eba92b3f8949a8ba25b8d98a8f694, type: 2}
m_UseCustomRendererAsset: 1
m_CustomRendererAsset: {fileID: 11400000, guid: 2310b94e2d8f5463ab592fa99eefbe6f, type: 2}
m_PrefabParentObject: {fileID: 0}
m_PrefabInternal: {fileID: 0}
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_ClearFlags: 2
m_BackGroundColor: {r: 0, g: 0, b: 0, a: 1}
m_ClearFlags: 3
m_BackGroundColor: {r: 0.17021184, g: 0.8018868, b: 0.7888453, a: 1}
m_projectionMatrixMode: 1
m_SensorSize: {x: 36, y: 24}
m_LensShift: {x: 0, y: 0}
m_GateFitMode: 2
m_FocalLength: 50
m_NormalizedViewPortRect:
serializedVersion: 2
x: 0

m_TargetTexture: {fileID: 0}
m_TargetDisplay: 0
m_TargetEye: 3
m_HDR: 1
m_HDR: 0
m_AllowMSAA: 1
m_AllowDynamicResolution: 0
m_ForceIntoRT: 0

--- !u!4 &282840814
Transform:
m_ObjectHideFlags: 0
m_PrefabParentObject: {fileID: 0}
m_PrefabInternal: {fileID: 0}
m_CorrespondingSourceObject: {fileID: 0}
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}

--- !u!114 &282840815
MonoBehaviour:
m_ObjectHideFlags: 0
m_PrefabParentObject: {fileID: 0}
m_PrefabInternal: {fileID: 0}
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 282840810}
m_Enabled: 1
m_EditorHideFlags: 0

m_Device: 0
m_PoseSource: 6
m_PoseProviderComponent: {fileID: 0}
m_TrackingType: 0
m_UpdateType: 0
m_UseRelativeTransform: 1

m_PrefabParentObject: {fileID: 0}
m_PrefabInternal: {fileID: 0}
serializedVersion: 5
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
serializedVersion: 6
m_Component:
- component: {fileID: 427002220}
- component: {fileID: 427002219}

--- !u!114 &427002219
MonoBehaviour:
m_ObjectHideFlags: 0
m_PrefabParentObject: {fileID: 0}
m_PrefabInternal: {fileID: 0}
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 427002218}
m_Enabled: 1
m_EditorHideFlags: 0

--- !u!4 &427002220
Transform:
m_ObjectHideFlags: 0
m_PrefabParentObject: {fileID: 0}
m_PrefabInternal: {fileID: 0}
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 427002218}
m_LocalRotation: {x: 0, y: 0, z: 0, w: 1}
m_LocalPosition: {x: 0, y: 0, z: 0}

--- !u!1 &1015722065
GameObject:
m_ObjectHideFlags: 0
m_PrefabParentObject: {fileID: 0}
m_PrefabInternal: {fileID: 0}
serializedVersion: 5
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
serializedVersion: 6
m_Component:
- component: {fileID: 1015722067}
- component: {fileID: 1015722066}

--- !u!108 &1015722066
Light:
m_ObjectHideFlags: 0
m_PrefabParentObject: {fileID: 0}
m_PrefabInternal: {fileID: 0}
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 1015722065}
m_Enabled: 1
serializedVersion: 8

serializedVersion: 2
m_Bits: 4294967295
m_Lightmapping: 4
m_LightShadowCasterMode: 0
m_AreaSize: {x: 1, y: 1}
m_BounceIntensity: 1
m_ColorTemperature: 6570

--- !u!4 &1015722067
Transform:
m_ObjectHideFlags: 0
m_PrefabParentObject: {fileID: 0}
m_PrefabInternal: {fileID: 0}
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 1015722065}
m_LocalRotation: {x: 0.40821788, y: -0.23456968, z: 0.10938163, w: 0.8754261}
m_LocalPosition: {x: 0, y: 3, z: 0}

--- !u!1 &1335839533
GameObject:
m_ObjectHideFlags: 0
m_PrefabParentObject: {fileID: 0}
m_PrefabInternal: {fileID: 0}
serializedVersion: 5
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
serializedVersion: 6
m_Component:
- component: {fileID: 1335839535}
- component: {fileID: 1335839534}

--- !u!114 &1335839534
MonoBehaviour:
m_ObjectHideFlags: 0
m_PrefabParentObject: {fileID: 0}
m_PrefabInternal: {fileID: 0}
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 1335839533}
m_Enabled: 1
m_EditorHideFlags: 0

--- !u!4 &1335839535
Transform:
m_ObjectHideFlags: 0
m_PrefabParentObject: {fileID: 0}
m_PrefabInternal: {fileID: 0}
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 1335839533}
m_LocalRotation: {x: 0, y: 0, z: 0, w: 1}
m_LocalPosition: {x: 0, y: 0, z: 0}

--- !u!114 &1335839536
MonoBehaviour:
m_ObjectHideFlags: 0
m_PrefabParentObject: {fileID: 0}
m_PrefabInternal: {fileID: 0}
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 1335839533}
m_Enabled: 1
m_EditorHideFlags: 0

m_PointCloudPrefab: {fileID: 1854016325464908, guid: 0d4f49e744bffd14eb527ba76c9bba12,
type: 2}
m_PointCloudPrefab: {fileID: 1854016325464908, guid: 0d4f49e744bffd14eb527ba76c9bba12, type: 2}
m_PrefabParentObject: {fileID: 0}
m_PrefabInternal: {fileID: 0}
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 1335839533}
m_Enabled: 1
m_EditorHideFlags: 0

m_PlanePrefab: {fileID: 1568414836858200, guid: f0e0be81472ff1243aa2afa27e5d0e61,
type: 2}
m_PlanePrefab: {fileID: 1568414836858200, guid: f0e0be81472ff1243aa2afa27e5d0e61, type: 2}
m_PrefabParentObject: {fileID: 0}
m_PrefabInternal: {fileID: 0}
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 1335839533}
m_Enabled: 1
m_EditorHideFlags: 0

m_PlacedPrefab: {fileID: 1934569588295450, guid: b34b6c8f1206a6844b983e23b9da0441,
type: 2}
m_PlacedPrefab: {fileID: 1934569588295450, guid: b34b6c8f1206a6844b983e23b9da0441, type: 2}

7
ProjectSettings/GraphicsSettings.asset


- {fileID: 16000, guid: 0000000000000000f000000000000000, type: 0}
- {fileID: 16002, guid: 0000000000000000f000000000000000, type: 0}
m_PreloadedShaders: []
m_SpritesDefaultMaterial: {fileID: 10754, guid: 0000000000000000f000000000000000,
type: 0}
m_CustomRenderPipeline: {fileID: 0}
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_FogKeepExp: 1
m_FogKeepExp2: 1
m_AlbedoSwatchInfos: []
m_LightsUseLinearIntensity: 0
m_LightsUseLinearIntensity: 1
m_LightsUseColorTemperature: 0

8
Assets/LWRPSupport.meta


fileFormatVersion: 2
guid: 276a124b17bce4dfb829de86ace2732f
folderAsset: yes
DefaultImporter:
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant:

29
Assets/Prefabs/LightweightRP.asset


%YAML 1.1
%TAG !u! tag:unity3d.com,2011:
--- !u!114 &11400000
MonoBehaviour:
m_ObjectHideFlags: 0
m_PrefabParentObject: {fileID: 0}
m_PrefabInternal: {fileID: 0}
m_GameObject: {fileID: 0}
m_Enabled: 1
m_EditorHideFlags: 0
m_Script: {fileID: 11500000, guid: bf2edee5c58d82540a51f03df9d42094, type: 3}
m_Name: LightweightRP
m_EditorClassIdentifier:
kAssetVersion: 2
m_MaxPixelLights: 4
m_SupportsVertexLight: 0
m_RequireDepthTexture: 0
m_RequireSoftParticles: 0
m_SupportsHDR: 0
m_MSAA: 4
m_RenderScale: 1
m_ShadowType: 1
m_ShadowAtlasResolution: 2048
m_ShadowNearPlaneOffset: 2
m_ShadowDistance: 50
m_ShadowCascades: 2
m_Cascade2Split: 0.25
m_Cascade4Split: {x: 0.067, y: 0.2, z: 0.467}
m_ResourcesAsset: {fileID: 11400000, guid: aac5a08c32552a14c89394b703f1978a, type: 2}

8
Assets/Prefabs/LightweightRP.asset.meta


fileFormatVersion: 2
guid: b01a4952003554c0191ed57356e5830a
NativeFormatImporter:
externalObjects: {}
mainObjectFileID: 11400000
userData:
assetBundleName:
assetBundleVariant:

56
Assets/LWRPSupport/ARCoreBackgroundLWRP.shader


Shader "Unlit/ARCoreBackgroundLWRP"
{
Properties
{
_MainTex("Texture", 2D) = "white" {}
}
// For GLES3
SubShader
{
Pass
{
ZWrite Off
GLSLPROGRAM
#pragma only_renderers gles3
#ifdef SHADER_API_GLES3
#extension GL_OES_EGL_image_external_essl3 : require
#endif
uniform mat4 _UnityDisplayTransform;
#ifdef VERTEX
varying vec2 textureCoord;
void main()
{
#ifdef SHADER_API_GLES3
float flippedV = 1.0 - gl_MultiTexCoord0.y;
textureCoord.x = _UnityDisplayTransform[0].x * gl_MultiTexCoord0.x + _UnityDisplayTransform[1].x * flippedV + _UnityDisplayTransform[2].x;
textureCoord.y = _UnityDisplayTransform[0].y * gl_MultiTexCoord0.x + _UnityDisplayTransform[1].y * flippedV + _UnityDisplayTransform[2].y;
gl_Position = gl_ModelViewProjectionMatrix * gl_Vertex;
#endif
}
#endif
#ifdef FRAGMENT
varying vec2 textureCoord;
uniform samplerExternalOES _MainTex;
void main()
{
#ifdef SHADER_API_GLES3
gl_FragColor = texture(_MainTex, textureCoord);
#endif
}
#endif
ENDGLSL
}
}
FallBack Off
}

9
Assets/LWRPSupport/ARCoreBackgroundLWRP.shader.meta


fileFormatVersion: 2
guid: f5b5c0be693bb45f9b7b9f28210c1c87
ShaderImporter:
externalObjects: {}
defaultTextures: []
nonModifiableTextures: []
userData:
assetBundleName:
assetBundleVariant:

87
Assets/LWRPSupport/ARCoreBackgroundLWRPMaterial.mat


%YAML 1.1
%TAG !u! tag:unity3d.com,2011:
--- !u!21 &2100000
Material:
serializedVersion: 6
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_Name: ARCoreBackgroundLWRPMaterial
m_Shader: {fileID: 4800000, guid: f5b5c0be693bb45f9b7b9f28210c1c87, type: 3}
m_ShaderKeywords:
m_LightmapFlags: 4
m_EnableInstancingVariants: 0
m_DoubleSidedGI: 0
m_CustomRenderQueue: -1
stringTagMap: {}
disabledShaderPasses: []
m_SavedProperties:
serializedVersion: 3
m_TexEnvs:
- _BumpMap:
m_Texture: {fileID: 0}
m_Scale: {x: 1, y: 1}
m_Offset: {x: 0, y: 0}
- _DetailAlbedoMap:
m_Texture: {fileID: 0}
m_Scale: {x: 1, y: 1}
m_Offset: {x: 0, y: 0}
- _DetailMask:
m_Texture: {fileID: 0}
m_Scale: {x: 1, y: 1}
m_Offset: {x: 0, y: 0}
- _DetailNormalMap:
m_Texture: {fileID: 0}
m_Scale: {x: 1, y: 1}
m_Offset: {x: 0, y: 0}
- _EmissionMap:
m_Texture: {fileID: 0}
m_Scale: {x: 1, y: 1}
m_Offset: {x: 0, y: 0}
- _MainTex:
m_Texture: {fileID: 0}
m_Scale: {x: 1, y: 1}
m_Offset: {x: 0, y: 0}
- _MetallicGlossMap:
m_Texture: {fileID: 0}
m_Scale: {x: 1, y: 1}
m_Offset: {x: 0, y: 0}
- _OcclusionMap:
m_Texture: {fileID: 0}
m_Scale: {x: 1, y: 1}
m_Offset: {x: 0, y: 0}
- _ParallaxMap:
m_Texture: {fileID: 0}
m_Scale: {x: 1, y: 1}
m_Offset: {x: 0, y: 0}
- _SpecGlossMap:
m_Texture: {fileID: 0}
m_Scale: {x: 1, y: 1}
m_Offset: {x: 0, y: 0}
m_Floats:
- _AlphaClip: 0
- _Blend: 0
- _BumpScale: 1
- _Cull: 2
- _Cutoff: 0.5
- _DetailNormalMapScale: 1
- _DstBlend: 0
- _GlossMapScale: 1
- _Glossiness: 0.5
- _GlossyReflections: 1
- _Metallic: 0
- _OcclusionStrength: 1
- _Parallax: 0.02
- _ReceiveShadows: 1
- _SmoothnessTextureChannel: 0
- _SpecularHighlights: 1
- _SrcBlend: 1
- _Surface: 0
- _UVSec: 0
- _WorkflowMode: 1
- _ZWrite: 1
m_Colors:
- _Color: {r: 0.5, g: 0.5, b: 0.5, a: 1}
- _EmissionColor: {r: 0, g: 0, b: 0, a: 1}
- _SpecColor: {r: 0.2, g: 0.2, b: 0.2, a: 1}

8
Assets/LWRPSupport/ARCoreBackgroundLWRPMaterial.mat.meta


fileFormatVersion: 2
guid: 5bd0883a437ba4ed8a4572cda9d2e23d
NativeFormatImporter:
externalObjects: {}
mainObjectFileID: 2100000
userData:
assetBundleName:
assetBundleVariant:

95
Assets/LWRPSupport/ARKitLWRPMaterial.mat


%YAML 1.1
%TAG !u! tag:unity3d.com,2011:
--- !u!21 &2100000
Material:
serializedVersion: 6
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_Name: ARKitLWRPMaterial
m_Shader: {fileID: 4800000, guid: 5c791e8fa990e481990e754655cd123d, type: 3}
m_ShaderKeywords:
m_LightmapFlags: 4
m_EnableInstancingVariants: 0
m_DoubleSidedGI: 0
m_CustomRenderQueue: -1
stringTagMap: {}
disabledShaderPasses: []
m_SavedProperties:
serializedVersion: 3
m_TexEnvs:
- _BumpMap:
m_Texture: {fileID: 0}
m_Scale: {x: 1, y: 1}
m_Offset: {x: 0, y: 0}
- _DetailAlbedoMap:
m_Texture: {fileID: 0}
m_Scale: {x: 1, y: 1}
m_Offset: {x: 0, y: 0}
- _DetailMask:
m_Texture: {fileID: 0}
m_Scale: {x: 1, y: 1}
m_Offset: {x: 0, y: 0}
- _DetailNormalMap:
m_Texture: {fileID: 0}
m_Scale: {x: 1, y: 1}
m_Offset: {x: 0, y: 0}
- _EmissionMap:
m_Texture: {fileID: 0}
m_Scale: {x: 1, y: 1}
m_Offset: {x: 0, y: 0}
- _MainTex:
m_Texture: {fileID: 0}
m_Scale: {x: 1, y: 1}
m_Offset: {x: 0, y: 0}
- _MetallicGlossMap:
m_Texture: {fileID: 0}
m_Scale: {x: 1, y: 1}
m_Offset: {x: 0, y: 0}
- _OcclusionMap:
m_Texture: {fileID: 0}
m_Scale: {x: 1, y: 1}
m_Offset: {x: 0, y: 0}
- _ParallaxMap:
m_Texture: {fileID: 0}
m_Scale: {x: 1, y: 1}
m_Offset: {x: 0, y: 0}
- _SpecGlossMap:
m_Texture: {fileID: 0}
m_Scale: {x: 1, y: 1}
m_Offset: {x: 0, y: 0}
- _textureCbCr:
m_Texture: {fileID: 0}
m_Scale: {x: 1, y: 1}
m_Offset: {x: 0, y: 0}
- _textureY:
m_Texture: {fileID: 0}
m_Scale: {x: 1, y: 1}
m_Offset: {x: 0, y: 0}
m_Floats:
- _AlphaClip: 0
- _Blend: 0
- _BumpScale: 1
- _Cull: 2
- _Cutoff: 0.5
- _DetailNormalMapScale: 1
- _DstBlend: 0
- _GlossMapScale: 1
- _Glossiness: 0.5
- _GlossyReflections: 1
- _Metallic: 0
- _OcclusionStrength: 1
- _Parallax: 0.02
- _ReceiveShadows: 1
- _SmoothnessTextureChannel: 0
- _SpecularHighlights: 1
- _SrcBlend: 1
- _Surface: 0
- _UVSec: 0
- _WorkflowMode: 1
- _ZWrite: 1
m_Colors:
- _Color: {r: 0.5, g: 0.5, b: 0.5, a: 1}
- _EmissionColor: {r: 0, g: 0, b: 0, a: 1}
- _SpecColor: {r: 0.2, g: 0.2, b: 0.2, a: 1}

8
Assets/LWRPSupport/ARKitLWRPMaterial.mat.meta


fileFormatVersion: 2
guid: 91c809f5df4d84941a85f4cd21a290f7
NativeFormatImporter:
externalObjects: {}
mainObjectFileID: 2100000
userData:
assetBundleName:
assetBundleVariant:

77
Assets/LWRPSupport/ARKitLWRPShader.shader


Shader "Unlit/ARKitLWRP"
{
Properties
{
_textureY ("TextureY", 2D) = "white" {}
_textureCbCr ("TextureCbCr", 2D) = "black" {}
}
SubShader
{
Tags { "RenderType" = "Opaque" "RenderPipeline" = "LightweightPipeline"}
LOD 100
Pass
{
Name "Default"
Tags { "LightMode" = "LightweightForward"}
ZTest Always ZWrite Off
HLSLPROGRAM
// Required to compile gles 2.0 with standard srp library
#pragma prefer_hlslcc gles
#pragma exclude_renderers d3d11_9x
#pragma vertex Vertex
#pragma fragment Fragment
#include "LWRP/ShaderLibrary/Core.hlsl"
float4x4 _UnityDisplayTransform;
struct VertexInput
{
float4 vertex : POSITION;
float2 uv : TEXCOORD0;
};
struct VertexOutput
{
half4 pos : SV_POSITION;
half2 uv : TEXCOORD0;
};
TEXTURE2D(_textureY);
SAMPLER(sampler_textureY);
TEXTURE2D(_textureCbCr);
SAMPLER(sampler_textureCbCr);
VertexOutput Vertex(VertexInput i)
{
VertexOutput o;
o.pos = TransformObjectToHClip(i.vertex.xyz);
o.uv.x = (_UnityDisplayTransform[0].x * i.uv.x + _UnityDisplayTransform[1].x * (i.uv.y) + _UnityDisplayTransform[2].x);
o.uv.y = (_UnityDisplayTransform[0].y * i.uv.x + _UnityDisplayTransform[1].y * (i.uv.y) + _UnityDisplayTransform[2].y);
return o;
}
half4 Fragment(VertexOutput i) : SV_Target
{
half y = SAMPLE_TEXTURE2D(_textureY, sampler_textureY, i.uv).r;
half4 ycbcr = half4(y, SAMPLE_TEXTURE2D(_textureCbCr, sampler_textureCbCr, i.uv).rg, 1.0);
const half4x4 ycbcrToRGBTransform = half4x4(
half4(1.0, +0.0000, +1.4020, -0.7010),
half4(1.0, -0.3441, -0.7141, +0.5291),
half4(1.0, +1.7720, +0.0000, -0.8860),
half4(0.0, +0.0000, +0.0000, +1.0000)
);
return mul(ycbcrToRGBTransform, ycbcr);
}
ENDHLSL
}
}
}

9
Assets/LWRPSupport/ARKitLWRPShader.shader.meta


fileFormatVersion: 2
guid: 5c791e8fa990e481990e754655cd123d
ShaderImporter:
externalObjects: {}
defaultTextures: []
nonModifiableTextures: []
userData:
assetBundleName:
assetBundleVariant:

56
Assets/LWRPSupport/LWRPBackgroundRenderer.cs



namespace UnityEngine.XR.ARFoundation.LWRPSupport
{
public class LWRPBackgroundRenderer : ARFoundationBackgroundRenderer
{
CameraClearFlags _savedClearFlags;
LWRPBeforeCameraRender _lwrpBeforeCameraRender;
protected override bool EnableARBackgroundRendering()
{
if (m_BackgroundMaterial == null)
return false;
camera = m_Camera ? m_Camera : Camera.main;
if (camera == null)
return false;
// Clear flags
_savedClearFlags = camera.clearFlags;
camera.clearFlags = CameraClearFlags.Depth;
if (_lwrpBeforeCameraRender == null)
{
_lwrpBeforeCameraRender = camera.gameObject.GetComponent<LWRPBeforeCameraRender>();
}
_lwrpBeforeCameraRender.SetupBlitMaterial(m_BackgroundMaterial);
return true;
}
protected override void DisableARBackgroundRendering()
{
if (m_BackgroundMaterial == null)
return;
camera = m_Camera ? m_Camera : Camera.main;
if (camera == null)
return;
camera.clearFlags = _savedClearFlags;
if (_lwrpBeforeCameraRender != null)
{
_lwrpBeforeCameraRender.SetupBlitMaterial(null);
_lwrpBeforeCameraRender = null;
}
}
}
}

11
Assets/LWRPSupport/LWRPBackgroundRenderer.cs.meta


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

17
Assets/LWRPSupport/LWRPBackroundRendererAsset.asset


%YAML 1.1
%TAG !u! tag:unity3d.com,2011:
--- !u!114 &11400000
MonoBehaviour:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 0}
m_Enabled: 1
m_EditorHideFlags: 0
m_Script: {fileID: 11500000, guid: 3974c4b6d5b67422c935da45b02d23f2, type: 3}
m_Name: LWRPBackroundRendererAsset
m_EditorClassIdentifier:
MaterialsUsed:
- {fileID: 2100000, guid: 91c809f5df4d84941a85f4cd21a290f7, type: 2}
- {fileID: 2100000, guid: 5bd0883a437ba4ed8a4572cda9d2e23d, type: 2}

8
Assets/LWRPSupport/LWRPBackroundRendererAsset.asset.meta


fileFormatVersion: 2
guid: 2310b94e2d8f5463ab592fa99eefbe6f
NativeFormatImporter:
externalObjects: {}
mainObjectFileID: 11400000
userData:
assetBundleName:
assetBundleVariant:

73
Assets/LWRPSupport/LWRPBackroundRendererAsset.cs



using System;
using UnityEngine.Experimental.Rendering.LightweightPipeline;
using UnityEngine.Rendering;
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>
public Material[] MaterialsUsed;
public override ARFoundationBackgroundRenderer CreateARBackgroundRenderer()
{
var bUseRenderPipeline = GraphicsSettings.renderPipelineAsset != null;
return bUseRenderPipeline ? new LWRPBackgroundRenderer() : new ARFoundationBackgroundRenderer();
}
public override void CreateHelperComponents(GameObject cameraGameObject)
{
var bUseRenderPipeline = GraphicsSettings.renderPipelineAsset != null;
if (bUseRenderPipeline)
{
var lbcr = cameraGameObject.GetComponent<LWRPBeforeCameraRender>();
if (lbcr == null)
{
cameraGameObject.AddComponent<LWRPBeforeCameraRender>();
}
var lacd = cameraGameObject.GetComponent<LightweightAdditionalCameraData>();
if (lacd == null)
{
lacd = cameraGameObject.AddComponent<LightweightAdditionalCameraData>();
}
lacd.renderShadows = false;
lacd.requiresColorTexture = false;
lacd.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.
string 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);
}
}
}

11
Assets/LWRPSupport/LWRPBackroundRendererAsset.cs.meta


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

35
Assets/LWRPSupport/LWRPBeforeCameraRender.cs



using UnityEngine.Experimental.Rendering;
using UnityEngine.Rendering;
using UnityEngine.Experimental.Rendering.LightweightPipeline;
namespace UnityEngine.XR.ARFoundation
{
public class LWRPBeforeCameraRender : MonoBehaviour, LightweightPipeline.IBeforeCameraRender
{
const string k_ARBlitTag = "ARBackground Blit Pass";
Material BlitMaterial { get; set; }
public void SetupBlitMaterial(Material material)
{
this.BlitMaterial = material;
}
public void ExecuteBeforeCameraRender(ScriptableRenderContext context, Camera camera, LightweightPipeline.PipelineSettings pipelineSettings,
ScriptableRenderer renderer)
{
if (BlitMaterial == null) return;
CommandBuffer cmd = CommandBufferPool.Get(k_ARBlitTag);
cmd.Blit(null, BuiltinRenderTextureType.CameraTarget, BlitMaterial);
context.ExecuteCommandBuffer(cmd);
CommandBufferPool.Release(cmd);
}
}
}

11
Assets/LWRPSupport/LWRPBeforeCameraRender.cs.meta


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

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


{
"name": "Unity.XR.ARFoundation.LWRPSupport",
"references": [
"Unity.XR.ARFoundation",
"Unity.RenderPipelines.Lightweight.Runtime",
"Unity.RenderPipelines.Core.Runtime"
],
"optionalUnityReferences": [],
"includePlatforms": [],
"excludePlatforms": [],
"allowUnsafeCode": false,
"overrideReferences": false,
"precompiledReferences": [],
"autoReferenced": true,
"defineConstraints": []
}

7
Assets/LWRPSupport/Unity.XR.ARFoundation.LWRPSupport.asmdef.meta


fileFormatVersion: 2
guid: 2a16b207c1243468a9f3d32431fa21b2
AssemblyDefinitionImporter:
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant:
正在加载...
取消
保存