From 17aed9d7db199a2c818b55acf15758e2d9c82831 Mon Sep 17 00:00:00 2001 From: Alexander Bogarsukov Date: Sun, 18 Aug 2019 17:35:58 +0300 Subject: [PATCH] Initial version --- .editorconfig | 105 ++++ .gitignore | 3 + Assets/Examples.meta | 10 + Assets/Examples/Scenes.meta | 10 + Assets/Examples/Scenes/Outline.unity | 460 ++++++++++++++++++ Assets/Examples/Scenes/Outline.unity.meta | 9 + Assets/Examples/Scripts.meta | 10 + .../Examples/Scripts/OutlineEffectBuilder.cs | 53 ++ .../Scripts/OutlineEffectBuilder.cs.meta | 13 + Assets/Plugins.meta | 10 + Assets/Plugins/UnityFx.Outline.meta | 10 + Assets/Plugins/UnityFx.Outline/Runtime.meta | 10 + .../UnityFx.Outline/Runtime/Scripts.meta | 10 + .../Runtime/Scripts/OutlineEffect.cs | 232 +++++++++ .../Runtime/Scripts/OutlineEffect.cs.meta | 17 + .../Runtime/Scripts/OutlineLayer.cs | 268 ++++++++++ .../Runtime/Scripts/OutlineLayer.cs.meta | 13 + .../UnityFx.Outline/Runtime/Shaders.meta | 10 + .../Runtime/Shaders/OutlinePostProcess.shader | 89 ++++ .../Shaders/OutlinePostProcess.shader.meta | 10 + .../Runtime/Shaders/OutlineRenderColor.shader | 41 ++ .../Shaders/OutlineRenderColor.shader.meta | 10 + .../Runtime/UnityFx.Tasks.asmdef | 3 + .../Runtime/UnityFx.Tasks.asmdef.meta | 9 + Assets/Plugins/UnityFx.Outline/package.json | 27 + .../Plugins/UnityFx.Outline/package.json.meta | 9 + CHANGELOG.md | 10 + LICENSE | 21 - LICENSE.md | 9 + README.md | 72 ++- 30 files changed, 1541 insertions(+), 22 deletions(-) create mode 100644 .editorconfig create mode 100644 Assets/Examples.meta create mode 100644 Assets/Examples/Scenes.meta create mode 100644 Assets/Examples/Scenes/Outline.unity create mode 100644 Assets/Examples/Scenes/Outline.unity.meta create mode 100644 Assets/Examples/Scripts.meta create mode 100644 Assets/Examples/Scripts/OutlineEffectBuilder.cs create mode 100644 Assets/Examples/Scripts/OutlineEffectBuilder.cs.meta create mode 100644 Assets/Plugins.meta create mode 100644 Assets/Plugins/UnityFx.Outline.meta create mode 100644 Assets/Plugins/UnityFx.Outline/Runtime.meta create mode 100644 Assets/Plugins/UnityFx.Outline/Runtime/Scripts.meta create mode 100644 Assets/Plugins/UnityFx.Outline/Runtime/Scripts/OutlineEffect.cs create mode 100644 Assets/Plugins/UnityFx.Outline/Runtime/Scripts/OutlineEffect.cs.meta create mode 100644 Assets/Plugins/UnityFx.Outline/Runtime/Scripts/OutlineLayer.cs create mode 100644 Assets/Plugins/UnityFx.Outline/Runtime/Scripts/OutlineLayer.cs.meta create mode 100644 Assets/Plugins/UnityFx.Outline/Runtime/Shaders.meta create mode 100644 Assets/Plugins/UnityFx.Outline/Runtime/Shaders/OutlinePostProcess.shader create mode 100644 Assets/Plugins/UnityFx.Outline/Runtime/Shaders/OutlinePostProcess.shader.meta create mode 100644 Assets/Plugins/UnityFx.Outline/Runtime/Shaders/OutlineRenderColor.shader create mode 100644 Assets/Plugins/UnityFx.Outline/Runtime/Shaders/OutlineRenderColor.shader.meta create mode 100644 Assets/Plugins/UnityFx.Outline/Runtime/UnityFx.Tasks.asmdef create mode 100644 Assets/Plugins/UnityFx.Outline/Runtime/UnityFx.Tasks.asmdef.meta create mode 100644 Assets/Plugins/UnityFx.Outline/package.json create mode 100644 Assets/Plugins/UnityFx.Outline/package.json.meta create mode 100644 CHANGELOG.md delete mode 100644 LICENSE create mode 100644 LICENSE.md diff --git a/.editorconfig b/.editorconfig new file mode 100644 index 0000000..9933dd0 --- /dev/null +++ b/.editorconfig @@ -0,0 +1,105 @@ +# EditorConfig is awesome: http://EditorConfig.org + +# top-most EditorConfig file +root = true + +# Use tabs for indentation. +[*] +indent_style = tab +trim_trailing_whitespace = true +insert_final_newline = true +# (Please don't specify an indent_size here; that has too many unintended consequences.) + +# Code files +[*.{cs,csx,vb,vbx}] +indent_size = 4 + +# Xml project files +[*.{csproj,vbproj,vcxproj,vcxproj.filters,proj,projitems,shproj}] +indent_size = 2 + +# Xml config files +[*.{props,targets,ruleset,config,nuspec,resx,vsixmanifest,vsct}] +indent_size = 2 + +# Yml config files +[*.{yml,yaml}] +indent_style = space +indent_size = 2 + +# JSON files +[*.json] +indent_size = 2 + +# Dotnet code style settings: +[*.{cs,vb}] +# Sort using and Import directives with System.* appearing first +dotnet_sort_system_directives_first = true + +# Avoid "this." and "Me." if not necessary +dotnet_style_qualification_for_field = false:suggestion +dotnet_style_qualification_for_property = false:suggestion +dotnet_style_qualification_for_method = false:suggestion +dotnet_style_qualification_for_event = false:suggestion + +# Use language keywords instead of framework type names for type references +dotnet_style_predefined_type_for_locals_parameters_members = true:warning +dotnet_style_predefined_type_for_member_access = true:warning + +# Suggest more modern language features when available +dotnet_style_object_initializer = true:suggestion +dotnet_style_collection_initializer = true:suggestion +dotnet_style_coalesce_expression = true:warning +dotnet_style_null_propagation = true:warning +dotnet_style_explicit_tuple_names = true:suggestion + +# CSharp code style settings: +[*.cs] +# Prefer "var" everywhere +csharp_style_var_for_built_in_types = true:suggestion +csharp_style_var_when_type_is_apparent = true:warning +csharp_style_var_elsewhere = true:warning + +# Prefer method-like constructs to have a block body +csharp_style_expression_bodied_methods = false:none +csharp_style_expression_bodied_constructors = false:none +csharp_style_expression_bodied_operators = false:none + +# Prefer property-like constructs to have an expression-body +csharp_style_expression_bodied_properties = true:suggestion +csharp_style_expression_bodied_indexers = true:suggestion +csharp_style_expression_bodied_accessors = true:none + +# Suggest more modern language features when available +csharp_style_pattern_matching_over_is_with_cast_check = true:suggestion +csharp_style_pattern_matching_over_as_with_null_check = true:suggestion +csharp_style_inlined_variable_declaration = true:warning +csharp_style_throw_expression = true:suggestion +csharp_style_conditional_delegate_call = true:suggestion +csharp_style_deconstructed_variable_declaration = true:suggestion + +csharp_prefer_simple_default_expression = true:suggestion +csharp_prefer_braces = true:warning + +# Newline settings +csharp_new_line_before_open_brace = all +csharp_new_line_before_else = true +csharp_new_line_before_catch = true +csharp_new_line_before_finally = true +csharp_new_line_before_members_in_object_initializers = true +csharp_new_line_before_members_in_anonymous_types = true +csharp_new_line_between_query_expression_clauses = true + +# Formatting settings +csharp_indent_case_contents = true +csharp_indent_switch_labels = true +csharp_indent_labels = flush_left + +csharp_space_after_cast = false +csharp_space_after_keywords_in_control_flow_statements = true +csharp_space_between_method_declaration_parameter_list_parentheses = false +csharp_space_between_method_call_parameter_list_parentheses = false +csharp_space_between_parentheses = false + +csharp_preserve_single_line_statements = false +csharp_preserve_single_line_blocks = true diff --git a/.gitignore b/.gitignore index 0210746..00e94e7 100644 --- a/.gitignore +++ b/.gitignore @@ -3,6 +3,9 @@ [Oo]bj/ [Bb]uild/ [Bb]uilds/ +[Pp]roject[Ss]ettings/ +[Pp]ackages/ +[Uu]nity[Pp]ackage[Mm]anager/ Assets/AssetStoreTools* # Visual Studio cache directory diff --git a/Assets/Examples.meta b/Assets/Examples.meta new file mode 100644 index 0000000..7a8f4bb --- /dev/null +++ b/Assets/Examples.meta @@ -0,0 +1,10 @@ +fileFormatVersion: 2 +guid: faeaadda5f8d8d14db2a4d6a51b99e42 +folderAsset: yes +timeCreated: 1566126961 +licenseType: Free +DefaultImporter: + externalObjects: {} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/Examples/Scenes.meta b/Assets/Examples/Scenes.meta new file mode 100644 index 0000000..99e36b8 --- /dev/null +++ b/Assets/Examples/Scenes.meta @@ -0,0 +1,10 @@ +fileFormatVersion: 2 +guid: 22f7f37d74888a24c9d14a3069a2939b +folderAsset: yes +timeCreated: 1566127079 +licenseType: Free +DefaultImporter: + externalObjects: {} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/Examples/Scenes/Outline.unity b/Assets/Examples/Scenes/Outline.unity new file mode 100644 index 0000000..2decad4 --- /dev/null +++ b/Assets/Examples/Scenes/Outline.unity @@ -0,0 +1,460 @@ +%YAML 1.1 +%TAG !u! tag:unity3d.com,2011: +--- !u!29 &1 +OcclusionCullingSettings: + m_ObjectHideFlags: 0 + serializedVersion: 2 + m_OcclusionBakeSettings: + smallestOccluder: 5 + smallestHole: 0.25 + backfaceThreshold: 100 + m_SceneGUID: 00000000000000000000000000000000 + m_OcclusionCullingData: {fileID: 0} +--- !u!104 &2 +RenderSettings: + m_ObjectHideFlags: 0 + serializedVersion: 8 + m_Fog: 0 + m_FogColor: {r: 0.5, g: 0.5, b: 0.5, a: 1} + m_FogMode: 3 + m_FogDensity: 0.01 + m_LinearFogStart: 0 + m_LinearFogEnd: 300 + m_AmbientSkyColor: {r: 0.212, g: 0.227, b: 0.259, a: 1} + m_AmbientEquatorColor: {r: 0.114, g: 0.125, b: 0.133, a: 1} + m_AmbientGroundColor: {r: 0.047, g: 0.043, b: 0.035, a: 1} + m_AmbientIntensity: 1 + m_AmbientMode: 0 + m_SubtractiveShadowColor: {r: 0.42, g: 0.478, b: 0.627, a: 1} + m_SkyboxMaterial: {fileID: 10304, guid: 0000000000000000f000000000000000, type: 0} + m_HaloStrength: 0.5 + m_FlareStrength: 1 + m_FlareFadeSpeed: 3 + m_HaloTexture: {fileID: 0} + m_SpotCookie: {fileID: 10001, guid: 0000000000000000e000000000000000, type: 0} + m_DefaultReflectionMode: 0 + m_DefaultReflectionResolution: 128 + m_ReflectionBounces: 1 + m_ReflectionIntensity: 1 + m_CustomReflection: {fileID: 0} + m_Sun: {fileID: 0} + m_IndirectSpecularColor: {r: 0.44657844, g: 0.49641222, b: 0.57481694, a: 1} +--- !u!157 &3 +LightmapSettings: + m_ObjectHideFlags: 0 + serializedVersion: 11 + m_GIWorkflowMode: 0 + m_GISettings: + serializedVersion: 2 + m_BounceScale: 1 + m_IndirectOutputScale: 1 + m_AlbedoBoost: 1 + m_TemporalCoherenceThreshold: 1 + m_EnvironmentLightingMode: 0 + m_EnableBakedLightmaps: 1 + m_EnableRealtimeLightmaps: 1 + m_LightmapEditorSettings: + serializedVersion: 9 + m_Resolution: 2 + m_BakeResolution: 40 + m_TextureWidth: 1024 + m_TextureHeight: 1024 + m_AO: 0 + m_AOMaxDistance: 1 + m_CompAOExponent: 1 + m_CompAOExponentDirect: 0 + m_Padding: 2 + m_LightmapParameters: {fileID: 0} + m_LightmapsBakeMode: 1 + m_TextureCompression: 1 + m_FinalGather: 0 + m_FinalGatherFiltering: 1 + m_FinalGatherRayCount: 256 + m_ReflectionCompression: 2 + m_MixedBakeMode: 2 + m_BakeBackend: 0 + m_PVRSampling: 1 + m_PVRDirectSampleCount: 32 + m_PVRSampleCount: 500 + m_PVRBounces: 2 + m_PVRFilterTypeDirect: 0 + m_PVRFilterTypeIndirect: 0 + m_PVRFilterTypeAO: 0 + m_PVRFilteringMode: 1 + m_PVRCulling: 1 + m_PVRFilteringGaussRadiusDirect: 1 + m_PVRFilteringGaussRadiusIndirect: 5 + m_PVRFilteringGaussRadiusAO: 2 + m_PVRFilteringAtrousPositionSigmaDirect: 0.5 + m_PVRFilteringAtrousPositionSigmaIndirect: 2 + m_PVRFilteringAtrousPositionSigmaAO: 1 + m_LightingDataAsset: {fileID: 0} + m_UseShadowmask: 1 +--- !u!196 &4 +NavMeshSettings: + serializedVersion: 2 + m_ObjectHideFlags: 0 + m_BuildSettings: + serializedVersion: 2 + agentTypeID: 0 + agentRadius: 0.5 + agentHeight: 2 + agentSlope: 45 + agentClimb: 0.4 + ledgeDropHeight: 0 + maxJumpAcrossDistance: 0 + minRegionArea: 2 + manualCellSize: 0 + cellSize: 0.16666667 + manualTileSize: 0 + tileSize: 256 + accuratePlacement: 0 + debug: + m_Flags: 0 + m_NavMeshData: {fileID: 0} +--- !u!1 &167171210 +GameObject: + m_ObjectHideFlags: 0 + m_PrefabParentObject: {fileID: 0} + m_PrefabInternal: {fileID: 0} + serializedVersion: 5 + m_Component: + - component: {fileID: 167171212} + - component: {fileID: 167171211} + m_Layer: 0 + m_Name: Directional Light + m_TagString: Untagged + m_Icon: {fileID: 0} + m_NavMeshLayer: 0 + m_StaticEditorFlags: 0 + m_IsActive: 1 +--- !u!108 &167171211 +Light: + m_ObjectHideFlags: 0 + m_PrefabParentObject: {fileID: 0} + m_PrefabInternal: {fileID: 0} + m_GameObject: {fileID: 167171210} + m_Enabled: 1 + serializedVersion: 8 + m_Type: 1 + m_Color: {r: 1, g: 0.95686275, b: 0.8392157, a: 1} + m_Intensity: 1 + m_Range: 10 + m_SpotAngle: 30 + m_CookieSize: 10 + m_Shadows: + m_Type: 2 + m_Resolution: -1 + m_CustomResolution: -1 + m_Strength: 1 + m_Bias: 0.05 + m_NormalBias: 0.4 + m_NearPlane: 0.2 + m_Cookie: {fileID: 0} + m_DrawHalo: 0 + m_Flare: {fileID: 0} + m_RenderMode: 0 + m_CullingMask: + serializedVersion: 2 + m_Bits: 4294967295 + m_Lightmapping: 4 + m_AreaSize: {x: 1, y: 1} + m_BounceIntensity: 1 + m_ColorTemperature: 6570 + m_UseColorTemperature: 0 + m_ShadowRadius: 0 + m_ShadowAngle: 0 +--- !u!4 &167171212 +Transform: + m_ObjectHideFlags: 0 + m_PrefabParentObject: {fileID: 0} + m_PrefabInternal: {fileID: 0} + m_GameObject: {fileID: 167171210} + m_LocalRotation: {x: 0.40821788, y: -0.23456968, z: 0.10938163, w: 0.8754261} + m_LocalPosition: {x: 0, y: 3, z: 0} + m_LocalScale: {x: 1, y: 1, z: 1} + m_Children: [] + m_Father: {fileID: 0} + m_RootOrder: 1 + m_LocalEulerAnglesHint: {x: 50, y: -30, z: 0} +--- !u!1 &692811812 +GameObject: + m_ObjectHideFlags: 0 + m_PrefabParentObject: {fileID: 0} + m_PrefabInternal: {fileID: 0} + serializedVersion: 5 + m_Component: + - component: {fileID: 692811816} + - component: {fileID: 692811815} + - component: {fileID: 692811814} + - component: {fileID: 692811813} + - component: {fileID: 692811818} + - component: {fileID: 692811817} + m_Layer: 0 + m_Name: Main Camera + m_TagString: MainCamera + m_Icon: {fileID: 0} + m_NavMeshLayer: 0 + m_StaticEditorFlags: 0 + m_IsActive: 1 +--- !u!81 &692811813 +AudioListener: + m_ObjectHideFlags: 0 + m_PrefabParentObject: {fileID: 0} + m_PrefabInternal: {fileID: 0} + m_GameObject: {fileID: 692811812} + m_Enabled: 1 +--- !u!124 &692811814 +Behaviour: + m_ObjectHideFlags: 0 + m_PrefabParentObject: {fileID: 0} + m_PrefabInternal: {fileID: 0} + m_GameObject: {fileID: 692811812} + m_Enabled: 1 +--- !u!20 &692811815 +Camera: + m_ObjectHideFlags: 0 + m_PrefabParentObject: {fileID: 0} + m_PrefabInternal: {fileID: 0} + m_GameObject: {fileID: 692811812} + m_Enabled: 1 + serializedVersion: 2 + m_ClearFlags: 1 + m_BackGroundColor: {r: 0.19215687, g: 0.3019608, b: 0.4745098, a: 0} + m_NormalizedViewPortRect: + serializedVersion: 2 + x: 0 + y: 0 + width: 1 + height: 1 + near clip plane: 0.3 + far clip plane: 1000 + field of view: 60 + orthographic: 0 + orthographic size: 5 + m_Depth: -1 + m_CullingMask: + serializedVersion: 2 + m_Bits: 4294967295 + m_RenderingPath: -1 + m_TargetTexture: {fileID: 0} + m_TargetDisplay: 0 + m_TargetEye: 3 + m_HDR: 1 + m_AllowMSAA: 1 + m_ForceIntoRT: 0 + m_OcclusionCulling: 1 + m_StereoConvergence: 10 + m_StereoSeparation: 0.022 +--- !u!4 &692811816 +Transform: + m_ObjectHideFlags: 0 + m_PrefabParentObject: {fileID: 0} + m_PrefabInternal: {fileID: 0} + m_GameObject: {fileID: 692811812} + m_LocalRotation: {x: 0, y: 0, z: 0, w: 1} + m_LocalPosition: {x: 0, y: 1, z: -10} + m_LocalScale: {x: 1, y: 1, z: 1} + m_Children: + - {fileID: 1579373806} + - {fileID: 748173443} + m_Father: {fileID: 0} + m_RootOrder: 0 + m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} +--- !u!114 &692811817 +MonoBehaviour: + m_ObjectHideFlags: 0 + m_PrefabParentObject: {fileID: 0} + m_PrefabInternal: {fileID: 0} + m_GameObject: {fileID: 692811812} + m_Enabled: 1 + m_EditorHideFlags: 0 + m_Script: {fileID: 11500000, guid: 5a318c96b1bc1614683eccf7abd717a1, type: 3} + m_Name: + m_EditorClassIdentifier: + _outlineGos: + - {fileID: 1579373802} + - {fileID: 748173439} + _outlineWidth: 5 + _outlineColor: {r: 1, g: 0, b: 0, a: 1} +--- !u!114 &692811818 +MonoBehaviour: + m_ObjectHideFlags: 0 + m_PrefabParentObject: {fileID: 0} + m_PrefabInternal: {fileID: 0} + m_GameObject: {fileID: 692811812} + m_Enabled: 1 + m_EditorHideFlags: 0 + m_Script: {fileID: 11500000, guid: 270d3185d159bf54fb4cddbb42235437, type: 3} + m_Name: + m_EditorClassIdentifier: + _renderColorShader: {fileID: 4800000, guid: ac20fbf75bafe454aba5ef3c098349df, type: 3} + _postProcessShader: {fileID: 4800000, guid: 41c9acbf41c8245498ac9beab378de12, type: 3} +--- !u!1 &748173439 +GameObject: + m_ObjectHideFlags: 0 + m_PrefabParentObject: {fileID: 0} + m_PrefabInternal: {fileID: 0} + serializedVersion: 5 + m_Component: + - component: {fileID: 748173443} + - component: {fileID: 748173442} + - component: {fileID: 748173441} + - component: {fileID: 748173440} + m_Layer: 0 + m_Name: Cube + m_TagString: Untagged + m_Icon: {fileID: 0} + m_NavMeshLayer: 0 + m_StaticEditorFlags: 0 + m_IsActive: 1 +--- !u!23 &748173440 +MeshRenderer: + m_ObjectHideFlags: 0 + m_PrefabParentObject: {fileID: 0} + m_PrefabInternal: {fileID: 0} + m_GameObject: {fileID: 748173439} + m_Enabled: 1 + m_CastShadows: 1 + m_ReceiveShadows: 1 + m_DynamicOccludee: 1 + m_MotionVectors: 1 + m_LightProbeUsage: 1 + m_ReflectionProbeUsage: 1 + m_Materials: + - {fileID: 10303, guid: 0000000000000000f000000000000000, type: 0} + m_StaticBatchInfo: + firstSubMesh: 0 + subMeshCount: 0 + m_StaticBatchRoot: {fileID: 0} + m_ProbeAnchor: {fileID: 0} + m_LightProbeVolumeOverride: {fileID: 0} + m_ScaleInLightmap: 1 + m_PreserveUVs: 1 + 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!65 &748173441 +BoxCollider: + m_ObjectHideFlags: 0 + m_PrefabParentObject: {fileID: 0} + m_PrefabInternal: {fileID: 0} + m_GameObject: {fileID: 748173439} + 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!33 &748173442 +MeshFilter: + m_ObjectHideFlags: 0 + m_PrefabParentObject: {fileID: 0} + m_PrefabInternal: {fileID: 0} + m_GameObject: {fileID: 748173439} + m_Mesh: {fileID: 10202, guid: 0000000000000000e000000000000000, type: 0} +--- !u!4 &748173443 +Transform: + m_ObjectHideFlags: 0 + m_PrefabParentObject: {fileID: 0} + m_PrefabInternal: {fileID: 0} + m_GameObject: {fileID: 748173439} + m_LocalRotation: {x: 0, y: 0, z: 0, w: 1} + m_LocalPosition: {x: -1.51, y: 0, z: 3.39} + m_LocalScale: {x: 1, y: 1, z: 1} + m_Children: [] + m_Father: {fileID: 692811816} + m_RootOrder: 1 + m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} +--- !u!1 &1579373802 +GameObject: + m_ObjectHideFlags: 0 + m_PrefabParentObject: {fileID: 0} + m_PrefabInternal: {fileID: 0} + serializedVersion: 5 + m_Component: + - component: {fileID: 1579373806} + - component: {fileID: 1579373805} + - component: {fileID: 1579373804} + - component: {fileID: 1579373803} + m_Layer: 0 + m_Name: Sphere + m_TagString: Untagged + m_Icon: {fileID: 0} + m_NavMeshLayer: 0 + m_StaticEditorFlags: 0 + m_IsActive: 1 +--- !u!23 &1579373803 +MeshRenderer: + m_ObjectHideFlags: 0 + m_PrefabParentObject: {fileID: 0} + m_PrefabInternal: {fileID: 0} + m_GameObject: {fileID: 1579373802} + m_Enabled: 1 + m_CastShadows: 1 + m_ReceiveShadows: 1 + m_DynamicOccludee: 1 + m_MotionVectors: 1 + m_LightProbeUsage: 1 + m_ReflectionProbeUsage: 1 + m_Materials: + - {fileID: 10303, guid: 0000000000000000f000000000000000, type: 0} + m_StaticBatchInfo: + firstSubMesh: 0 + subMeshCount: 0 + m_StaticBatchRoot: {fileID: 0} + m_ProbeAnchor: {fileID: 0} + m_LightProbeVolumeOverride: {fileID: 0} + m_ScaleInLightmap: 1 + m_PreserveUVs: 1 + 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!135 &1579373804 +SphereCollider: + m_ObjectHideFlags: 0 + m_PrefabParentObject: {fileID: 0} + m_PrefabInternal: {fileID: 0} + m_GameObject: {fileID: 1579373802} + m_Material: {fileID: 0} + m_IsTrigger: 0 + m_Enabled: 1 + serializedVersion: 2 + m_Radius: 0.5 + m_Center: {x: 0, y: 0, z: 0} +--- !u!33 &1579373805 +MeshFilter: + m_ObjectHideFlags: 0 + m_PrefabParentObject: {fileID: 0} + m_PrefabInternal: {fileID: 0} + m_GameObject: {fileID: 1579373802} + m_Mesh: {fileID: 10207, guid: 0000000000000000e000000000000000, type: 0} +--- !u!4 &1579373806 +Transform: + m_ObjectHideFlags: 0 + m_PrefabParentObject: {fileID: 0} + m_PrefabInternal: {fileID: 0} + m_GameObject: {fileID: 1579373802} + m_LocalRotation: {x: -0, y: -0, z: -0, w: 1} + m_LocalPosition: {x: 0.52, y: 0, z: 3.35} + m_LocalScale: {x: 1, y: 1, z: 1} + m_Children: [] + m_Father: {fileID: 692811816} + m_RootOrder: 0 + m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} diff --git a/Assets/Examples/Scenes/Outline.unity.meta b/Assets/Examples/Scenes/Outline.unity.meta new file mode 100644 index 0000000..bb769c6 --- /dev/null +++ b/Assets/Examples/Scenes/Outline.unity.meta @@ -0,0 +1,9 @@ +fileFormatVersion: 2 +guid: e1f1f5e7ceb61b746b9f2016f0e53a93 +timeCreated: 1566127107 +licenseType: Free +DefaultImporter: + externalObjects: {} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/Examples/Scripts.meta b/Assets/Examples/Scripts.meta new file mode 100644 index 0000000..0b14ca7 --- /dev/null +++ b/Assets/Examples/Scripts.meta @@ -0,0 +1,10 @@ +fileFormatVersion: 2 +guid: 404ea2aedc6d1f24685d160324a2cb73 +folderAsset: yes +timeCreated: 1566127090 +licenseType: Free +DefaultImporter: + externalObjects: {} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/Examples/Scripts/OutlineEffectBuilder.cs b/Assets/Examples/Scripts/OutlineEffectBuilder.cs new file mode 100644 index 0000000..c02a9cc --- /dev/null +++ b/Assets/Examples/Scripts/OutlineEffectBuilder.cs @@ -0,0 +1,53 @@ +// Copyright (C) 2019 Alexander Bogarsukov. All rights reserved. +// See the LICENSE.md file in the project root for more information. + +using System; +using UnityEngine; + +namespace UnityFx.Outline.Examples +{ + /// + /// Helperr class for managing outlines from editor. + /// + [RequireComponent(typeof(OutlineEffect))] + public class OutlineEffectBuilder : MonoBehaviour + { + #region data + +#pragma warning disable 0649 + + [SerializeField] + private GameObject[] _outlineGos; + [SerializeField] + private int _outlineWidth = 5; + [SerializeField] + private Color _outlineColor = Color.red; + +#pragma warning restore 0649 + + private OutlineEffect _outlineEffect; + private OutlineLayer _outlineLayer; + + #endregion + + #region MonoBehaviour + + private void Awake() + { + _outlineEffect = GetComponent(); + _outlineLayer = _outlineEffect.AddLayer(); + } + + private void Update() + { + foreach (var go in _outlineGos) + { + _outlineLayer.OutlineColor = _outlineColor; + _outlineLayer.OutlineWidth = _outlineWidth; + _outlineLayer.Add(go); + } + } + + #endregion + } +} diff --git a/Assets/Examples/Scripts/OutlineEffectBuilder.cs.meta b/Assets/Examples/Scripts/OutlineEffectBuilder.cs.meta new file mode 100644 index 0000000..7150935 --- /dev/null +++ b/Assets/Examples/Scripts/OutlineEffectBuilder.cs.meta @@ -0,0 +1,13 @@ +fileFormatVersion: 2 +guid: 5a318c96b1bc1614683eccf7abd717a1 +timeCreated: 1566138009 +licenseType: Free +MonoImporter: + externalObjects: {} + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/Plugins.meta b/Assets/Plugins.meta new file mode 100644 index 0000000..aa18e8f --- /dev/null +++ b/Assets/Plugins.meta @@ -0,0 +1,10 @@ +fileFormatVersion: 2 +guid: eb53fafbd9395414e9244e0f7eb923ca +folderAsset: yes +timeCreated: 1566126961 +licenseType: Free +DefaultImporter: + externalObjects: {} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/Plugins/UnityFx.Outline.meta b/Assets/Plugins/UnityFx.Outline.meta new file mode 100644 index 0000000..c424a54 --- /dev/null +++ b/Assets/Plugins/UnityFx.Outline.meta @@ -0,0 +1,10 @@ +fileFormatVersion: 2 +guid: 766865668fa015b4494bbe7d5b6af917 +folderAsset: yes +timeCreated: 1566126961 +licenseType: Free +DefaultImporter: + externalObjects: {} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/Plugins/UnityFx.Outline/Runtime.meta b/Assets/Plugins/UnityFx.Outline/Runtime.meta new file mode 100644 index 0000000..d5034b4 --- /dev/null +++ b/Assets/Plugins/UnityFx.Outline/Runtime.meta @@ -0,0 +1,10 @@ +fileFormatVersion: 2 +guid: bc6bfa143e596d949867e28985573575 +folderAsset: yes +timeCreated: 1566126961 +licenseType: Free +DefaultImporter: + externalObjects: {} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/Plugins/UnityFx.Outline/Runtime/Scripts.meta b/Assets/Plugins/UnityFx.Outline/Runtime/Scripts.meta new file mode 100644 index 0000000..bfafa3d --- /dev/null +++ b/Assets/Plugins/UnityFx.Outline/Runtime/Scripts.meta @@ -0,0 +1,10 @@ +fileFormatVersion: 2 +guid: 5474ddc00e5e1574cba82c3dbad68ded +folderAsset: yes +timeCreated: 1566126961 +licenseType: Free +DefaultImporter: + externalObjects: {} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/Plugins/UnityFx.Outline/Runtime/Scripts/OutlineEffect.cs b/Assets/Plugins/UnityFx.Outline/Runtime/Scripts/OutlineEffect.cs new file mode 100644 index 0000000..2fe4c94 --- /dev/null +++ b/Assets/Plugins/UnityFx.Outline/Runtime/Scripts/OutlineEffect.cs @@ -0,0 +1,232 @@ +// Copyright (C) 2019 Alexander Bogarsukov. All rights reserved. +// See the LICENSE.md file in the project root for more information. + +using System; +using System.Collections.Generic; +using UnityEngine; +using UnityEngine.Rendering; + +namespace UnityFx.Outline +{ + /// + /// Post-effect script. Should be attached to camera. + /// + /// + /// + public sealed class OutlineEffect : MonoBehaviour + { + #region data + + private const string _effectName = "Outline"; + +#pragma warning disable 0649 + + [SerializeField] + private Shader _renderColorShader; + [SerializeField] + private Shader _postProcessShader; + +#pragma warning restore 0649 + + private List _layers; + private CommandBuffer _commandBuffer; + private Material _renderMaterial; + + #endregion + + #region interface + + /// + /// Gets or sets a that renders objects outlined with a solid while color. + /// + public Shader RenderColorShader + { + get + { + return _renderColorShader; + } + set + { + if (value == null) + { + throw new ArgumentNullException("RenderColorShader"); + } + + if (_renderColorShader != value) + { + _renderColorShader = value; + + if (_renderMaterial) + { + _renderMaterial.shader = value; + } + } + } + } + + /// + /// Gets or sets a that renders outline around the mask, generated by . + /// + public Shader PostProcessShader + { + get + { + return _postProcessShader; + } + set + { + if (value == null) + { + throw new ArgumentNullException("PostProcessShader"); + } + + if (_postProcessShader != value) + { + _postProcessShader = value; + + foreach (var layers in _layers) + { + layers.PostProcessMaterial.shader = _postProcessShader; + } + } + } + } + + /// + /// Gets all registered outlie layers. + /// + public IEnumerable Layers + { + get + { + if (_layers == null) + { + _layers = new List(); + } + + return _layers; + } + } + + /// + /// Creates a new outlie layer. + /// + public OutlineLayer AddLayer() + { + if (_layers == null) + { + _layers = new List(); + } + + if (_renderMaterial == null) + { + _renderMaterial = new Material(_renderColorShader); + } + + var layer = new OutlineLayer(_renderMaterial, new Material(_postProcessShader)); + _layers.Add(layer); + return layer; + } + + /// + /// Removes the specified layer. + /// + public void RemoveLayer(OutlineLayer layer) + { + if (_layers != null) + { + _layers.Remove(layer); + } + } + + /// + /// Removes all layers. + /// + public void RemoveAllLayers() + { + if (_layers != null) + { + _layers.Clear(); + } + } + + #endregion + + #region MonoBehaviour + + private void OnEnable() + { + var camera = GetComponent(); + + if (camera) + { + _commandBuffer = new CommandBuffer(); + _commandBuffer.name = _effectName; + + FillCommandBuffer(_commandBuffer); + + camera.AddCommandBuffer(CameraEvent.BeforeImageEffects, _commandBuffer); + } + } + + private void OnDisable() + { + var camera = GetComponent(); + + if (camera) + { + camera.RemoveCommandBuffer(CameraEvent.BeforeImageEffects, _commandBuffer); + } + + if (_commandBuffer != null) + { + _commandBuffer.Dispose(); + _commandBuffer = null; + } + } + + private void Update() + { + var needUpdate = false; + + foreach (var layer in _layers) + { + if (layer.IsChanged) + { + needUpdate = true; + break; + } + } + + if (needUpdate) + { + FillCommandBuffer(_commandBuffer); + } + } + + #endregion + + #region implementation + + private void FillCommandBuffer(CommandBuffer cmdbuf) + { + var rtId = Shader.PropertyToID("_MainTex"); + var rt = new RenderTargetIdentifier(rtId); + var dst = new RenderTargetIdentifier(BuiltinRenderTextureType.CameraTarget); + + cmdbuf.BeginSample(_effectName); + cmdbuf.Clear(); + cmdbuf.GetTemporaryRT(rtId, -1, -1, 0, FilterMode.Bilinear, RenderTextureFormat.R8); + + foreach (var layer in _layers) + { + layer.FillCommandBuffer(cmdbuf, rt, dst); + } + + cmdbuf.ReleaseTemporaryRT(rtId); + cmdbuf.EndSample(_effectName); + } + + #endregion + } +} diff --git a/Assets/Plugins/UnityFx.Outline/Runtime/Scripts/OutlineEffect.cs.meta b/Assets/Plugins/UnityFx.Outline/Runtime/Scripts/OutlineEffect.cs.meta new file mode 100644 index 0000000..176f249 --- /dev/null +++ b/Assets/Plugins/UnityFx.Outline/Runtime/Scripts/OutlineEffect.cs.meta @@ -0,0 +1,17 @@ +fileFormatVersion: 2 +guid: 270d3185d159bf54fb4cddbb42235437 +timeCreated: 1566137875 +licenseType: Free +MonoImporter: + externalObjects: {} + serializedVersion: 2 + defaultReferences: + - _renderColorShader: {fileID: 4800000, guid: ac20fbf75bafe454aba5ef3c098349df, + type: 3} + - _postProcessShader: {fileID: 4800000, guid: 41c9acbf41c8245498ac9beab378de12, + type: 3} + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/Plugins/UnityFx.Outline/Runtime/Scripts/OutlineLayer.cs b/Assets/Plugins/UnityFx.Outline/Runtime/Scripts/OutlineLayer.cs new file mode 100644 index 0000000..21eb626 --- /dev/null +++ b/Assets/Plugins/UnityFx.Outline/Runtime/Scripts/OutlineLayer.cs @@ -0,0 +1,268 @@ +// Copyright (C) 2019 Alexander Bogarsukov. All rights reserved. +// See the LICENSE.md file in the project root for more information. + +using System; +using System.Collections; +using System.Collections.Generic; +using UnityEngine; +using UnityEngine.Rendering; + +namespace UnityFx.Outline +{ + /// + /// A single outline layer. + /// + /// + public sealed class OutlineLayer : ICollection + { + #region data + + private const string _outlineColorParamName = "_Color"; + private const string _outlineWidthParamName = "_Width"; + + private readonly Material _renderMaterial; + private readonly Material _postProcessMaterial; + private readonly Dictionary _outlineObjects = new Dictionary(); + + private Color _outlineColor = Color.green; + private int _outlineWidth = 5; + private bool _changed = true; + + #endregion + + #region interface + + /// + /// Gets or sets outline color for the layer. + /// + /// + public Color OutlineColor + { + get + { + return _outlineColor; + } + set + { + if (_outlineColor != value) + { + _outlineColor = value; + _postProcessMaterial.SetColor(_outlineColorParamName, value); + _changed = true; + } + } + } + + /// + /// Gets or sets outline width in pixels. Only positive values are allowed. + /// + /// + public int OutlineWidth + { + get + { + return _outlineWidth; + } + set + { + if (value <= 0) + { + throw new ArgumentOutOfRangeException("OutlineWidth"); + } + + if (_outlineWidth != value) + { + _outlineWidth = value; + _postProcessMaterial.SetInt(_outlineWidthParamName, value); + _changed = true; + } + } + } + + /// + /// Gets a value indicating whether the layer contains unapplied changes. + /// + public bool IsChanged + { + get + { + return _changed; + } + } + + /// + /// Gets the material used for outline rendering. + /// + internal Material PostProcessMaterial + { + get + { + return _postProcessMaterial; + } + } + + /// + /// Initializes a new instance of the class. + /// + internal OutlineLayer(Material renderMaterial, Material postProcessMaterial) + { + Debug.Assert(renderMaterial); + Debug.Assert(postProcessMaterial); + + _renderMaterial = renderMaterial; + _postProcessMaterial = postProcessMaterial; + _postProcessMaterial.SetColor(_outlineColorParamName, _outlineColor); + _postProcessMaterial.SetInt(_outlineWidthParamName, _outlineWidth); + } + + /// + /// Adds a new object to the layer. + /// + public void Add(GameObject go, int ignoreLayerMask) + { + if (go == null) + { + throw new ArgumentNullException("go"); + } + + if (!_outlineObjects.ContainsKey(go)) + { + var renderers = go.GetComponentsInChildren(); + + if (renderers != null) + { + if (renderers.Length > 0 && ignoreLayerMask != 0) + { + var filteredRenderers = new List(renderers.Length); + + for (var i = 0; i < renderers.Length; ++i) + { + if ((renderers[i].gameObject.layer & ignoreLayerMask) == 0) + { + filteredRenderers.Add(renderers[i]); + } + } + + renderers = filteredRenderers.ToArray(); + } + } + else + { + renderers = new Renderer[0]; + } + + _outlineObjects.Add(go, renderers); + _changed = true; + } + } + + /// + /// Renders the layer into the passed. + /// + internal void FillCommandBuffer(CommandBuffer commandBuffer, RenderTargetIdentifier rt, RenderTargetIdentifier dst) + { + Debug.Assert(commandBuffer != null); + + foreach (var kvp in _outlineObjects) + { + if (kvp.Key) + { + commandBuffer.SetRenderTarget(rt); + commandBuffer.ClearRenderTarget(false, true, Color.black); + + foreach (var renderer in kvp.Value) + { + if (renderer) + { + for (var i = 0; i < renderer.sharedMaterials.Length; ++i) + { + commandBuffer.DrawRenderer(renderer, _renderMaterial, i); + } + } + } + + commandBuffer.Blit(rt, dst, _postProcessMaterial); + } + } + + _changed = false; + } + + #endregion + + #region ICollection + + /// + public int Count + { + get + { + return _outlineObjects.Count; + } + } + + /// + public bool IsReadOnly + { + get + { + return false; + } + } + + /// + public void Add(GameObject go) + { + Add(go, 0); + } + + /// + public bool Remove(GameObject go) + { + if (_outlineObjects.Remove(go)) + { + _changed = true; + } + + return false; + } + + /// + public bool Contains(GameObject go) + { + return _outlineObjects.ContainsKey(go); + } + + /// + public void Clear() + { + _outlineObjects.Clear(); + _changed = true; + } + + /// + public void CopyTo(GameObject[] array, int arrayIndex) + { + _outlineObjects.Keys.CopyTo(array, arrayIndex); + } + + #endregion + + #region IEnumerable + + public IEnumerator GetEnumerator() + { + return _outlineObjects.Keys.GetEnumerator(); + } + + IEnumerator IEnumerable.GetEnumerator() + { + return _outlineObjects.Keys.GetEnumerator(); + } + + #endregion + + #region implementation + #endregion + } +} diff --git a/Assets/Plugins/UnityFx.Outline/Runtime/Scripts/OutlineLayer.cs.meta b/Assets/Plugins/UnityFx.Outline/Runtime/Scripts/OutlineLayer.cs.meta new file mode 100644 index 0000000..f199256 --- /dev/null +++ b/Assets/Plugins/UnityFx.Outline/Runtime/Scripts/OutlineLayer.cs.meta @@ -0,0 +1,13 @@ +fileFormatVersion: 2 +guid: 1360e19784ddfac45a7dcb6ba39595ed +timeCreated: 1566130871 +licenseType: Free +MonoImporter: + externalObjects: {} + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/Plugins/UnityFx.Outline/Runtime/Shaders.meta b/Assets/Plugins/UnityFx.Outline/Runtime/Shaders.meta new file mode 100644 index 0000000..bf1ab62 --- /dev/null +++ b/Assets/Plugins/UnityFx.Outline/Runtime/Shaders.meta @@ -0,0 +1,10 @@ +fileFormatVersion: 2 +guid: e4ede0e617beaeb4a8781136599aa84e +folderAsset: yes +timeCreated: 1566126961 +licenseType: Free +DefaultImporter: + externalObjects: {} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/Plugins/UnityFx.Outline/Runtime/Shaders/OutlinePostProcess.shader b/Assets/Plugins/UnityFx.Outline/Runtime/Shaders/OutlinePostProcess.shader new file mode 100644 index 0000000..321ffef --- /dev/null +++ b/Assets/Plugins/UnityFx.Outline/Runtime/Shaders/OutlinePostProcess.shader @@ -0,0 +1,89 @@ +// Copyright (C) 2019 Alexander Bogarsukov. All rights reserved. +// See the LICENSE.md file in the project root for more information. + +// Renders outline based on a texture produces by 'UnityF/Outline/RenderColor' output. +// Modified version of 'Custom/Post Outline' shader taken from https://willweissman.wordpress.com/tutorials/shaders/unity-shaderlab-object-outlines/. + +// TODO: Blur the outline. +Shader "UnityFx/Outline/PostProcess" +{ + Properties + { + _Color("Outline Color", Color) = (1, 0, 0, 1) + _Width("Outline Thickness", Range(1, 30)) = 5 + _MainTex("Main Texture", 2D) = "white"{} + } + + SubShader + { + Blend SrcAlpha OneMinusSrcAlpha + + Pass + { + CGPROGRAM + + #pragma vertex vert + #pragma fragment frag + #include "UnityCG.cginc" + + sampler2D _MainTex; + + // _TexelSize is a float2 that says how much screen space a texel occupies. + float2 _MainTex_TexelSize; + float4 _Color; + int _Width; + + struct v2f + { + float4 pos : POSITION; + float2 uvs : TEXCOORD0; + }; + + v2f vert(appdata_base v) + { + v2f o; + + // Despite the fact that we are only drawing a quad to the screen, Unity requires us to multiply vertices by our MVP matrix, presumably to keep things working when inexperienced people try copying code from other shaders. + o.pos = UnityObjectToClipPos(v.vertex); + + // Also, we need to fix the UVs to match our screen space coordinates. + o.uvs = ComputeScreenPos(o.pos); + + return o; + } + + half4 frag(v2f i) : COLOR + { + // If something already exists underneath the fragment, discard the fragment. + if (tex2D(_MainTex, i.uvs.xy).r > 0) + { + discard; + } + + // Split texel size into smaller words. + float TX_x = _MainTex_TexelSize.x; + float TX_y = _MainTex_TexelSize.y; + + // And a final intensity that increments based on surrounding intensities. + float colorIntensityInRadius; + + int n = _Width; + + // For every iteration we need to do horizontally. + for (int k = 0; k < n; k += 1) + { + // For every iteration we need to do vertically. + for (int j = 0; j < n; j += 1) + { + // Increase our output color by the pixels in the area. + colorIntensityInRadius += tex2D(_MainTex, i.uvs.xy + float2((k - (float)n / 2) * TX_x, (j - (float)n / 2) * TX_y)).r; + } + } + + return colorIntensityInRadius * _Color; + } + + ENDCG + } + } +} diff --git a/Assets/Plugins/UnityFx.Outline/Runtime/Shaders/OutlinePostProcess.shader.meta b/Assets/Plugins/UnityFx.Outline/Runtime/Shaders/OutlinePostProcess.shader.meta new file mode 100644 index 0000000..bb55354 --- /dev/null +++ b/Assets/Plugins/UnityFx.Outline/Runtime/Shaders/OutlinePostProcess.shader.meta @@ -0,0 +1,10 @@ +fileFormatVersion: 2 +guid: 41c9acbf41c8245498ac9beab378de12 +timeCreated: 1566126977 +licenseType: Free +ShaderImporter: + externalObjects: {} + defaultTextures: [] + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/Plugins/UnityFx.Outline/Runtime/Shaders/OutlineRenderColor.shader b/Assets/Plugins/UnityFx.Outline/Runtime/Shaders/OutlineRenderColor.shader new file mode 100644 index 0000000..2d81bf9 --- /dev/null +++ b/Assets/Plugins/UnityFx.Outline/Runtime/Shaders/OutlineRenderColor.shader @@ -0,0 +1,41 @@ +// Copyright (C) 2019 Alexander Bogarsukov. All rights reserved. +// See the LICENSE.md file in the project root for more information. + +// Renders everything with while color. +// Modified version of 'Custom/DrawSimple' shader taken from https://willweissman.wordpress.com/tutorials/shaders/unity-shaderlab-object-outlines/. +Shader "UnityFx/Outline/RenderColor" +{ + SubShader + { + ZWrite Off + ZTest Always + Lighting Off + + Pass + { + CGPROGRAM + + #pragma vertex vert + #pragma fragment frag + + struct v2f + { + float4 pos: POSITION; + }; + + v2f vert(v2f i) + { + v2f o; + o.pos = UnityObjectToClipPos(i.pos); + return o; + } + + half4 frag(): COLOR0 + { + return half4(1, 1, 1, 1); + } + + ENDCG + } + } +} diff --git a/Assets/Plugins/UnityFx.Outline/Runtime/Shaders/OutlineRenderColor.shader.meta b/Assets/Plugins/UnityFx.Outline/Runtime/Shaders/OutlineRenderColor.shader.meta new file mode 100644 index 0000000..66aa3a2 --- /dev/null +++ b/Assets/Plugins/UnityFx.Outline/Runtime/Shaders/OutlineRenderColor.shader.meta @@ -0,0 +1,10 @@ +fileFormatVersion: 2 +guid: ac20fbf75bafe454aba5ef3c098349df +timeCreated: 1566126977 +licenseType: Free +ShaderImporter: + externalObjects: {} + defaultTextures: [] + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/Plugins/UnityFx.Outline/Runtime/UnityFx.Tasks.asmdef b/Assets/Plugins/UnityFx.Outline/Runtime/UnityFx.Tasks.asmdef new file mode 100644 index 0000000..af0702d --- /dev/null +++ b/Assets/Plugins/UnityFx.Outline/Runtime/UnityFx.Tasks.asmdef @@ -0,0 +1,3 @@ +{ + "name": "UnityFx.Outline" +} diff --git a/Assets/Plugins/UnityFx.Outline/Runtime/UnityFx.Tasks.asmdef.meta b/Assets/Plugins/UnityFx.Outline/Runtime/UnityFx.Tasks.asmdef.meta new file mode 100644 index 0000000..6a74c49 --- /dev/null +++ b/Assets/Plugins/UnityFx.Outline/Runtime/UnityFx.Tasks.asmdef.meta @@ -0,0 +1,9 @@ +fileFormatVersion: 2 +guid: de7ed7f8e7092c144bd17cbabf282ba3 +timeCreated: 1566126961 +licenseType: Free +DefaultImporter: + externalObjects: {} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/Plugins/UnityFx.Outline/package.json b/Assets/Plugins/UnityFx.Outline/package.json new file mode 100644 index 0000000..afa83bf --- /dev/null +++ b/Assets/Plugins/UnityFx.Outline/package.json @@ -0,0 +1,27 @@ +{ + "name": "com.unityfx.outline", + "version": "0.1.0", + "displayName": "Outline post-effect for Unity", + "description": "Provides Unity helpers for outline rendering.", + "unity": "2017.2", + "keywords": [ + "UnityFx", + "UnityFx.Outline", + "outline", + "post-effect" + ], + "category": "UnityFx", + "author": { + "name": "Arvtesh", + "email": "arvtesh@gmail.com" + }, + "license": "MIT", + "homepage": "https://github.com/Arvtesh/UnityFx.Outline", + "repository": { + "type": "git", + "url": "https://github.com/Arvtesh/UnityFx.Outline.git" + }, + "bugs": { + "url": "https://github.com/Arvtesh/UnityFx.Outline/issues" + } +} diff --git a/Assets/Plugins/UnityFx.Outline/package.json.meta b/Assets/Plugins/UnityFx.Outline/package.json.meta new file mode 100644 index 0000000..d824967 --- /dev/null +++ b/Assets/Plugins/UnityFx.Outline/package.json.meta @@ -0,0 +1,9 @@ +fileFormatVersion: 2 +guid: 411b5b9873de2d244ac737335a5117d6 +timeCreated: 1566126977 +licenseType: Free +TextScriptImporter: + externalObjects: {} + userData: + assetBundleName: + assetBundleVariant: diff --git a/CHANGELOG.md b/CHANGELOG.md new file mode 100644 index 0000000..cf1e0bc --- /dev/null +++ b/CHANGELOG.md @@ -0,0 +1,10 @@ +# UnityFx.Outline changelog +All notable changes to this project will be documented in this file. + +The format is based on [Keep a Changelog](http://keepachangelog.com/); this project adheres to [Semantic Versioning](http://semver.org/). + +## [0.1.0] - Unreleased + +### Added +- Initial release. + diff --git a/LICENSE b/LICENSE deleted file mode 100644 index 1dd35c2..0000000 --- a/LICENSE +++ /dev/null @@ -1,21 +0,0 @@ -MIT License - -Copyright (c) 2019 Arvtesh - -Permission is hereby granted, free of charge, to any person obtaining a copy -of this software and associated documentation files (the "Software"), to deal -in the Software without restriction, including without limitation the rights -to use, copy, modify, merge, publish, distribute, sublicense, and/or sell -copies of the Software, and to permit persons to whom the Software is -furnished to do so, subject to the following conditions: - -The above copyright notice and this permission notice shall be included in all -copies or substantial portions of the Software. - -THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, -OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE -SOFTWARE. diff --git a/LICENSE.md b/LICENSE.md new file mode 100644 index 0000000..b9229bd --- /dev/null +++ b/LICENSE.md @@ -0,0 +1,9 @@ +# MIT License + +Copyright (c) 2019 Alexander Bogarsukov. + +Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. diff --git a/README.md b/README.md index ba76ff2..d6bacac 100644 --- a/README.md +++ b/README.md @@ -1,2 +1,72 @@ # UnityFx.Outline -Outline post-effect for Unity3d + +Channel | UnityFx.Outline | +---------|---------------| +Github | [![GitHub release](https://img.shields.io/github/release/Arvtesh/UnityFx.Outline.svg?logo=github)](https://github.com/Arvtesh/UnityFx.Outline/releases) +Npm | [![Npm release](https://img.shields.io/npm/v/com.unityfx.outline.svg)](https://www.npmjs.com/package/com.unityfx.outline) ![npm](https://img.shields.io/npm/dt/com.unityfx.outline) + +**Requires Unity 2017 or higher.** + +## Synopsis + +*UnityFx.Outline* defines tools that can be used to render outline post-effect. + +Please see [CHANGELOG](CHANGELOG.md) for information on recent changes. + +## Getting Started +### Prerequisites +You may need the following software installed in order to build/use the library: +- [Unity3d](https://store.unity.com/). + +### Getting the code +You can get the code by cloning the github repository using your preffered git client UI or you can do it from command line as follows: +```cmd +git clone https://github.com/Arvtesh/UnityFx.Outline.git +``` + +### Npm package + +Npm package is available at [npmjs.com](https://www.npmjs.com/package/com.unityfx.outline). To use it, add the following line to dependencies section of your `manifest.json`. Unity should download and link the package automatically: +```json +{ + "scopedRegistries": [ + { + "name": "Arvtesh", + "url": "https://registry.npmjs.org/", + "scopes": [ + "com.unityfx" + ] + } + ], + "dependencies": { + "com.unityfx.outline": "0.1.0" + } +} +``` + +## Understanding the concepts +TODO + +## Motivation +The project was initially created to help author with his [Unity3d](https://unity3d.com) projects. There are not many reusable open-source examples of it, so here it is. Hope it will be useful for someone. + +## Documentation +Please see the links below for extended information on the product: +- [Unity forums](https://forum.unity.com/threads/TODO/). +- [CHANGELOG](CHANGELOG.md). +- [SUPPORT](.github/SUPPORT.md). + +## Useful links +- [A great outline tutorial](https://willweissman.wordpress.com/tutorials/shaders/unity-shaderlab-object-outlines/). +- [Command buffers tutorial](https://lindenreid.wordpress.com/2018/09/13/using-command-buffers-in-unity-selective-bloom/). +- [Gaussian blur tutorial](https://www.ronja-tutorials.com/2018/08/27/postprocessing-blur.html). +- [Gaussian blur 2](http://rastergrid.com/blog/2010/09/efficient-gaussian-blur-with-linear-sampling/). + +## Contributing +Please see [contributing guide](.github/CONTRIBUTING.md) for details. + +## Versioning +The project uses [SemVer](https://semver.org/) versioning pattern. For the versions available, see [tags in this repository](https://github.com/Arvtesh/UnityFx.Outline/tags). + +## License +Please see the [![license](https://img.shields.io/github/license/Arvtesh/UnityFx.Outline.svg)](LICENSE.md) for details.