diff --git a/Assets/RUPRenderer_Outline.asset b/Assets/RUPRenderer_Outline.asset new file mode 100644 index 00000000..b3e9a48d --- /dev/null +++ b/Assets/RUPRenderer_Outline.asset @@ -0,0 +1,74 @@ +%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: de640fe3d0db1804a85f9fc8f5cadab6, type: 3} + m_Name: RUPRenderer_Outline + m_EditorClassIdentifier: + m_RendererFeatures: + - {fileID: 4571534152605731102} + - {fileID: 2138636722869391233} + m_RendererFeatureMap: 1e89a13c175a713f814f3cbac4f6ad1d + postProcessData: {fileID: 11400000, guid: 41439944d30ece34e96484bdb6645b55, type: 2} + xrSystemData: {fileID: 11400000, guid: 60e1133243b97e347b653163a8c01b64, type: 2} + shaders: + blitPS: {fileID: 4800000, guid: c17132b1f77d20942aa75f8429c0f8bc, type: 3} + copyDepthPS: {fileID: 4800000, guid: d6dae50ee9e1bfa4db75f19f99355220, type: 3} + screenSpaceShadowPS: {fileID: 4800000, guid: 0f854b35a0cf61a429bd5dcfea30eddd, type: 3} + samplingPS: {fileID: 4800000, guid: 04c410c9937594faa893a11dceb85f7e, type: 3} + tileDepthInfoPS: {fileID: 0} + tileDeferredPS: {fileID: 0} + stencilDeferredPS: {fileID: 4800000, guid: e9155b26e1bc55942a41e518703fe304, type: 3} + fallbackErrorPS: {fileID: 4800000, guid: e6e9a19c3678ded42a3bc431ebef7dbd, type: 3} + materialErrorPS: {fileID: 4800000, guid: 5fd9a8feb75a4b5894c241777f519d4e, type: 3} + m_OpaqueLayerMask: + serializedVersion: 2 + m_Bits: 4294967295 + m_TransparentLayerMask: + serializedVersion: 2 + m_Bits: 4294967295 + m_DefaultStencilState: + overrideStencilState: 0 + stencilReference: 0 + stencilCompareFunction: 8 + passOperation: 2 + failOperation: 0 + zFailOperation: 0 + m_ShadowTransparentReceive: 1 + m_RenderingMode: 0 + m_AccurateGbufferNormals: 0 +--- !u!114 &2138636722869391233 +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: 5c478a49859fb4241aeef0317db339fe, type: 3} + m_Name: NewOutlineFeature + m_EditorClassIdentifier: + m_Active: 1 + settings: + outlineMaterial: {fileID: 2100000, guid: 04ce7361143e03e4ca1b8b55fb35d03c, type: 2} +--- !u!114 &4571534152605731102 +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: 3c0c301f9e8bcb74583ece56b872b224, type: 3} + m_Name: NewDepthNormalsFeature + m_EditorClassIdentifier: + m_Active: 1 diff --git a/Assets/RUPRenderer_Outline.asset.meta b/Assets/RUPRenderer_Outline.asset.meta new file mode 100644 index 00000000..66449366 --- /dev/null +++ b/Assets/RUPRenderer_Outline.asset.meta @@ -0,0 +1,8 @@ +fileFormatVersion: 2 +guid: bac777ead124be147b4d66a611b22ab9 +NativeFormatImporter: + externalObjects: {} + mainObjectFileID: 11400000 + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/Resources/Games/builtToScaleDS.prefab b/Assets/Resources/Games/builtToScaleDS.prefab index 0ac33727..0899a629 100644 --- a/Assets/Resources/Games/builtToScaleDS.prefab +++ b/Assets/Resources/Games/builtToScaleDS.prefab @@ -222,7 +222,7 @@ Transform: m_PrefabAsset: {fileID: 0} m_GameObject: {fileID: 4052947733920485538} m_LocalRotation: {x: 0.077828385, y: -0.9212198, z: 0.29045945, w: 0.24684015} - m_LocalPosition: {x: 3.35, y: 5.35, z: 6.75} + m_LocalPosition: {x: 3.35, y: 5.205, z: 6.75} m_LocalScale: {x: 1, y: 1, z: 1} m_Children: [] m_Father: {fileID: 4631944531018638297} @@ -253,8 +253,8 @@ Camera: height: 1 near clip plane: 0.3 far clip plane: 1000 - field of view: 49 - orthographic: 1 + field of view: 13 + orthographic: 0 orthographic size: 1 m_Depth: 0 m_CullingMask: @@ -288,7 +288,7 @@ MonoBehaviour: m_RequiresOpaqueTextureOption: 2 m_CameraType: 0 m_Cameras: [] - m_RendererIndex: -1 + m_RendererIndex: 1 m_VolumeLayerMask: serializedVersion: 2 m_Bits: 1 @@ -822,23 +822,23 @@ PrefabInstance: - target: {fileID: 6244928046365892280, guid: 26c46c4ecd6e69145a6e971ac2cf6dcf, type: 3} propertyPath: m_Materials.Array.data[0] value: - objectReference: {fileID: 2100000, guid: 8ed30616db50b7e4a8e9022ca6085652, type: 2} + objectReference: {fileID: 2100000, guid: 05418807da86e2146bc9e10ad24a33aa, type: 2} - target: {fileID: 6244928046365892280, guid: 26c46c4ecd6e69145a6e971ac2cf6dcf, type: 3} propertyPath: m_Materials.Array.data[1] value: - objectReference: {fileID: 2100000, guid: 8ed30616db50b7e4a8e9022ca6085652, type: 2} + objectReference: {fileID: 2100000, guid: 05418807da86e2146bc9e10ad24a33aa, type: 2} - target: {fileID: 6244928046365892280, guid: 26c46c4ecd6e69145a6e971ac2cf6dcf, type: 3} propertyPath: m_Materials.Array.data[2] value: - objectReference: {fileID: 2100000, guid: 8ed30616db50b7e4a8e9022ca6085652, type: 2} + objectReference: {fileID: 2100000, guid: 05418807da86e2146bc9e10ad24a33aa, type: 2} - target: {fileID: 6244928046365892280, guid: 26c46c4ecd6e69145a6e971ac2cf6dcf, type: 3} propertyPath: m_Materials.Array.data[3] value: - objectReference: {fileID: 2100000, guid: 8ed30616db50b7e4a8e9022ca6085652, type: 2} + objectReference: {fileID: 2100000, guid: 05418807da86e2146bc9e10ad24a33aa, type: 2} - target: {fileID: 6244928046365892280, guid: 26c46c4ecd6e69145a6e971ac2cf6dcf, type: 3} propertyPath: m_Materials.Array.data[4] value: - objectReference: {fileID: 2100000, guid: 8ed30616db50b7e4a8e9022ca6085652, type: 2} + objectReference: {fileID: 2100000, guid: 05418807da86e2146bc9e10ad24a33aa, type: 2} - target: {fileID: 6261893698081059527, guid: 26c46c4ecd6e69145a6e971ac2cf6dcf, type: 3} propertyPath: m_Layer value: 10 @@ -984,7 +984,7 @@ PrefabInstance: - target: {fileID: 1457549886834139525, guid: 4d6a1ca519b6789419c00178b5d2b983, type: 3} propertyPath: m_Materials.Array.data[0] value: - objectReference: {fileID: 2100000, guid: 8ed30616db50b7e4a8e9022ca6085652, type: 2} + objectReference: {fileID: 2100000, guid: 05418807da86e2146bc9e10ad24a33aa, type: 2} - target: {fileID: 1457549886834139525, guid: 4d6a1ca519b6789419c00178b5d2b983, type: 3} propertyPath: m_Materials.Array.data[1] value: @@ -992,11 +992,11 @@ PrefabInstance: - target: {fileID: 1457549886834139525, guid: 4d6a1ca519b6789419c00178b5d2b983, type: 3} propertyPath: m_Materials.Array.data[2] value: - objectReference: {fileID: 2100000, guid: 8ed30616db50b7e4a8e9022ca6085652, type: 2} + objectReference: {fileID: 2100000, guid: 05418807da86e2146bc9e10ad24a33aa, type: 2} - target: {fileID: 1457549886834139525, guid: 4d6a1ca519b6789419c00178b5d2b983, type: 3} propertyPath: m_Materials.Array.data[3] value: - objectReference: {fileID: 2100000, guid: 8ed30616db50b7e4a8e9022ca6085652, type: 2} + objectReference: {fileID: 2100000, guid: 05418807da86e2146bc9e10ad24a33aa, type: 2} - target: {fileID: 1457549886834139525, guid: 4d6a1ca519b6789419c00178b5d2b983, type: 3} propertyPath: m_Materials.Array.data[4] value: @@ -1306,19 +1306,19 @@ PrefabInstance: - target: {fileID: 4518858451777631492, guid: e6239db4d6763504fa0e5ad6ce9761b7, type: 3} propertyPath: m_Materials.Array.data[0] value: - objectReference: {fileID: 2100000, guid: 8ed30616db50b7e4a8e9022ca6085652, type: 2} + objectReference: {fileID: 2100000, guid: 05418807da86e2146bc9e10ad24a33aa, type: 2} - target: {fileID: 4518858451777631492, guid: e6239db4d6763504fa0e5ad6ce9761b7, type: 3} propertyPath: m_Materials.Array.data[1] value: - objectReference: {fileID: 2100000, guid: 8ed30616db50b7e4a8e9022ca6085652, type: 2} + objectReference: {fileID: 2100000, guid: 05418807da86e2146bc9e10ad24a33aa, type: 2} - target: {fileID: 4518858451777631492, guid: e6239db4d6763504fa0e5ad6ce9761b7, type: 3} propertyPath: m_Materials.Array.data[2] value: - objectReference: {fileID: 2100000, guid: 8ed30616db50b7e4a8e9022ca6085652, type: 2} + objectReference: {fileID: 2100000, guid: 05418807da86e2146bc9e10ad24a33aa, type: 2} - target: {fileID: 4518858451777631492, guid: e6239db4d6763504fa0e5ad6ce9761b7, type: 3} propertyPath: m_Materials.Array.data[3] value: - objectReference: {fileID: 2100000, guid: 8ed30616db50b7e4a8e9022ca6085652, type: 2} + objectReference: {fileID: 2100000, guid: 05418807da86e2146bc9e10ad24a33aa, type: 2} - target: {fileID: 5833730649146179553, guid: e6239db4d6763504fa0e5ad6ce9761b7, type: 3} propertyPath: m_Layer value: 10 @@ -1602,6 +1602,10 @@ PrefabInstance: propertyPath: m_Layer value: 10 objectReference: {fileID: 0} + - target: {fileID: -7700258416935688289, guid: c9dfe6e539f24b14c8918dba9c6e35eb, type: 3} + propertyPath: m_IsActive + value: 1 + objectReference: {fileID: 0} - target: {fileID: -3487895895819380211, guid: c9dfe6e539f24b14c8918dba9c6e35eb, type: 3} propertyPath: m_Layer value: 10 @@ -1638,6 +1642,10 @@ PrefabInstance: propertyPath: m_Materials.Array.data[0] value: objectReference: {fileID: 2100000, guid: 05418807da86e2146bc9e10ad24a33aa, type: 2} + - target: {fileID: 3065674648482680293, guid: c9dfe6e539f24b14c8918dba9c6e35eb, type: 3} + propertyPath: m_Materials.Array.data[1] + value: + objectReference: {fileID: 2100000, guid: 05418807da86e2146bc9e10ad24a33aa, type: 2} - target: {fileID: 3065674648482680293, guid: c9dfe6e539f24b14c8918dba9c6e35eb, type: 3} propertyPath: m_Materials.Array.data[2] value: @@ -1645,7 +1653,7 @@ PrefabInstance: - target: {fileID: 3065674648482680293, guid: c9dfe6e539f24b14c8918dba9c6e35eb, type: 3} propertyPath: m_Materials.Array.data[3] value: - objectReference: {fileID: 2100000, guid: 8ed30616db50b7e4a8e9022ca6085652, type: 2} + objectReference: {fileID: 2100000, guid: 05418807da86e2146bc9e10ad24a33aa, type: 2} - target: {fileID: 8813323920513627783, guid: c9dfe6e539f24b14c8918dba9c6e35eb, type: 3} propertyPath: m_Layer value: 10 diff --git a/Assets/Resources/Sprites/Games/BuiltToScaleDS/Materials/Rod.mat b/Assets/Resources/Sprites/Games/BuiltToScaleDS/Materials/Object.mat similarity index 94% rename from Assets/Resources/Sprites/Games/BuiltToScaleDS/Materials/Rod.mat rename to Assets/Resources/Sprites/Games/BuiltToScaleDS/Materials/Object.mat index d0ffdf97..b7fb8ced 100644 --- a/Assets/Resources/Sprites/Games/BuiltToScaleDS/Materials/Rod.mat +++ b/Assets/Resources/Sprites/Games/BuiltToScaleDS/Materials/Object.mat @@ -7,14 +7,15 @@ Material: m_CorrespondingSourceObject: {fileID: 0} m_PrefabInstance: {fileID: 0} m_PrefabAsset: {fileID: 0} - m_Name: Rod - m_Shader: {fileID: 4800000, guid: d1e828882cbb32942ab1fcff1c69e1fe, type: 3} + m_Name: Object + m_Shader: {fileID: 4800000, guid: 8d2bb70cbf9db8d4da26e15b26e74248, type: 3} m_ShaderKeywords: m_LightmapFlags: 4 m_EnableInstancingVariants: 0 m_DoubleSidedGI: 0 - m_CustomRenderQueue: -1 - stringTagMap: {} + m_CustomRenderQueue: 2000 + stringTagMap: + RenderType: Opaque disabledShaderPasses: [] m_SavedProperties: serializedVersion: 3 @@ -98,6 +99,7 @@ Material: - _EnvironmentReflections: 1 - _GlossMapScale: 0 - _Glossiness: 0 + - _GlossinessSource: 0 - _GlossyReflections: 0 - _IndirectLightMultiplier: 1 - _IsFace: 0 @@ -116,8 +118,11 @@ Material: - _ReceiveShadowMappingPosOffset: 0 - _ReceiveShadows: 1 - _SampleGI: 0 + - _Shininess: 0 - _Smoothness: 0.5 + - _SmoothnessSource: 0 - _SmoothnessTextureChannel: 0 + - _SpecSource: 0 - _SpecularHighlights: 1 - _SrcBlend: 1 - _Surface: 0 diff --git a/Assets/Resources/Sprites/Games/BuiltToScaleDS/Materials/Rod.mat.meta b/Assets/Resources/Sprites/Games/BuiltToScaleDS/Materials/Object.mat.meta similarity index 100% rename from Assets/Resources/Sprites/Games/BuiltToScaleDS/Materials/Rod.mat.meta rename to Assets/Resources/Sprites/Games/BuiltToScaleDS/Materials/Object.mat.meta diff --git a/Assets/Shaders/Outline.meta b/Assets/Shaders/Outline.meta new file mode 100644 index 00000000..64fe4a10 --- /dev/null +++ b/Assets/Shaders/Outline.meta @@ -0,0 +1,8 @@ +fileFormatVersion: 2 +guid: b44f936e68483464e83e2ee23b5a1867 +folderAsset: yes +DefaultImporter: + externalObjects: {} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/Shaders/Outline/DepthNormalsFeature.cs b/Assets/Shaders/Outline/DepthNormalsFeature.cs new file mode 100644 index 00000000..15434114 --- /dev/null +++ b/Assets/Shaders/Outline/DepthNormalsFeature.cs @@ -0,0 +1,113 @@ +using UnityEngine; +using UnityEngine.Rendering; +using UnityEngine.Rendering.Universal; + +public class DepthNormalsFeature : ScriptableRendererFeature +{ + class DepthNormalsPass : ScriptableRenderPass + { + int kDepthBufferBits = 32; + private RenderTargetHandle depthAttachmentHandle { get; set; } + internal RenderTextureDescriptor descriptor { get; private set; } + + private Material depthNormalsMaterial = null; + private FilteringSettings m_FilteringSettings; + string m_ProfilerTag = "DepthNormals Prepass"; + ShaderTagId m_ShaderTagId = new ShaderTagId("DepthOnly"); + + public DepthNormalsPass(RenderQueueRange renderQueueRange, LayerMask layerMask, Material material) + { + m_FilteringSettings = new FilteringSettings(renderQueueRange, layerMask); + depthNormalsMaterial = material; + } + + public void Setup(RenderTextureDescriptor baseDescriptor, RenderTargetHandle depthAttachmentHandle) + { + this.depthAttachmentHandle = depthAttachmentHandle; + baseDescriptor.colorFormat = RenderTextureFormat.ARGB32; + baseDescriptor.depthBufferBits = kDepthBufferBits; + descriptor = baseDescriptor; + } + + // This method is called before executing the render pass. + // It can be used to configure render targets and their clear state. Also to create temporary render target textures. + // When empty this render pass will render to the active camera render target. + // You should never call CommandBuffer.SetRenderTarget. Instead call ConfigureTarget and ConfigureClear. + // The render pipeline will ensure target setup and clearing happens in an performance manner. + public override void Configure(CommandBuffer cmd, RenderTextureDescriptor cameraTextureDescriptor) + { + cmd.GetTemporaryRT(depthAttachmentHandle.id, descriptor, FilterMode.Point); + ConfigureTarget(depthAttachmentHandle.Identifier()); + ConfigureClear(ClearFlag.All, Color.black); + } + + // Here you can implement the rendering logic. + // Use ScriptableRenderContext to issue drawing commands or execute command buffers + // https://docs.unity3d.com/ScriptReference/Rendering.ScriptableRenderContext.html + // You don't have to call ScriptableRenderContext.submit, the render pipeline will call it at specific points in the pipeline. + public override void Execute(ScriptableRenderContext context, ref RenderingData renderingData) + { + CommandBuffer cmd = CommandBufferPool.Get(m_ProfilerTag); + + using (new ProfilingSample(cmd, m_ProfilerTag)) + { + context.ExecuteCommandBuffer(cmd); + cmd.Clear(); + + var sortFlags = renderingData.cameraData.defaultOpaqueSortFlags; + var drawSettings = CreateDrawingSettings(m_ShaderTagId, ref renderingData, sortFlags); + drawSettings.perObjectData = PerObjectData.None; + + + ref CameraData cameraData = ref renderingData.cameraData; + Camera camera = cameraData.camera; + if (cameraData.isStereoEnabled) + context.StartMultiEye(camera); + + + drawSettings.overrideMaterial = depthNormalsMaterial; + + + context.DrawRenderers(renderingData.cullResults, ref drawSettings, + ref m_FilteringSettings); + + cmd.SetGlobalTexture("_CameraDepthNormalsTexture", depthAttachmentHandle.id); + } + + context.ExecuteCommandBuffer(cmd); + CommandBufferPool.Release(cmd); + } + + /// Cleanup any allocated resources that were created during the execution of this render pass. + public override void FrameCleanup(CommandBuffer cmd) + { + if (depthAttachmentHandle != RenderTargetHandle.CameraTarget) + { + cmd.ReleaseTemporaryRT(depthAttachmentHandle.id); + depthAttachmentHandle = RenderTargetHandle.CameraTarget; + } + } + } + + DepthNormalsPass depthNormalsPass; + RenderTargetHandle depthNormalsTexture; + Material depthNormalsMaterial; + + public override void Create() + { + depthNormalsMaterial = CoreUtils.CreateEngineMaterial("Hidden/Internal-DepthNormalsTexture"); + depthNormalsPass = new DepthNormalsPass(RenderQueueRange.opaque, -1, depthNormalsMaterial); + depthNormalsPass.renderPassEvent = RenderPassEvent.AfterRenderingPrePasses; + depthNormalsTexture.Init("_CameraDepthNormalsTexture"); + } + + // Here you can inject one or multiple render passes in the renderer. + // This method is called when setting up the renderer once per-camera. + public override void AddRenderPasses(ScriptableRenderer renderer, ref RenderingData renderingData) + { + depthNormalsPass.Setup(renderingData.cameraData.cameraTargetDescriptor, depthNormalsTexture); + renderer.EnqueuePass(depthNormalsPass); + } +} + + diff --git a/Assets/Shaders/Outline/DepthNormalsFeature.cs.meta b/Assets/Shaders/Outline/DepthNormalsFeature.cs.meta new file mode 100644 index 00000000..057f2691 --- /dev/null +++ b/Assets/Shaders/Outline/DepthNormalsFeature.cs.meta @@ -0,0 +1,11 @@ +fileFormatVersion: 2 +guid: 3c0c301f9e8bcb74583ece56b872b224 +MonoImporter: + externalObjects: {} + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/Shaders/Outline/Outline.hlsl b/Assets/Shaders/Outline/Outline.hlsl new file mode 100644 index 00000000..156e983d --- /dev/null +++ b/Assets/Shaders/Outline/Outline.hlsl @@ -0,0 +1,67 @@ +TEXTURE2D(_CameraColorTexture); +SAMPLER(sampler_CameraColorTexture); +float4 _CameraColorTexture_TexelSize; + +TEXTURE2D(_CameraDepthTexture); +SAMPLER(sampler_CameraDepthTexture); + +TEXTURE2D(_CameraDepthNormalsTexture); +SAMPLER(sampler_CameraDepthNormalsTexture); + +float3 DecodeNormal(float4 enc) +{ + float kScale = 1.7777; + float3 nn = enc.xyz*float3(2*kScale,2*kScale,0) + float3(-kScale,-kScale,1); + float g = 2.0 / dot(nn.xyz,nn.xyz); + float3 n; + n.xy = g*nn.xy; + n.z = g-1; + return n; +} + +void Outline_float(float2 UV, float OutlineThickness, float DepthSensitivity, float NormalsSensitivity, float ColorSensitivity, float4 OutlineColor, out float4 Out) +{ + float halfScaleFloor = floor(OutlineThickness * 0.5); + float halfScaleCeil = ceil(OutlineThickness * 0.5); + float2 Texel = (1.0) / float2(_CameraColorTexture_TexelSize.z, _CameraColorTexture_TexelSize.w); + + float2 uvSamples[4]; + float depthSamples[4]; + float3 normalSamples[4], colorSamples[4]; + + uvSamples[0] = UV - float2(Texel.x, Texel.y) * halfScaleFloor; + uvSamples[1] = UV + float2(Texel.x, Texel.y) * halfScaleCeil; + uvSamples[2] = UV + float2(Texel.x * halfScaleCeil, -Texel.y * halfScaleFloor); + uvSamples[3] = UV + float2(-Texel.x * halfScaleFloor, Texel.y * halfScaleCeil); + + for(int i = 0; i < 4 ; i++) + { + depthSamples[i] = SAMPLE_TEXTURE2D(_CameraDepthTexture, sampler_CameraDepthTexture, uvSamples[i]).r; + normalSamples[i] = DecodeNormal(SAMPLE_TEXTURE2D(_CameraDepthNormalsTexture, sampler_CameraDepthNormalsTexture, uvSamples[i])); + colorSamples[i] = SAMPLE_TEXTURE2D(_CameraColorTexture, sampler_CameraColorTexture, uvSamples[i]); + } + + // Depth + float depthFiniteDifference0 = depthSamples[1] - depthSamples[0]; + float depthFiniteDifference1 = depthSamples[3] - depthSamples[2]; + float edgeDepth = sqrt(pow(depthFiniteDifference0, 2) + pow(depthFiniteDifference1, 2)) * 100; + float depthThreshold = (1/DepthSensitivity) * depthSamples[0]; + edgeDepth = edgeDepth > depthThreshold ? 1 : 0; + + // Normals + float3 normalFiniteDifference0 = normalSamples[1] - normalSamples[0]; + float3 normalFiniteDifference1 = normalSamples[3] - normalSamples[2]; + float edgeNormal = sqrt(dot(normalFiniteDifference0, normalFiniteDifference0) + dot(normalFiniteDifference1, normalFiniteDifference1)); + edgeNormal = edgeNormal > (1/NormalsSensitivity) ? 1 : 0; + + // Color + float3 colorFiniteDifference0 = colorSamples[1] - colorSamples[0]; + float3 colorFiniteDifference1 = colorSamples[3] - colorSamples[2]; + float edgeColor = sqrt(dot(colorFiniteDifference0, colorFiniteDifference0) + dot(colorFiniteDifference1, colorFiniteDifference1)); + edgeColor = edgeColor > (1/ColorSensitivity) ? 1 : 0; + + float edge = max(edgeDepth, max(edgeNormal, edgeColor)); + + float4 original = SAMPLE_TEXTURE2D(_CameraColorTexture, sampler_CameraColorTexture, uvSamples[0]); + Out = ((1 - edge) * original) + (edge * lerp(original, OutlineColor, OutlineColor.a)); +} \ No newline at end of file diff --git a/Assets/Shaders/Outline/Outline.hlsl.meta b/Assets/Shaders/Outline/Outline.hlsl.meta new file mode 100644 index 00000000..783472fe --- /dev/null +++ b/Assets/Shaders/Outline/Outline.hlsl.meta @@ -0,0 +1,10 @@ +fileFormatVersion: 2 +guid: e658a006105f1214b96587bba83f0f67 +ShaderImporter: + externalObjects: {} + defaultTextures: [] + nonModifiableTextures: [] + preprocessorOverride: 0 + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/Shaders/Outline/OutlineFeature.cs b/Assets/Shaders/Outline/OutlineFeature.cs new file mode 100644 index 00000000..3a72d5d0 --- /dev/null +++ b/Assets/Shaders/Outline/OutlineFeature.cs @@ -0,0 +1,101 @@ +using UnityEngine; +using UnityEngine.Rendering; +using UnityEngine.Rendering.Universal; + +public class OutlineFeature : ScriptableRendererFeature +{ + class OutlinePass : ScriptableRenderPass + { + private RenderTargetIdentifier source { get; set; } + private RenderTargetHandle destination { get; set; } + public Material outlineMaterial = null; + RenderTargetHandle temporaryColorTexture; + + public void Setup(RenderTargetIdentifier source, RenderTargetHandle destination) + { + this.source = source; + this.destination = destination; + } + + public OutlinePass(Material outlineMaterial) + { + this.outlineMaterial = outlineMaterial; + } + + + + // This method is called before executing the render pass. + // It can be used to configure render targets and their clear state. Also to create temporary render target textures. + // When empty this render pass will render to the active camera render target. + // You should never call CommandBuffer.SetRenderTarget. Instead call ConfigureTarget and ConfigureClear. + // The render pipeline will ensure target setup and clearing happens in an performance manner. + public override void Configure(CommandBuffer cmd, RenderTextureDescriptor cameraTextureDescriptor) + { + + } + + // Here you can implement the rendering logic. + // Use ScriptableRenderContext to issue drawing commands or execute command buffers + // https://docs.unity3d.com/ScriptReference/Rendering.ScriptableRenderContext.html + // You don't have to call ScriptableRenderContext.submit, the render pipeline will call it at specific points in the pipeline. + public override void Execute(ScriptableRenderContext context, ref RenderingData renderingData) + { + CommandBuffer cmd = CommandBufferPool.Get("_OutlinePass"); + + RenderTextureDescriptor opaqueDescriptor = renderingData.cameraData.cameraTargetDescriptor; + opaqueDescriptor.depthBufferBits = 0; + + if (destination == RenderTargetHandle.CameraTarget) + { + cmd.GetTemporaryRT(temporaryColorTexture.id, opaqueDescriptor, FilterMode.Point); + Blit(cmd, source, temporaryColorTexture.Identifier(), outlineMaterial, 0); + Blit(cmd, temporaryColorTexture.Identifier(), source); + + } + else Blit(cmd, source, destination.Identifier(), outlineMaterial, 0); + + context.ExecuteCommandBuffer(cmd); + CommandBufferPool.Release(cmd); + } + + /// Cleanup any allocated resources that were created during the execution of this render pass. + public override void FrameCleanup(CommandBuffer cmd) + { + + if (destination == RenderTargetHandle.CameraTarget) + cmd.ReleaseTemporaryRT(temporaryColorTexture.id); + } + } + + [System.Serializable] + public class OutlineSettings + { + public Material outlineMaterial = null; + } + + public OutlineSettings settings = new OutlineSettings(); + OutlinePass outlinePass; + RenderTargetHandle outlineTexture; + + public override void Create() + { + outlinePass = new OutlinePass(settings.outlineMaterial); + outlinePass.renderPassEvent = RenderPassEvent.AfterRenderingTransparents; + outlineTexture.Init("_OutlineTexture"); + } + + // Here you can inject one or multiple render passes in the renderer. + // This method is called when setting up the renderer once per-camera. + public override void AddRenderPasses(ScriptableRenderer renderer, ref RenderingData renderingData) + { + if (settings.outlineMaterial == null) + { + Debug.LogWarningFormat("Missing Outline Material"); + return; + } + outlinePass.Setup(renderer.cameraColorTarget, RenderTargetHandle.CameraTarget); + renderer.EnqueuePass(outlinePass); + } +} + + diff --git a/Assets/Shaders/Outline/OutlineFeature.cs.meta b/Assets/Shaders/Outline/OutlineFeature.cs.meta new file mode 100644 index 00000000..5cf89a81 --- /dev/null +++ b/Assets/Shaders/Outline/OutlineFeature.cs.meta @@ -0,0 +1,11 @@ +fileFormatVersion: 2 +guid: 5c478a49859fb4241aeef0317db339fe +MonoImporter: + externalObjects: {} + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/Shaders/Outline/OutlineGraph.shadergraph b/Assets/Shaders/Outline/OutlineGraph.shadergraph new file mode 100644 index 00000000..a3526309 --- /dev/null +++ b/Assets/Shaders/Outline/OutlineGraph.shadergraph @@ -0,0 +1,1079 @@ +{ + "m_SGVersion": 2, + "m_Type": "UnityEditor.ShaderGraph.GraphData", + "m_ObjectId": "101c640f8d974e6d8e3d02ecd30dd979", + "m_Properties": [ + { + "m_Id": "fb4f91cd611641a19ab2c20ea38a5e48" + }, + { + "m_Id": "e9b169a309f047ad9db140790c55f5f3" + }, + { + "m_Id": "a15d1ac5e5b0403195aa3cb236acaad4" + }, + { + "m_Id": "a1bb49bdbd8d42fabeb2fbf4240a2851" + }, + { + "m_Id": "8222ec55b4da40d4aec694ebb08fcb83" + } + ], + "m_Keywords": [], + "m_Nodes": [ + { + "m_Id": "a5a7e258028346829323d9a3aa4e655e" + }, + { + "m_Id": "2b2edad694f145c78e4af1d01b6dfbca" + }, + { + "m_Id": "cabafc9e70104c78ab436c963cbca526" + }, + { + "m_Id": "c612f2e45aec41b4919cf6bf4a4eba2f" + }, + { + "m_Id": "e301e5cb7fde48a0bbb0499c9bcf4db6" + }, + { + "m_Id": "492c98de55964700876c0aa096b21ead" + }, + { + "m_Id": "4c44e491d76f49d1bf66f8f5865c7ef0" + }, + { + "m_Id": "9224de795c2c4a5fae9f3aba42c298f7" + }, + { + "m_Id": "c0d1750e0a5748689264ae55bfe0d516" + }, + { + "m_Id": "c57411153e0e48cfb9397a75ead48042" + }, + { + "m_Id": "1bea251ccd754bb4a511147f55c0536a" + } + ], + "m_GroupDatas": [], + "m_StickyNoteDatas": [], + "m_Edges": [ + { + "m_OutputSlot": { + "m_Node": { + "m_Id": "1bea251ccd754bb4a511147f55c0536a" + }, + "m_SlotId": 0 + }, + "m_InputSlot": { + "m_Node": { + "m_Id": "e301e5cb7fde48a0bbb0499c9bcf4db6" + }, + "m_SlotId": 6 + } + }, + { + "m_OutputSlot": { + "m_Node": { + "m_Id": "492c98de55964700876c0aa096b21ead" + }, + "m_SlotId": 0 + }, + "m_InputSlot": { + "m_Node": { + "m_Id": "e301e5cb7fde48a0bbb0499c9bcf4db6" + }, + "m_SlotId": 1 + } + }, + { + "m_OutputSlot": { + "m_Node": { + "m_Id": "4c44e491d76f49d1bf66f8f5865c7ef0" + }, + "m_SlotId": 0 + }, + "m_InputSlot": { + "m_Node": { + "m_Id": "e301e5cb7fde48a0bbb0499c9bcf4db6" + }, + "m_SlotId": 2 + } + }, + { + "m_OutputSlot": { + "m_Node": { + "m_Id": "9224de795c2c4a5fae9f3aba42c298f7" + }, + "m_SlotId": 0 + }, + "m_InputSlot": { + "m_Node": { + "m_Id": "e301e5cb7fde48a0bbb0499c9bcf4db6" + }, + "m_SlotId": 3 + } + }, + { + "m_OutputSlot": { + "m_Node": { + "m_Id": "c0d1750e0a5748689264ae55bfe0d516" + }, + "m_SlotId": 0 + }, + "m_InputSlot": { + "m_Node": { + "m_Id": "e301e5cb7fde48a0bbb0499c9bcf4db6" + }, + "m_SlotId": 4 + } + }, + { + "m_OutputSlot": { + "m_Node": { + "m_Id": "c57411153e0e48cfb9397a75ead48042" + }, + "m_SlotId": 0 + }, + "m_InputSlot": { + "m_Node": { + "m_Id": "e301e5cb7fde48a0bbb0499c9bcf4db6" + }, + "m_SlotId": 5 + } + }, + { + "m_OutputSlot": { + "m_Node": { + "m_Id": "e301e5cb7fde48a0bbb0499c9bcf4db6" + }, + "m_SlotId": 0 + }, + "m_InputSlot": { + "m_Node": { + "m_Id": "c612f2e45aec41b4919cf6bf4a4eba2f" + }, + "m_SlotId": 0 + } + } + ], + "m_VertexContext": { + "m_Position": { + "x": 0.0, + "y": 0.0 + }, + "m_Blocks": [ + { + "m_Id": "a5a7e258028346829323d9a3aa4e655e" + }, + { + "m_Id": "2b2edad694f145c78e4af1d01b6dfbca" + }, + { + "m_Id": "cabafc9e70104c78ab436c963cbca526" + } + ] + }, + "m_FragmentContext": { + "m_Position": { + "x": 0.0, + "y": 200.0 + }, + "m_Blocks": [ + { + "m_Id": "c612f2e45aec41b4919cf6bf4a4eba2f" + } + ] + }, + "m_PreviewData": { + "serializedMesh": { + "m_SerializedMesh": "{\"mesh\":{\"instanceID\":0}}", + "m_Guid": "" + } + }, + "m_Path": "Shader Graphs", + "m_ConcretePrecision": 0, + "m_PreviewMode": 2, + "m_OutputNode": { + "m_Id": "" + }, + "m_ActiveTargets": [ + { + "m_Id": "b6cc61b2648946bd8a5493f2a46541ee" + } + ] +} + +{ + "m_SGVersion": 0, + "m_Type": "UnityEditor.ShaderGraph.PropertyNode", + "m_ObjectId": "1bea251ccd754bb4a511147f55c0536a", + "m_Group": { + "m_Id": "" + }, + "m_Name": "Property", + "m_DrawState": { + "m_Expanded": true, + "m_Position": { + "serializedVersion": "2", + "x": -697.0000610351563, + "y": 206.0, + "width": 146.0, + "height": 34.0 + } + }, + "m_Slots": [ + { + "m_Id": "323c351d32754d90ae22b7b365dd5754" + } + ], + "synonyms": [], + "m_Precision": 0, + "m_PreviewExpanded": true, + "m_PreviewMode": 0, + "m_CustomColors": { + "m_SerializableColors": [] + }, + "m_Property": { + "m_Id": "8222ec55b4da40d4aec694ebb08fcb83" + } +} + +{ + "m_SGVersion": 0, + "m_Type": "UnityEditor.ShaderGraph.Vector1MaterialSlot", + "m_ObjectId": "22b411e83d094d1d986945a3cb614b2f", + "m_Id": 0, + "m_DisplayName": "Thickness", + "m_SlotType": 1, + "m_Hidden": false, + "m_ShaderOutputName": "Out", + "m_StageCapability": 3, + "m_Value": 0.0, + "m_DefaultValue": 0.0, + "m_Labels": [] +} + +{ + "m_SGVersion": 0, + "m_Type": "UnityEditor.ShaderGraph.BlockNode", + "m_ObjectId": "2b2edad694f145c78e4af1d01b6dfbca", + "m_Group": { + "m_Id": "" + }, + "m_Name": "VertexDescription.Normal", + "m_DrawState": { + "m_Expanded": true, + "m_Position": { + "serializedVersion": "2", + "x": 0.0, + "y": 0.0, + "width": 0.0, + "height": 0.0 + } + }, + "m_Slots": [ + { + "m_Id": "6acf13c510354c5ab7fe208557d70d77" + } + ], + "synonyms": [], + "m_Precision": 0, + "m_PreviewExpanded": true, + "m_PreviewMode": 0, + "m_CustomColors": { + "m_SerializableColors": [] + }, + "m_SerializedDescriptor": "VertexDescription.Normal" +} + +{ + "m_SGVersion": 0, + "m_Type": "UnityEditor.ShaderGraph.Vector4MaterialSlot", + "m_ObjectId": "323c351d32754d90ae22b7b365dd5754", + "m_Id": 0, + "m_DisplayName": "Outline Color", + "m_SlotType": 1, + "m_Hidden": false, + "m_ShaderOutputName": "Out", + "m_StageCapability": 3, + "m_Value": { + "x": 0.0, + "y": 0.0, + "z": 0.0, + "w": 0.0 + }, + "m_DefaultValue": { + "x": 0.0, + "y": 0.0, + "z": 0.0, + "w": 0.0 + }, + "m_Labels": [] +} + +{ + "m_SGVersion": 0, + "m_Type": "UnityEditor.ShaderGraph.ColorRGBMaterialSlot", + "m_ObjectId": "36a9c411d300402589aeb6c829801606", + "m_Id": 0, + "m_DisplayName": "Base Color", + "m_SlotType": 0, + "m_Hidden": false, + "m_ShaderOutputName": "BaseColor", + "m_StageCapability": 2, + "m_Value": { + "x": 0.5, + "y": 0.5, + "z": 0.5 + }, + "m_DefaultValue": { + "x": 0.0, + "y": 0.0, + "z": 0.0 + }, + "m_Labels": [], + "m_ColorMode": 0, + "m_DefaultColor": { + "r": 0.5, + "g": 0.5, + "b": 0.5, + "a": 1.0 + } +} + +{ + "m_SGVersion": 0, + "m_Type": "UnityEditor.ShaderGraph.Vector1MaterialSlot", + "m_ObjectId": "4001793a4a09463599d4ae6d339847c0", + "m_Id": 3, + "m_DisplayName": "DepthSensitivity", + "m_SlotType": 0, + "m_Hidden": false, + "m_ShaderOutputName": "DepthSensitivity", + "m_StageCapability": 3, + "m_Value": 0.0, + "m_DefaultValue": 0.0, + "m_Labels": [] +} + +{ + "m_SGVersion": 0, + "m_Type": "UnityEditor.ShaderGraph.Vector1MaterialSlot", + "m_ObjectId": "431205b987ed4bee9b295200a492982c", + "m_Id": 0, + "m_DisplayName": "Normals Sensitivity", + "m_SlotType": 1, + "m_Hidden": false, + "m_ShaderOutputName": "Out", + "m_StageCapability": 3, + "m_Value": 0.0, + "m_DefaultValue": 0.0, + "m_Labels": [] +} + +{ + "m_SGVersion": 0, + "m_Type": "UnityEditor.ShaderGraph.UVNode", + "m_ObjectId": "492c98de55964700876c0aa096b21ead", + "m_Group": { + "m_Id": "" + }, + "m_Name": "UV", + "m_DrawState": { + "m_Expanded": true, + "m_Position": { + "serializedVersion": "2", + "x": -968.0, + "y": -67.0, + "width": 208.0, + "height": 314.0 + } + }, + "m_Slots": [ + { + "m_Id": "f748cf8ae3a74680992de2f5efd06c57" + } + ], + "synonyms": [], + "m_Precision": 0, + "m_PreviewExpanded": false, + "m_PreviewMode": 0, + "m_CustomColors": { + "m_SerializableColors": [] + }, + "m_OutputChannel": 0 +} + +{ + "m_SGVersion": 0, + "m_Type": "UnityEditor.ShaderGraph.PropertyNode", + "m_ObjectId": "4c44e491d76f49d1bf66f8f5865c7ef0", + "m_Group": { + "m_Id": "" + }, + "m_Name": "Property", + "m_DrawState": { + "m_Expanded": true, + "m_Position": { + "serializedVersion": "2", + "x": -680.0000610351563, + "y": 63.000003814697269, + "width": 129.0, + "height": 34.0 + } + }, + "m_Slots": [ + { + "m_Id": "22b411e83d094d1d986945a3cb614b2f" + } + ], + "synonyms": [], + "m_Precision": 0, + "m_PreviewExpanded": true, + "m_PreviewMode": 0, + "m_CustomColors": { + "m_SerializableColors": [] + }, + "m_Property": { + "m_Id": "fb4f91cd611641a19ab2c20ea38a5e48" + } +} + +{ + "m_SGVersion": 0, + "m_Type": "UnityEditor.ShaderGraph.NormalMaterialSlot", + "m_ObjectId": "6acf13c510354c5ab7fe208557d70d77", + "m_Id": 0, + "m_DisplayName": "Normal", + "m_SlotType": 0, + "m_Hidden": false, + "m_ShaderOutputName": "Normal", + "m_StageCapability": 1, + "m_Value": { + "x": 0.0, + "y": 0.0, + "z": 0.0 + }, + "m_DefaultValue": { + "x": 0.0, + "y": 0.0, + "z": 0.0 + }, + "m_Labels": [], + "m_Space": 0 +} + +{ + "m_SGVersion": 0, + "m_Type": "UnityEditor.ShaderGraph.Vector2MaterialSlot", + "m_ObjectId": "795e6bbadc17459b8b16b48223e8e40c", + "m_Id": 1, + "m_DisplayName": "UV", + "m_SlotType": 0, + "m_Hidden": false, + "m_ShaderOutputName": "UV", + "m_StageCapability": 3, + "m_Value": { + "x": 0.0, + "y": 0.0 + }, + "m_DefaultValue": { + "x": 0.0, + "y": 0.0 + }, + "m_Labels": [] +} + +{ + "m_SGVersion": 3, + "m_Type": "UnityEditor.ShaderGraph.Internal.ColorShaderProperty", + "m_ObjectId": "8222ec55b4da40d4aec694ebb08fcb83", + "m_Guid": { + "m_GuidSerialized": "731cbee6-8a23-4a41-8034-624c0042ffa7" + }, + "m_Name": "Outline Color", + "m_DefaultReferenceName": "Color_8222ec55b4da40d4aec694ebb08fcb83", + "m_OverrideReferenceName": "", + "m_GeneratePropertyBlock": true, + "m_Precision": 0, + "overrideHLSLDeclaration": false, + "hlslDeclarationOverride": 0, + "m_Hidden": false, + "m_Value": { + "r": 0.0, + "g": 0.0, + "b": 0.0, + "a": 0.0 + }, + "m_ColorMode": 0 +} + +{ + "m_SGVersion": 0, + "m_Type": "UnityEditor.ShaderGraph.Vector4MaterialSlot", + "m_ObjectId": "866d537257f64c0e90c1b36782413124", + "m_Id": 6, + "m_DisplayName": "OutlineColor", + "m_SlotType": 0, + "m_Hidden": false, + "m_ShaderOutputName": "OutlineColor", + "m_StageCapability": 3, + "m_Value": { + "x": 0.0, + "y": 0.0, + "z": 0.0, + "w": 0.0 + }, + "m_DefaultValue": { + "x": 0.0, + "y": 0.0, + "z": 0.0, + "w": 0.0 + }, + "m_Labels": [] +} + +{ + "m_SGVersion": 0, + "m_Type": "UnityEditor.ShaderGraph.Vector1MaterialSlot", + "m_ObjectId": "8a7f31c796d941b88a480c56ca1777d7", + "m_Id": 0, + "m_DisplayName": "Depth Sensitivity", + "m_SlotType": 1, + "m_Hidden": false, + "m_ShaderOutputName": "Out", + "m_StageCapability": 3, + "m_Value": 0.0, + "m_DefaultValue": 0.0, + "m_Labels": [] +} + +{ + "m_SGVersion": 0, + "m_Type": "UnityEditor.ShaderGraph.PropertyNode", + "m_ObjectId": "9224de795c2c4a5fae9f3aba42c298f7", + "m_Group": { + "m_Id": "" + }, + "m_Name": "Property", + "m_DrawState": { + "m_Expanded": true, + "m_Position": { + "serializedVersion": "2", + "x": -716.0, + "y": 96.99999237060547, + "width": 165.0, + "height": 34.0 + } + }, + "m_Slots": [ + { + "m_Id": "8a7f31c796d941b88a480c56ca1777d7" + } + ], + "synonyms": [], + "m_Precision": 0, + "m_PreviewExpanded": true, + "m_PreviewMode": 0, + "m_CustomColors": { + "m_SerializableColors": [] + }, + "m_Property": { + "m_Id": "e9b169a309f047ad9db140790c55f5f3" + } +} + +{ + "m_SGVersion": 1, + "m_Type": "UnityEditor.ShaderGraph.Internal.Vector1ShaderProperty", + "m_ObjectId": "a15d1ac5e5b0403195aa3cb236acaad4", + "m_Guid": { + "m_GuidSerialized": "793d3091-3015-4509-beb0-1b26abe548d2" + }, + "m_Name": "Normals Sensitivity", + "m_DefaultReferenceName": "Vector1_a15d1ac5e5b0403195aa3cb236acaad4", + "m_OverrideReferenceName": "", + "m_GeneratePropertyBlock": true, + "m_Precision": 0, + "overrideHLSLDeclaration": false, + "hlslDeclarationOverride": 0, + "m_Hidden": false, + "m_Value": 0.0, + "m_FloatType": 0, + "m_RangeValues": { + "x": 0.0, + "y": 1.0 + } +} + +{ + "m_SGVersion": 1, + "m_Type": "UnityEditor.ShaderGraph.Internal.Vector1ShaderProperty", + "m_ObjectId": "a1bb49bdbd8d42fabeb2fbf4240a2851", + "m_Guid": { + "m_GuidSerialized": "31dd6407-31bf-47a8-b251-122dbbfa03ad" + }, + "m_Name": "Color Sensitivity", + "m_DefaultReferenceName": "Vector1_a1bb49bdbd8d42fabeb2fbf4240a2851", + "m_OverrideReferenceName": "", + "m_GeneratePropertyBlock": true, + "m_Precision": 0, + "overrideHLSLDeclaration": false, + "hlslDeclarationOverride": 0, + "m_Hidden": false, + "m_Value": 0.0, + "m_FloatType": 0, + "m_RangeValues": { + "x": 0.0, + "y": 1.0 + } +} + +{ + "m_SGVersion": 0, + "m_Type": "UnityEditor.ShaderGraph.BlockNode", + "m_ObjectId": "a5a7e258028346829323d9a3aa4e655e", + "m_Group": { + "m_Id": "" + }, + "m_Name": "VertexDescription.Position", + "m_DrawState": { + "m_Expanded": true, + "m_Position": { + "serializedVersion": "2", + "x": 0.0, + "y": 0.0, + "width": 0.0, + "height": 0.0 + } + }, + "m_Slots": [ + { + "m_Id": "c0a7c258aa7f4b2992efe07acda4a5b1" + } + ], + "synonyms": [], + "m_Precision": 0, + "m_PreviewExpanded": true, + "m_PreviewMode": 0, + "m_CustomColors": { + "m_SerializableColors": [] + }, + "m_SerializedDescriptor": "VertexDescription.Position" +} + +{ + "m_SGVersion": 0, + "m_Type": "UnityEditor.Rendering.Universal.ShaderGraph.UniversalUnlitSubTarget", + "m_ObjectId": "ad72c57a4bf14da19c7fd56da3cce153" +} + +{ + "m_SGVersion": 0, + "m_Type": "UnityEditor.ShaderGraph.Vector1MaterialSlot", + "m_ObjectId": "af9ab44694874caf83ad1023ebd64b93", + "m_Id": 2, + "m_DisplayName": "OutlineThickness", + "m_SlotType": 0, + "m_Hidden": false, + "m_ShaderOutputName": "OutlineThickness", + "m_StageCapability": 3, + "m_Value": 0.0, + "m_DefaultValue": 0.0, + "m_Labels": [] +} + +{ + "m_SGVersion": 0, + "m_Type": "UnityEditor.Rendering.Universal.ShaderGraph.UniversalTarget", + "m_ObjectId": "b6cc61b2648946bd8a5493f2a46541ee", + "m_ActiveSubTarget": { + "m_Id": "ad72c57a4bf14da19c7fd56da3cce153" + }, + "m_SurfaceType": 0, + "m_AlphaMode": 0, + "m_TwoSided": false, + "m_AlphaClip": false, + "m_CustomEditorGUI": "" +} + +{ + "m_SGVersion": 0, + "m_Type": "UnityEditor.ShaderGraph.PositionMaterialSlot", + "m_ObjectId": "c0a7c258aa7f4b2992efe07acda4a5b1", + "m_Id": 0, + "m_DisplayName": "Position", + "m_SlotType": 0, + "m_Hidden": false, + "m_ShaderOutputName": "Position", + "m_StageCapability": 1, + "m_Value": { + "x": 0.0, + "y": 0.0, + "z": 0.0 + }, + "m_DefaultValue": { + "x": 0.0, + "y": 0.0, + "z": 0.0 + }, + "m_Labels": [], + "m_Space": 0 +} + +{ + "m_SGVersion": 0, + "m_Type": "UnityEditor.ShaderGraph.PropertyNode", + "m_ObjectId": "c0d1750e0a5748689264ae55bfe0d516", + "m_Group": { + "m_Id": "" + }, + "m_Name": "Property", + "m_DrawState": { + "m_Expanded": true, + "m_Position": { + "serializedVersion": "2", + "x": -728.0000610351563, + "y": 131.0, + "width": 177.00001525878907, + "height": 34.0 + } + }, + "m_Slots": [ + { + "m_Id": "431205b987ed4bee9b295200a492982c" + } + ], + "synonyms": [], + "m_Precision": 0, + "m_PreviewExpanded": true, + "m_PreviewMode": 0, + "m_CustomColors": { + "m_SerializableColors": [] + }, + "m_Property": { + "m_Id": "a15d1ac5e5b0403195aa3cb236acaad4" + } +} + +{ + "m_SGVersion": 0, + "m_Type": "UnityEditor.ShaderGraph.PropertyNode", + "m_ObjectId": "c57411153e0e48cfb9397a75ead48042", + "m_Group": { + "m_Id": "" + }, + "m_Name": "Property", + "m_DrawState": { + "m_Expanded": true, + "m_Position": { + "serializedVersion": "2", + "x": -713.0000610351563, + "y": 172.0, + "width": 162.00001525878907, + "height": 34.0 + } + }, + "m_Slots": [ + { + "m_Id": "d58f7f0f8cde4375ba845acabfdc6c1b" + } + ], + "synonyms": [], + "m_Precision": 0, + "m_PreviewExpanded": true, + "m_PreviewMode": 0, + "m_CustomColors": { + "m_SerializableColors": [] + }, + "m_Property": { + "m_Id": "a1bb49bdbd8d42fabeb2fbf4240a2851" + } +} + +{ + "m_SGVersion": 0, + "m_Type": "UnityEditor.ShaderGraph.BlockNode", + "m_ObjectId": "c612f2e45aec41b4919cf6bf4a4eba2f", + "m_Group": { + "m_Id": "" + }, + "m_Name": "SurfaceDescription.BaseColor", + "m_DrawState": { + "m_Expanded": true, + "m_Position": { + "serializedVersion": "2", + "x": 0.0, + "y": 0.0, + "width": 0.0, + "height": 0.0 + } + }, + "m_Slots": [ + { + "m_Id": "36a9c411d300402589aeb6c829801606" + } + ], + "synonyms": [], + "m_Precision": 0, + "m_PreviewExpanded": true, + "m_PreviewMode": 0, + "m_CustomColors": { + "m_SerializableColors": [] + }, + "m_SerializedDescriptor": "SurfaceDescription.BaseColor" +} + +{ + "m_SGVersion": 0, + "m_Type": "UnityEditor.ShaderGraph.BlockNode", + "m_ObjectId": "cabafc9e70104c78ab436c963cbca526", + "m_Group": { + "m_Id": "" + }, + "m_Name": "VertexDescription.Tangent", + "m_DrawState": { + "m_Expanded": true, + "m_Position": { + "serializedVersion": "2", + "x": 0.0, + "y": 0.0, + "width": 0.0, + "height": 0.0 + } + }, + "m_Slots": [ + { + "m_Id": "f2582c0c5fcb4e77a6e6e93bd6d9cce3" + } + ], + "synonyms": [], + "m_Precision": 0, + "m_PreviewExpanded": true, + "m_PreviewMode": 0, + "m_CustomColors": { + "m_SerializableColors": [] + }, + "m_SerializedDescriptor": "VertexDescription.Tangent" +} + +{ + "m_SGVersion": 0, + "m_Type": "UnityEditor.ShaderGraph.Vector1MaterialSlot", + "m_ObjectId": "d3bcdb271b264d97838797690bfdaa4a", + "m_Id": 4, + "m_DisplayName": "NormalsSensitivity", + "m_SlotType": 0, + "m_Hidden": false, + "m_ShaderOutputName": "NormalsSensitivity", + "m_StageCapability": 3, + "m_Value": 0.0, + "m_DefaultValue": 0.0, + "m_Labels": [] +} + +{ + "m_SGVersion": 0, + "m_Type": "UnityEditor.ShaderGraph.Vector1MaterialSlot", + "m_ObjectId": "d58f7f0f8cde4375ba845acabfdc6c1b", + "m_Id": 0, + "m_DisplayName": "Color Sensitivity", + "m_SlotType": 1, + "m_Hidden": false, + "m_ShaderOutputName": "Out", + "m_StageCapability": 3, + "m_Value": 0.0, + "m_DefaultValue": 0.0, + "m_Labels": [] +} + +{ + "m_SGVersion": 1, + "m_Type": "UnityEditor.ShaderGraph.CustomFunctionNode", + "m_ObjectId": "e301e5cb7fde48a0bbb0499c9bcf4db6", + "m_Group": { + "m_Id": "" + }, + "m_Name": "Outline (Custom Function)", + "m_DrawState": { + "m_Expanded": true, + "m_Position": { + "serializedVersion": "2", + "x": -461.0, + "y": 0.0, + "width": 219.00001525878907, + "height": 398.0000305175781 + } + }, + "m_Slots": [ + { + "m_Id": "795e6bbadc17459b8b16b48223e8e40c" + }, + { + "m_Id": "af9ab44694874caf83ad1023ebd64b93" + }, + { + "m_Id": "4001793a4a09463599d4ae6d339847c0" + }, + { + "m_Id": "d3bcdb271b264d97838797690bfdaa4a" + }, + { + "m_Id": "e6b9a623bccf4b9fb6f104eaeab070f9" + }, + { + "m_Id": "866d537257f64c0e90c1b36782413124" + }, + { + "m_Id": "f25a19d40b3649a1a54f151d0e372413" + } + ], + "synonyms": [], + "m_Precision": 0, + "m_PreviewExpanded": true, + "m_PreviewMode": 0, + "m_CustomColors": { + "m_SerializableColors": [] + }, + "m_SourceType": 0, + "m_FunctionName": "Outline", + "m_FunctionSource": "e658a006105f1214b96587bba83f0f67", + "m_FunctionBody": "Enter function body here..." +} + +{ + "m_SGVersion": 0, + "m_Type": "UnityEditor.ShaderGraph.Vector1MaterialSlot", + "m_ObjectId": "e6b9a623bccf4b9fb6f104eaeab070f9", + "m_Id": 5, + "m_DisplayName": "ColorSensitivity", + "m_SlotType": 0, + "m_Hidden": false, + "m_ShaderOutputName": "ColorSensitivity", + "m_StageCapability": 3, + "m_Value": 0.0, + "m_DefaultValue": 0.0, + "m_Labels": [] +} + +{ + "m_SGVersion": 1, + "m_Type": "UnityEditor.ShaderGraph.Internal.Vector1ShaderProperty", + "m_ObjectId": "e9b169a309f047ad9db140790c55f5f3", + "m_Guid": { + "m_GuidSerialized": "80e75bda-f6c9-4cd4-b86d-a9e7364f0b9c" + }, + "m_Name": "Depth Sensitivity", + "m_DefaultReferenceName": "Vector1_e9b169a309f047ad9db140790c55f5f3", + "m_OverrideReferenceName": "", + "m_GeneratePropertyBlock": true, + "m_Precision": 0, + "overrideHLSLDeclaration": false, + "hlslDeclarationOverride": 0, + "m_Hidden": false, + "m_Value": 0.0, + "m_FloatType": 0, + "m_RangeValues": { + "x": 0.0, + "y": 1.0 + } +} + +{ + "m_SGVersion": 0, + "m_Type": "UnityEditor.ShaderGraph.TangentMaterialSlot", + "m_ObjectId": "f2582c0c5fcb4e77a6e6e93bd6d9cce3", + "m_Id": 0, + "m_DisplayName": "Tangent", + "m_SlotType": 0, + "m_Hidden": false, + "m_ShaderOutputName": "Tangent", + "m_StageCapability": 1, + "m_Value": { + "x": 0.0, + "y": 0.0, + "z": 0.0 + }, + "m_DefaultValue": { + "x": 0.0, + "y": 0.0, + "z": 0.0 + }, + "m_Labels": [], + "m_Space": 0 +} + +{ + "m_SGVersion": 0, + "m_Type": "UnityEditor.ShaderGraph.Vector4MaterialSlot", + "m_ObjectId": "f25a19d40b3649a1a54f151d0e372413", + "m_Id": 0, + "m_DisplayName": "Out", + "m_SlotType": 1, + "m_Hidden": false, + "m_ShaderOutputName": "Out", + "m_StageCapability": 3, + "m_Value": { + "x": 0.0, + "y": 0.0, + "z": 0.0, + "w": 0.0 + }, + "m_DefaultValue": { + "x": 0.0, + "y": 0.0, + "z": 0.0, + "w": 0.0 + }, + "m_Labels": [] +} + +{ + "m_SGVersion": 0, + "m_Type": "UnityEditor.ShaderGraph.Vector4MaterialSlot", + "m_ObjectId": "f748cf8ae3a74680992de2f5efd06c57", + "m_Id": 0, + "m_DisplayName": "Out", + "m_SlotType": 1, + "m_Hidden": false, + "m_ShaderOutputName": "Out", + "m_StageCapability": 3, + "m_Value": { + "x": 0.0, + "y": 0.0, + "z": 0.0, + "w": 0.0 + }, + "m_DefaultValue": { + "x": 0.0, + "y": 0.0, + "z": 0.0, + "w": 0.0 + }, + "m_Labels": [] +} + +{ + "m_SGVersion": 1, + "m_Type": "UnityEditor.ShaderGraph.Internal.Vector1ShaderProperty", + "m_ObjectId": "fb4f91cd611641a19ab2c20ea38a5e48", + "m_Guid": { + "m_GuidSerialized": "a2ba4c1e-b979-4a3b-af31-82e8965be377" + }, + "m_Name": "Thickness", + "m_DefaultReferenceName": "Vector1_fb4f91cd611641a19ab2c20ea38a5e48", + "m_OverrideReferenceName": "", + "m_GeneratePropertyBlock": true, + "m_Precision": 0, + "overrideHLSLDeclaration": false, + "hlslDeclarationOverride": 0, + "m_Hidden": false, + "m_Value": 0.0, + "m_FloatType": 0, + "m_RangeValues": { + "x": 0.0, + "y": 1.0 + } +} + diff --git a/Assets/Shaders/Outline/OutlineGraph.shadergraph.meta b/Assets/Shaders/Outline/OutlineGraph.shadergraph.meta new file mode 100644 index 00000000..c51dea50 --- /dev/null +++ b/Assets/Shaders/Outline/OutlineGraph.shadergraph.meta @@ -0,0 +1,10 @@ +fileFormatVersion: 2 +guid: f76d58d96252f6340a66313aa13ca2a9 +ScriptedImporter: + internalIDToNameTable: [] + externalObjects: {} + serializedVersion: 2 + userData: + assetBundleName: + assetBundleVariant: + script: {fileID: 11500000, guid: 625f186215c104763be7675aa2d941aa, type: 3} diff --git a/Assets/Resources/Sprites/Games/BuiltToScaleDS/Materials/Shooter.mat b/Assets/Shaders/Outline/OutlineMat.mat similarity index 74% rename from Assets/Resources/Sprites/Games/BuiltToScaleDS/Materials/Shooter.mat rename to Assets/Shaders/Outline/OutlineMat.mat index 7353e0e9..668a34ee 100644 --- a/Assets/Resources/Sprites/Games/BuiltToScaleDS/Materials/Shooter.mat +++ b/Assets/Shaders/Outline/OutlineMat.mat @@ -1,5 +1,18 @@ %YAML 1.1 %TAG !u! tag:unity3d.com,2011: +--- !u!114 &-4790166311513782184 +MonoBehaviour: + m_ObjectHideFlags: 11 + 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: d0353a89b1f911e48b9e16bdc9f2e058, type: 3} + m_Name: + m_EditorClassIdentifier: + version: 4 --- !u!21 &2100000 Material: serializedVersion: 6 @@ -7,8 +20,8 @@ Material: m_CorrespondingSourceObject: {fileID: 0} m_PrefabInstance: {fileID: 0} m_PrefabAsset: {fileID: 0} - m_Name: Shooter - m_Shader: {fileID: 4800000, guid: d1e828882cbb32942ab1fcff1c69e1fe, type: 3} + m_Name: OutlineMat + m_Shader: {fileID: -6465566751694194690, guid: f76d58d96252f6340a66313aa13ca2a9, type: 3} m_ShaderKeywords: m_LightmapFlags: 4 m_EnableInstancingVariants: 0 @@ -55,10 +68,6 @@ Material: m_Texture: {fileID: 0} m_Scale: {x: 1, y: 1} m_Offset: {x: 0, y: 0} - - _OutlineZOffsetMaskTex: - 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} @@ -80,40 +89,28 @@ Material: m_Scale: {x: 1, y: 1} m_Offset: {x: 0, y: 0} m_Floats: - - _AdditionalLightIgnoreCelShade: 0.9 + - Vector1_a15d1ac5e5b0403195aa3cb236acaad4: 1 + - Vector1_a1bb49bdbd8d42fabeb2fbf4240a2851: 0 + - Vector1_e9b169a309f047ad9db140790c55f5f3: 1 + - Vector1_fb4f91cd611641a19ab2c20ea38a5e48: 3 - _AlphaClip: 0 - _Blend: 0 - _BumpScale: 1 - - _CelShadeMidPoint: -0.5 - - _CelShadeSoftness: 0.05 - _ClearCoatMask: 0 - _ClearCoatSmoothness: 0 - _Cull: 2 - - _Cutoff: 0.379 + - _Cutoff: 0.5 - _DetailAlbedoMapScale: 1 - _DetailNormalMapScale: 1 - - _DirectLightMultiplier: 1 - _DstBlend: 0 - - _EmissionMulByBaseColor: 0 - _EnvironmentReflections: 1 - _GlossMapScale: 0 - _Glossiness: 0 - _GlossyReflections: 0 - - _IndirectLightMultiplier: 1 - - _IsFace: 1 - - _MainLightIgnoreCelShade: 0 - _Metallic: 0 - - _OcclusionRemapEnd: 1 - - _OcclusionRemapStart: 0 - _OcclusionStrength: 1 - - _OutlineWidth: 4 - - _OutlineZOffset: 0 - - _OutlineZOffsetMaskRemapEnd: 1 - - _OutlineZOffsetMaskRemapStart: 0 - _Parallax: 0.005 - _QueueOffset: 0 - - _ReceiveShadowMappingAmount: 0.65 - - _ReceiveShadowMappingPosOffset: 0 - _ReceiveShadows: 1 - _SampleGI: 0 - _Smoothness: 0.5 @@ -121,32 +118,12 @@ Material: - _SpecularHighlights: 1 - _SrcBlend: 1 - _Surface: 0 - - _UseAlphaClipping: 0 - - _UseEmission: 0 - - _UseOcclusion: 0 - _WorkflowMode: 1 - _ZWrite: 1 m_Colors: + - Color_8222ec55b4da40d4aec694ebb08fcb83: {r: 0, g: 0, b: 0, a: 1} - _BaseColor: {r: 1, g: 1, b: 1, a: 1} - _Color: {r: 1, g: 1, b: 1, a: 1} - _EmissionColor: {r: 0, g: 0, b: 0, a: 1} - - _EmissionMapChannelMask: {r: 1, g: 1, b: 1, a: 0} - - _IndirectLightMinColor: {r: 0, g: 0, b: 0, a: 1} - - _OcclusionMapChannelMask: {r: 1, g: 0, b: 0, a: 0} - - _OutlineColor: {r: 0, g: 0, b: 0, a: 1} - - _ShadowMapColor: {r: 0, g: 0, b: 0, a: 1} - _SpecColor: {r: 0.2, g: 0.2, b: 0.2, a: 1} m_BuildTextureStacks: [] ---- !u!114 &6906235552092181016 -MonoBehaviour: - m_ObjectHideFlags: 11 - 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: d0353a89b1f911e48b9e16bdc9f2e058, type: 3} - m_Name: - m_EditorClassIdentifier: - version: 4 diff --git a/Assets/Resources/Sprites/Games/BuiltToScaleDS/Materials/Shooter.mat.meta b/Assets/Shaders/Outline/OutlineMat.mat.meta similarity index 79% rename from Assets/Resources/Sprites/Games/BuiltToScaleDS/Materials/Shooter.mat.meta rename to Assets/Shaders/Outline/OutlineMat.mat.meta index 4ec1d9ce..699118cb 100644 --- a/Assets/Resources/Sprites/Games/BuiltToScaleDS/Materials/Shooter.mat.meta +++ b/Assets/Shaders/Outline/OutlineMat.mat.meta @@ -1,5 +1,5 @@ fileFormatVersion: 2 -guid: 8ed30616db50b7e4a8e9022ca6085652 +guid: 04ce7361143e03e4ca1b8b55fb35d03c NativeFormatImporter: externalObjects: {} mainObjectFileID: 2100000 diff --git a/Assets/UniversalRenderPipelineAsset.asset b/Assets/UniversalRenderPipelineAsset.asset index c6963a30..421701fb 100644 --- a/Assets/UniversalRenderPipelineAsset.asset +++ b/Assets/UniversalRenderPipelineAsset.asset @@ -18,8 +18,9 @@ MonoBehaviour: m_RendererData: {fileID: 0} m_RendererDataList: - {fileID: 11400000, guid: 37ad3e282ebe43b4fb53a62d5ccec241, type: 2} + - {fileID: 11400000, guid: bac777ead124be147b4d66a611b22ab9, type: 2} m_DefaultRendererIndex: 0 - m_RequireDepthTexture: 0 + m_RequireDepthTexture: 1 m_RequireOpaqueTexture: 0 m_OpaqueDownsampling: 1 m_SupportsTerrainHoles: 1