This commit is contained in:
taosuqi 2025-11-17 15:51:24 +08:00
parent eaf19ac938
commit d111221bd8
167 changed files with 23697 additions and 0 deletions

View File

@ -0,0 +1,12 @@
fileFormatVersion: 2
guid: eaf7f56fbcfa343efb5081d4309cb76b
timeCreated: 1548711355
licenseType: Store
MonoImporter:
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

View File

@ -0,0 +1,92 @@
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.Rendering;
using UnityEditor;
namespace HighlightPlus {
public class TransparentWithDepth {
static Material bmDepthOnly;
[MenuItem ("GameObject/Effects/Highlight Plus/Add Depth To Transparent Object", false, 100)]
static void AddDepthOption () {
Renderer renderer = GetRenderer ();
if (renderer == null)
return;
if (!EditorUtility.DisplayDialog ("Add Depth To Transparent Object", "This option will force the transparent object to write to the depth buffer by adding a new special material to the renderer (existing materials are preserved) so it can occlude and allow See-Through effect.\nOnly use on transparent objects.\n\nProceed?", "Yes", "No")) {
return;
}
Material[] materials = renderer.sharedMaterials;
for (int k = 0; k < materials.Length; k++) {
if (materials [k] == bmDepthOnly) {
EditorUtility.DisplayDialog ("Depth Support", "Already set! Nothing to do.", "Ok");
return;
}
}
if (materials == null) {
renderer.sharedMaterial = bmDepthOnly;
} else {
List<Material> newMaterials = new List<Material> (materials);
newMaterials.Insert (0, bmDepthOnly);
renderer.sharedMaterials = newMaterials.ToArray ();
}
}
[MenuItem ("GameObject/Effects/Highlight Plus/Remove Depth Compatibility", false, 101)]
static void RemoveDepthOption () {
Renderer renderer = GetRenderer ();
if (renderer == null)
return;
Material[] materials = renderer.sharedMaterials;
for (int k = 0; k < materials.Length; k++) {
if (materials [k] == bmDepthOnly) {
List<Material> newMaterials = new List<Material> (renderer.sharedMaterials);
newMaterials.RemoveAt (k);
renderer.sharedMaterials = newMaterials.ToArray ();
return;
}
}
for (int k = 0; k < materials.Length; k++) {
if (materials [k] == bmDepthOnly) {
EditorUtility.DisplayDialog ("Depth Support", "This object was not previously modified! Nothing to do.", "Ok");
return;
}
}
}
static Renderer GetRenderer () {
if (Selection.activeGameObject == null) {
EditorUtility.DisplayDialog ("Depth Support", "This option can only be used on GameObjects.", "Ok");
return null;
}
Renderer renderer = Selection.activeGameObject.GetComponent<Renderer> ();
if (renderer == null) {
EditorUtility.DisplayDialog ("Depth Support", "This option can only be used on GameObjects with a Renderer component attached.", "Ok");
return null;
}
if (bmDepthOnly == null) {
bmDepthOnly = Resources.Load<Material> ("HighlightPlus/HighlightPlusDepthWrite");
if (bmDepthOnly == null) {
EditorUtility.DisplayDialog ("Depth Support", "HighlightPlusDepthWrite material not found!", "Ok");
return null;
}
}
return renderer;
}
}
}

View File

@ -0,0 +1,13 @@
fileFormatVersion: 2
guid: be6e3be6d17ed49a3bd16d816815d6fd
timeCreated: 1515683694
licenseType: Store
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

View File

@ -0,0 +1,8 @@
fileFormatVersion: 2
guid: 3302310c4cbf644e2b5dc5c588f0213f
folderAsset: yes
DefaultImporter:
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant:

View File

@ -0,0 +1,8 @@
fileFormatVersion: 2
guid: 6ec7787befe3645f7a6f10c3762dc3df
folderAsset: yes
DefaultImporter:
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant:

View File

@ -0,0 +1,95 @@
%YAML 1.1
%TAG !u! tag:unity3d.com,2011:
--- !u!114 &-7137549924450841197
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: 473a86c9e274347dfbdde619584cebe9, type: 3}
m_Name: NewHighlightPlusRenderPassFeature
m_EditorClassIdentifier:
m_Active: 1
renderPassEvent: 500
clearStencil: 0
--- !u!114 &-1700769429572189234
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: a1614fc811f8f184697d9bee70ab9fe5, type: 3}
m_Name: DecalRendererFeature
m_EditorClassIdentifier:
m_Active: 1
m_Settings:
technique: 0
maxDrawDistance: 1000
dBufferSettings:
surfaceData: 2
screenSpaceSettings:
normalBlend: 0
useGBuffer: 1
m_CopyDepthPS: {fileID: 4800000, guid: d6dae50ee9e1bfa4db75f19f99355220, type: 3}
m_DBufferClear: {fileID: 4800000, guid: f056d8bd2a1c7e44e9729144b4c70395, type: 3}
--- !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: HighlightPlusForwardRenderer
m_EditorClassIdentifier:
debugShaders:
debugReplacementPS: {fileID: 4800000, guid: cf852408f2e174538bcd9b7fda1c5ae7, type: 3}
m_RendererFeatures:
- {fileID: -7137549924450841197}
- {fileID: -1700769429572189234}
m_RendererFeatureMap: ce83810137a765e8e48b81e159787579
m_UseNativeRenderPass: 0
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}
stencilDeferredPS: {fileID: 4800000, guid: e9155b26e1bc55942a41e518703fe304, type: 3}
fallbackErrorPS: {fileID: 4800000, guid: e6e9a19c3678ded42a3bc431ebef7dbd, type: 3}
materialErrorPS: {fileID: 4800000, guid: 5fd9a8feb75a4b5894c241777f519d4e, type: 3}
coreBlitPS: {fileID: 4800000, guid: 93446b5c5339d4f00b85c159e1159b7c, type: 3}
coreBlitColorAndDepthPS: {fileID: 4800000, guid: d104b2fc1ca6445babb8e90b0758136b, type: 3}
cameraMotionVector: {fileID: 4800000, guid: c56b7e0d4c7cb484e959caeeedae9bbf, type: 3}
objectMotionVector: {fileID: 4800000, guid: 7b3ede40266cd49a395def176e1bc486, type: 3}
m_AssetVersion: 2
m_OpaqueLayerMask:
serializedVersion: 2
m_Bits: 4294967295
m_TransparentLayerMask:
serializedVersion: 2
m_Bits: 4294967295
m_DefaultStencilState:
overrideStencilState: 0
stencilReference: 0
stencilCompareFunction: 8
passOperation: 0
failOperation: 0
zFailOperation: 0
m_ShadowTransparentReceive: 1
m_RenderingMode: 0
m_DepthPrimingMode: 0
m_CopyDepthMode: 0
m_AccurateGbufferNormals: 0
m_ClusteredRendering: 0
m_TileSize: 32
m_IntermediateTextureMode: 1

View File

@ -0,0 +1,8 @@
fileFormatVersion: 2
guid: 47db18f3169384f6b87445e6447e189e
NativeFormatImporter:
externalObjects: {}
mainObjectFileID: 0
userData:
assetBundleName:
assetBundleVariant:

View File

@ -0,0 +1,135 @@
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.Rendering;
using UnityEngine.Rendering.Universal;
namespace HighlightPlus {
public class HighlightPlusRenderPassFeature : ScriptableRendererFeature {
class HighlightPass : ScriptableRenderPass {
// far objects render first
class DistanceComparer : IComparer<HighlightEffect> {
public Vector3 camPos;
public int Compare(HighlightEffect e1, HighlightEffect e2) {
Vector3 e1Pos = e1 == null ? Vector3.zero : e1.transform.position;
float dx1 = e1Pos.x - camPos.x;
float dy1 = e1Pos.y - camPos.y;
float dz1 = e1Pos.z - camPos.z;
float distE1 = dx1 * dx1 + dy1 * dy1 + dz1 * dz1;
Vector3 e2Pos = e2 == null ? Vector3.zero : e2.transform.position;
float dx2 = e2Pos.x - camPos.x;
float dy2 = e2Pos.y - camPos.y;
float dz2 = e2Pos.z - camPos.z;
float distE2 = dx2 * dx2 + dy2 * dy2 + dz2 * dz2;
if (distE1 > distE2) return -1;
if (distE1 < distE2) return 1;
return 0;
}
}
public bool usesCameraOverlay = false;
ScriptableRenderer renderer;
RenderTextureDescriptor cameraTextureDescriptor;
DistanceComparer effectDistanceComparer;
static bool isVREnabled;
bool clearStencil;
FullScreenBlitMethod fullScreenBlitMethod = FullScreenBlit;
public void Setup(HighlightPlusRenderPassFeature passFeature, ScriptableRenderer renderer) {
this.renderPassEvent = passFeature.renderPassEvent;
this.clearStencil = passFeature.clearStencil;
this.renderer = renderer;
if (effectDistanceComparer == null) {
effectDistanceComparer = new DistanceComparer();
}
isVREnabled = UnityEngine.XR.XRSettings.enabled && Application.isPlaying;
}
public override void Configure(CommandBuffer cmd, RenderTextureDescriptor cameraTextureDescriptor) {
this.cameraTextureDescriptor = cameraTextureDescriptor;
#if UNITY_2021_2_OR_NEWER
ConfigureInput(ScriptableRenderPassInput.Depth);
#endif
}
public override void Execute(ScriptableRenderContext context, ref RenderingData renderingData) {
Camera cam = renderingData.cameraData.camera;
int camLayer = 1 << cam.gameObject.layer;
RenderTargetIdentifier cameraColorTarget = renderer.cameraColorTarget;
RenderTargetIdentifier cameraDepthTarget = renderer.cameraDepthTarget;
#if !UNITY_2021_2_OR_NEWER
// In Unity 2021.2, when MSAA > 1, cameraDepthTarget is no longer cameraColorTarget
if (!usesCameraOverlay && (cameraTextureDescriptor.msaaSamples > 1 || cam.cameraType == CameraType.SceneView)) {
cameraDepthTarget = cameraColorTarget;
}
#endif
if (!HighlightEffect.customSorting && (Time.frameCount % 10 == 0 || !Application.isPlaying)) {
effectDistanceComparer.camPos = cam.transform.position;
HighlightEffect.effects.Sort(effectDistanceComparer);
}
int count = HighlightEffect.effects.Count;
bool clearStencil = this.clearStencil;
for (int k = 0; k < count; k++) {
HighlightEffect effect = HighlightEffect.effects[k];
if (effect.isActiveAndEnabled) {
if ((effect.camerasLayerMask & camLayer) == 0) continue;
CommandBuffer cb = effect.GetCommandBuffer(cam, cameraColorTarget, cameraDepthTarget, fullScreenBlitMethod, clearStencil);
if (cb != null) {
context.ExecuteCommandBuffer(cb);
clearStencil = false;
}
}
}
}
static Matrix4x4 matrix4x4identity = Matrix4x4.identity;
static void FullScreenBlit(CommandBuffer cmd, RenderTargetIdentifier source, RenderTargetIdentifier destination, Material material, int passIndex) {
destination = new RenderTargetIdentifier(destination, 0, CubemapFace.Unknown, -1);
cmd.SetRenderTarget(destination);
cmd.SetGlobalTexture(ShaderParams.MainTex, source);
cmd.SetGlobalFloat(ShaderParams.AspectRatio, isVREnabled ? 0.5f : 1);
cmd.DrawMesh(RenderingUtils.fullscreenMesh, matrix4x4identity, material, 0, passIndex);
}
public override void FrameCleanup(CommandBuffer cmd) {
}
}
HighlightPass renderPass;
public RenderPassEvent renderPassEvent = RenderPassEvent.AfterRenderingTransparents;
[Tooltip("Clears stencil buffer before rendering highlight effects. This option can solve compatibility issues with shaders that also use stencil buffers.")]
public bool clearStencil;
public static bool installed;
void OnDisable() {
installed = false;
}
public override void Create() {
renderPass = new HighlightPass();
}
// This method is called when setting up the renderer once per-camera.
public override void AddRenderPasses(ScriptableRenderer renderer, ref RenderingData renderingData) {
#if UNITY_2019_4_OR_NEWER
if (renderingData.cameraData.renderType == CameraRenderType.Base) {
Camera cam = renderingData.cameraData.camera;
renderPass.usesCameraOverlay = cam.GetUniversalAdditionalCameraData().cameraStack.Count > 0;
}
#endif
renderPass.Setup(this, renderer);
renderer.EnqueuePass(renderPass);
installed = true;
}
}
}

View File

@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: 473a86c9e274347dfbdde619584cebe9
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

View File

@ -0,0 +1,75 @@
%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: bf2edee5c58d82540a51f03df9d42094, type: 3}
m_Name: UniversalRenderPipelineAsset
m_EditorClassIdentifier:
k_AssetVersion: 9
k_AssetPreviousVersion: 9
m_RendererType: 1
m_RendererData: {fileID: 0}
m_RendererDataList:
- {fileID: 11400000, guid: 47db18f3169384f6b87445e6447e189e, type: 2}
m_DefaultRendererIndex: 0
m_RequireDepthTexture: 1
m_RequireOpaqueTexture: 0
m_OpaqueDownsampling: 1
m_SupportsTerrainHoles: 1
m_StoreActionsOptimization: 0
m_SupportsHDR: 1
m_MSAA: 2
m_RenderScale: 1
m_UpscalingFilter: 0
m_FsrOverrideSharpness: 0
m_FsrSharpness: 0.92
m_MainLightRenderingMode: 1
m_MainLightShadowsSupported: 1
m_MainLightShadowmapResolution: 2048
m_AdditionalLightsRenderingMode: 1
m_AdditionalLightsPerObjectLimit: 4
m_AdditionalLightShadowsSupported: 0
m_AdditionalLightsShadowmapResolution: 512
m_AdditionalLightsShadowResolutionTierLow: 128
m_AdditionalLightsShadowResolutionTierMedium: 256
m_AdditionalLightsShadowResolutionTierHigh: 512
m_ReflectionProbeBlending: 0
m_ReflectionProbeBoxProjection: 0
m_ShadowDistance: 50
m_ShadowCascadeCount: 1
m_Cascade2Split: 0.25
m_Cascade3Split: {x: 0.1, y: 0.3}
m_Cascade4Split: {x: 0.067, y: 0.2, z: 0.467}
m_CascadeBorder: 0.1
m_ShadowDepthBias: 1
m_ShadowNormalBias: 1
m_AnyShadowsSupported: 1
m_SoftShadowsSupported: 1
m_ConservativeEnclosingSphere: 0
m_NumIterationsEnclosingSphere: 64
m_AdditionalLightsCookieResolution: 2048
m_AdditionalLightsCookieFormat: 3
m_UseSRPBatcher: 1
m_SupportsDynamicBatching: 0
m_MixedLightingSupported: 1
m_SupportsLightLayers: 0
m_DebugLevel: 0
m_UseAdaptivePerformance: 1
m_ColorGradingMode: 0
m_ColorGradingLutSize: 32
m_UseFastSRGBLinearConversion: 0
m_ShadowType: 1
m_LocalShadowsSupported: 0
m_LocalShadowsAtlasResolution: 256
m_MaxPixelLights: 0
m_ShadowAtlasResolution: 256
m_ShaderVariantLogLevel: 0
m_VolumeFrameworkUpdateMode: 0
m_ShadowCascades: 0

View File

@ -0,0 +1,8 @@
fileFormatVersion: 2
guid: 7cb1de89cd1dc44c5be43a3f6664fb90
NativeFormatImporter:
externalObjects: {}
mainObjectFileID: 0
userData:
assetBundleName:
assetBundleVariant:

View File

@ -0,0 +1,321 @@
**************************************
* HIGHLIGHT PLUS *
* Created by Ramiro Oliva (Kronnect) *
* README FILE *
**************************************
Notice about Universal Rendering Pipeline
-----------------------------------------
This package is designed for URP.
It requires Unity 2019.3 and URP 7.1.6 or later
To install the plugin correctly:
1) Make sure you have Universal Rendering Pipeline asset installed (from Package Manager).
2) Go to Project Settings / Graphics.
3) Double click the Universal Rendering Pipeline asset.
4) Double click the Forward Renderer asset.
5) Click "+" to add the Highlight Plus Renderer Feature to the list of the Forward Renderer Features.
Note: URP assets can be assigned to Settings / Graphics and also Settings / Quality. Check both sections!
You can also find a HighlightPlusForwardRenderer asset in the Highlight Plus / Pipelines / URP folder.
Make sure the Highlight Plus Scriptable Renderer Feature is listed in the Renderer Features of the Forward Renderer in the pipeline asset.
Video instructions: https://youtu.be/EgyBs8v9aRI
Quick help: how to use this asset?
----------------------------------
1) Highlighting specific objects: add HighlightEffect.cs script to any GameObject. Customize the appearance options.
In the Highlight Effect inspector, you can specify which objects, in addition to this one, are also affected by the effect:
a) Only this object
b) This object and its children
c) All objects from the root to the children
d) All objects belonging to a layer
2) Control highlight effect when mouse is over:
Add HighlightTrigger.cs script to the GameObject. It will activate highlight on the gameobject when mouse pass over it.
3) Highlighting any object in the scene:
Select top menu GameObject -> Effects -> Highlight Plus -> Create Manager.
Customize appearance and behaviour of Highlight Manager. Those settings are default settings for all objects. If you want different settings for certain objects just add another HighlightEffect script to each different object. The manager will use those settings.
4) Make transparent shaders compatible with See-Through effect:
If you want the See-Through effect be seen through other transparent objects, they need to be modified so they write to depth buffer (by default transparent objects do not write to z-buffer).
To do so, select top menu GameObject -> Effects -> Highlight Plus -> Add Depth To Transparent Object.
5) Static batching:
Objects marked as "static" need a MeshCollider in order to be highlighted. This is because Unity combines the meshes of static objects so it's not possible to highlight individual objects if their meshes are combined.
To allow highlighting static objects make sure they have a MeshCollider attached (the MeshCollider can be disabled).
Help & Support Forum
--------------------
Check the Documentation (PDF) for detailed instructions:
Have any question or issue?
* Support Forum: https://kronnect.com/support
* Twitter: @Kronnect
* Email (non support): contact@kronnect.com
If you like Highlight Plus, please rate it on the Asset Store. It encourages us to keep improving it! Thanks!
Future updates
--------------
All our assets follow an incremental development process by which a few beta releases are published on our support forum (kronnect.com).
We encourage you to signup and engage our forum. The forum is the primary support and feature discussions medium.
Of course, all updates of Highlight Plus will be eventually available on the Asset Store.
More Cool Assets!
-----------------
Check out our other assets here:
https://assetstore.unity.com/publishers/15018
Version history
---------------
Current version
- Added "Camera Distance Fade" option
- Improved see-through accurate method which now takes into account multi-part meshes from compound parents
- [Fix] Fixed glow/outline aspect ratio in Single Pass Instanced VR mode
Version 8.5
- Improved outline effect when combining "Independent" option with many elements in "Children" selection
- Improved see-through border only effect
Version 8.4.1
- [Fix] Fixed unnecessary memory allocation in the render feature
Version 8.4
- Added "Border Only" option to See-Through effect
- Adding a Highlight Effect component to a parent no longer deactivates highlighted children
Version 8.3
- Upgraded to Unity 2020.3.16 as minimum
Version 8.2
- Added "Ignore Mask" option to glow. Can be used to render the glow effect alone
- [Fix] Fixed issue with new input system and highlight manager/trigger if no Event System is present in the scene
- [Fix] Fixed glow passes UI overlap in Unity 2021.3.3 due to reorderable array bug
Version 8.1
- Selection state is now visible in inspector (used only by trigger and manager components)
- [Fix] Fixed outer glow not showing in higher quality with visibility set to normal and orthographic camera
- [Fix] Fixed mobile input using the new input system
- [Fix] Fixed outline settings mismatch when using a combination of Highlight Trigger and Manager
Version 8.0
- Added SelectObject / ToggleObject / UnselectObject methods to Highlight Manager
- Added ability to apply custom sorting to effects (check documentation: Custom sorting section)
- Independent option is now moved to Highlight Options section and affects both outline and glow
- Added "Clear Stencil" option to Highlight Plus Render Feature (useful to solve compatibility with other assets that use stencil buffers)
Version 7.9.2
- [Fix] Fixed an issue in Unity 2021.2 when using MSAA and High Quality outline/glow
Version 7.9.1
- Default values for all effects are now 0 (disabled) except outline so desired effects must be enabled. This option allows you to ensure no extra/undesired effects are activated by mistake
- Redesigned Highlight Plus Profile editor interface
- Removed dependency of HighlightManager
Version 7.8
- Added outer glow blend mode option
- API: added OnObjectHighlightStart/End events to HighlightTrigger (check documentation for differences with similar events on Highlight Effect main script)
- [Fix] API: Fixed specific issues with SetTarget method when used on shader graph based materials that don't use standard texture names
Version 7.7.2
- [Fix] Fixed fade in/out issue when disabling/enabling objects
Version 7.7
- Added support for the new Input System
- [Fix] Fixes to the align to ground option of target fx effect
Version 7.6.2
- [Fix] VR: fixed target effect "Align to Ground" issue with Single Pass Instanced
Version 7.6.1
- [Fix] Fixed overlay animation speed issue
Version 7.6
- Added "Target FX Align to Ground" option
- Added isSeeThroughOccluded(camera). Is true when any see-through occluder using raycast mode is blocking the see-through effect
- All shader keywords are now of local type reducing global keyword usage
- Fixes and improvements to see-through when combined with outline/outer glow
Version 7.5.2
- [Fix] See-through is now visible when using glow/outline/inner glow with Always Visible option
Version 7.5.1
- [Fix] Fixed regression bug with Outline in High Quality mode
Version 7.5
- Added new HitFX style: "Local Hit"
- Added new demo scene showcasing the HitFx variations
- Added "Overlay Texture" option
- Added "Min Distance" option to Highlight Manager and Highlight Trigger
- Added support for "Domain Reload" disabled option
- API: added OnObjectHighlightStart, OnObjectHighlightEnd events to HighlightManager
- [Fix] Fixed inner glow and overlay issue when MaterialPropertyBlock is used on the character material
Version 7.1
- Added "Respect UI" to Highlight Manager and Trigger which blocks interaction if pointer is over an UI element
Version 7.0.2
- Memory optimizations
Version 7.0
- Added support for Single Pass Instanced
- Internal improvements and fixes
Version 6.9
- Added "Ordered" option to see-through
- Removed "Non Overlap" option from see-through as now it pervents overdraw by default
Version 6.8
- Improvements to see-through rendering order
- [Fix] Fixed properties not being reflected in scene immediately when invoking Undo
Version 6.7
- Added "SeeThrough Max Depth" option. Limits the visibility of the see-through effect to certain distance from the occluders
- Added "SeeThrough Check Individual Objects" option. If enabled, occlusion test is performed for each individual child of the object, instead of using combined bounds
Version 6.6
- Added "SeeThrough Depth Offset" option. This option allows you to control the minimum distance from the occluder to the object before showing the see-through effect
- Added "SeeThrough Non Overlap" option. Enable it only if the see-through effect produces flickering due to overlapping geometry in the hidden object
- [Fix] Fixed properties not being reflected in scene immediately when invoking Undo
Version 6.5.2
- Added inspector tooltips and improved documentation
Version 6.5.1
- Calling ProfileLoad() method will now assign that profile to the highlight effect component in addition to loading its values
- Prevents _Time overflow which can cause glitching on some Android devices
Version 6.5
- Name filter now is ignored when effect group is set to Only This Object
- New shader "HighlightPlus/Geometry/UIMask" to cancel highlight effects when rendering through a UI Canvas (see documentation)
Version 6.4
- Added "Cameras Layer Mask" to specify which cameras can render the effects
- Hit FX color in Highlight Profile now exposes HDR color options
Version 6.3.1
- Added "Single Selection" option to Highlight Manager/Trigger
- Added "Toggle" option to Highlight Manager/Trigger
- Selection is cleared now when clicking anywhere in the scene (requires Highlight Manager)
- API: added SetGlowColor
- Improved Highlight Manager inspector
Version 6.2
- Added TargetFX Scale To Object Bounds (defaults to false)
- Added support for HDR color to Hit FX color field
- Option to list occluders in the inspector when See Through Occluder Mask "Accurate" option is enabled
Version 6.1
- Added more accurate occluder layer system ("Accurate" option)
- Added default hit fx settings to inspector & profile
- Added hit fx modes (overlay or inner glow)
Version 6.0
- Added Selection feature
- Inspector: sections can be now collapsed to reduce screen space
- API: added OnObjectSelected / OnObjectUnSelected events
Version 5.5 4/Apr/2021
- [Fix] Fixed glow overlay when MSAA is disabled on Windows
Version 5.4 5/Feb/2021
- Added Visibility option to targete effect
- Stencil mask is no longer computed when only overlay or inner glow is used improving performance
Version 5.3.4 22/01/2021
- Optimizations to material setters
- [Fix] Fixed outline color issue with quality level set to medium
Version 5.3.3
- Effects now reflect object transform changes when combines meshes option is enabled
Version 5.3
- Added "Combine Meshes" option to profile
- Optimizations and fixes
Version 5.2
- Added "Object Name Filter" option to profile
Version 5.1
- Added "Border When Hidden" effect (outline when see-through triggers)
Version 5.0.1
- Added support for Unity 2020.2 beta
Version 5.0
- API: added "TargetFX" method to programmatically start the target effect
- Added support for double-sided shader effects
Version 4.9
- Added "Medium" quality level
Version 4.8.2
- [Fix] Fixed issue with outline set to fastest and glow using highest in latest URP version
Version 4.8.1
- [Fix] Fixed issue with outline/glow when overlay cameras are present on the stack
Version 4.8
- Added "Outer Glow Blend Passes" option
- [Fix] Fixed outline & glow issue with alpha cutout when using non-highest quality mode
Version 4.7
- Added "Normals Option" with Smooth, Preserve and Reorient variants to improve results
- Target effect now only renders once per gameobject if a specific target transform is specified
- API: added OnTargetAnimates. Allows you to override center, rotation and scale of target effect on a per-frame basis.
Version 4.6
- Added "SubMesh Mask" which allows to exclude certain submeshes
- [Fix] Fixed shader compilation issue with Single Pass Instanced mode enabled
Version 4.4
- Exposed "Smooth Normals" option in inspector.
Version 4.3.2
- Added HitFX effect
- Improvements to SeeThrough Occluder when Detection Mode is set to RayCast
Version 4.3.1
- [Fix] Fixed issue with Highlight Effect Occluder script
Version 4.3
- Added GPU instancing support for outline / outer glow effects
Version 4.2.2
- [Fix] Fixed effect being rendered when object is outside of frustum camera
Version 4.2.1
- Profile: added "Constant Width" property
- Enabled HDR color picker to Color properties
- [Fix] Fixed missing outline with flat surfaces like quads under certain angles
Version 4.2
- Glow/Outline downsampling option added to profiles
- [Fix] Removed VR API usage console warning
Version 4.1
- Added Outline Independent option
- [Fix] Fixed error when highlight script is added to an empty gameobject
Version 4.0
- Support for URP Scriptable Rendering Feature

View File

@ -0,0 +1,8 @@
fileFormatVersion: 2
guid: 53265a9967ed548efaf71f5807638781
timeCreated: 1542901568
licenseType: Store
TextScriptImporter:
userData:
assetBundleName:
assetBundleVariant:

View File

@ -0,0 +1,8 @@
fileFormatVersion: 2
guid: a233cc5176ac642f89469b5d4c676c89
folderAsset: yes
DefaultImporter:
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant:

View File

@ -0,0 +1,9 @@
fileFormatVersion: 2
guid: 3a476022645d74299b862c36d0daa1df
folderAsset: yes
timeCreated: 1542876301
licenseType: Store
DefaultImporter:
userData:
assetBundleName:
assetBundleVariant:

View File

@ -0,0 +1,9 @@
fileFormatVersion: 2
guid: 6bd97436761b94109a0785ed6823647c
folderAsset: yes
timeCreated: 1542893576
licenseType: Store
DefaultImporter:
userData:
assetBundleName:
assetBundleVariant:

View File

@ -0,0 +1,10 @@
#ifndef CUSTOM_VERTEX_TRANSFORM_INCLUDED
#define CUSTOM_VERTEX_TRANSFORM_INCLUDED
float4 ComputeVertexPosition(float4 vertex) {
// Add here any custom vertex transform
float4 pos = UnityObjectToClipPos(vertex);
return pos;
}
#endif

View File

@ -0,0 +1,9 @@
fileFormatVersion: 2
guid: 26b31a85c4f4c4b11850968651dddfeb
ShaderImporter:
externalObjects: {}
defaultTextures: []
nonModifiableTextures: []
userData:
assetBundleName:
assetBundleVariant:

View File

@ -0,0 +1,49 @@
Shader "HighlightPlus/Geometry/JustDepth"
{
Properties
{
}
SubShader
{
Tags { "RenderType"="Opaque" }
ColorMask 0
Pass
{
CGPROGRAM
#pragma vertex vert
#pragma fragment frag
#include "UnityCG.cginc"
#include "CustomVertexTransform.cginc"
struct appdata
{
float4 vertex : POSITION;
UNITY_VERTEX_INPUT_INSTANCE_ID
};
struct v2f
{
float4 pos : SV_POSITION;
UNITY_VERTEX_OUTPUT_STEREO
};
v2f vert (appdata v)
{
v2f o;
UNITY_SETUP_INSTANCE_ID(v);
UNITY_INITIALIZE_OUTPUT(v2f, o);
UNITY_INITIALIZE_VERTEX_OUTPUT_STEREO(o);
o.pos = ComputeVertexPosition(v.vertex);
return o;
}
fixed4 frag (v2f i) : SV_Target
{
return 0;
}
ENDCG
}
}
}

View File

@ -0,0 +1,10 @@
fileFormatVersion: 2
guid: 058a572e30b2d446bade2dda32bcef0f
timeCreated: 1515682635
licenseType: Store
ShaderImporter:
externalObjects: {}
defaultTextures: []
userData:
assetBundleName:
assetBundleVariant:

View File

@ -0,0 +1,150 @@
Shader "HighlightPlus/Geometry/BlurGlow" {
Properties {
_Color ("Color", Color) = (1,1,0) // not used; dummy property to avoid inspector warning "material has no _Color property"
_BlurScale("Blur Scale", Float) = 2.0
_Speed("Speed", Float) = 1
}
SubShader
{
ZTest Always
ZWrite Off
Cull Off
CGINCLUDE
#include "UnityCG.cginc"
UNITY_DECLARE_SCREENSPACE_TEXTURE(_MainTex);
float4 _MainTex_TexelSize;
float4 _MainTex_ST;
float _BlurScale, _Speed;
float _AspectRatio;
struct appdata {
float4 vertex : POSITION;
float2 texcoord : TEXCOORD0;
UNITY_VERTEX_INPUT_INSTANCE_ID
};
struct v2fCross {
float4 pos : SV_POSITION;
float2 uv: TEXCOORD0;
float2 uv1: TEXCOORD1;
float2 uv2: TEXCOORD2;
float2 uv3: TEXCOORD3;
float2 uv4: TEXCOORD4;
UNITY_VERTEX_INPUT_INSTANCE_ID
UNITY_VERTEX_OUTPUT_STEREO
};
v2fCross vertCross(appdata v) {
v2fCross o;
UNITY_SETUP_INSTANCE_ID(v);
UNITY_TRANSFER_INSTANCE_ID(v, o);
UNITY_INITIALIZE_VERTEX_OUTPUT_STEREO(o);
o.pos = v.vertex;
o.pos.y *= _ProjectionParams.x;
o.uv = v.texcoord;
float3 offsets = _MainTex_TexelSize.xyx * float3(1, _AspectRatio, -1);
o.uv1 = v.texcoord - offsets.xy;
o.uv2 = v.texcoord - offsets.zy;
o.uv3 = v.texcoord + offsets.zy;
o.uv4 = v.texcoord + offsets.xy;
return o;
}
v2fCross vertBlurH(appdata v) {
v2fCross o;
UNITY_SETUP_INSTANCE_ID(v);
UNITY_TRANSFER_INSTANCE_ID(v, o);
UNITY_INITIALIZE_VERTEX_OUTPUT_STEREO(o);
o.pos = v.vertex;
o.pos.y *= _ProjectionParams.x;
float animatedWidth = _BlurScale * (1.0 + 0.25 * sin(_Time.w * _Speed));
o.uv = v.texcoord;
float2 inc = float2(_MainTex_TexelSize.x * 1.3846153846 * animatedWidth, 0);
o.uv1 = v.texcoord - inc;
o.uv2 = v.texcoord + inc;
float2 inc2 = float2(_MainTex_TexelSize.x * 3.2307692308 * animatedWidth, 0);
o.uv3 = v.texcoord - inc2;
o.uv4 = v.texcoord + inc2;
return o;
}
v2fCross vertBlurV(appdata v) {
v2fCross o;
UNITY_SETUP_INSTANCE_ID(v);
UNITY_TRANSFER_INSTANCE_ID(v, o);
UNITY_INITIALIZE_VERTEX_OUTPUT_STEREO(o);
o.pos = v.vertex;
o.pos.y *= _ProjectionParams.x;
float animatedWidth = _AspectRatio * _BlurScale * (1.0 + 0.25 * sin(_Time.w * _Speed));
o.uv = v.texcoord;
float2 inc = float2(0, _MainTex_TexelSize.y * 1.3846153846 * animatedWidth);
o.uv1 = v.texcoord - inc;
o.uv2 = v.texcoord + inc;
float2 inc2 = float2(0, _MainTex_TexelSize.y * 3.2307692308 * animatedWidth);
o.uv3 = v.texcoord - inc2;
o.uv4 = v.texcoord + inc2;
return o;
}
float4 fragBlur (v2fCross i): SV_Target {
UNITY_SETUP_INSTANCE_ID(i);
UNITY_SETUP_STEREO_EYE_INDEX_POST_VERTEX(i);
float4 pixel = UNITY_SAMPLE_SCREENSPACE_TEXTURE(_MainTex, i.uv) * 0.2270270270
+ (UNITY_SAMPLE_SCREENSPACE_TEXTURE(_MainTex, i.uv1) + UNITY_SAMPLE_SCREENSPACE_TEXTURE(_MainTex, i.uv2)) * 0.3162162162
+ (UNITY_SAMPLE_SCREENSPACE_TEXTURE(_MainTex, i.uv3) + UNITY_SAMPLE_SCREENSPACE_TEXTURE(_MainTex, i.uv4)) * 0.0702702703;
return pixel;
}
float4 fragResample(v2fCross i) : SV_Target {
UNITY_SETUP_INSTANCE_ID(i);
UNITY_SETUP_STEREO_EYE_INDEX_POST_VERTEX(i);
float4 c1 = UNITY_SAMPLE_SCREENSPACE_TEXTURE(_MainTex, i.uv1);
float4 c2 = UNITY_SAMPLE_SCREENSPACE_TEXTURE(_MainTex, i.uv2);
float4 c3 = UNITY_SAMPLE_SCREENSPACE_TEXTURE(_MainTex, i.uv3);
float4 c4 = UNITY_SAMPLE_SCREENSPACE_TEXTURE(_MainTex, i.uv4);
return (c1+c2+c3+c4) * 0.25;
}
ENDCG
Pass {
CGPROGRAM
#pragma vertex vertBlurH
#pragma fragment fragBlur
#pragma fragmentoption ARB_precision_hint_fastest
#pragma target 3.0
ENDCG
}
Pass {
CGPROGRAM
#pragma vertex vertBlurV
#pragma fragment fragBlur
#pragma fragmentoption ARB_precision_hint_fastest
#pragma target 3.0
ENDCG
}
Pass {
CGPROGRAM
#pragma vertex vertCross
#pragma fragment fragResample
#pragma fragmentoption ARB_precision_hint_fastest
#pragma target 3.0
ENDCG
}
}
}

View File

@ -0,0 +1,9 @@
fileFormatVersion: 2
guid: 84c84ee93ec484bdda371ffbdebfcc7c
timeCreated: 1556874239
licenseType: Store
ShaderImporter:
defaultTextures: []
userData:
assetBundleName:
assetBundleVariant:

View File

@ -0,0 +1,146 @@
Shader "HighlightPlus/Geometry/BlurOutline" {
Properties {
_Color ("Color", Color) = (1,1,0) // not used; dummy property to avoid inspector warning "material has no _Color property"
_BlurScale("Blur Scale", Float) = 2.0
}
SubShader
{
ZTest Always
ZWrite Off
Cull Off
CGINCLUDE
#include "UnityCG.cginc"
UNITY_DECLARE_SCREENSPACE_TEXTURE(_MainTex);
float4 _MainTex_TexelSize;
float4 _MainTex_ST;
float _BlurScale;
float _AspectRatio;
struct appdata {
float4 vertex : POSITION;
float2 texcoord : TEXCOORD0;
UNITY_VERTEX_INPUT_INSTANCE_ID
};
struct v2fCross {
float4 pos : SV_POSITION;
float2 uv: TEXCOORD0;
float2 uv1: TEXCOORD1;
float2 uv2: TEXCOORD2;
float2 uv3: TEXCOORD3;
float2 uv4: TEXCOORD4;
UNITY_VERTEX_INPUT_INSTANCE_ID
UNITY_VERTEX_OUTPUT_STEREO
};
v2fCross vertCross(appdata v) {
v2fCross o;
UNITY_SETUP_INSTANCE_ID(v);
UNITY_TRANSFER_INSTANCE_ID(v, o);
UNITY_INITIALIZE_VERTEX_OUTPUT_STEREO(o);
o.pos = v.vertex;
o.pos.y *= _ProjectionParams.x;
o.uv = v.texcoord;
float3 offsets = _MainTex_TexelSize.xyx * float3(1, _AspectRatio, -1);
o.uv1 = v.texcoord - offsets.xy;
o.uv2 = v.texcoord - offsets.zy;
o.uv3 = v.texcoord + offsets.zy;
o.uv4 = v.texcoord + offsets.xy;
return o;
}
v2fCross vertBlurH(appdata v) {
v2fCross o;
UNITY_SETUP_INSTANCE_ID(v);
UNITY_TRANSFER_INSTANCE_ID(v, o);
UNITY_INITIALIZE_VERTEX_OUTPUT_STEREO(o);
o.pos = v.vertex;
o.pos.y *= _ProjectionParams.x;
o.uv = v.texcoord;
float2 inc = float2(_MainTex_TexelSize.x * 1.3846153846 * _BlurScale, 0);
o.uv1 = v.texcoord - inc;
o.uv2 = v.texcoord + inc;
float2 inc2 = float2(_MainTex_TexelSize.x * 3.2307692308 * _BlurScale, 0);
o.uv3 = v.texcoord - inc2;
o.uv4 = v.texcoord + inc2;
return o;
}
v2fCross vertBlurV(appdata v) {
v2fCross o;
UNITY_SETUP_INSTANCE_ID(v);
UNITY_TRANSFER_INSTANCE_ID(v, o);
UNITY_INITIALIZE_VERTEX_OUTPUT_STEREO(o);
o.pos = v.vertex;
o.pos.y *= _ProjectionParams.x;
o.uv = v.texcoord;
float2 inc = float2(0, _MainTex_TexelSize.y * 1.3846153846 * _BlurScale);
o.uv1 = v.texcoord - inc;
o.uv2 = v.texcoord + inc;
float2 inc2 = float2(0, _MainTex_TexelSize.y * 3.2307692308 * _BlurScale);
o.uv3 = v.texcoord - inc2;
o.uv4 = v.texcoord + inc2;
return o;
}
float4 fragBlur (v2fCross i): SV_Target {
UNITY_SETUP_INSTANCE_ID(i);
UNITY_SETUP_STEREO_EYE_INDEX_POST_VERTEX(i);
float4 pixel = UNITY_SAMPLE_SCREENSPACE_TEXTURE(_MainTex, i.uv) * 0.2270270270
+ (UNITY_SAMPLE_SCREENSPACE_TEXTURE(_MainTex, i.uv1) + UNITY_SAMPLE_SCREENSPACE_TEXTURE(_MainTex, i.uv2)) * 0.3162162162
+ (UNITY_SAMPLE_SCREENSPACE_TEXTURE(_MainTex, i.uv3) + UNITY_SAMPLE_SCREENSPACE_TEXTURE(_MainTex, i.uv4)) * 0.0702702703;
return pixel;
}
float4 fragResample(v2fCross i) : SV_Target {
UNITY_SETUP_INSTANCE_ID(i);
UNITY_SETUP_STEREO_EYE_INDEX_POST_VERTEX(i);
float4 c1 = UNITY_SAMPLE_SCREENSPACE_TEXTURE(_MainTex, i.uv1);
float4 c2 = UNITY_SAMPLE_SCREENSPACE_TEXTURE(_MainTex, i.uv2);
float4 c3 = UNITY_SAMPLE_SCREENSPACE_TEXTURE(_MainTex, i.uv3);
float4 c4 = UNITY_SAMPLE_SCREENSPACE_TEXTURE(_MainTex, i.uv4);
return (c1+c2+c3+c4) * 0.25;
}
ENDCG
Pass {
CGPROGRAM
#pragma vertex vertBlurH
#pragma fragment fragBlur
#pragma fragmentoption ARB_precision_hint_fastest
#pragma target 3.0
ENDCG
}
Pass {
CGPROGRAM
#pragma vertex vertBlurV
#pragma fragment fragBlur
#pragma fragmentoption ARB_precision_hint_fastest
#pragma target 3.0
ENDCG
}
Pass {
CGPROGRAM
#pragma vertex vertCross
#pragma fragment fragResample
#pragma fragmentoption ARB_precision_hint_fastest
#pragma target 3.0
ENDCG
}
}
}

View File

@ -0,0 +1,9 @@
fileFormatVersion: 2
guid: 74f3491dcf1224f0c91238381c035439
timeCreated: 1556874239
licenseType: Store
ShaderImporter:
defaultTextures: []
userData:
assetBundleName:
assetBundleVariant:

View File

@ -0,0 +1,95 @@
Shader "HighlightPlus/ClearStencil"
{
Properties
{
}
SubShader
{
Stencil {
Ref 2
Comp Always
Pass zero
}
ZTest Always
ZWrite Off
Cull Off
ColorMask 0
Pass // clear stencil full screen
{
CGPROGRAM
#pragma vertex vert
#pragma fragment frag
#include "UnityCG.cginc"
struct appdata
{
float4 vertex : POSITION;
UNITY_VERTEX_INPUT_INSTANCE_ID
};
struct v2f
{
float4 pos : SV_POSITION;
UNITY_VERTEX_OUTPUT_STEREO
};
v2f vert (appdata v)
{
v2f o;
UNITY_SETUP_INSTANCE_ID(v);
UNITY_INITIALIZE_OUTPUT(v2f, o);
UNITY_INITIALIZE_VERTEX_OUTPUT_STEREO(o);
o.pos = float4(v.vertex.xy, 0, 0.5);
return o;
}
fixed4 frag (v2f i) : SV_Target
{
return 0;
}
ENDCG
}
Pass // clear stencil object-space
{
CGPROGRAM
#pragma vertex vert
#pragma fragment frag
#include "UnityCG.cginc"
#include "CustomVertexTransform.cginc"
struct appdata
{
float4 vertex : POSITION;
UNITY_VERTEX_INPUT_INSTANCE_ID
};
struct v2f
{
float4 pos : SV_POSITION;
UNITY_VERTEX_OUTPUT_STEREO
};
v2f vert (appdata v)
{
v2f o;
UNITY_SETUP_INSTANCE_ID(v);
UNITY_INITIALIZE_OUTPUT(v2f, o);
UNITY_INITIALIZE_VERTEX_OUTPUT_STEREO(o);
o.pos = ComputeVertexPosition(v.vertex);
return o;
}
fixed4 frag (v2f i) : SV_Target
{
return 0;
}
ENDCG
}
}
}

View File

@ -0,0 +1,9 @@
fileFormatVersion: 2
guid: 844773224daae4c31a9160897f833c5b
ShaderImporter:
externalObjects: {}
defaultTextures: []
nonModifiableTextures: []
userData:
assetBundleName:
assetBundleVariant:

View File

@ -0,0 +1,151 @@
Shader "HighlightPlus/Geometry/ComposeGlow" {
Properties {
_MainTex ("Texture", Any) = "black" {}
_Color ("Color", Color) = (1,1,1) // not used; dummy property to avoid inspector warning "material has no _Color property"
[HideInInspector] _Cull ("Cull Mode", Int) = 2
[HideInInspector] _ZTest ("ZTest Mode", Int) = 0
[HideInInspector] _Flip("Flip", Vector) = (0, 1, 0)
[HideInInspector] _BlendSrc("Blend Src", Int) = 1
[HideInInspector] _BlendDst("Blend Dst", Int) = 1
_Debug("Debug Color", Color) = (0,0,0,0)
[HideInInspector] _GlowStencilComp ("Stencil Comp", Int) = 6
}
SubShader
{
Tags { "Queue"="Transparent+102" "RenderType"="Transparent" "DisableBatching" = "True" }
Blend [_BlendSrc] [_BlendDst]
// Compose effect on camera target
Pass
{
ZWrite Off
ZTest [_ZTest]
Cull Off //[_Cull]
Stencil {
Ref 2
Comp [_GlowStencilComp]
Pass keep
ReadMask 2
WriteMask 2
}
CGPROGRAM
#pragma vertex vert
#pragma fragment frag
#include "UnityCG.cginc"
UNITY_DECLARE_SCREENSPACE_TEXTURE(_HPComposeGlowFinal);
fixed4 _Color;
float3 _Flip;
fixed4 _Debug;
struct appdata
{
float4 vertex : POSITION;
UNITY_VERTEX_INPUT_INSTANCE_ID
};
struct v2f
{
float4 pos: SV_POSITION;
float4 scrPos: TEXCOORD0;
UNITY_VERTEX_INPUT_INSTANCE_ID
UNITY_VERTEX_OUTPUT_STEREO
};
v2f vert (appdata v)
{
v2f o;
UNITY_SETUP_INSTANCE_ID(v);
UNITY_INITIALIZE_OUTPUT(v2f, o);
UNITY_TRANSFER_INSTANCE_ID(v, o);
UNITY_INITIALIZE_VERTEX_OUTPUT_STEREO(o);
o.pos = UnityObjectToClipPos(v.vertex);
o.scrPos = ComputeScreenPos(o.pos);
o.scrPos.y = o.scrPos.w * _Flip.x + o.scrPos.y * _Flip.y;
return o;
}
fixed4 frag (v2f i) : SV_Target
{
UNITY_SETUP_INSTANCE_ID(i);
UNITY_SETUP_STEREO_EYE_INDEX_POST_VERTEX(i);
fixed4 glow = UNITY_SAMPLE_SCREENSPACE_TEXTURE(_HPComposeGlowFinal, i.scrPos.xy/i.scrPos.w);
fixed4 color = _Color;
color *= glow.r;
color += _Debug;
color.a = saturate(color.a);
return color;
}
ENDCG
}
// Compose effect on camera target (full-screen blit)
Pass
{
ZWrite Off
ZTest Always //[_ZTest]
Cull Off //[_Cull]
Stencil {
Ref 2
Comp NotEqual
Pass keep
ReadMask 2
WriteMask 2
}
CGPROGRAM
#pragma vertex vert
#pragma fragment frag
#include "UnityCG.cginc"
UNITY_DECLARE_SCREENSPACE_TEXTURE(_MainTex);
float4 _MainTex_ST;
fixed4 _Color;
float3 _Flip;
struct appdata
{
float4 vertex : POSITION;
float2 uv : TEXCOORD0;
UNITY_VERTEX_INPUT_INSTANCE_ID
};
struct v2f
{
float4 pos: SV_POSITION;
float2 uv : TEXCOORD0;
UNITY_VERTEX_INPUT_INSTANCE_ID
UNITY_VERTEX_OUTPUT_STEREO
};
v2f vert(appdata v)
{
v2f o;
UNITY_SETUP_INSTANCE_ID(v);
UNITY_INITIALIZE_OUTPUT(v2f, o);
UNITY_INITIALIZE_VERTEX_OUTPUT_STEREO(o);
o.pos = UnityObjectToClipPos(v.vertex);
o.uv = UnityStereoScreenSpaceUVAdjust(v.uv, _MainTex_ST);
o.uv.y = _Flip.x + o.uv.y * _Flip.y;
return o;
}
fixed4 frag(v2f i) : SV_Target
{
UNITY_SETUP_INSTANCE_ID(i);
UNITY_SETUP_STEREO_EYE_INDEX_POST_VERTEX(i);
fixed4 glow = UNITY_SAMPLE_SCREENSPACE_TEXTURE(_MainTex, i.uv);
fixed4 color = _Color;
color *= glow.r;
color.a = saturate(color.a);
return color;
}
ENDCG
}
}
}

View File

@ -0,0 +1,9 @@
fileFormatVersion: 2
guid: 975a91ee935da4d9c8a3e807fecd8047
timeCreated: 1544699251
licenseType: Store
ShaderImporter:
defaultTextures: []
userData:
assetBundleName:
assetBundleVariant:

View File

@ -0,0 +1,150 @@
Shader "HighlightPlus/Geometry/ComposeOutline" {
Properties {
_MainTex ("Texture", Any) = "black" {}
_Color("Color", Color) = (1,1,1) // not used; dummy property to avoid inspector warning "material has no _Color property"
_Cull("Cull Mode", Int) = 2
_ZTest("ZTest Mode", Int) = 0
_Flip("Flip", Vector) = (0, 1, 0)
_Debug("Debug Color", Color) = (0,0,0,0)
}
SubShader
{
Tags { "Queue" = "Transparent+120" "RenderType" = "Transparent" "DisableBatching" = "True" }
Blend SrcAlpha OneMinusSrcAlpha
// Compose effect on camera target (optimal quad blit)
Pass
{
ZWrite Off
ZTest [_ZTest]
Cull Off // [_Cull]
Stencil {
Ref 2
Comp NotEqual
Pass keep
ReadMask 2
WriteMask 2
}
CGPROGRAM
#pragma vertex vert
#pragma fragment frag
#include "UnityCG.cginc"
UNITY_DECLARE_SCREENSPACE_TEXTURE(_HPComposeOutlineFinal);
fixed4 _Color;
float3 _Flip;
fixed4 _Debug;
struct appdata
{
float4 vertex : POSITION;
UNITY_VERTEX_INPUT_INSTANCE_ID
};
struct v2f
{
float4 pos: SV_POSITION;
float4 scrPos: TEXCOORD0;
UNITY_VERTEX_INPUT_INSTANCE_ID
UNITY_VERTEX_OUTPUT_STEREO
};
v2f vert (appdata v)
{
v2f o;
UNITY_SETUP_INSTANCE_ID(v);
UNITY_INITIALIZE_OUTPUT(v2f, o);
UNITY_TRANSFER_INSTANCE_ID(v, o);
UNITY_INITIALIZE_VERTEX_OUTPUT_STEREO(o);
o.pos = UnityObjectToClipPos(v.vertex);
o.scrPos = ComputeScreenPos(o.pos);
o.scrPos.y = o.scrPos.w * _Flip.x + o.scrPos.y * _Flip.y;
return o;
}
fixed4 frag (v2f i) : SV_Target
{
UNITY_SETUP_INSTANCE_ID(i);
UNITY_SETUP_STEREO_EYE_INDEX_POST_VERTEX(i);
fixed4 outline = UNITY_SAMPLE_SCREENSPACE_TEXTURE(_HPComposeOutlineFinal, i.scrPos.xy/i.scrPos.w);
fixed4 color = _Color;
color.a *= outline.r;
color += _Debug;
color.a = saturate(color.a);
return color;
}
ENDCG
}
// Compose effect on camera target (full-screen blit)
Pass
{
ZWrite Off
ZTest Always //[_ZTest]
Cull Off // [_Cull]
Stencil {
Ref 2
Comp NotEqual
Pass keep
ReadMask 2
WriteMask 2
}
CGPROGRAM
#pragma vertex vert
#pragma fragment frag
#include "UnityCG.cginc"
UNITY_DECLARE_SCREENSPACE_TEXTURE(_MainTex);
float4 _MainTex_ST;
fixed4 _Color;
float3 _Flip;
struct appdata
{
float4 vertex : POSITION;
float2 uv : TEXCOORD0;
UNITY_VERTEX_INPUT_INSTANCE_ID
};
struct v2f
{
float4 pos: SV_POSITION;
float2 uv : TEXCOORD0;
UNITY_VERTEX_INPUT_INSTANCE_ID
UNITY_VERTEX_OUTPUT_STEREO
};
v2f vert(appdata v)
{
v2f o;
UNITY_SETUP_INSTANCE_ID(v);
UNITY_INITIALIZE_OUTPUT(v2f, o);
UNITY_TRANSFER_INSTANCE_ID(v, o);
UNITY_INITIALIZE_VERTEX_OUTPUT_STEREO(o);
o.pos = UnityObjectToClipPos(v.vertex);
o.uv = UnityStereoScreenSpaceUVAdjust(v.uv, _MainTex_ST);
o.uv.y = _Flip.x + o.uv.y * _Flip.y;
return o;
}
fixed4 frag(v2f i) : SV_Target
{
UNITY_SETUP_INSTANCE_ID(i);
UNITY_SETUP_STEREO_EYE_INDEX_POST_VERTEX(i);
fixed4 outline = UNITY_SAMPLE_SCREENSPACE_TEXTURE(_MainTex, i.uv);
fixed4 color = _Color;
color.a *= outline.r;
color = saturate(color);
return color;
}
ENDCG
}
}
}

View File

@ -0,0 +1,9 @@
fileFormatVersion: 2
guid: 0a6de74b6cfa9440182f8f56e4a0e4f1
timeCreated: 1544699251
licenseType: Store
ShaderImporter:
defaultTextures: []
userData:
assetBundleName:
assetBundleVariant:

View File

@ -0,0 +1,95 @@
%YAML 1.1
%TAG !u! tag:unity3d.com,2011:
--- !u!21 &2100000
Material:
serializedVersion: 6
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_Name: HighlightGlow
m_Shader: {fileID: 4800000, guid: 049d9e75e07674a78a703cf1203c07dd, type: 3}
m_ShaderKeywords:
m_LightmapFlags: 4
m_EnableInstancingVariants: 1
m_DoubleSidedGI: 0
m_CustomRenderQueue: -1
stringTagMap: {}
disabledShaderPasses: []
m_SavedProperties:
serializedVersion: 3
m_TexEnvs:
- _BaseMap:
m_Texture: {fileID: 0}
m_Scale: {x: 1, y: 1}
m_Offset: {x: 0, y: 0}
- _BumpMap:
m_Texture: {fileID: 0}
m_Scale: {x: 1, y: 1}
m_Offset: {x: 0, y: 0}
- _EmissionMap:
m_Texture: {fileID: 0}
m_Scale: {x: 1, y: 1}
m_Offset: {x: 0, y: 0}
- _MainTex:
m_Texture: {fileID: 0}
m_Scale: {x: 1, y: 1}
m_Offset: {x: 0, y: 0}
- _MetallicGlossMap:
m_Texture: {fileID: 0}
m_Scale: {x: 1, y: 1}
m_Offset: {x: 0, y: 0}
- _OcclusionMap:
m_Texture: {fileID: 0}
m_Scale: {x: 1, y: 1}
m_Offset: {x: 0, y: 0}
- _SpecGlossMap:
m_Texture: {fileID: 0}
m_Scale: {x: 1, y: 1}
m_Offset: {x: 0, y: 0}
m_Floats:
- _AlphaClip: 0
- _Blend: 0
- _BumpScale: 1
- _ConstantWidth: 1
- _Cull: 2
- _Cutoff: 0.5
- _DstBlend: 0
- _EnvironmentReflections: 1
- _GlossMapScale: 0
- _Glossiness: 0
- _GlossyReflections: 0
- _GlowZTest: 4
- _Metallic: 0
- _OcclusionStrength: 1
- _QueueOffset: 0
- _ReceiveShadows: 1
- _Smoothness: 0.5
- _SmoothnessTextureChannel: 0
- _SpecularHighlights: 1
- _SrcBlend: 1
- _Surface: 0
- _WorkflowMode: 1
- _ZWrite: 1
m_Colors:
- _BaseColor: {r: 0.5, g: 0.5, b: 0.5, a: 1}
- _Color: {r: 0.5, g: 0.5, b: 0.5, a: 1}
- _EmissionColor: {r: 0, g: 0, b: 0, a: 1}
- _Glow: {r: 1, g: 0.025, b: 0.75, a: 0.5}
- _Glow2: {r: 0.01, g: 1, b: 0.5, a: 0}
- _GlowColor: {r: 1, g: 1, b: 1, a: 1}
- _GlowDirection: {r: 1, g: 1, b: 0, a: 1}
- _SpecColor: {r: 0.2, g: 0.2, b: 0.2, a: 1}
--- !u!114 &8957597210722627563
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: 1

View File

@ -0,0 +1,8 @@
fileFormatVersion: 2
guid: 41672e7b4c6544aedbffb9e271c7ef7c
NativeFormatImporter:
externalObjects: {}
mainObjectFileID: 0
userData:
assetBundleName:
assetBundleVariant:

View File

@ -0,0 +1,119 @@
Shader "HighlightPlus/Geometry/Glow" {
Properties {
_MainTex ("Texture", Any) = "white" {}
_Glow2 ("Glow2", Vector) = (0.01, 1, 0.5, 0)
_Color ("Color", Color) = (1,1,1) // not used; dummy property to avoid inspector warning "material has no _Color property"
_Cull ("Cull Mode", Int) = 2
_ConstantWidth ("Constant Width", Float) = 1
_GlowZTest ("ZTest", Int) = 4
_GlowStencilOp ("Stencil Operation", Int) = 0
_CutOff("CutOff", Float ) = 0.5
_GlowStencilComp ("Stencil Comp", Int) = 6
}
SubShader
{
Tags { "Queue"="Transparent+102" "RenderType"="Transparent" "DisableBatching"="True" }
// Glow passes
Pass
{
Stencil {
Ref 2
Comp [_GlowStencilComp]
Pass [_GlowStencilOp]
ReadMask 2
WriteMask 2
}
Blend SrcAlpha OneMinusSrcAlpha
ZWrite Off
Cull [_Cull]
ZTest [_GlowZTest]
CGPROGRAM
#pragma vertex vert
#pragma fragment frag
#pragma multi_compile_instancing
#pragma multi_compile_local _ HP_ALPHACLIP
#include "UnityCG.cginc"
#include "CustomVertexTransform.cginc"
struct appdata
{
float4 vertex : POSITION;
float3 normal : NORMAL;
float2 uv : TEXCOORD0;
UNITY_VERTEX_INPUT_INSTANCE_ID
};
struct v2f
{
float4 pos : SV_POSITION;
fixed4 color : COLOR;
float2 uv : TEXCOORD0;
UNITY_VERTEX_INPUT_INSTANCE_ID
UNITY_VERTEX_OUTPUT_STEREO
};
//float4 _Glow; // x = intensity, y = width, z = magic number 1, w = magic number 2
float3 _Glow2; // x = outline width, y = glow speed, z = dither on/off
float _ConstantWidth;
fixed _CutOff;
sampler _MainTex;
float4 _MainTex_ST;
float4 _MainTex_TexelSize;
UNITY_INSTANCING_BUFFER_START(Props)
UNITY_DEFINE_INSTANCED_PROP(float4, _GlowColor)
UNITY_DEFINE_INSTANCED_PROP(float4, _Glow)
UNITY_DEFINE_INSTANCED_PROP(float4, _GlowDirection)
UNITY_INSTANCING_BUFFER_END(Props)
v2f vert (appdata v)
{
v2f o;
UNITY_SETUP_INSTANCE_ID(v);
UNITY_TRANSFER_INSTANCE_ID(v, o);
UNITY_INITIALIZE_OUTPUT(v2f, o);
UNITY_INITIALIZE_VERTEX_OUTPUT_STEREO(o);
float4 pos = ComputeVertexPosition(v.vertex);
float3 norm = mul ((float3x3)UNITY_MATRIX_IT_MV, v.normal);
float2 offset = any(norm.xy)!=0 ? TransformViewToProjection(normalize(norm.xy)) : 0.0.xx;
float2 glowDirection = UNITY_ACCESS_INSTANCED_PROP(Props, _GlowDirection);
#if defined(UNITY_STEREO_INSTANCING_ENABLED) || defined(UNITY_STEREO_MULTIVIEW_ENABLED) || defined(SINGLE_PASS_STEREO)
glowDirection.x *= 2.0;
#endif
offset += glowDirection;
float z = lerp(UNITY_Z_0_FAR_FROM_CLIPSPACE(pos.z), 2.0, UNITY_MATRIX_P[3][3]);
z = _ConstantWidth * (z - 2.0) + 2.0;
float outlineWidth = _Glow2.x;
float4 glow = UNITY_ACCESS_INSTANCED_PROP(Props, _Glow);
float animatedWidth = glow.y * (1.0 + 0.25 * sin(_Time.w * _Glow2.y));
offset *= z * (outlineWidth + animatedWidth);
pos.xy += offset;
o.pos = pos;
o.color = UNITY_ACCESS_INSTANCED_PROP(Props, _GlowColor);
o.color.a = glow.x;
o.uv = TRANSFORM_TEX (v.uv, _MainTex);
return o;
}
fixed4 frag (v2f i) : SV_Target
{
UNITY_SETUP_INSTANCE_ID(i);
#if HP_ALPHACLIP
fixed4 col = tex2D(_MainTex, i.uv);
clip(col.a - _CutOff);
#endif
fixed4 color = i.color;
float4 glow = UNITY_ACCESS_INSTANCED_PROP(Props, _Glow);
float2 screenPos = floor( i.pos.xy * glow.z ) * glow.w;
color.a *= saturate(_Glow2.z + frac(screenPos.x + screenPos.y));
return color;
}
ENDCG
}
}
}

View File

@ -0,0 +1,9 @@
fileFormatVersion: 2
guid: 049d9e75e07674a78a703cf1203c07dd
timeCreated: 1544699250
licenseType: Store
ShaderImporter:
defaultTextures: []
userData:
assetBundleName:
assetBundleVariant:

View File

@ -0,0 +1,91 @@
Shader "HighlightPlus/Geometry/InnerGlow" {
Properties {
_MainTex ("Texture", Any) = "white" {}
_Color ("Color", Color) = (1,1,1) // not used; dummy property to avoid inspector warning "material has no _Color property"
_InnerGlowColor ("Inner Glow Color", Color) = (1,1,1,1)
_InnerGlowWidth ("Width", Float) = 1.0
_CutOff("CutOff", Float ) = 0.5
_Cull ("Cull Mode", Int) = 2
_InnerGlowZTest ("ZTest", Int) = 4
}
SubShader
{
Tags { "Queue"="Transparent+122" "RenderType"="Transparent" }
// Inner Glow
Pass
{
Stencil {
Ref 4
ReadMask 4
Comp NotEqual
Pass keep
}
Blend SrcAlpha One
ZWrite Off
Offset -1, -1
ZTest [_InnerGlowZTest]
Cull [_Cull]
CGPROGRAM
#pragma vertex vert
#pragma fragment frag
#pragma multi_compile_local _ HP_ALPHACLIP
#include "UnityCG.cginc"
#include "CustomVertexTransform.cginc"
struct appdata
{
float4 vertex : POSITION;
float2 uv : TEXCOORD0;
float3 normal : NORMAL;
UNITY_VERTEX_INPUT_INSTANCE_ID
};
struct v2f
{
float4 pos : SV_POSITION;
float2 uv : TEXCOORD0;
float3 wpos : TEXCOORD1;
float3 normal : NORMAL;
UNITY_VERTEX_OUTPUT_STEREO
};
sampler _MainTex;
float4 _MainTex_ST;
fixed _CutOff;
fixed4 _InnerGlowColor;
fixed _InnerGlowWidth;
v2f vert (appdata v)
{
v2f o;
UNITY_SETUP_INSTANCE_ID(v);
UNITY_INITIALIZE_OUTPUT(v2f, o);
UNITY_INITIALIZE_VERTEX_OUTPUT_STEREO(o);
o.pos = ComputeVertexPosition(v.vertex);
o.wpos = mul(unity_ObjectToWorld, v.vertex).xyz;
o.normal = UnityObjectToWorldNormal(v.normal);
o.uv = TRANSFORM_TEX (v.uv, _MainTex);
return o;
}
fixed4 frag (v2f i) : SV_Target
{
#if HP_ALPHACLIP
fixed4 color = tex2D(_MainTex, i.uv);
clip(color.a - _CutOff);
#endif
float3 viewDir = normalize(i.wpos - _WorldSpaceCameraPos.xyz);
fixed dx = saturate(_InnerGlowWidth - abs(dot(viewDir, normalize(i.normal)))) / _InnerGlowWidth;
fixed4 col = _InnerGlowColor * dx;
return col;
}
ENDCG
}
}
}

View File

@ -0,0 +1,9 @@
fileFormatVersion: 2
guid: e5a069457bd344391acd5af227c0ce11
timeCreated: 1544699250
licenseType: Store
ShaderImporter:
defaultTextures: []
userData:
assetBundleName:
assetBundleVariant:

View File

@ -0,0 +1,114 @@
Shader "HighlightPlus/Geometry/Mask" {
Properties {
_MainTex ("Texture", Any) = "white" {}
_Color ("Color", Color) = (1,1,1) // not used; dummy property to avoid inspector warning "material has no _Color property"
_CutOff("CutOff", Float ) = 0.5
_Cull ("Cull Mode", Int) = 2
_ZTest("ZTest", Int) = 4
}
SubShader
{
Tags { "Queue"="Transparent+100" "RenderType"="Transparent" "DisableBatching"="True" }
CGINCLUDE
#include "UnityCG.cginc"
#include "CustomVertexTransform.cginc"
sampler _MainTex;
float4 _MainTex_ST;
float4 _MainTex_TexelSize;
fixed _CutOff;
struct appdata
{
float4 vertex : POSITION;
float2 uv : TEXCOORD0;
UNITY_VERTEX_INPUT_INSTANCE_ID
};
struct v2f
{
float4 pos: SV_POSITION;
float2 uv : TEXCOORD0;
UNITY_VERTEX_OUTPUT_STEREO
};
v2f vert (appdata v)
{
v2f o;
UNITY_SETUP_INSTANCE_ID(v);
UNITY_INITIALIZE_OUTPUT(v2f, o);
UNITY_INITIALIZE_VERTEX_OUTPUT_STEREO(o);
o.pos = ComputeVertexPosition(v.vertex);
o.uv = TRANSFORM_TEX (v.uv, _MainTex);
#if UNITY_REVERSED_Z
o.pos.z += 0.0001;
#else
o.pos.z -= 0.0001;
#endif
return o;
}
fixed4 frag (v2f i) : SV_Target
{
#if HP_ALPHACLIP
fixed4 col = tex2D(_MainTex, i.uv);
clip(col.a - _CutOff);
#endif
return 0;
}
ENDCG
// Create mask
Pass
{
Name "Mask"
Stencil {
Ref 2
Comp always
Pass replace
WriteMask 2
ReadMask 2
}
ColorMask 0
ZWrite Off
Cull [_Cull] // default Cull Back improves glow in high quality)
ZTest [_ZTest]
CGPROGRAM
#pragma vertex vert
#pragma fragment frag
#pragma multi_compile_local _ HP_ALPHACLIP
ENDCG
}
// Create mask for see-through (the only difference is the ZTest)
Pass
{
Name "See-through Mask"
Stencil {
Ref 2
Comp always
Pass replace
WriteMask 2
ReadMask 2
}
ColorMask 0
ZWrite Off
Cull [_Cull] // default Cull Back improves glow in high quality)
ZTest LEqual
CGPROGRAM
#pragma vertex vert
#pragma fragment frag
#pragma multi_compile_local _ HP_ALPHACLIP
ENDCG
}
}
}

View File

@ -0,0 +1,9 @@
fileFormatVersion: 2
guid: e694fa934b6db4a00b8d4b9887115332
timeCreated: 1544699251
licenseType: Store
ShaderImporter:
defaultTextures: []
userData:
assetBundleName:
assetBundleVariant:

View File

@ -0,0 +1,58 @@
Shader "HighlightPlus/Geometry/SeeThroughOccluder" {
Properties {
_MainTex ("Texture", Any) = "white" {}
_Color ("Color", Color) = (1,1,1) // not used; dummy property to avoid inspector warning "material has no _Color property"
}
SubShader
{
Tags { "Queue"="Transparent+100" "RenderType"="Transparent" }
// Create mask
Pass
{
Stencil {
Ref 2
Comp always
Pass DecrWrap
}
ColorMask 0
ZWrite Off
Offset -1, -1
CGPROGRAM
#pragma vertex vert
#pragma fragment frag
#include "UnityCG.cginc"
struct appdata
{
float4 vertex : POSITION;
UNITY_VERTEX_INPUT_INSTANCE_ID
};
struct v2f
{
float4 pos : SV_POSITION;
UNITY_VERTEX_OUTPUT_STEREO
};
v2f vert (appdata v)
{
v2f o;
UNITY_SETUP_INSTANCE_ID(v);
UNITY_INITIALIZE_OUTPUT(v2f, o);
UNITY_INITIALIZE_VERTEX_OUTPUT_STEREO(o);
o.pos = UnityObjectToClipPos(v.vertex);
return o;
}
fixed4 frag (v2f i) : SV_Target
{
return 0;
}
ENDCG
}
}
}

View File

@ -0,0 +1,9 @@
fileFormatVersion: 2
guid: 229baf997355a43cda580dd4cf86b71e
timeCreated: 1544699251
licenseType: Store
ShaderImporter:
defaultTextures: []
userData:
assetBundleName:
assetBundleVariant:

View File

@ -0,0 +1,94 @@
%YAML 1.1
%TAG !u! tag:unity3d.com,2011:
--- !u!114 &-6555637095062934885
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: 1
--- !u!21 &2100000
Material:
serializedVersion: 6
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_Name: HighlightOutline
m_Shader: {fileID: 4800000, guid: cbbf740e9c8644e8492d08b1a3fd0203, type: 3}
m_ShaderKeywords:
m_LightmapFlags: 4
m_EnableInstancingVariants: 1
m_DoubleSidedGI: 0
m_CustomRenderQueue: -1
stringTagMap: {}
disabledShaderPasses: []
m_SavedProperties:
serializedVersion: 3
m_TexEnvs:
- _BaseMap:
m_Texture: {fileID: 0}
m_Scale: {x: 1, y: 1}
m_Offset: {x: 0, y: 0}
- _BumpMap:
m_Texture: {fileID: 0}
m_Scale: {x: 1, y: 1}
m_Offset: {x: 0, y: 0}
- _EmissionMap:
m_Texture: {fileID: 0}
m_Scale: {x: 1, y: 1}
m_Offset: {x: 0, y: 0}
- _MainTex:
m_Texture: {fileID: 0}
m_Scale: {x: 1, y: 1}
m_Offset: {x: 0, y: 0}
- _MetallicGlossMap:
m_Texture: {fileID: 0}
m_Scale: {x: 1, y: 1}
m_Offset: {x: 0, y: 0}
- _OcclusionMap:
m_Texture: {fileID: 0}
m_Scale: {x: 1, y: 1}
m_Offset: {x: 0, y: 0}
- _SpecGlossMap:
m_Texture: {fileID: 0}
m_Scale: {x: 1, y: 1}
m_Offset: {x: 0, y: 0}
m_Floats:
- _AlphaClip: 0
- _Blend: 0
- _BumpScale: 1
- _ConstantWidth: 1
- _Cull: 2
- _Cutoff: 0.5
- _DstBlend: 0
- _EnvironmentReflections: 1
- _GlossMapScale: 0
- _Glossiness: 0
- _GlossyReflections: 0
- _Metallic: 0
- _OcclusionStrength: 1
- _OutlineWidth: 0.01
- _OutlineZTest: 4
- _QueueOffset: 0
- _ReceiveShadows: 1
- _Smoothness: 0.5
- _SmoothnessTextureChannel: 0
- _SpecularHighlights: 1
- _SrcBlend: 1
- _Surface: 0
- _WorkflowMode: 1
- _ZWrite: 1
m_Colors:
- _BaseColor: {r: 0.5, g: 0.5, b: 0.5, a: 1}
- _Color: {r: 0.5, g: 0.5, b: 0.5, a: 1}
- _EmissionColor: {r: 0, g: 0, b: 0, a: 1}
- _OutlineColor: {r: 0, g: 0, b: 0, a: 1}
- _OutlineDirection: {r: 0, g: 0, b: 0, a: 1}
- _SpecColor: {r: 0.2, g: 0.2, b: 0.2, a: 1}

View File

@ -0,0 +1,8 @@
fileFormatVersion: 2
guid: 580895c3d590f4760ba7d0ee2a5dc624
NativeFormatImporter:
externalObjects: {}
mainObjectFileID: 0
userData:
assetBundleName:
assetBundleVariant:

View File

@ -0,0 +1,160 @@
Shader "HighlightPlus/Geometry/Outline" {
Properties {
_MainTex ("Texture", Any) = "white" {}
_OutlineWidth ("Outline Offset", Float) = 0.01
_Color ("Color", Color) = (1,1,1) // not used; dummy property to avoid inspector warning "material has no _Color property"
_Cull ("Cull Mode", Int) = 2
_ConstantWidth ("Constant Width", Float) = 1
_OutlineZTest("ZTest", Int) = 4
_CutOff("CutOff", Float ) = 0.5
}
SubShader
{
Tags { "Queue"="Transparent+120" "RenderType"="Transparent" "DisableBatching"="True" }
Pass
{
Name "Outline"
Stencil {
Ref 2
Comp NotEqual
Pass replace
ReadMask 2
WriteMask 2
}
Blend SrcAlpha OneMinusSrcAlpha
ZWrite Off
Cull [_Cull]
ZTest [_OutlineZTest]
CGPROGRAM
#pragma vertex vert
#pragma fragment frag
#pragma multi_compile_instancing
#pragma multi_compile_local _ HP_ALPHACLIP
#include "UnityCG.cginc"
#include "CustomVertexTransform.cginc"
struct appdata
{
float4 vertex : POSITION;
float3 normal : NORMAL;
float2 uv : TEXCOORD0;
UNITY_VERTEX_INPUT_INSTANCE_ID
};
struct v2f
{
float4 pos : SV_POSITION;
float2 uv : TEXCOORD0;
UNITY_VERTEX_OUTPUT_STEREO
};
fixed4 _OutlineColor;
float _OutlineWidth;
float _ConstantWidth;
fixed _CutOff;
sampler _MainTex;
float4 _MainTex_ST;
float4 _MainTex_TexelSize;
UNITY_INSTANCING_BUFFER_START(Props)
UNITY_DEFINE_INSTANCED_PROP(float4, _OutlineDirection)
UNITY_INSTANCING_BUFFER_END(Props)
v2f vert (appdata v)
{
v2f o;
UNITY_SETUP_INSTANCE_ID(v);
UNITY_INITIALIZE_OUTPUT(v2f, o);
UNITY_INITIALIZE_VERTEX_OUTPUT_STEREO(o);
o.pos = ComputeVertexPosition(v.vertex);
float3 norm = mul ((float3x3)UNITY_MATRIX_IT_MV, v.normal);
float2 offset = any(norm.xy)!=0 ? TransformViewToProjection(normalize(norm.xy)) : 0.0.xx;
float z = lerp(UNITY_Z_0_FAR_FROM_CLIPSPACE(o.pos.z), 2.0, UNITY_MATRIX_P[3][3]);
z = _ConstantWidth * (z - 2.0) + 2.0;
float4 outlineDirection = UNITY_ACCESS_INSTANCED_PROP(Props, _OutlineDirection);
#if defined(UNITY_STEREO_INSTANCING_ENABLED) || defined(UNITY_STEREO_MULTIVIEW_ENABLED) || defined(SINGLE_PASS_STEREO)
outlineDirection.x *= 2.0;
#endif
o.pos.xy += offset * z * _OutlineWidth + outlineDirection.xy * z;
o.uv = TRANSFORM_TEX (v.uv, _MainTex);
return o;
}
fixed4 frag (v2f i) : SV_Target
{
#if HP_ALPHACLIP
fixed4 col = tex2D(_MainTex, i.uv);
clip(col.a - _CutOff);
#endif
return _OutlineColor;
}
ENDCG
}
Pass
{
Name "Outline Clear Stencil"
Stencil {
Ref 2
Comp Always
Pass zero
}
ColorMask 0
ZWrite Off
Cull [_Cull]
ZTest [_OutlineZTest]
CGPROGRAM
#pragma vertex vert
#pragma fragment frag
#include "UnityCG.cginc"
#include "CustomVertexTransform.cginc"
struct appdata
{
float4 vertex : POSITION;
float3 normal : NORMAL;
UNITY_VERTEX_INPUT_INSTANCE_ID
};
struct v2f
{
float4 pos : SV_POSITION;
UNITY_VERTEX_OUTPUT_STEREO
};
fixed4 _OutlineColor;
float _OutlineWidth;
float2 _OutlineDirection;
float _ConstantWidth;
v2f vert (appdata v)
{
v2f o;
UNITY_SETUP_INSTANCE_ID(v);
UNITY_INITIALIZE_OUTPUT(v2f, o);
UNITY_INITIALIZE_VERTEX_OUTPUT_STEREO(o);
o.pos = ComputeVertexPosition(v.vertex);
float3 norm = mul ((float3x3)UNITY_MATRIX_IT_MV, v.normal);
float2 offset = any(norm.xy)!=0 ? TransformViewToProjection(normalize(norm.xy)) : 0.0.xx;
float z = lerp(UNITY_Z_0_FAR_FROM_CLIPSPACE(o.pos.z), 2.0, UNITY_MATRIX_P[3][3]);
z = _ConstantWidth * (z - 2.0) + 2.0;
o.pos.xy += offset * z * _OutlineWidth + _OutlineDirection * z;
return o;
}
fixed4 frag (v2f i) : SV_Target
{
return 0;
}
ENDCG
}
}
}

View File

@ -0,0 +1,9 @@
fileFormatVersion: 2
guid: cbbf740e9c8644e8492d08b1a3fd0203
timeCreated: 1544699250
licenseType: Store
ShaderImporter:
defaultTextures: []
userData:
assetBundleName:
assetBundleVariant:

View File

@ -0,0 +1,122 @@
Shader "HighlightPlus/Geometry/Overlay" {
Properties {
_MainTex ("Texture", Any) = "white" {}
_Color ("Color", Color) = (1,1,1) // not used; dummy property to avoid inspector warning "material has no _Color property"
_OverlayColor ("Overlay Color", Color) = (1,1,1,1)
_OverlayBackColor ("Overlay Back Color", Color) = (1,1,1,1)
_OverlayData("Overlay Data", Vector) = (1,0.5,1,1)
_OverlayHitPosData("Overlay Hit Pos Data", Vector) = (0,0,0,0)
_OverlayTexture("Overlay Texture", 2D) = "white" {}
_CutOff("CutOff", Float ) = 0.5
_Cull ("Cull Mode", Int) = 2
}
SubShader
{
Tags { "Queue"="Transparent+121" "RenderType"="Transparent" "DisableBatching"="True" }
// Overlay
Pass
{
Stencil {
Ref 4
ReadMask 4
Comp NotEqual
Pass keep
}
Blend SrcAlpha OneMinusSrcAlpha
ZWrite Off
Offset -1, -1
Cull [_Cull]
CGPROGRAM
#pragma vertex vert
#pragma fragment frag
#pragma multi_compile_local _ HP_ALPHACLIP
#pragma multi_compile_local _ HP_USES_OVERLAY_TEXTURE
#include "UnityCG.cginc"
#include "CustomVertexTransform.cginc"
struct appdata
{
float4 vertex : POSITION;
float2 uv : TEXCOORD0;
float3 norm : NORMAL;
UNITY_VERTEX_INPUT_INSTANCE_ID
};
struct v2f
{
float4 pos : SV_POSITION;
float2 uv : TEXCOORD0;
float3 wpos : TEXCOORD1;
float3 wnorm : TEXCOORD2;
UNITY_VERTEX_OUTPUT_STEREO
};
fixed4 _OverlayColor;
sampler2D _MainTex;
float4 _MainTex_ST;
fixed4 _OverlayBackColor;
fixed4 _OverlayData; // x = speed, y = MinIntensity, z = blend, w = texture scale
float4 _OverlayHitPosData;
float _OverlayHitStartTime;
fixed _CutOff;
sampler2D _OverlayTexture;
v2f vert (appdata v)
{
v2f o;
UNITY_SETUP_INSTANCE_ID(v);
UNITY_INITIALIZE_OUTPUT(v2f, o);
UNITY_INITIALIZE_VERTEX_OUTPUT_STEREO(o);
o.pos = ComputeVertexPosition(v.vertex);
o.wpos = mul(unity_ObjectToWorld, v.vertex).xyz;
o.wnorm = UnityObjectToWorldNormal(v.norm);
o.uv = TRANSFORM_TEX (v.uv, _MainTex);
return o;
}
fixed4 frag (v2f i) : SV_Target
{
fixed4 color = tex2D(_MainTex, i.uv);
#if HP_ALPHACLIP
clip(color.a - _CutOff);
#endif
float time = _Time.y % 1000;
fixed t = _OverlayData.y + (1.0 - _OverlayData.y) * 2.0 * abs(0.5 - frac(time * _OverlayData.x));
fixed4 col = lerp(_OverlayColor, color * _OverlayBackColor * _OverlayColor, _OverlayData.z);
col.a *= t;
if (_OverlayHitPosData.w>0) {
float elapsed = _Time.y - _OverlayHitStartTime;
float hitDist = distance(i.wpos, _OverlayHitPosData.xyz);
float atten = saturate( min(elapsed, _OverlayHitPosData.w) / hitDist );
col.a *= atten;
}
#if HP_USES_OVERLAY_TEXTURE
half3 triblend = saturate(pow(i.wnorm, 4));
triblend /= max(dot(triblend, half3(1,1,1)), 0.0001);
// triplanar uvs
float3 tpos = i.wpos * _OverlayData.w;
float2 uvX = tpos.zy;
float2 uvY = tpos.xz;
float2 uvZ = tpos.xy;
// albedo textures
fixed4 colX = tex2D(_OverlayTexture, uvX);
fixed4 colY = tex2D(_OverlayTexture, uvY);
fixed4 colZ = tex2D(_OverlayTexture, uvZ);
fixed4 tex = colX * triblend.x + colY * triblend.y + colZ * triblend.z;
col *= tex;
#endif
return col;
}
ENDCG
}
}
}

View File

@ -0,0 +1,9 @@
fileFormatVersion: 2
guid: d17a98d19ada34bb7b4f86130e590159
timeCreated: 1544699250
licenseType: Store
ShaderImporter:
defaultTextures: []
userData:
assetBundleName:
assetBundleVariant:

View File

@ -0,0 +1,76 @@
%YAML 1.1
%TAG !u! tag:unity3d.com,2011:
--- !u!21 &2100000
Material:
serializedVersion: 6
m_ObjectHideFlags: 0
m_PrefabParentObject: {fileID: 0}
m_PrefabInternal: {fileID: 0}
m_Name: HighlightPlusDepthWrite
m_Shader: {fileID: 4800000, guid: 058a572e30b2d446bade2dda32bcef0f, type: 3}
m_ShaderKeywords:
m_LightmapFlags: 4
m_EnableInstancingVariants: 0
m_DoubleSidedGI: 0
m_CustomRenderQueue: -1
stringTagMap: {}
disabledShaderPasses: []
m_SavedProperties:
serializedVersion: 3
m_TexEnvs:
- _BumpMap:
m_Texture: {fileID: 0}
m_Scale: {x: 1, y: 1}
m_Offset: {x: 0, y: 0}
- _DetailAlbedoMap:
m_Texture: {fileID: 0}
m_Scale: {x: 1, y: 1}
m_Offset: {x: 0, y: 0}
- _DetailMask:
m_Texture: {fileID: 0}
m_Scale: {x: 1, y: 1}
m_Offset: {x: 0, y: 0}
- _DetailNormalMap:
m_Texture: {fileID: 0}
m_Scale: {x: 1, y: 1}
m_Offset: {x: 0, y: 0}
- _EmissionMap:
m_Texture: {fileID: 0}
m_Scale: {x: 1, y: 1}
m_Offset: {x: 0, y: 0}
- _MainTex:
m_Texture: {fileID: 0}
m_Scale: {x: 1, y: 1}
m_Offset: {x: 0, y: 0}
- _MetallicGlossMap:
m_Texture: {fileID: 0}
m_Scale: {x: 1, y: 1}
m_Offset: {x: 0, y: 0}
- _OcclusionMap:
m_Texture: {fileID: 0}
m_Scale: {x: 1, y: 1}
m_Offset: {x: 0, y: 0}
- _ParallaxMap:
m_Texture: {fileID: 0}
m_Scale: {x: 1, y: 1}
m_Offset: {x: 0, y: 0}
m_Floats:
- _BumpScale: 1
- _Cutoff: 0.5
- _DetailNormalMapScale: 1
- _DstBlend: 0
- _GlossMapScale: 1
- _Glossiness: 0.5
- _GlossyReflections: 1
- _Metallic: 0
- _Mode: 0
- _OcclusionStrength: 1
- _Parallax: 0.02
- _SmoothnessTextureChannel: 0
- _SpecularHighlights: 1
- _SrcBlend: 1
- _UVSec: 0
- _ZWrite: 1
m_Colors:
- _Color: {r: 1, g: 1, b: 1, a: 1}
- _EmissionColor: {r: 0, g: 0, b: 0, a: 1}

View File

@ -0,0 +1,9 @@
fileFormatVersion: 2
guid: 825cb444e111842cf97788cbb7583edd
timeCreated: 1546857910
licenseType: Store
NativeFormatImporter:
mainObjectFileID: 2100000
userData:
assetBundleName:
assetBundleVariant:

View File

@ -0,0 +1,124 @@
Shader "HighlightPlus/Geometry/SeeThrough" {
Properties {
_MainTex ("Texture", Any) = "white" {}
_SeeThrough ("See Through", Range(0,1)) = 0.8
_SeeThroughTintColor ("See Through Tint Color", Color) = (1,0,0,0.8)
_SeeThroughNoise("Noise", Float) = 1
_Color ("Color", Color) = (1,1,1) // not used; dummy property to avoid inspector warning "material has no _Color property"
_CutOff("CutOff", Float ) = 0.5
_SeeThroughStencilRef ("Stencil Ref", Int) = 2
_SeeThroughStencilComp ("Stencil Comp", Int) = 5
_SeeThroughStencilPassOp ("Stencil Pass Operation", Int) = 0
_SeeThroughDepthOffset ("Depth Offset", Float) = 0
_SeeThroughMaxDepth("Max Depth", Float) = 0
}
SubShader
{
Tags { "Queue"="Transparent+201" "RenderType"="Transparent" "DisableBatching"="True" }
// See through effect
Pass
{
Name "See-through"
Stencil {
ReadMask 3
WriteMask 3
Ref [_SeeThroughStencilRef]
Comp [_SeeThroughStencilComp]
Pass [_SeeThroughStencilPassOp]
Fail [_SeeThroughStencilPassOp]
}
ZTest Greater
ZWrite Off
Blend SrcAlpha OneMinusSrcAlpha
CGPROGRAM
#pragma vertex vert
#pragma fragment frag
#pragma multi_compile_local _ HP_ALPHACLIP
#pragma multi_compile_local _ HP_DEPTH_OFFSET
#pragma multi_compile_local _ HP_SEETHROUGH_ONLY_BORDER
#include "UnityCG.cginc"
#include "CustomVertexTransform.cginc"
struct appdata
{
float4 vertex : POSITION;
float3 normal : NORMAL;
float2 uv : TEXCOORD0;
UNITY_VERTEX_INPUT_INSTANCE_ID
};
struct v2f
{
float4 pos: SV_POSITION;
float2 uv : TEXCOORD0;
#if HP_DEPTH_OFFSET
float4 scrPos : TEXCOORD1;
float depth : TEXCOORD2;
#endif
UNITY_VERTEX_OUTPUT_STEREO
};
sampler2D _MainTex;
float4 _MainTex_ST;
fixed _SeeThrough;
fixed4 _SeeThroughTintColor;
fixed _CutOff;
fixed _SeeThroughNoise;
float _SeeThroughDepthOffset;
float _SeeThroughMaxDepth;
UNITY_DECLARE_DEPTH_TEXTURE(_CameraDepthTexture);
v2f vert (appdata v)
{
v2f o;
UNITY_SETUP_INSTANCE_ID(v);
UNITY_INITIALIZE_OUTPUT(v2f, o);
UNITY_INITIALIZE_VERTEX_OUTPUT_STEREO(o);
o.pos = ComputeVertexPosition(v.vertex);
#if HP_DEPTH_OFFSET
o.scrPos = ComputeScreenPos(o.pos);
COMPUTE_EYEDEPTH(o.depth);
#endif
o.uv = TRANSFORM_TEX(v.uv, _MainTex);
return o;
}
float GetEyeDepth(float rawDepth) {
float persp = LinearEyeDepth(rawDepth);
float ortho = (_ProjectionParams.z-_ProjectionParams.y)*(1-rawDepth)+_ProjectionParams.y;
return lerp(persp,ortho,unity_OrthoParams.w);
}
fixed4 frag (v2f i) : SV_Target
{
#if HP_SEETHROUGH_ONLY_BORDER
return 0;
#else
#if HP_DEPTH_OFFSET
float sceneZ = SAMPLE_DEPTH_TEXTURE(_CameraDepthTexture, i.scrPos.xy / i.scrPos.w);
float sceneDepth = GetEyeDepth(sceneZ);
if (i.depth - sceneDepth - _SeeThroughDepthOffset < 0 || i.depth - sceneDepth > _SeeThroughMaxDepth) discard;
#endif
fixed4 col = tex2D(_MainTex, i.uv);
#if HP_ALPHACLIP
clip(col.a - _CutOff);
#endif
col.rgb = lerp(col.rgb, _SeeThroughTintColor.rgb, _SeeThroughTintColor.a);
float scry = i.pos.y;
float time = _Time.w % 1.0;
col.rgb += _SeeThroughNoise *(frac( scry * time ) * 0.1);
col.a = _SeeThrough;
col.a = lerp(col.a, col.a * ( (scry % 2) - 1.0 ), _SeeThroughNoise);
return col;
#endif // HP_ONLY_BORDER
}
ENDCG
}
}
}

View File

@ -0,0 +1,9 @@
fileFormatVersion: 2
guid: 47198bbf0b2a44882aceef6af17a467d
timeCreated: 1544699250
licenseType: Store
ShaderImporter:
defaultTextures: []
userData:
assetBundleName:
assetBundleVariant:

View File

@ -0,0 +1,118 @@
Shader "HighlightPlus/Geometry/SeeThroughBorder" {
Properties {
_MainTex ("Texture", Any) = "white" {}
_SeeThroughBorderColor ("Outline Color", Color) = (0,0,0,1)
_Color ("Color", Color) = (1,1,1) // not used; dummy property to avoid inspector warning "material has no _Color property"
_CutOff("CutOff", Float ) = 0.5
_SeeThroughBorderWidth ("Outline Offset", Float) = 0.01
_SeeThroughBorderConstantWidth ("Constant Width", Float) = 1
_SeeThroughStencilRef ("Stencil Ref", Int) = 2
_SeeThroughStencilComp ("Stencil Comp", Int) = 5
_SeeThroughDepthOffset ("Depth Offset", Float) = 0
_SeeThroughMaxDepth("Max Depth", Float) = 0
_SeeThroughStencilPassOp ("Stencil Pass Operation", Int) = 0
}
SubShader
{
Tags { "Queue"="Transparent+201" "RenderType"="Transparent" "DisableBatching"="True" }
// See through effect
Pass
{
Name "See-through border"
Stencil {
ReadMask 3
WriteMask 3
Ref [_SeeThroughStencilRef]
Comp [_SeeThroughStencilComp]
Pass [_SeeThroughStencilPassOp]
Fail [_SeeThroughStencilPassOp]
}
ZTest Greater
ZWrite Off
Blend SrcAlpha OneMinusSrcAlpha
CGPROGRAM
#pragma vertex vert
#pragma fragment frag
#pragma multi_compile_local _ HP_ALPHACLIP
#pragma multi_compile_local _ HP_DEPTH_OFFSET
#include "UnityCG.cginc"
#include "CustomVertexTransform.cginc"
struct appdata
{
float4 vertex : POSITION;
float2 uv : TEXCOORD0;
float3 normal : NORMAL;
UNITY_VERTEX_INPUT_INSTANCE_ID
};
struct v2f
{
float4 pos: SV_POSITION;
float2 uv : TEXCOORD0;
#if HP_DEPTH_OFFSET
float4 scrPos : TEXCOORD1;
float depth : TEXCOORD2;
#endif
UNITY_VERTEX_OUTPUT_STEREO
};
sampler2D _MainTex;
float4 _MainTex_ST;
fixed4 _SeeThroughBorderColor;
fixed _CutOff;
float _SeeThroughDepthOffset;
float _SeeThroughMaxDepth;
float _SeeThroughBorderWidth;
float _SeeThroughBorderConstantWidth;
UNITY_DECLARE_DEPTH_TEXTURE(_CameraDepthTexture);
v2f vert (appdata v)
{
v2f o;
UNITY_SETUP_INSTANCE_ID(v);
UNITY_INITIALIZE_OUTPUT(v2f, o);
UNITY_INITIALIZE_VERTEX_OUTPUT_STEREO(o);
o.pos = ComputeVertexPosition(v.vertex);
#if HP_DEPTH_OFFSET
o.scrPos = ComputeScreenPos(o.pos);
COMPUTE_EYEDEPTH(o.depth);
#endif
float3 norm = mul ((float3x3)UNITY_MATRIX_IT_MV, v.normal);
float2 offset = any(norm.xy)!=0 ? TransformViewToProjection(normalize(norm.xy)) : 0.0.xx;
float z = lerp(UNITY_Z_0_FAR_FROM_CLIPSPACE(o.pos.z), 2.0, UNITY_MATRIX_P[3][3]);
z = _SeeThroughBorderConstantWidth * (z - 2.0) + 2.0;
o.pos.xy += offset * z * _SeeThroughBorderWidth;
o.uv = TRANSFORM_TEX(v.uv, _MainTex);
return o;
}
float GetEyeDepth(float rawDepth) {
float persp = LinearEyeDepth(rawDepth);
float ortho = (_ProjectionParams.z-_ProjectionParams.y)*(1-rawDepth)+_ProjectionParams.y;
return lerp(persp,ortho,unity_OrthoParams.w);
}
fixed4 frag (v2f i) : SV_Target
{
#if HP_DEPTH_OFFSET
float sceneZ = SAMPLE_DEPTH_TEXTURE(_CameraDepthTexture, i.scrPos.xy / i.scrPos.w);
float sceneDepth = GetEyeDepth(sceneZ);
if (i.depth - sceneDepth - _SeeThroughDepthOffset < 0 || i.depth - sceneDepth > _SeeThroughMaxDepth) discard;
#endif
#if HP_ALPHACLIP
fixed4 col = tex2D(_MainTex, i.uv);
clip(col.a - _CutOff);
#endif
return _SeeThroughBorderColor;
}
ENDCG
}
}
}

View File

@ -0,0 +1,9 @@
fileFormatVersion: 2
guid: fe0a98aa774224cf1bc4a800a586a33a
ShaderImporter:
externalObjects: {}
defaultTextures: []
nonModifiableTextures: []
userData:
assetBundleName:
assetBundleVariant:

View File

@ -0,0 +1,62 @@
Shader "HighlightPlus/Geometry/SeeThroughMask" {
Properties {
_MainTex ("Texture", Any) = "white" {}
_Color ("Color", Color) = (1,1,1) // not used; dummy property to avoid inspector warning "material has no _Color property"
}
SubShader
{
Tags { "Queue"="Transparent+201" "RenderType"="Transparent" "DisableBatching"="True" }
// See through effect
Pass
{
Name "See-through mask"
Stencil {
WriteMask 3
Ref 1
Comp always
Pass replace
}
ZTest Always
ZWrite Off
ColorMask 0
CGPROGRAM
#pragma vertex vert
#pragma fragment frag
#include "UnityCG.cginc"
#include "CustomVertexTransform.cginc"
struct appdata
{
float4 vertex : POSITION;
UNITY_VERTEX_INPUT_INSTANCE_ID
};
struct v2f
{
float4 pos: SV_POSITION;
UNITY_VERTEX_OUTPUT_STEREO
};
v2f vert (appdata v)
{
v2f o;
UNITY_SETUP_INSTANCE_ID(v);
UNITY_INITIALIZE_OUTPUT(v2f, o);
UNITY_INITIALIZE_VERTEX_OUTPUT_STEREO(o);
o.pos = ComputeVertexPosition(v.vertex);
return o;
}
fixed4 frag (v2f i) : SV_Target
{
return 0;
}
ENDCG
}
}
}

View File

@ -0,0 +1,9 @@
fileFormatVersion: 2
guid: 457d76fdfc7c4472faeb0297c0edab29
ShaderImporter:
externalObjects: {}
defaultTextures: []
nonModifiableTextures: []
userData:
assetBundleName:
assetBundleVariant:

View File

@ -0,0 +1,102 @@
Shader "HighlightPlus/Geometry/SolidColor" {
Properties {
_MainTex ("Texture", Any) = "white" {}
_Color ("Color", Color) = (1,1,1) // not used; dummy property to avoid inspector warning "material has no _Color property"
_CutOff("CutOff", Float ) = 0.5
_Cull ("Cull Mode", Int) = 2
_ZTest("ZTest", Int) = 4
}
SubShader
{
Tags { "Queue"="Transparent+100" "RenderType"="Transparent" "DisableBatching" = "True" }
// Compose effect on camera target
Pass
{
ZWrite Off
Cull [_Cull]
ZTest Always
Stencil {
Ref 2
Comp NotEqual
Pass replace
}
CGPROGRAM
#pragma vertex vert
#pragma fragment frag
#pragma multi_compile_local _ HP_ALPHACLIP
#pragma multi_compile_local _ HP_DEPTHCLIP
#include "UnityCG.cginc"
#include "CustomVertexTransform.cginc"
sampler _MainTex;
#if HP_DEPTHCLIP
UNITY_DECLARE_DEPTH_TEXTURE(_CameraDepthTexture);
#endif
float4 _MainTex_ST;
fixed _CutOff;
fixed4 _Color;
struct appdata
{
float4 vertex : POSITION;
float2 uv : TEXCOORD0;
UNITY_VERTEX_INPUT_INSTANCE_ID
};
struct v2f
{
float4 pos : SV_POSITION;
float2 uv : TEXCOORD0;
#if HP_DEPTHCLIP
float depth : TEXCOORD1;
float4 scrPos : TEXCOORD2;
#endif
UNITY_VERTEX_INPUT_INSTANCE_ID
UNITY_VERTEX_OUTPUT_STEREO
};
v2f vert (appdata v)
{
v2f o;
UNITY_SETUP_INSTANCE_ID(v);
UNITY_INITIALIZE_OUTPUT(v2f, o);
UNITY_TRANSFER_INSTANCE_ID(v, o);
UNITY_INITIALIZE_VERTEX_OUTPUT_STEREO(o);
o.pos = ComputeVertexPosition(v.vertex);
o.uv = TRANSFORM_TEX (v.uv, _MainTex);
#if HP_DEPTHCLIP
COMPUTE_EYEDEPTH(o.depth);
o.scrPos = ComputeScreenPos(o.pos);
#endif
return o;
}
fixed4 frag (v2f i) : SV_Target
{
UNITY_SETUP_INSTANCE_ID(i);
UNITY_SETUP_STEREO_EYE_INDEX_POST_VERTEX(i);
#if HP_ALPHACLIP
fixed4 col = tex2D(_MainTex, i.uv);
clip(col.a - _CutOff);
#endif
#if HP_DEPTHCLIP
float depthRaw = SAMPLE_DEPTH_TEXTURE(_CameraDepthTexture, UnityStereoTransformScreenSpaceTex(i.scrPos.xy / i.scrPos.w ));
float depthPersp = LinearEyeDepth(depthRaw);
#if defined(UNITY_REVERSED_Z)
depthRaw = 1.0 - depthRaw;
#endif
float depthOrtho = lerp(_ProjectionParams.y, _ProjectionParams.z, depthRaw);
float vz = unity_OrthoParams.w ? depthOrtho : depthPersp;
clip( vz - i.depth * 0.999);
#endif
return fixed4(1.0, 1.0, 1.0, 1.0);
}
ENDCG
}
}
}

View File

@ -0,0 +1,9 @@
fileFormatVersion: 2
guid: 77643996218224478a471439e0ea5fb4
timeCreated: 1544699251
licenseType: Store
ShaderImporter:
defaultTextures: []
userData:
assetBundleName:
assetBundleVariant:

View File

@ -0,0 +1,168 @@
Shader "HighlightPlus/Geometry/Target" {
Properties {
_MainTex ("Texture", 2D) = "white" {}
_Color ("Color", Color) = (1,1,1,1)
_ZTest ("ZTest", Int) = 0
}
SubShader
{
Tags { "RenderType" = "Transparent" "Queue" = "Transparent-1" "DisableBatching" = "True" }
// Target FX decal
Pass
{
Stencil {
Ref 2
Comp NotEqual
ReadMask 2
}
Blend SrcAlpha OneMinusSrcAlpha
ZWrite Off
ZTest [_ZTest]
Cull Off
HLSLPROGRAM
#pragma vertex vert
#pragma fragment frag
#pragma target 3.0
#include "Packages/com.unity.render-pipelines.universal/ShaderLibrary/Core.hlsl"
#include "Packages/com.unity.render-pipelines.universal/ShaderLibrary/DeclareDepthTexture.hlsl"
struct appdata
{
float3 positionOS : POSITION;
UNITY_VERTEX_INPUT_INSTANCE_ID
};
struct v2f
{
float4 positionCS : SV_POSITION;
float4 screenPos : TEXCOORD0;
float4 rayVS : TEXCOORD1;
float3 camPosVS : TEXCOORD2;
UNITY_VERTEX_INPUT_INSTANCE_ID
UNITY_VERTEX_OUTPUT_STEREO
};
sampler2D _MainTex;
CBUFFER_START(UnityPerMaterial)
float4 _MainTex_ST;
half4 _Color;
float4 _TargetFXRenderData;
CBUFFER_END
#define GROUND_NORMAL _TargetFXRenderData.xyz
#define FADE_POWER _TargetFXRenderData.w
v2f vert(appdata input)
{
v2f o;
UNITY_SETUP_INSTANCE_ID(input);
UNITY_TRANSFER_INSTANCE_ID(input, o);
UNITY_INITIALIZE_VERTEX_OUTPUT_STEREO(o);
VertexPositionInputs vertexPositionInput = GetVertexPositionInputs(input.positionOS);
o.positionCS = vertexPositionInput.positionCS;
o.screenPos = ComputeScreenPos(o.positionCS);
float3 viewRay = vertexPositionInput.positionVS;
o.rayVS.w = viewRay.z;
float4x4 viewToObject = mul(UNITY_MATRIX_I_M, UNITY_MATRIX_I_V);
o.rayVS.xyz = mul((float3x3)viewToObject, -viewRay);
o.camPosVS = mul(viewToObject, float4(0,0,0,1)).xyz;
return o;
}
half4 frag(v2f i) : SV_Target
{
UNITY_SETUP_INSTANCE_ID(i);
UNITY_SETUP_STEREO_EYE_INDEX_POST_VERTEX(i);
float depth = SampleSceneDepth(i.screenPos.xy / i.screenPos.w);
float3 decalPos;
if(unity_OrthoParams.w) {
#if defined(UNITY_REVERSED_Z)
depth = 1.0 - depth;
#endif
float sceneDepthVS = lerp(_ProjectionParams.y, _ProjectionParams.z, depth);
float2 rayVSEnd = float2(unity_OrthoParams.xy * (i.screenPos.xy - 0.5) * 2.0);
float4 posVS = float4(rayVSEnd, -sceneDepthVS, 1);
float3 wpos = mul(UNITY_MATRIX_I_V, posVS).xyz;
decalPos = mul(GetWorldToObjectMatrix(), float4(wpos, 1)).xyz;
} else {
float depthEye = LinearEyeDepth(depth, _ZBufferParams);
decalPos = i.camPosVS + (i.rayVS.xyz / i.rayVS.w) * depthEye;
}
clip(0.5 - abs(decalPos));
// check normal
float3 normal = normalize(cross(ddx(decalPos), -ddy(decalPos)));
float slope = dot(normal, GROUND_NORMAL);
clip(slope - 0.01);
float2 uv = decalPos.xz + 0.5;
half4 col = tex2D(_MainTex, uv);
col *= _Color;
// atten with elevation
col.a /= 1.0 + pow(1.0 + max(0, decalPos.y - 0.1), FADE_POWER);
return col;
}
ENDHLSL
}
Pass
{
Blend SrcAlpha OneMinusSrcAlpha
ZWrite Off
ZTest [_ZTest]
Cull Off
CGPROGRAM
#pragma vertex vert
#pragma fragment frag
#include "UnityCG.cginc"
struct appdata
{
float4 vertex : POSITION;
float2 uv : TEXCOORD0;
UNITY_VERTEX_INPUT_INSTANCE_ID
};
struct v2f
{
float4 pos : SV_POSITION;
float2 uv : TEXCOORD0;
UNITY_VERTEX_OUTPUT_STEREO
};
sampler2D _MainTex;
fixed4 _Color;
v2f vert (appdata v)
{
v2f o;
UNITY_SETUP_INSTANCE_ID(v);
UNITY_INITIALIZE_OUTPUT(v2f, o);
UNITY_INITIALIZE_VERTEX_OUTPUT_STEREO(o);
o.pos = UnityObjectToClipPos(v.vertex);
o.uv = v.uv;
return o;
}
fixed4 frag (v2f i) : SV_Target
{
return tex2D(_MainTex, i.uv) * _Color;
}
ENDCG
}
}
}

View File

@ -0,0 +1,9 @@
fileFormatVersion: 2
guid: 54328cae8f89d442da972097ce4f23d9
timeCreated: 1544699250
licenseType: Store
ShaderImporter:
defaultTextures: []
userData:
assetBundleName:
assetBundleVariant:

View File

@ -0,0 +1,96 @@
%YAML 1.1
%TAG !u! tag:unity3d.com,2011:
--- !u!114 &-2752029129534311206
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: 1
--- !u!21 &2100000
Material:
serializedVersion: 6
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_Name: HighlightUIMask
m_Shader: {fileID: 4800000, guid: 3e461a1484e2948598abca48b53d8b58, type: 3}
m_ShaderKeywords:
m_LightmapFlags: 4
m_EnableInstancingVariants: 0
m_DoubleSidedGI: 0
m_CustomRenderQueue: -1
stringTagMap: {}
disabledShaderPasses: []
m_SavedProperties:
serializedVersion: 3
m_TexEnvs:
- _BaseMap:
m_Texture: {fileID: 0}
m_Scale: {x: 1, y: 1}
m_Offset: {x: 0, y: 0}
- _BumpMap:
m_Texture: {fileID: 0}
m_Scale: {x: 1, y: 1}
m_Offset: {x: 0, y: 0}
- _EmissionMap:
m_Texture: {fileID: 0}
m_Scale: {x: 1, y: 1}
m_Offset: {x: 0, y: 0}
- _MainTex:
m_Texture: {fileID: 0}
m_Scale: {x: 1, y: 1}
m_Offset: {x: 0, y: 0}
- _MetallicGlossMap:
m_Texture: {fileID: 0}
m_Scale: {x: 1, y: 1}
m_Offset: {x: 0, y: 0}
- _OcclusionMap:
m_Texture: {fileID: 0}
m_Scale: {x: 1, y: 1}
m_Offset: {x: 0, y: 0}
- _SpecGlossMap:
m_Texture: {fileID: 0}
m_Scale: {x: 1, y: 1}
m_Offset: {x: 0, y: 0}
m_Floats:
- _AlphaClip: 0
- _Blend: 0
- _BumpScale: 1
- _ColorMask: 15
- _Cull: 2
- _CutOff: 0.5
- _Cutoff: 0.5
- _DstBlend: 0
- _EnvironmentReflections: 1
- _GlossMapScale: 0
- _Glossiness: 0
- _GlossyReflections: 0
- _Metallic: 0
- _OcclusionStrength: 1
- _QueueOffset: 0
- _ReceiveShadows: 1
- _Smoothness: 0.5
- _SmoothnessTextureChannel: 0
- _SpecularHighlights: 1
- _SrcBlend: 1
- _Stencil: 0
- _StencilComp: 8
- _StencilOp: 0
- _StencilReadMask: 255
- _StencilWriteMask: 255
- _Surface: 0
- _WorkflowMode: 1
- _ZWrite: 1
m_Colors:
- _BaseColor: {r: 0.5, g: 0.5, b: 0.5, a: 1}
- _Color: {r: 0.5, g: 0.5, b: 0.5, a: 1}
- _EmissionColor: {r: 0, g: 0, b: 0, a: 1}
- _SpecColor: {r: 0.2, g: 0.2, b: 0.2, a: 1}

View File

@ -0,0 +1,8 @@
fileFormatVersion: 2
guid: 779128a8e84b44d4db81443c424af511
NativeFormatImporter:
externalObjects: {}
mainObjectFileID: 0
userData:
assetBundleName:
assetBundleVariant:

View File

@ -0,0 +1,77 @@
Shader "HighlightPlus/UI/Mask" {
Properties {
_MainTex ("Texture", Any) = "white" {}
_Color ("Color", Color) = (1,1,1) // not used; dummy property to avoid inspector warning "material has no _Color property"
_CutOff("CutOff", Float ) = 0.5
_StencilComp("Stencil Comparison", Float) = 8
_Stencil("Stencil ID", Float) = 0
_StencilOp("Stencil Operation", Float) = 0
_StencilWriteMask("Stencil Write Mask", Float) = 255
_StencilReadMask("Stencil Read Mask", Float) = 255
_ColorMask("Color Mask", Float) = 15
}
SubShader
{
Tags { "Queue"="Transparent" "RenderType"="Transparent" "IgnoreProjector" = "True" }
// Create mask
Pass
{
Stencil {
Ref 6
Comp always
Pass replace
ReadMask 6
WriteMask 6
}
ColorMask 0
ZWrite Off
Cull Off
CGPROGRAM
#pragma vertex vert
#pragma fragment frag
#include "UnityCG.cginc"
#include "CustomVertexTransform.cginc"
sampler _MainTex;
float4 _MainTex_ST;
float4 _MainTex_TexelSize;
fixed _CutOff;
struct appdata
{
float4 vertex : POSITION;
float2 uv : TEXCOORD0;
UNITY_VERTEX_INPUT_INSTANCE_ID
};
struct v2f
{
float4 pos: SV_POSITION;
float2 uv : TEXCOORD0;
UNITY_VERTEX_OUTPUT_STEREO
};
v2f vert (appdata v)
{
v2f o;
UNITY_SETUP_INSTANCE_ID(v);
UNITY_INITIALIZE_OUTPUT(v2f, o);
UNITY_INITIALIZE_VERTEX_OUTPUT_STEREO(o);
o.pos = ComputeVertexPosition(v.vertex);
o.uv = TRANSFORM_TEX (v.uv, _MainTex);
return o;
}
fixed4 frag (v2f i) : SV_Target
{
fixed4 col = tex2D(_MainTex, i.uv);
clip(col.a - _CutOff);
return 0;
}
ENDCG
}
}
}

View File

@ -0,0 +1,9 @@
fileFormatVersion: 2
guid: 3e461a1484e2948598abca48b53d8b58
ShaderImporter:
externalObjects: {}
defaultTextures: []
nonModifiableTextures: []
userData:
assetBundleName:
assetBundleVariant:

Binary file not shown.

After

Width:  |  Height:  |  Size: 46 KiB

View File

@ -0,0 +1,100 @@
fileFormatVersion: 2
guid: 1de3c566a6c8c405b9f6f453137273ec
timeCreated: 1555360741
licenseType: Store
TextureImporter:
fileIDToRecycleName: {}
serializedVersion: 4
mipmaps:
mipMapMode: 0
enableMipMap: 0
sRGBTexture: 1
linearTexture: 0
fadeOut: 0
borderMipMap: 0
mipMapFadeDistanceStart: 1
mipMapFadeDistanceEnd: 3
bumpmap:
convertToNormalMap: 0
externalNormalMap: 0
heightScale: 0.25
normalMapFilter: 0
isReadable: 0
grayScaleToAlpha: 0
generateCubemap: 6
cubemapConvolution: 0
seamlessCubemap: 0
textureFormat: 1
maxTextureSize: 2048
textureSettings:
filterMode: -1
aniso: -1
mipBias: -1
wrapMode: -1
nPOTScale: 1
lightmap: 0
compressionQuality: 50
spriteMode: 0
spriteExtrude: 1
spriteMeshType: 1
alignment: 0
spritePivot: {x: 0.5, y: 0.5}
spriteBorder: {x: 0, y: 0, z: 0, w: 0}
spritePixelsToUnits: 100
alphaUsage: 1
alphaIsTransparency: 1
spriteTessellationDetail: -1
textureType: 0
textureShape: 1
maxTextureSizeSet: 0
compressionQualitySet: 0
textureFormatSet: 0
platformSettings:
- buildTarget: DefaultTexturePlatform
maxTextureSize: 2048
textureFormat: -1
textureCompression: 1
compressionQuality: 50
crunchedCompression: 0
allowsAlphaSplitting: 0
overridden: 0
- buildTarget: Standalone
maxTextureSize: 2048
textureFormat: -1
textureCompression: 1
compressionQuality: 50
crunchedCompression: 0
allowsAlphaSplitting: 0
overridden: 0
- buildTarget: iPhone
maxTextureSize: 2048
textureFormat: -1
textureCompression: 1
compressionQuality: 50
crunchedCompression: 0
allowsAlphaSplitting: 0
overridden: 0
- buildTarget: Android
maxTextureSize: 2048
textureFormat: -1
textureCompression: 1
compressionQuality: 50
crunchedCompression: 0
allowsAlphaSplitting: 0
overridden: 0
- buildTarget: WebGL
maxTextureSize: 2048
textureFormat: -1
textureCompression: 1
compressionQuality: 50
crunchedCompression: 0
allowsAlphaSplitting: 0
overridden: 0
spriteSheet:
serializedVersion: 2
sprites: []
outline: []
spritePackingTag:
userData:
assetBundleName:
assetBundleVariant:

View File

@ -0,0 +1,9 @@
fileFormatVersion: 2
guid: 89ce39cd6bb34454bbaf48f1d111f236
folderAsset: yes
timeCreated: 1542876305
licenseType: Store
DefaultImporter:
userData:
assetBundleName:
assetBundleVariant:

File diff suppressed because it is too large Load Diff

View File

@ -0,0 +1,12 @@
fileFormatVersion: 2
guid: 888380afc233049ce9e618f9f36c8ba8
timeCreated: 1545593776
licenseType: Store
MonoImporter:
serializedVersion: 2
defaultReferences: []
executionOrder: 900
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

View File

@ -0,0 +1,84 @@
using UnityEngine;
namespace HighlightPlus {
public enum HitFxMode {
Overlay = 0,
InnerGlow = 1,
LocalHit = 2
}
public partial class HighlightEffect : MonoBehaviour {
[Range(0,1)] public float hitFxInitialIntensity;
public HitFxMode hitFxMode = HitFxMode.Overlay;
public float hitFxFadeOutDuration = 0.25f;
[ColorUsage(true, true)] public Color hitFxColor = Color.white;
public float hitFxRadius = 0.5f;
float hitInitialIntensity;
float hitStartTime;
float hitFadeOutDuration;
Color hitColor;
bool hitActive;
Vector3 hitPosition;
float hitRadius;
/// <summary>
/// Performs a hit effect using default values
/// </summary>
public void HitFX() {
HitFX(hitFxColor, hitFxFadeOutDuration, hitFxInitialIntensity);
}
/// <summary>
/// Performs a hit effect localized at hit position and radius with default values
/// </summary>
public void HitFX(Vector3 position) {
HitFX(hitFxColor, hitFxFadeOutDuration, hitFxInitialIntensity, position, hitFxRadius);
}
/// <summary>
/// Performs a hit effect using desired color, fade out duration and optionally initial intensity (0-1)
/// </summary>
public void HitFX(Color color, float fadeOutDuration, float initialIntensity = 1f) {
hitInitialIntensity = initialIntensity;
hitFadeOutDuration = fadeOutDuration;
hitColor = color;
hitStartTime = Time.time;
hitActive = true;
if (overlay == 0) {
UpdateMaterialProperties();
}
}
/// <summary>
/// Performs a hit effect using desired color, fade out duration, initial intensity (0-1), hit position and radius of effect
/// </summary>
public void HitFX(Color color, float fadeOutDuration, float initialIntensity, Vector3 position, float radius) {
hitInitialIntensity = initialIntensity;
hitFadeOutDuration = fadeOutDuration;
hitColor = color;
hitStartTime = Time.time;
hitActive = true;
hitPosition = position;
hitRadius = radius;
if (overlay == 0) {
UpdateMaterialProperties();
}
}
/// <summary>
/// Initiates the target FX on demand using predefined configuration (see targetFX... properties)
/// </summary>
public void TargetFX() {
targetFxStartTime = Time.time;
if (!targetFX) {
targetFX = true;
UpdateMaterialProperties();
}
}
}
}

View File

@ -0,0 +1,12 @@
fileFormatVersion: 2
guid: e749f80d0d29a49d49d6e0f4752065cd
timeCreated: 1542876337
licenseType: Store
MonoImporter:
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

View File

@ -0,0 +1,265 @@
using System;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.Rendering;
namespace HighlightPlus {
public partial class HighlightEffect : MonoBehaviour {
static readonly List<HighlightSeeThroughOccluder> occluders = new List<HighlightSeeThroughOccluder>();
static readonly Dictionary<Camera, int> occludersFrameCount = new Dictionary<Camera, int>();
static Material fxMatOccluder;
static RaycastHit[] hits;
static Collider[] colliders;
/// <summary>
/// True if the see-through is cancelled by an occluder using raycast method
/// </summary>
public bool IsSeeThroughOccluded(Camera cam) {
// Compute bounds
Bounds bounds = new Bounds();
for (int r = 0; r < rms.Length; r++) {
if (rms[r].renderer != null) {
if (bounds.size.x == 0) {
bounds = rms[r].renderer.bounds;
} else {
bounds.Encapsulate(rms[r].renderer.bounds);
}
}
}
Vector3 pos = bounds.center;
Vector3 camPos = cam.transform.position;
Vector3 offset = pos - camPos;
float maxDistance = Vector3.Distance(pos, camPos);
if (hits == null || hits.Length == 0) {
hits = new RaycastHit[64];
}
int occludersCount = occluders.Count;
int hitCount = Physics.BoxCastNonAlloc(pos - offset, bounds.extents * 0.9f, offset.normalized, hits, Quaternion.identity, maxDistance);
for (int k = 0; k < hitCount; k++) {
for (int j = 0; j < occludersCount; j++) {
if (hits[k].collider.transform == occluders[j].transform) {
return true;
}
}
}
return false;
}
public static void RegisterOccluder(HighlightSeeThroughOccluder occluder) {
if (!occluders.Contains(occluder)) {
occluders.Add(occluder);
}
}
public static void UnregisterOccluder(HighlightSeeThroughOccluder occluder) {
if (occluders.Contains(occluder)) {
occluders.Remove(occluder);
}
}
/// <summary>
/// Test see-through occluders.
/// </summary>
/// <param name="cam">The camera to be tested</param>
/// <returns>Returns true if there's no raycast-based occluder cancelling the see-through effect</returns>
public bool RenderSeeThroughOccluders(CommandBuffer cb, Camera cam) {
int occludersCount = occluders.Count;
if (occludersCount == 0 || rmsCount == 0) return true;
bool useRayCastCheck = false;
// Check if raycast method is needed
for (int k = 0; k < occludersCount; k++) {
HighlightSeeThroughOccluder occluder = occluders[k];
if (occluder == null || !occluder.isActiveAndEnabled) continue;
if (occluder.detectionMethod == DetectionMethod.RayCast) {
useRayCastCheck = true;
break;
}
}
if (useRayCastCheck) {
if (IsSeeThroughOccluded(cam)) return false;
}
// do not render see-through occluders more than once this frame per camera (there can be many highlight effect scripts in the scene, we only need writing to stencil once)
int lastFrameCount;
occludersFrameCount.TryGetValue(cam, out lastFrameCount);
int currentFrameCount = Time.frameCount;
if (currentFrameCount == lastFrameCount) return true;
occludersFrameCount[cam] = currentFrameCount;
if (fxMatOccluder == null) {
InitMaterial(ref fxMatOccluder, "HighlightPlus/Geometry/SeeThroughOccluder");
if (fxMatOccluder == null) return true;
}
for (int k = 0; k < occludersCount; k++) {
HighlightSeeThroughOccluder occluder = occluders[k];
if (occluder == null || !occluder.isActiveAndEnabled) continue;
if (occluder.detectionMethod == DetectionMethod.Stencil) {
if (occluder.meshData == null || occluder.meshData.Length == 0) continue;
// Per renderer
for (int m = 0; m < occluder.meshData.Length; m++) {
// Per submesh
Renderer renderer = occluder.meshData[m].renderer;
if (renderer.isVisible) {
for (int s = 0; s < occluder.meshData[m].subMeshCount; s++) {
cb.DrawRenderer(renderer, fxMatOccluder, s);
}
}
}
}
}
return true;
}
bool CheckOcclusion(Camera cam) {
float now = Time.time;
int frameCount = Time.frameCount; // ensure all cameras are checked this frame
if (Time.time - occlusionCheckLastTime < seeThroughOccluderCheckInterval && Application.isPlaying && occlusionRenderFrame != frameCount) return lastOcclusionTestResult;
occlusionCheckLastTime = now;
occlusionRenderFrame = frameCount;
if (rms.Length == 0 || rms[0].renderer == null) return false;
Vector3 camPos = cam.transform.position;
Quaternion quaternionIdentity = Quaternion.identity;
if (colliders == null || colliders.Length == 0) {
colliders = new Collider[1];
}
if (seeThroughOccluderCheckIndividualObjects) {
for (int r = 0; r < rms.Length; r++) {
if (rms[r].renderer != null) {
Bounds bounds = rms[r].renderer.bounds;
Vector3 pos = bounds.center;
float maxDistance = Vector3.Distance(pos, camPos);
Vector3 extents = bounds.extents * seeThroughOccluderThreshold;
if (Physics.OverlapBoxNonAlloc(pos, extents, colliders, quaternionIdentity, seeThroughOccluderMask) > 0) {
lastOcclusionTestResult = true;
return true;
}
if (Physics.BoxCast(pos, extents, (camPos - pos).normalized, quaternionIdentity, maxDistance, seeThroughOccluderMask)) {
lastOcclusionTestResult = true;
return true;
}
}
}
lastOcclusionTestResult = false;
return false;
} else {
// Compute combined bounds
Bounds bounds = rms[0].renderer.bounds;
for (int r = 1; r < rms.Length; r++) {
if (rms[r].renderer != null) {
bounds.Encapsulate(rms[r].renderer.bounds);
}
}
Vector3 pos = bounds.center;
Vector3 extents = bounds.extents * seeThroughOccluderThreshold;
if (Physics.OverlapBoxNonAlloc(pos, extents, colliders, quaternionIdentity, seeThroughOccluderMask) > 0) {
lastOcclusionTestResult = true;
return true;
}
float maxDistance = Vector3.Distance(pos, camPos);
lastOcclusionTestResult = Physics.BoxCast(pos, extents, (camPos - pos).normalized, quaternionIdentity, maxDistance, seeThroughOccluderMask);
return lastOcclusionTestResult;
}
}
const int MAX_OCCLUDER_HITS = 50;
static RaycastHit[] occluderHits;
readonly Dictionary<Camera, List<Renderer>> cachedOccludersPerCamera = new Dictionary<Camera, List<Renderer>>();
void AddWithoutRepetition<T>(List<T> target, List<T> source) {
int sourceCount = source.Count;
for (int k = 0; k < sourceCount; k++) {
T entry = source[k];
if (entry != null && !target.Contains(entry)) {
target.Add(entry);
}
}
}
void CheckOcclusionAccurate(CommandBuffer cbuf, Camera cam) {
List<Renderer> occluderRenderers;
if (!cachedOccludersPerCamera.TryGetValue(cam, out occluderRenderers)) {
occluderRenderers = new List<Renderer>();
cachedOccludersPerCamera[cam] = occluderRenderers;
}
float now = Time.time;
int frameCount = Time.frameCount; // ensure all cameras are checked this frame
bool reuse = Time.time - occlusionCheckLastTime < seeThroughOccluderCheckInterval && Application.isPlaying && occlusionRenderFrame != frameCount;
if (!reuse) {
if (rms.Length == 0 || rms[0].renderer == null) return;
occlusionCheckLastTime = now;
occlusionRenderFrame = frameCount;
Quaternion quaternionIdentity = Quaternion.identity;
Vector3 camPos = cam.transform.position;
occluderRenderers.Clear();
if (occluderHits == null || occluderHits.Length < MAX_OCCLUDER_HITS) {
occluderHits = new RaycastHit[MAX_OCCLUDER_HITS];
}
if (seeThroughOccluderCheckIndividualObjects) {
for (int r = 0; r < rms.Length; r++) {
if (rms[r].renderer != null) {
Bounds bounds = rms[r].renderer.bounds;
Vector3 pos = bounds.center;
float maxDistance = Vector3.Distance(pos, camPos);
int numOccluderHits = Physics.BoxCastNonAlloc(pos, bounds.extents * seeThroughOccluderThreshold, (camPos - pos).normalized, occluderHits, quaternionIdentity, maxDistance, seeThroughOccluderMask);
for (int k = 0; k < numOccluderHits; k++) {
occluderHits[k].collider.transform.root.GetComponentsInChildren(tempRR);
AddWithoutRepetition(occluderRenderers, tempRR);
}
}
}
} else {
// Compute combined bounds
Bounds bounds = rms[0].renderer.bounds;
for (int r = 1; r < rms.Length; r++) {
if (rms[r].renderer != null) {
bounds.Encapsulate(rms[r].renderer.bounds);
}
}
Vector3 pos = bounds.center;
float maxDistance = Vector3.Distance(pos, camPos);
int numOccluderHits = Physics.BoxCastNonAlloc(pos, bounds.extents * seeThroughOccluderThreshold, (camPos - pos).normalized, occluderHits, quaternionIdentity, maxDistance, seeThroughOccluderMask);
for (int k = 0; k < numOccluderHits; k++) {
occluderHits[k].collider.transform.root.GetComponentsInChildren(tempRR);
AddWithoutRepetition(occluderRenderers, tempRR);
}
}
}
// render occluders
int occluderRenderersCount = occluderRenderers.Count;
if (occluderRenderersCount > 0) {
for (int k = 0; k < occluderRenderersCount; k++) {
Renderer r = occluderRenderers[k];
cbuf.DrawRenderer(r, fxMatSeeThroughMask);
}
}
}
public List<Renderer> GetOccluders(Camera camera) {
List<Renderer> occluders = null;
if (cachedOccludersPerCamera != null) {
cachedOccludersPerCamera.TryGetValue(camera, out occluders);
}
return occluders;
}
}
}

View File

@ -0,0 +1,12 @@
fileFormatVersion: 2
guid: d0bc1f04199a64e66ae9630062b3a6ad
timeCreated: 1542876337
licenseType: Store
MonoImporter:
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

View File

@ -0,0 +1,421 @@
using System;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.EventSystems;
namespace HighlightPlus {
public delegate bool OnObjectSelectionEvent(GameObject obj);
[RequireComponent(typeof(HighlightEffect))]
[DefaultExecutionOrder(100)]
[HelpURL("https://www.dropbox.com/s/1p9h8xys68lm4a3/Documentation.pdf?dl=0")]
public class HighlightManager : MonoBehaviour {
[Tooltip("Enables highlight when pointer is over this object.")]
public bool highlightOnHover = true;
public LayerMask layerMask = -1;
public Camera raycastCamera;
public RayCastSource raycastSource = RayCastSource.MousePosition;
[Tooltip("Minimum distance for target.")]
public float minDistance;
[Tooltip("Maximum distance for target. 0 = infinity")]
public float maxDistance;
[Tooltip("Blocks interaction if pointer is over an UI element")]
public bool respectUI = true;
[Tooltip("If the object will be selected by clicking with mouse or tapping on it.")]
public bool selectOnClick;
[Tooltip("Optional profile for objects selected by clicking on them")]
public HighlightProfile selectedProfile;
[Tooltip("Profile to use whtn object is selected and highlighted.")]
public HighlightProfile selectedAndHighlightedProfile;
[Tooltip("Automatically deselects other previously selected objects")]
public bool singleSelection;
[Tooltip("Toggles selection on/off when clicking object")]
public bool toggle;
HighlightEffect baseEffect, currentEffect;
Transform currentObject;
public readonly static List<HighlightEffect> selectedObjects = new List<HighlightEffect>();
public event OnObjectSelectionEvent OnObjectSelected;
public event OnObjectSelectionEvent OnObjectUnSelected;
public event OnObjectHighlightEvent OnObjectHighlightStart;
public event OnObjectHighlightEvent OnObjectHighlightEnd;
public static int lastTriggerTime;
static HighlightManager _instance;
public static HighlightManager instance {
get {
if (_instance == null) {
_instance = FindObjectOfType<HighlightManager>();
}
return _instance;
}
}
[RuntimeInitializeOnLoadMethod]
void DomainReloadDisabledSupport() {
selectedObjects.Clear();
lastTriggerTime = 0;
_instance = null;
}
void OnEnable() {
currentObject = null;
currentEffect = null;
if (baseEffect == null) {
baseEffect = GetComponent<HighlightEffect> ();
if (baseEffect == null) {
baseEffect = gameObject.AddComponent<HighlightEffect> ();
}
}
raycastCamera = GetComponent<Camera> ();
if (raycastCamera == null) {
raycastCamera = GetCamera ();
if (raycastCamera == null) {
Debug.LogError ("Highlight Manager: no camera found!");
}
}
InputProxy.Init();
}
void OnDisable () {
SwitchesCollider (null);
internal_DeselectAll();
}
void Update () {
if (raycastCamera == null)
return;
#if ENABLE_INPUT_SYSTEM
if (respectUI) {
EventSystem es = EventSystem.current;
if (es == null) {
es = CreateEventSystem();
}
List<RaycastResult> raycastResults = new List<RaycastResult>();
PointerEventData eventData = new PointerEventData(es);
Vector3 cameraPos = raycastCamera.transform.position;
if (raycastSource == RayCastSource.MousePosition) {
eventData.position = InputProxy.mousePosition;
} else {
eventData.position = new Vector2(raycastCamera.pixelWidth * 0.5f, raycastCamera.pixelHeight * 0.5f);
}
es.RaycastAll(eventData, raycastResults);
int hitCount = raycastResults.Count;
// check UI blocker
bool blocked = false;
for (int k = 0; k < hitCount; k++) {
RaycastResult rr = raycastResults[k];
if (rr.module is UnityEngine.UI.GraphicRaycaster) {
blocked = true;
break;
}
}
if (blocked) return;
// look for our gameobject
for (int k = 0; k < hitCount; k++) {
RaycastResult rr = raycastResults[k];
float distance = Vector3.Distance(rr.worldPosition, cameraPos);
if (distance < minDistance || (maxDistance > 0 && distance > maxDistance)) continue;
GameObject theGameObject = rr.gameObject;
if ((layerMask & (1 << rr.gameObject.layer)) == 0) continue;
// is this object state controller by Highlight Trigger?
HighlightTrigger trigger = theGameObject.GetComponent<HighlightTrigger>();
if (trigger != null) return;
// Toggles selection
Transform t = theGameObject.transform;
if (InputProxy.GetMouseButtonDown(0)) {
if (selectOnClick) {
ToggleSelection(t, !toggle);
} else if (lastTriggerTime < Time.frameCount) {
internal_DeselectAll();
}
} else {
// Check if the object has a Highlight Effect
if (t != currentObject) {
SwitchesCollider(t);
}
}
return;
}
}
// if not blocked by UI and no hit found, fallback to raycast (required if no PhysicsRaycaster is present on the camera)
#endif
Ray ray;
if (raycastSource == RayCastSource.MousePosition) {
#if !ENABLE_INPUT_SYSTEM
if (!CanInteract()) {
return;
}
#endif
ray = raycastCamera.ScreenPointToRay(InputProxy.mousePosition);
} else {
ray = new Ray(raycastCamera.transform.position, raycastCamera.transform.forward);
}
RaycastHit hitInfo;
if (Physics.Raycast(ray, out hitInfo, maxDistance > 0 ? maxDistance : raycastCamera.farClipPlane, layerMask) && Vector3.Distance(hitInfo.point, ray.origin) >= minDistance) {
Transform t = hitInfo.collider.transform;
// is this object state controller by Highlight Trigger?
HighlightTrigger trigger = t.GetComponent<HighlightTrigger>();
if (trigger != null) return;
// Toggles selection
if (InputProxy.GetMouseButtonDown(0)) {
if (selectOnClick) {
ToggleSelection(t, !toggle);
} else if (lastTriggerTime < Time.frameCount) {
internal_DeselectAll();
}
} else {
// Check if the object has a Highlight Effect
if (t != currentObject) {
SwitchesCollider(t);
}
}
return;
}
// no hit
if (InputProxy.GetMouseButtonDown(0) && lastTriggerTime < Time.frameCount) {
internal_DeselectAll();
}
SwitchesCollider (null);
}
#if ENABLE_INPUT_SYSTEM
EventSystem CreateEventSystem() {
GameObject eo = new GameObject("Event System created by Highlight Plus", typeof(EventSystem), typeof(UnityEngine.InputSystem.UI.InputSystemUIInputModule));
return eo.GetComponent<EventSystem>();
}
#endif
void SwitchesCollider (Transform newObject) {
if (currentEffect != null) {
if (highlightOnHover) {
Highlight(false);
}
currentEffect = null;
}
currentObject = newObject;
if (newObject == null) return;
HighlightTrigger ht = newObject.GetComponent<HighlightTrigger>();
if (ht != null && ht.enabled)
return;
HighlightEffect otherEffect = newObject.GetComponent<HighlightEffect> ();
if (otherEffect == null) {
// Check if there's a parent highlight effect that includes this object
HighlightEffect parentEffect = newObject.GetComponentInParent<HighlightEffect>();
if (parentEffect != null && parentEffect.Includes(newObject)) {
currentEffect = parentEffect;
if (highlightOnHover) {
Highlight(true);
}
return;
}
}
currentEffect = otherEffect != null ? otherEffect : baseEffect;
baseEffect.enabled = currentEffect == baseEffect;
currentEffect.SetTarget(currentObject);
if (highlightOnHover) {
Highlight(true);
}
}
bool CanInteract() {
if (!respectUI) return true;
EventSystem es = EventSystem.current;
if (es == null) return true;
if (Application.isMobilePlatform && InputProxy.touchCount > 0 && es.IsPointerOverGameObject(InputProxy.GetFingerIdFromTouch(0))) {
return false;
} else if (es.IsPointerOverGameObject(-1))
return false;
return true;
}
void ToggleSelection(Transform t, bool forceSelection) {
// We need a highlight effect on each selected object
HighlightEffect hb = t.GetComponent<HighlightEffect>();
if (hb == null) {
HighlightEffect parentEffect = t.GetComponentInParent<HighlightEffect>();
if (parentEffect != null && parentEffect.Includes(t)) {
hb = parentEffect;
if (hb.previousSettings == null) {
hb.previousSettings = ScriptableObject.CreateInstance<HighlightProfile>();
}
hb.previousSettings.Save(hb);
} else {
hb = t.gameObject.AddComponent<HighlightEffect>();
hb.previousSettings = ScriptableObject.CreateInstance<HighlightProfile>();
// copy default highlight effect settings from this manager into this highlight plus component
hb.previousSettings.Save(baseEffect);
hb.previousSettings.Load(hb);
}
}
bool currentState = hb.isSelected;
bool newState = forceSelection ? true : !currentState;
if (newState == currentState) return;
if (newState) {
if (OnObjectSelected != null && !OnObjectSelected(t.gameObject)) return;
} else {
if (OnObjectUnSelected != null && !OnObjectUnSelected(t.gameObject)) return;
}
if (singleSelection) {
internal_DeselectAll();
}
currentEffect = hb;
currentEffect.isSelected = newState;
baseEffect.enabled = false;
if (currentEffect.isSelected) {
if (currentEffect.previousSettings == null) {
currentEffect.previousSettings = ScriptableObject.CreateInstance<HighlightProfile>();
}
hb.previousSettings.Save(hb);
if (!selectedObjects.Contains(currentEffect)) {
selectedObjects.Add(currentEffect);
}
} else {
if (currentEffect.previousSettings != null) {
currentEffect.previousSettings.Load(hb);
}
if (selectedObjects.Contains(currentEffect)) {
selectedObjects.Remove(currentEffect);
}
}
Highlight(true);
}
void Highlight(bool state) {
if (state) {
if (!currentEffect.highlighted) {
if (OnObjectHighlightStart != null && currentEffect.target != null) {
if (!OnObjectHighlightStart(currentEffect.target.gameObject)) return;
}
}
} else {
if (currentEffect.highlighted) {
if (OnObjectHighlightEnd != null && currentEffect.target != null) {
OnObjectHighlightEnd(currentEffect.target.gameObject);
}
}
}
if (selectOnClick) {
if (currentEffect.isSelected) {
if (state && selectedAndHighlightedProfile != null) {
selectedAndHighlightedProfile.Load(currentEffect);
} else if (selectedProfile != null) {
selectedProfile.Load(currentEffect);
} else {
currentEffect.previousSettings.Load(currentEffect);
}
if (currentEffect.highlighted) {
currentEffect.UpdateMaterialProperties();
} else {
currentEffect.SetHighlighted(true);
}
return;
} else if (!highlightOnHover) {
currentEffect.SetHighlighted(false);
return;
}
}
currentEffect.SetHighlighted(state);
}
public static Camera GetCamera() {
Camera raycastCamera = Camera.main;
if (raycastCamera == null) {
raycastCamera = FindObjectOfType<Camera>();
}
return raycastCamera;
}
void internal_DeselectAll() {
foreach (HighlightEffect hb in selectedObjects) {
if (hb != null && hb.gameObject != null) {
if (OnObjectUnSelected != null) {
if (!OnObjectUnSelected(hb.gameObject)) continue;
}
hb.RestorePreviousHighlightEffectSettings();
hb.isSelected = false;
hb.SetHighlighted(false);
}
}
selectedObjects.Clear();
}
public static void DeselectAll() {
foreach (HighlightEffect hb in selectedObjects) {
if (hb != null && hb.gameObject != null) {
hb.isSelected = false;
if (hb.highlighted && _instance != null) {
_instance.Highlight(false);
} else {
hb.SetHighlighted(false);
}
}
}
selectedObjects.Clear();
}
/// <summary>
/// Manually causes highlight manager to select an object
/// </summary>
public void SelectObject(Transform t) {
ToggleSelection(t, true);
}
/// <summary>
/// Manually causes highlight manager to toggle selection on an object
/// </summary>
public void ToggleObject(Transform t) {
ToggleSelection(t, false);
}
/// <summary>
/// Manually causes highlight manager to unselect an object
/// </summary>
public void UnselectObject(Transform t) {
if (t == null) return;
HighlightEffect hb = t.GetComponent<HighlightEffect>();
if (hb == null) return;
if (selectedObjects.Contains(hb)) {
if (OnObjectUnSelected != null) {
if (!OnObjectUnSelected(hb.gameObject)) return;
}
hb.isSelected = false;
hb.SetHighlighted(false);
selectedObjects.Remove(hb);
}
}
}
}

View File

@ -0,0 +1,12 @@
fileFormatVersion: 2
guid: af4d46fd89b9543e5be2358ac0c9ced0
timeCreated: 1542876337
licenseType: Store
MonoImporter:
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

View File

@ -0,0 +1,362 @@
using UnityEngine;
namespace HighlightPlus {
[CreateAssetMenu(menuName = "Highlight Plus Profile", fileName = "Highlight Plus Profile", order = 100)]
[HelpURL("https://www.dropbox.com/s/1p9h8xys68lm4a3/Documentation.pdf?dl=0")]
public class HighlightProfile : ScriptableObject {
[Tooltip("Different options to specify which objects are affected by this Highlight Effect component.")]
public TargetOptions effectGroup = TargetOptions.Children;
[Tooltip("The layer that contains the affected objects by this effect when effectGroup is set to LayerMask.")]
public LayerMask effectGroupLayer = -1;
[Tooltip("Only include objects whose names contains this text.")]
public string effectNameFilter;
[Tooltip("Combine meshes of all objects in this group affected by Highlight Effect reducing draw calls.")]
public bool combineMeshes;
[Tooltip("The alpha threshold for transparent cutout objects. Pixels with alpha below this value will be discarded.")]
[Range(0, 1)]
public float alphaCutOff;
[Tooltip("If back facing triangles are ignored.Backfaces triangles are not visible but you may set this property to false to force highlight effects to act on those triangles as well.")]
public bool cullBackFaces = true;
[Tooltip("Normals handling option:\nPreserve original: use original mesh normals.\nSmooth: average normals to produce a smoother outline/glow mesh based effect.\nReorient: recomputes normals based on vertex direction to centroid.")]
public NormalsOption normalsOption;
public float fadeInDuration;
public float fadeOutDuration;
[Tooltip("Fades out effects based on distance to camera")]
public bool cameraDistanceFade;
[Tooltip("The closest distance particles can get to the camera before they fade from the cameras view.")]
public float cameraDistanceFadeNear;
[Tooltip("The farthest distance particles can get away from the camera before they fade from the cameras view.")]
public float cameraDistanceFadeFar = 1000;
[Tooltip("Keeps the outline/glow size unaffected by object distance.")]
public bool constantWidth = true;
[Range(0, 1)]
[Tooltip("Intensity of the overlay effect. A value of 0 disables the overlay completely.")]
public float overlay;
[ColorUsage(true, true)] public Color overlayColor = Color.yellow;
public float overlayAnimationSpeed = 1f;
[Range(0, 1)]
public float overlayMinIntensity = 0.5f;
[Range(0, 1)]
[Tooltip("Controls the blending or mix of the overlay color with the natural colors of the object.")]
public float overlayBlending = 1.0f;
[Tooltip("Optional overlay texture.")]
public Texture2D overlayTexture;
public float overlayTextureScale = 1f;
[Range(0, 1)]
[Tooltip("Intensity of the outline. A value of 0 disables the outline completely.")]
public float outline = 1f;
[ColorUsage(true, true)] public Color outlineColor = Color.black;
public float outlineWidth = 0.45f;
public QualityLevel outlineQuality = QualityLevel.High;
[Range(1, 8)]
[Tooltip("Reduces the quality of the outline but improves performance a bit.")]
public int outlineDownsampling = 2;
public Visibility outlineVisibility = Visibility.Normal;
[Tooltip("If enabled, this object won't combine the outline with other objects.")]
public bool outlineIndependent;
[Range(0, 5)]
[Tooltip("The intensity of the outer glow effect. A value of 0 disables the glow completely.")]
public float glow;
public float glowWidth = 0.4f;
public QualityLevel glowQuality = QualityLevel.High;
[Range(1, 8)]
[Tooltip("Reduces the quality of the glow but improves performance a bit.")]
public int glowDownsampling = 2;
[ColorUsage(true, true)] public Color glowHQColor = new Color(0.64f, 1f, 0f, 1f);
[Tooltip("When enabled, outer glow renders with dithering. When disabled, glow appears as a solid color.")]
public bool glowDithering = true;
[Tooltip("Seed for the dithering effect")]
public float glowMagicNumber1 = 0.75f;
[Tooltip("Another seed for the dithering effect that combines with first seed to create different patterns")]
public float glowMagicNumber2 = 0.5f;
public float glowAnimationSpeed = 1f;
public Visibility glowVisibility = Visibility.Normal;
public GlowBlendMode glowBlendMode = GlowBlendMode.Additive;
[Tooltip("Blends glow passes one after another. If this option is disabled, glow passes won't overlap (in this case, make sure the glow pass 1 has a smaller offset than pass 2, etc.)")]
public bool glowBlendPasses = true;
public GlowPassData[] glowPasses;
[Tooltip("If enabled, glow effect will not use a stencil mask. This can be used to render the glow effect alone.")]
public bool glowIgnoreMask;
[Range(0, 5f)]
[Tooltip("The intensity of the inner glow effect. A value of 0 disables the glow completely.")]
public float innerGlow;
[Range(0, 2)]
public float innerGlowWidth = 1f;
[ColorUsage(true, true)] public Color innerGlowColor = Color.white;
public Visibility innerGlowVisibility = Visibility.Normal;
[Tooltip("Enables the targetFX effect. This effect draws an animated sprite over the object.")]
public bool targetFX;
public Texture2D targetFXTexture;
[ColorUsage(true, true)] public Color targetFXColor = Color.white;
public float targetFXRotationSpeed = 50f;
public float targetFXInitialScale = 4f;
public float targetFXEndScale = 1.5f;
[Tooltip("Makes target scale relative to object renderer bounds.")]
public bool targetFXScaleToRenderBounds;
[Tooltip("Places target FX sprite at the bottom of the highlighted object.")]
public bool targetFXAlignToGround;
[Tooltip("Max distance from the center of the highlighted object to the ground.")]
public float targetFXGroundMaxDistance = 15f;
public LayerMask targetFXGroundLayerMask = -1;
[Tooltip("Fade out effect with altitude")]
public float targetFXFadePower = 32;
public float targetFXTransitionDuration = 0.5f;
public float targetFXStayDuration = 1.5f;
public Visibility targetFXVisibility = Visibility.AlwaysOnTop;
[Tooltip("See-through mode for this Highlight Effect component.")]
public SeeThroughMode seeThrough = SeeThroughMode.Never;
[Tooltip("This mask setting let you specify which objects will be considered as occluders and cause the see-through effect for this Highlight Effect component. For example, you assign your walls to a different layer and specify that layer here, so only walls and not other objects, like ground or ceiling, will trigger the see-through effect.")]
public LayerMask seeThroughOccluderMask = -1;
[Tooltip("Uses stencil buffers to ensure pixel-accurate occlusion test. If this option is disabled, only physics raycasting is used to test for occlusion.")]
public bool seeThroughOccluderMaskAccurate;
[Tooltip("A multiplier for the occluder volume size which can be used to reduce the actual size of occluders when Highlight Effect checks if they're occluding this object.")]
[Range(0.01f, 0.9f)] public float seeThroughOccluderThreshold = 0.4f;
[Tooltip("The interval of time between occlusion tests.")]
public float seeThroughOccluderCheckInterval = 1f;
[Tooltip("If enabled, occlusion test is performed for each children element. If disabled, the bounds of all children is combined and a single occlusion test is performed for the combined bounds.")]
public bool seeThroughOccluderCheckIndividualObjects;
[Tooltip("Shows the see-through effect only if the occluder if at this 'offset' distance from the object.")]
public float seeThroughDepthOffset;
[Tooltip("Hides the see-through effect if the occluder is further than this distance from the object (0 = infinite)")]
public float seeThroughMaxDepth;
[Range(0, 5f)] public float seeThroughIntensity = 0.8f;
[Range(0, 1)] public float seeThroughTintAlpha = 0.5f;
public Color seeThroughTintColor = Color.red;
[Range(0, 1)] public float seeThroughNoise = 1f;
[Range(0, 1)] public float seeThroughBorder;
public Color seeThroughBorderColor = Color.black;
public float seeThroughBorderWidth = 0.45f;
[Tooltip("Only display the border instead of the full see-through effect.")]
public bool seeThroughBorderOnly;
[Tooltip("This option clears the stencil buffer after rendering the see-through effect which results in correct rendering order and supports other stencil-based effects that render afterwards.")]
public bool seeThroughOrdered;
[Range(0, 1)] public float hitFxInitialIntensity;
public HitFxMode hitFxMode = HitFxMode.Overlay;
public float hitFxFadeOutDuration = 0.25f;
[ColorUsage(true, true)] public Color hitFxColor = Color.white;
public float hitFxRadius = 0.5f;
public void Load(HighlightEffect effect) {
effect.effectGroup = effectGroup;
effect.effectGroupLayer = effectGroupLayer;
effect.effectNameFilter = effectNameFilter;
effect.combineMeshes = combineMeshes;
effect.alphaCutOff = alphaCutOff;
effect.cullBackFaces = cullBackFaces;
effect.normalsOption = normalsOption;
effect.fadeInDuration = fadeInDuration;
effect.fadeOutDuration = fadeOutDuration;
effect.cameraDistanceFade = cameraDistanceFade;
effect.cameraDistanceFadeFar = cameraDistanceFadeFar;
effect.cameraDistanceFadeNear = cameraDistanceFadeNear;
effect.constantWidth = constantWidth;
effect.overlay = overlay;
effect.overlayColor = overlayColor;
effect.overlayAnimationSpeed = overlayAnimationSpeed;
effect.overlayMinIntensity = overlayMinIntensity;
effect.overlayBlending = overlayBlending;
effect.overlayTexture = overlayTexture;
effect.overlayTextureScale = overlayTextureScale;
effect.outline = outline;
effect.outlineColor = outlineColor;
effect.outlineWidth = outlineWidth;
effect.outlineQuality = outlineQuality;
effect.outlineDownsampling = outlineDownsampling;
effect.outlineVisibility = outlineVisibility;
effect.outlineIndependent = outlineIndependent;
effect.glow = glow;
effect.glowWidth = glowWidth;
effect.glowQuality = glowQuality;
effect.glowDownsampling = glowDownsampling;
effect.glowHQColor = glowHQColor;
effect.glowDithering = glowDithering;
effect.glowMagicNumber1 = glowMagicNumber1;
effect.glowMagicNumber2 = glowMagicNumber2;
effect.glowAnimationSpeed = glowAnimationSpeed;
effect.glowVisibility = glowVisibility;
effect.glowBlendMode = glowBlendMode;
effect.glowBlendPasses = glowBlendPasses;
effect.glowPasses = GetGlowPassesCopy(glowPasses);
effect.glowIgnoreMask = glowIgnoreMask;
effect.innerGlow = innerGlow;
effect.innerGlowWidth = innerGlowWidth;
effect.innerGlowColor = innerGlowColor;
effect.innerGlowVisibility = innerGlowVisibility;
effect.targetFX = targetFX;
effect.targetFXColor = targetFXColor;
effect.targetFXInitialScale = targetFXInitialScale;
effect.targetFXEndScale = targetFXEndScale;
effect.targetFXScaleToRenderBounds = targetFXScaleToRenderBounds;
effect.targetFXAlignToGround = targetFXAlignToGround;
effect.targetFXGroundMaxDistance = targetFXGroundMaxDistance;
effect.targetFXGroundLayerMask = targetFXGroundLayerMask;
effect.targetFXFadePower = targetFXFadePower;
effect.targetFXRotationSpeed = targetFXRotationSpeed;
effect.targetFXStayDuration = targetFXStayDuration;
effect.targetFXTexture = targetFXTexture;
effect.targetFXTransitionDuration = targetFXTransitionDuration;
effect.targetFXVisibility = targetFXVisibility;
effect.seeThrough = seeThrough;
effect.seeThroughOccluderMask = seeThroughOccluderMask;
effect.seeThroughOccluderMaskAccurate = seeThroughOccluderMaskAccurate;
effect.seeThroughOccluderThreshold = seeThroughOccluderThreshold;
effect.seeThroughOccluderCheckInterval = seeThroughOccluderCheckInterval;
effect.seeThroughOccluderCheckIndividualObjects = seeThroughOccluderCheckIndividualObjects;
effect.seeThroughIntensity = seeThroughIntensity;
effect.seeThroughTintAlpha = seeThroughTintAlpha;
effect.seeThroughTintColor = seeThroughTintColor;
effect.seeThroughNoise = seeThroughNoise;
effect.seeThroughBorder = seeThroughBorder;
effect.seeThroughBorderColor = seeThroughBorderColor;
effect.seeThroughBorderWidth = seeThroughBorderWidth;
effect.seeThroughBorderOnly = seeThroughBorderOnly;
effect.seeThroughDepthOffset = seeThroughDepthOffset;
effect.seeThroughMaxDepth = seeThroughMaxDepth;
effect.seeThroughOrdered = seeThroughOrdered;
effect.hitFxInitialIntensity = hitFxInitialIntensity;
effect.hitFxMode = hitFxMode;
effect.hitFxFadeOutDuration = hitFxFadeOutDuration;
effect.hitFxColor = hitFxColor;
effect.hitFxRadius = hitFxRadius;
effect.UpdateMaterialProperties();
}
public void Save(HighlightEffect effect) {
effectGroup = effect.effectGroup;
effectGroupLayer = effect.effectGroupLayer;
effectNameFilter = effect.effectNameFilter;
combineMeshes = effect.combineMeshes;
alphaCutOff = effect.alphaCutOff;
cullBackFaces = effect.cullBackFaces;
normalsOption = effect.normalsOption;
fadeInDuration = effect.fadeInDuration;
fadeOutDuration = effect.fadeOutDuration;
cameraDistanceFade = effect.cameraDistanceFade;
cameraDistanceFadeFar = effect.cameraDistanceFadeFar;
cameraDistanceFadeNear = effect.cameraDistanceFadeNear;
constantWidth = effect.constantWidth;
overlay = effect.overlay;
overlayColor = effect.overlayColor;
overlayAnimationSpeed = effect.overlayAnimationSpeed;
overlayMinIntensity = effect.overlayMinIntensity;
overlayBlending = effect.overlayBlending;
overlayTexture = effect.overlayTexture;
overlayTextureScale = effect.overlayTextureScale;
outline = effect.outline;
outlineColor = effect.outlineColor;
outlineWidth = effect.outlineWidth;
outlineQuality = effect.outlineQuality;
outlineDownsampling = effect.outlineDownsampling;
outlineVisibility = effect.outlineVisibility;
outlineIndependent = effect.outlineIndependent;
glow = effect.glow;
glowWidth = effect.glowWidth;
glowQuality = effect.glowQuality;
glowDownsampling = effect.glowDownsampling;
glowHQColor = effect.glowHQColor;
glowDithering = effect.glowDithering;
glowMagicNumber1 = effect.glowMagicNumber1;
glowMagicNumber2 = effect.glowMagicNumber2;
glowAnimationSpeed = effect.glowAnimationSpeed;
glowVisibility = effect.glowVisibility;
glowBlendMode = effect.glowBlendMode;
glowBlendPasses = effect.glowBlendPasses;
glowPasses = GetGlowPassesCopy(effect.glowPasses);
glowIgnoreMask = effect.glowIgnoreMask;
innerGlow = effect.innerGlow;
innerGlowWidth = effect.innerGlowWidth;
innerGlowColor = effect.innerGlowColor;
innerGlowVisibility = effect.innerGlowVisibility;
targetFX = effect.targetFX;
targetFXColor = effect.targetFXColor;
targetFXInitialScale = effect.targetFXInitialScale;
targetFXEndScale = effect.targetFXEndScale;
targetFXScaleToRenderBounds = effect.targetFXScaleToRenderBounds;
targetFXAlignToGround = effect.targetFXAlignToGround;
targetFXGroundMaxDistance = effect.targetFXGroundMaxDistance;
targetFXGroundLayerMask = effect.targetFXGroundLayerMask;
targetFXFadePower = effect.targetFXFadePower;
targetFXRotationSpeed = effect.targetFXRotationSpeed;
targetFXStayDuration = effect.targetFXStayDuration;
targetFXTexture = effect.targetFXTexture;
targetFXTransitionDuration = effect.targetFXTransitionDuration;
targetFXVisibility = effect.targetFXVisibility;
seeThrough = effect.seeThrough;
seeThroughOccluderMask = effect.seeThroughOccluderMask;
seeThroughOccluderMaskAccurate = effect.seeThroughOccluderMaskAccurate;
seeThroughOccluderThreshold = effect.seeThroughOccluderThreshold;
seeThroughOccluderCheckInterval = effect.seeThroughOccluderCheckInterval;
seeThroughOccluderCheckIndividualObjects = effect.seeThroughOccluderCheckIndividualObjects;
seeThroughIntensity = effect.seeThroughIntensity;
seeThroughTintAlpha = effect.seeThroughTintAlpha;
seeThroughTintColor = effect.seeThroughTintColor;
seeThroughNoise = effect.seeThroughNoise;
seeThroughBorder = effect.seeThroughBorder;
seeThroughBorderColor = effect.seeThroughBorderColor;
seeThroughBorderWidth = effect.seeThroughBorderWidth;
seeThroughDepthOffset = effect.seeThroughDepthOffset;
seeThroughBorderOnly = effect.seeThroughBorderOnly;
seeThroughMaxDepth = effect.seeThroughMaxDepth;
seeThroughOrdered = effect.seeThroughOrdered;
hitFxInitialIntensity = effect.hitFxInitialIntensity;
hitFxMode = effect.hitFxMode;
hitFxFadeOutDuration = effect.hitFxFadeOutDuration;
hitFxColor = effect.hitFxColor;
hitFxRadius = effect.hitFxRadius;
}
GlowPassData[] GetGlowPassesCopy(GlowPassData[] glowPasses) {
if (glowPasses == null) {
return new GlowPassData[0];
}
GlowPassData[] pd = new GlowPassData[glowPasses.Length];
for (int k = 0; k < glowPasses.Length; k++) {
pd[k].alpha = glowPasses[k].alpha;
pd[k].color = glowPasses[k].color;
pd[k].offset = glowPasses[k].offset;
}
return pd;
}
private void OnValidate() {
seeThroughDepthOffset = Mathf.Max(0, seeThroughDepthOffset);
seeThroughMaxDepth = Mathf.Max(0, seeThroughMaxDepth);
seeThroughBorderWidth = Mathf.Max(0, seeThroughBorderWidth);
targetFXFadePower = Mathf.Max(0, targetFXFadePower);
cameraDistanceFadeNear = Mathf.Max(0, cameraDistanceFadeNear);
cameraDistanceFadeFar = Mathf.Max(0, cameraDistanceFadeFar);
if (glowPasses == null || glowPasses.Length == 0) {
glowPasses = new GlowPassData[4];
glowPasses[0] = new GlowPassData() { offset = 4, alpha = 0.1f, color = new Color(0.64f, 1f, 0f, 1f) };
glowPasses[1] = new GlowPassData() { offset = 3, alpha = 0.2f, color = new Color(0.64f, 1f, 0f, 1f) };
glowPasses[2] = new GlowPassData() { offset = 2, alpha = 0.3f, color = new Color(0.64f, 1f, 0f, 1f) };
glowPasses[3] = new GlowPassData() { offset = 1, alpha = 0.4f, color = new Color(0.64f, 1f, 0f, 1f) };
}
}
}
}

View File

@ -0,0 +1,12 @@
fileFormatVersion: 2
guid: 8e9253636bf2648bd813257f451f8486
timeCreated: 1549831900
licenseType: Store
MonoImporter:
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

View File

@ -0,0 +1,71 @@
using System;
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
namespace HighlightPlus {
public struct MeshData {
public Renderer renderer;
public int subMeshCount;
}
public enum DetectionMethod {
Stencil = 0,
RayCast = 1
}
[ExecuteInEditMode]
public class HighlightSeeThroughOccluder : MonoBehaviour {
public DetectionMethod detectionMethod = DetectionMethod.Stencil;
[NonSerialized]
public MeshData[] meshData;
List<Renderer> rr;
void OnEnable () {
if (gameObject.activeInHierarchy) {
Init();
}
}
void Init() {
if (detectionMethod == DetectionMethod.RayCast) {
HighlightEffect.RegisterOccluder(this);
return;
}
if (rr == null) {
rr = new List<Renderer>();
} else {
rr.Clear();
}
GetComponentsInChildren<Renderer>(rr);
int rrCount = rr.Count;
meshData = new MeshData[rrCount];
for (int k = 0; k < rrCount; k++) {
meshData[k].renderer = rr[k];
meshData[k].subMeshCount = 1;
if (rr[k] is MeshRenderer) {
MeshFilter mf = rr[k].GetComponent<MeshFilter>();
if (mf != null && mf.sharedMesh != null) {
meshData[k].subMeshCount = mf.sharedMesh.subMeshCount;
}
} else if (rr[k] is SkinnedMeshRenderer) {
SkinnedMeshRenderer smr = (SkinnedMeshRenderer)rr[k];
meshData[k].subMeshCount = smr.sharedMesh.subMeshCount;
}
}
if (rrCount > 0) {
HighlightEffect.RegisterOccluder(this);
}
}
void OnDisable () {
HighlightEffect.UnregisterOccluder(this);
}
}
}

View File

@ -0,0 +1,12 @@
fileFormatVersion: 2
guid: 8dd965ceab19c4729a9dabd8aeb2972a
timeCreated: 1542876337
licenseType: Store
MonoImporter:
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

View File

@ -0,0 +1,394 @@
using System;
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.EventSystems;
namespace HighlightPlus {
public enum TriggerMode {
ColliderEventsOnlyOnThisObject = 0,
RaycastOnThisObjectAndChildren = 1,
Volume = 2
}
public enum RayCastSource {
MousePosition = 0,
CameraDirection = 1
}
[RequireComponent(typeof(HighlightEffect))]
[ExecuteInEditMode]
[HelpURL("https://www.dropbox.com/s/1p9h8xys68lm4a3/Documentation.pdf?dl=0")]
public class HighlightTrigger : MonoBehaviour {
[Tooltip("Enables highlight when pointer is over this object.")]
public bool highlightOnHover = true;
[Tooltip("Used to trigger automatic highlighting including children objects.")]
#if ENABLE_INPUT_SYSTEM
public TriggerMode triggerMode = TriggerMode.RaycastOnThisObjectAndChildren;
#else
public TriggerMode triggerMode = TriggerMode.ColliderEventsOnlyOnThisObject;
#endif
public Camera raycastCamera;
public RayCastSource raycastSource = RayCastSource.MousePosition;
[Tooltip("Minimum distance for target.")]
public float minDistance;
[Tooltip("Maximum distance for target. 0 = infinity")]
public float maxDistance;
[Tooltip("Blocks interaction if pointer is over an UI element")]
public bool respectUI = true;
public LayerMask volumeLayerMask;
const int MAX_RAYCAST_HITS = 100;
[Tooltip("If the object will be selected by clicking with mouse or tapping on it.")]
public bool selectOnClick;
[Tooltip("Profile to use when object is selected by clicking on it.")]
public HighlightProfile selectedProfile;
[Tooltip("Profile to use whtn object is selected and highlighted.")]
public HighlightProfile selectedAndHighlightedProfile;
[Tooltip("Automatically deselects any other selected object prior selecting this one")]
public bool singleSelection;
[Tooltip("Toggles selection on/off when clicking object")]
public bool toggle;
[NonSerialized] public Collider[] colliders;
Collider currentCollider;
static RaycastHit[] hits;
HighlightEffect hb;
public HighlightEffect highlightEffect { get { return hb; } }
public event OnObjectSelectionEvent OnObjectSelected;
public event OnObjectSelectionEvent OnObjectUnSelected;
public event OnObjectHighlightEvent OnObjectHighlightStart;
public event OnObjectHighlightEvent OnObjectHighlightEnd;
TriggerMode currentTriggerMode;
[RuntimeInitializeOnLoadMethod]
void DomainReloadDisabledSupport() {
HighlightManager.selectedObjects.Clear();
}
void OnEnable() {
Init();
}
private void OnValidate() {
if (currentTriggerMode != triggerMode) {
currentTriggerMode = triggerMode;
if (currentTriggerMode == TriggerMode.RaycastOnThisObjectAndChildren) {
colliders = GetComponentsInChildren<Collider>();
if (hits == null || hits.Length != MAX_RAYCAST_HITS) {
hits = new RaycastHit[MAX_RAYCAST_HITS];
}
if (Application.isPlaying) {
StopAllCoroutines();
if (gameObject.activeInHierarchy) {
StartCoroutine(DoRayCast());
}
}
}
}
}
public void Init() {
if (raycastCamera == null) {
raycastCamera = HighlightManager.GetCamera();
}
currentTriggerMode = triggerMode;
if (triggerMode == TriggerMode.RaycastOnThisObjectAndChildren) {
colliders = GetComponentsInChildren<Collider>();
}
if (hb == null) {
hb = GetComponent<HighlightEffect>();
}
InputProxy.Init();
}
void Start() {
if (triggerMode == TriggerMode.RaycastOnThisObjectAndChildren) {
if (raycastCamera == null) {
raycastCamera = HighlightManager.GetCamera();
if (raycastCamera == null) {
Debug.LogError("Highlight Trigger on " + gameObject.name + ": no camera found!");
}
}
if (colliders != null && colliders.Length > 0) {
hits = new RaycastHit[MAX_RAYCAST_HITS];
if (Application.isPlaying) {
StartCoroutine(DoRayCast());
}
}
} else {
Collider collider = GetComponent<Collider>();
if (collider == null) {
if (GetComponent<MeshFilter>() != null) {
gameObject.AddComponent<MeshCollider>();
}
}
}
}
IEnumerator DoRayCast() {
yield return null;
while (triggerMode == TriggerMode.RaycastOnThisObjectAndChildren) {
if (raycastCamera == null) {
yield return null;
continue;
}
int hitCount;
bool hit = false;
#if ENABLE_INPUT_SYSTEM
if (respectUI) {
EventSystem es = EventSystem.current;
if (es == null) {
es = CreateEventSystem();
}
List<RaycastResult> raycastResults = new List<RaycastResult>();
PointerEventData eventData = new PointerEventData(es);
Vector3 cameraPos = raycastCamera.transform.position;
if (raycastSource == RayCastSource.MousePosition) {
eventData.position = InputProxy.mousePosition;
} else {
eventData.position = new Vector2(raycastCamera.pixelWidth * 0.5f, raycastCamera.pixelHeight * 0.5f);
}
es.RaycastAll(eventData, raycastResults);
hitCount = raycastResults.Count;
// check UI blocker
bool blocked = false;
for (int k = 0; k < hitCount; k++) {
RaycastResult rr = raycastResults[k];
if (rr.module is UnityEngine.UI.GraphicRaycaster) {
blocked = true;
break;
}
}
if (blocked) {
yield return null;
continue;
}
// look for our gameobject
for (int k = 0; k < hitCount; k++) {
RaycastResult rr = raycastResults[k];
float distance = Vector3.Distance(rr.worldPosition, cameraPos);
if (distance < minDistance || (maxDistance > 0 && distance > maxDistance)) continue;
GameObject theGameObject = rr.gameObject;
for (int c = 0; c < colliders.Length; c++) {
if (colliders[c].gameObject == theGameObject) {
Collider theCollider = colliders[c];
hit = true;
if (selectOnClick && InputProxy.GetMouseButtonDown(0)) {
ToggleSelection();
break;
} else if (theCollider != currentCollider) {
SwitchCollider(theCollider);
k = hitCount;
break;
}
}
}
}
}
// if not blocked by UI and no hit found, fallback to raycast (required if no PhysicsRaycaster is present on the camera)
#endif
Ray ray;
if (raycastSource == RayCastSource.MousePosition) {
#if !ENABLE_INPUT_SYSTEM
if (!CanInteract()) {
yield return null;
continue;
}
#endif
ray = raycastCamera.ScreenPointToRay(InputProxy.mousePosition);
} else {
ray = new Ray(raycastCamera.transform.position, raycastCamera.transform.forward);
}
if (maxDistance > 0) {
hitCount = Physics.RaycastNonAlloc(ray, hits, maxDistance);
} else {
hitCount = Physics.RaycastNonAlloc(ray, hits);
}
for (int k = 0; k < hitCount; k++) {
if (Vector3.Distance(hits[k].point, ray.origin) < minDistance) continue;
Collider theCollider = hits[k].collider;
for (int c = 0; c < colliders.Length; c++) {
if (colliders[c] == theCollider) {
hit = true;
if (selectOnClick && InputProxy.GetMouseButtonDown(0)) {
ToggleSelection();
break;
} else if (theCollider != currentCollider) {
SwitchCollider(theCollider);
k = hitCount;
break;
}
}
}
}
if (!hit && currentCollider != null) {
SwitchCollider(null);
}
yield return null;
}
}
#if ENABLE_INPUT_SYSTEM
EventSystem CreateEventSystem() {
GameObject eo = new GameObject("Event System created by Highlight Plus", typeof(EventSystem), typeof(UnityEngine.InputSystem.UI.InputSystemUIInputModule));
return eo.GetComponent<EventSystem>();
}
#endif
void SwitchCollider(Collider newCollider) {
if (!highlightOnHover && !hb.isSelected) return;
currentCollider = newCollider;
if (currentCollider != null) {
Highlight(true);
} else {
Highlight(false);
}
}
bool CanInteract() {
if (!respectUI) return true;
EventSystem es = EventSystem.current;
if (es == null) return true;
if (Application.isMobilePlatform && InputProxy.touchCount > 0 && es.IsPointerOverGameObject(InputProxy.GetFingerIdFromTouch(0))) {
return false;
} else if (es.IsPointerOverGameObject(-1))
return false;
return true;
}
void OnMouseDown() {
if (isActiveAndEnabled && triggerMode == TriggerMode.ColliderEventsOnlyOnThisObject) {
if (!CanInteract()) return;
if (selectOnClick && InputProxy.GetMouseButtonDown(0)) {
ToggleSelection();
return;
}
Highlight(true);
}
}
void OnMouseEnter() {
if (isActiveAndEnabled && triggerMode == TriggerMode.ColliderEventsOnlyOnThisObject) {
if (!CanInteract()) return;
Highlight(true);
}
}
void OnMouseExit() {
if (isActiveAndEnabled && triggerMode == TriggerMode.ColliderEventsOnlyOnThisObject) {
if (!CanInteract()) return;
Highlight(false);
}
}
void Highlight(bool state) {
if (state) {
if (!hb.highlighted) {
if (OnObjectHighlightStart != null && hb.target != null) {
if (!OnObjectHighlightStart(hb.target.gameObject)) return;
}
}
} else {
if (hb.highlighted) {
if (OnObjectHighlightEnd != null && hb.target != null) {
OnObjectHighlightEnd(hb.target.gameObject);
}
}
}
if (selectOnClick) {
if (hb.isSelected) {
if (state && selectedAndHighlightedProfile != null) {
selectedAndHighlightedProfile.Load(hb);
} else if (selectedProfile != null) {
selectedProfile.Load(hb);
} else {
hb.previousSettings.Load(hb);
}
if (hb.highlighted) {
hb.UpdateMaterialProperties();
} else {
hb.SetHighlighted(true);
}
return;
} else if (!highlightOnHover) {
hb.SetHighlighted(false);
return;
}
}
hb.SetHighlighted(state);
}
void ToggleSelection() {
HighlightManager.lastTriggerTime = Time.frameCount;
bool newState = toggle ? !hb.isSelected : true;
if (newState) {
if (OnObjectSelected != null && !OnObjectSelected(gameObject)) return;
} else {
if (OnObjectUnSelected != null && !OnObjectUnSelected(gameObject)) return;
}
if (singleSelection && newState) {
HighlightManager.DeselectAll();
}
hb.isSelected = newState;
if (newState && !HighlightManager.selectedObjects.Contains(hb)) {
HighlightManager.selectedObjects.Add(hb);
} else if (!newState && HighlightManager.selectedObjects.Contains(hb)) {
HighlightManager.selectedObjects.Remove(hb);
}
if (hb.isSelected) {
if (hb.previousSettings == null) {
hb.previousSettings = ScriptableObject.CreateInstance<HighlightProfile>();
}
hb.previousSettings.Save(hb);
} else {
hb.RestorePreviousHighlightEffectSettings();
}
Highlight(true);
}
public void OnTriggerEnter(Collider other) {
if (triggerMode == TriggerMode.Volume) {
if ((volumeLayerMask & (1 << other.gameObject.layer)) != 0) {
Highlight(true);
}
}
}
public void OnTriggerExit(Collider other) {
if (triggerMode == TriggerMode.Volume) {
if ((volumeLayerMask & (1 << other.gameObject.layer)) != 0) {
Highlight(false);
}
}
}
}
}

View File

@ -0,0 +1,12 @@
fileFormatVersion: 2
guid: 5009cbb7e54994bb586cde7a70f34e6b
timeCreated: 1542876337
licenseType: Store
MonoImporter:
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

View File

@ -0,0 +1,90 @@
using UnityEngine;
#if ENABLE_INPUT_SYSTEM
using UnityEngine.InputSystem;
using UnityEngine.InputSystem.Controls;
using EnhancedTouch = UnityEngine.InputSystem.EnhancedTouch;
#endif
namespace HighlightPlus {
public static class InputProxy {
#if ENABLE_INPUT_SYSTEM
static Vector3 lastPointerPosition;
public static void Init() {
if (!EnhancedTouch.EnhancedTouchSupport.enabled) {
EnhancedTouch.EnhancedTouchSupport.Enable();
}
}
public static Vector3 mousePosition {
get {
if (touchCount > 0) {
lastPointerPosition = EnhancedTouch.Touch.activeTouches[0].screenPosition;
} else {
Mouse m = Mouse.current;
if (m != null) {
lastPointerPosition = m.position.ReadValue();
}
}
return lastPointerPosition;
}
}
public static bool GetMouseButtonDown(int buttonIndex) {
if (touchCount > 0) {
return EnhancedTouch.Touch.activeTouches[0].phase == UnityEngine.InputSystem.TouchPhase.Began;
} else {
Mouse m = Mouse.current;
if (m == null) return false;
switch (buttonIndex) {
case 1: return m.rightButton.wasPressedThisFrame;
case 2: return m.middleButton.wasPressedThisFrame;
default: return m.leftButton.wasPressedThisFrame;
}
}
}
public static int touchCount { get { return EnhancedTouch.Touch.activeTouches.Count; } }
public static int GetFingerIdFromTouch(int touchIndex) {
EnhancedTouch.Touch touch = EnhancedTouch.Touch.activeTouches[touchIndex];
return touch.finger.index;
}
public static bool GetKeyDown(string name) {
return ((KeyControl)Keyboard.current[name]).wasPressedThisFrame;
}
#else
public static void Init() {}
public static Vector3 mousePosition {
get {
return Input.mousePosition;
}
}
public static bool GetMouseButtonDown(int buttonIndex) {
return Input.GetMouseButtonDown(buttonIndex);
}
public static int touchCount {
get { return Input.touchCount; }
}
public static int GetFingerIdFromTouch(int touchIndex) {
return Input.GetTouch(touchIndex).fingerId;
}
public static bool GetKeyDown(string name) {
return Input.GetKeyDown(name);
}
#endif
}
}

View File

@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: 22dd181849f53482686b5c26304410c2
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

View File

@ -0,0 +1,76 @@
using UnityEngine;
namespace HighlightPlus {
public static class ShaderParams {
// general uniforms
public static int Cull = Shader.PropertyToID("_Cull");
public static int BlurScale = Shader.PropertyToID("_BlurScale");
public static int Speed = Shader.PropertyToID("_Speed");
public static int ConstantWidth = Shader.PropertyToID("_ConstantWidth");
public static int CutOff = Shader.PropertyToID("_CutOff");
public static int ZTest = Shader.PropertyToID("_ZTest");
public static int Flip = Shader.PropertyToID("_Flip");
public static int Debug = Shader.PropertyToID("_Debug");
public static int Color = Shader.PropertyToID("_Color");
public static int MainTex = Shader.PropertyToID("_MainTex");
public static int BaseMap = Shader.PropertyToID("_BaseMap");
public static int BaseMapST = Shader.PropertyToID("_BaseMap_ST");
public static int AspectRatio = Shader.PropertyToID("_AspectRatio");
public static int BlendSrc = Shader.PropertyToID("_BlendSrc");
public static int BlendDst = Shader.PropertyToID("_BlendDst");
// outline uniforms
public static int OutlineWidth = Shader.PropertyToID("_OutlineWidth");
public static int OutlineZTest = Shader.PropertyToID("_OutlineZTest");
public static int OutlineDirection = Shader.PropertyToID("_OutlineDirection");
public static int OutlineColor = Shader.PropertyToID("_OutlineColor");
// glow uniforms
public static int GlowZTest = Shader.PropertyToID("_GlowZTest");
public static int GlowStencilComp = Shader.PropertyToID("_GlowStencilComp");
public static int GlowStencilOp = Shader.PropertyToID("_GlowStencilOp");
public static int GlowDirection = Shader.PropertyToID("_GlowDirection");
public static int Glow = Shader.PropertyToID("_Glow");
public static int GlowColor = Shader.PropertyToID("_GlowColor");
public static int Glow2 = Shader.PropertyToID("_Glow2");
// see-through uniforms
public static int SeeThrough = Shader.PropertyToID("_SeeThrough");
public static int SeeThroughNoise = Shader.PropertyToID("_SeeThroughNoise");
public static int SeeThroughBorderWidth = Shader.PropertyToID("_SeeThroughBorderWidth");
public static int SeeThroughBorderConstantWidth = Shader.PropertyToID("_SeeThroughBorderConstantWidth");
public static int SeeThroughTintColor = Shader.PropertyToID("_SeeThroughTintColor");
public static int SeeThroughBorderColor = Shader.PropertyToID("_SeeThroughBorderColor");
public static int SeeThroughStencilRef = Shader.PropertyToID("_SeeThroughStencilRef");
public static int SeeThroughStencilComp = Shader.PropertyToID("_SeeThroughStencilComp");
public static int SeeThroughStencilPassOp = Shader.PropertyToID("_SeeThroughStencilPassOp");
public static int SeeThroughDepthOffset = Shader.PropertyToID("_SeeThroughDepthOffset");
public static int SeeThroughMaxDepth = Shader.PropertyToID("_SeeThroughMaxDepth");
// inner glow uniforms
public static int InnerGlowWidth = Shader.PropertyToID("_InnerGlowWidth");
public static int InnerGlowZTest = Shader.PropertyToID("_InnerGlowZTest");
public static int InnerGlowColor = Shader.PropertyToID("_InnerGlowColor");
// overlay uniforms
public static int OverlayData = Shader.PropertyToID("_OverlayData");
public static int OverlayBackColor = Shader.PropertyToID("_OverlayBackColor");
public static int OverlayColor = Shader.PropertyToID("_OverlayColor");
public static int OverlayHitPosData = Shader.PropertyToID("_OverlayHitPosData");
public static int OverlayHitStartTime = Shader.PropertyToID("_OverlayHitStartTime");
public static int OverlayTexture = Shader.PropertyToID("_OverlayTexture");
// target uniforms
public static int TargetFXRenderData = Shader.PropertyToID("_TargetFXRenderData");
// keywords
public const string SKW_ALPHACLIP = "HP_ALPHACLIP";
public const string SKW_DEPTHCLIP = "HP_DEPTHCLIP";
public const string SKW_DEPTH_OFFSET = "HP_DEPTH_OFFSET";
public const string SKW_USES_OVERLAY_TEXTURE = "HP_USES_OVERLAY_TEXTURE";
public const string SKW_SEETHROUGH_ONLY_BORDER = "HP_SEETHROUGH_ONLY_BORDER";
}
}

View File

@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: 0c43adc34509547febe8181a2de00da5
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

Binary file not shown.

View File

@ -0,0 +1,33 @@
fileFormatVersion: 2
guid: 2431e08c00d60b349ab05a901120a8cd
PluginImporter:
externalObjects: {}
serializedVersion: 2
iconMap: {}
executionOrder: {}
defineConstraints: []
isPreloaded: 0
isOverridable: 0
isExplicitlyReferenced: 0
validateReferences: 1
platformData:
- first:
Any:
second:
enabled: 1
settings: {}
- first:
Editor: Editor
second:
enabled: 0
settings:
DefaultValueInitialized: true
- first:
Windows Store Apps: WindowsStoreApps
second:
enabled: 0
settings:
CPU: AnyCPU
userData:
assetBundleName:
assetBundleVariant:

8
Assets/Resources.meta Normal file
View File

@ -0,0 +1,8 @@
fileFormatVersion: 2
guid: 2de3288c544bf2744bf5eaa7871e51b7
folderAsset: yes
DefaultImporter:
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant:

File diff suppressed because it is too large Load Diff

View File

@ -0,0 +1,7 @@
fileFormatVersion: 2
guid: aa522b367577dea4fac07b18195c3d5a
DefaultImporter:
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant:

View File

@ -0,0 +1,267 @@
%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: 9
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: 705507994}
m_IndirectSpecularColor: {r: 0, g: 0, b: 0, a: 1}
m_UseRadianceAmbientProbe: 0
--- !u!157 &3
LightmapSettings:
m_ObjectHideFlags: 0
serializedVersion: 12
m_GIWorkflowMode: 1
m_GISettings:
serializedVersion: 2
m_BounceScale: 1
m_IndirectOutputScale: 1
m_AlbedoBoost: 1
m_EnvironmentLightingMode: 0
m_EnableBakedLightmaps: 1
m_EnableRealtimeLightmaps: 0
m_LightmapEditorSettings:
serializedVersion: 12
m_Resolution: 2
m_BakeResolution: 40
m_AtlasSize: 1024
m_AO: 0
m_AOMaxDistance: 1
m_CompAOExponent: 1
m_CompAOExponentDirect: 0
m_ExtractAmbientOcclusion: 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: 1
m_PVRSampling: 1
m_PVRDirectSampleCount: 32
m_PVRSampleCount: 500
m_PVRBounces: 2
m_PVREnvironmentSampleCount: 500
m_PVREnvironmentReferencePointCount: 2048
m_PVRFilteringMode: 2
m_PVRDenoiserTypeDirect: 0
m_PVRDenoiserTypeIndirect: 0
m_PVRDenoiserTypeAO: 0
m_PVRFilterTypeDirect: 0
m_PVRFilterTypeIndirect: 0
m_PVRFilterTypeAO: 0
m_PVREnvironmentMIS: 0
m_PVRCulling: 1
m_PVRFilteringGaussRadiusDirect: 1
m_PVRFilteringGaussRadiusIndirect: 5
m_PVRFilteringGaussRadiusAO: 2
m_PVRFilteringAtrousPositionSigmaDirect: 0.5
m_PVRFilteringAtrousPositionSigmaIndirect: 2
m_PVRFilteringAtrousPositionSigmaAO: 1
m_ExportTrainingData: 0
m_TrainingDataDestination: TrainingData
m_LightProbeSampleCountMultiplier: 4
m_LightingDataAsset: {fileID: 0}
m_LightingSettings: {fileID: 0}
--- !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 &705507993
GameObject:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInternal: {fileID: 0}
serializedVersion: 6
m_Component:
- component: {fileID: 705507995}
- component: {fileID: 705507994}
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 &705507994
Light:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInternal: {fileID: 0}
m_GameObject: {fileID: 705507993}
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: 1
m_LightShadowCasterMode: 0
m_AreaSize: {x: 1, y: 1}
m_BounceIntensity: 1
m_ColorTemperature: 6570
m_UseColorTemperature: 0
m_ShadowRadius: 0
m_ShadowAngle: 0
--- !u!4 &705507995
Transform:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInternal: {fileID: 0}
m_GameObject: {fileID: 705507993}
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 &963194225
GameObject:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInternal: {fileID: 0}
serializedVersion: 6
m_Component:
- component: {fileID: 963194228}
- component: {fileID: 963194227}
- component: {fileID: 963194226}
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 &963194226
AudioListener:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInternal: {fileID: 0}
m_GameObject: {fileID: 963194225}
m_Enabled: 1
--- !u!20 &963194227
Camera:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInternal: {fileID: 0}
m_GameObject: {fileID: 963194225}
m_Enabled: 1
serializedVersion: 2
m_ClearFlags: 1
m_BackGroundColor: {r: 0.19215687, g: 0.3019608, b: 0.4745098, a: 0}
m_projectionMatrixMode: 1
m_SensorSize: {x: 36, y: 24}
m_LensShift: {x: 0, y: 0}
m_GateFitMode: 2
m_FocalLength: 50
m_NormalizedViewPortRect:
serializedVersion: 2
x: 0
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_AllowDynamicResolution: 0
m_ForceIntoRT: 0
m_OcclusionCulling: 1
m_StereoConvergence: 10
m_StereoSeparation: 0.022
--- !u!4 &963194228
Transform:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInternal: {fileID: 0}
m_GameObject: {fileID: 963194225}
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: []
m_Father: {fileID: 0}
m_RootOrder: 0
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}

View File

@ -0,0 +1,7 @@
fileFormatVersion: 2
guid: 9fc0d4010bbf28b4594072e72b8655ab
DefaultImporter:
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant:

8
Assets/Scripts.meta Normal file
View File

@ -0,0 +1,8 @@
fileFormatVersion: 2
guid: 91f737b7465f78743a13d0443ad59ed6
folderAsset: yes
DefaultImporter:
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant:

View File

@ -0,0 +1,8 @@
fileFormatVersion: 2
guid: 637b0871377847b45bff3899b8c7d0b7
folderAsset: yes
DefaultImporter:
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant:

8
Assets/TextMesh Pro.meta Normal file
View File

@ -0,0 +1,8 @@
fileFormatVersion: 2
guid: f54d1bd14bd3ca042bd867b519fee8cc
folderAsset: yes
DefaultImporter:
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant:

View File

@ -0,0 +1,8 @@
fileFormatVersion: 2
guid: 8e7e8f5a82a3a134e91c54efd2274ea9
folderAsset: yes
DefaultImporter:
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant:

View File

@ -0,0 +1,470 @@
TextMesh Pro!
Advanced Text Rendering for Unity 3D
USER GUIDE
Release 1.0.54
Dec 2016
Copyright (C) 2016 Stephan Bouchard - All Rights Reserved
This manual, as well as the software described in it, is furnished under license and may
be used or copied only in accordance with the terms of such license. The content of
this manual is furnished for informational use only, is subject to change without notice
and should not be construed as a commitment by its authors. The author assumes no
responsibility or liability for any errors or inaccuracies that may appear in this manual.
TextMesh Pro!
User Guide / Table of Contents
Getting Started
Overview........................................................................................................................ 4
Installation..................................................................................................................... 4
Quick Start..................................................................................................................... 4
Support & API documentation.................................................................................. 4
TextMeshPro Component
Text Input Box............................................................................................................... 5
Font Settings................................................................................................................. 6
Material Editor & Shaders Overview
Shader Overview.......................................................................................................... 7
Material Editor UI Panels & Features........................................................................ 7
Font Asset Creator
General Overview...................................................................................................... 10
Font Asset
General Font Information & Sub-Assets............................................................... 13
Font Settings............................................................................................................... 13
Character Set Info...................................................................................................... 14
Kerning Table.............................................................................................................. 14
3 / 14
TextMesh Pro!
User Guide / Getting Started
Overview
This User Guide was designed to provide TextMesh Pro users with a basic overview of the
features and functionality of the tool.
Installation
Once you have downloaded TextMesh Pro from Unitys Asset Store, go to: “Assets->Import
Package->Custom Package...”. In the Import Asset window, find and select the TextMeshPro.
unitypackage file. After the “Importing package” window appears in Unity, verify that all items to
import are selected and then click the Import button in the bottom right of the window.
Quick Start
There are two TextMesh Pro components available. To add a new TextMesh Pro text object
which works with the Mesh Renderer, go to: “GameObject->3D Object->TextMeshPro Text”.
To add a TextMesh Pro Component which works with the New UI, go to: “GameObject->UI-
>TextMeshPro Text”.
You may also wish to watch this short video showing how to add TextMesh Pro text objects into
a scene.
Support & API Documentation
Should you have questions or require assistance, please visit the TextMesh Pro User Forum
where you will find additional information, Video Tutorials and FAQ. In the event you are unable
to find the information you seek, feel free to register and post on the user forum or to contact
Support@DigitalNativeStudios.com
Online Documentation is also available on TextMesh Pro including Rich Text tags, Shaders,
Scripting API and more.
4 / 14
TextMesh Pro!
User Guide / Component Overview
Component Overview
The TextMesh Pro component is divided into two sections: The Text Input and the Font Settings.
Text Input Box
This area is where you will type the text to be rendered. Multiple lines of text can be entered by
pressing <Enter> on your keyboard or by typing the special character \n.
Tabulation can be achieved by using \t. These are tab stops with a spacing interval equal to
roughly 25% of the point size. For an alternative to tabs, see the <pos> tag below.
The Text Input area also supports Rich Text tags. Tags are defined by enclosing the tag between
“<” and “>” characters. Below is a partial list of supported tags. Updated tag list is available here.
<b>Bold</b>
<i>Italics</i>
<u>Underline</u>
<s>Strikethrough</s>
<sup>Superscript</sup>
<sub>Subscript</sub>
<size=48>Point size 48</size>
<size=+18>Point size increased by 18</size>
<size=-18>Point size decreased by 18</size>
<pos=5.5>Characters positioned about 5.5 characters from left side.
<color=yellow>Yellow text</color>
<#00ff00>Green text</color>
5 / 14
TextMesh Pro!
User Guide / Component Overview
Font Settings
Font Asset This is the TextMeshPro Font Asset that
will be used to render the text.
Font Style Applies a global style to the text like
bold, italics, etc.
Vertex Color Color that will be assigned as a vertex
color for each character unless a color
tag has been specified.
Color Gradient Enables using a Vertex Color Gradient.
Override Color Tags Enables overriding color tags. This
results in all characters using the Face
Color instead of the color tag.
Font Size The point size of the characters.
Auto Size Dynamically adjusts the point size
between the min & max to fit the size
of the text container.
Character Spacing Controls the spacing between individual characters.
Spacing Enables adjustments to character, line and paragraph spacing.
Alignment Controls the alignment of the text. Options are Left, Center, Right and Justified. When Justified is
selected, the ratio controls how additional spacing is added between words and characters.
Enable Word Wrap Enables or disables Word Wrapping.
UV Mapping Options Controls how the texture (face & border) are mapping on the text object.
Enable Kerning Enables or disables Kerning if any kerning pairs are defined in the kerning table of the Font Asset.
Extra Padding Extra padding may be required for very small fonts. This extra padding prevents the characters
from being clipped.
6 / 14
TextMesh Pro!
User Guide / Material Editor & Shader Overview
Material Editor & Shaders
TextMeshPro includes several custom shaders along with a custom material editor which was
designed to keep things simple by only exposing those properties which are expected to be
modified.
There are two groups of shaders which include a Bitmap shader & a few Signed Distance Field
shaders. TextMesh Pros shaders can be found in “TextMeshPro/...” section of the shader list in
the material component. Below is a list and brief description of the SDF shaders. Updated shader
information is also available here.
Distance Field Mobile
This lightweight shader contains just the bare essential features and offers the best overall performance.
Distance Field
This more advanced shader includes a large selection of features. It is the shader that is assigned by default to all
Signed Distance Field font assets. It still offers excellent performance.
Distance Field Surface
This shader includes essentially the same features as the Distance Field shader. However, instead of using simulated
lighting, it uses the scene lights. These text objects can also cast shadows. This shader uses per pixel lighting.
Distance Field Surface Mobile
This is a lightweight version of the Surface shader with limited features. It uses per vertex lighting and does not use
directional information from lights. However it does factor in light distance.
Material Editor Feature Panels
In this section, you will find an overview of each of the feature panels used by the custom
material editor. Clicking on these panels will hide or reveal their features. Some of these panels
need to be enabled to turn on their functionality. Different panels will be available on the various
shaders.
Face Panel
Color - Select the color and transparency for the face of the characters.
This color will be combined with the vertex color.
Texture - Select a texture to be applied to the face of the characters.
The Color will affect the color of the texture. How the texture is applied
to the characters / text object is controlled by the mapping options in
the Editor Panel. The texture option is not available on all shaders.
Softness - Controls the softness of the face of the characters. Please not the face softness begins at the edge which
may be underneath the Outline.
Dilate - Increases or decreases the size of the characters.
7 / 14
TextMesh Pro!
User Guide / Material Editor & Shader Overview
Gloss - Controls how shiny the surface of the characters appears
when using the Surface shaders.
Outline Panel
Color - Controls the color and transparency for the Outline of the
characters.
Texture - Select a texture to be applied to the face of the characters.
The Color will affect the color of the texture. How the texture is
applied to the characters / text object is controlled by the mapping
options in the Editor Panel. The texture option is not available on all
shaders.
Thickness - Controls the thickness of the Outline. The Outline is
applied on the edge of the face and expands inwards and outwards.
Gloss - Controls how shiny the surface of the characters appears when using the Surface shaders.
Underlay Panel
Underlay can be used to add a shadow or border to the text object.
This is a very efficient way to add contrast to small text.
Color - Controls the color and transparency for the Underlay.
Offset (X, Y) - Controls the position of the Underlay. Please not
Underlay has a limited range.
Dilate - Increases or decreases the size of the underlay. This can be
used to make the shadow appear bigger or with an Offset of (0, 0)
create a nice border around the text.
Softness - Controls the softness of the underlay.
Bevel Panel
Bevel simulates the visual appearance of a 3D bevel on a 2D object.
Type - Two types are available; Outer and Inner bevel.
Amount - Controls the amount of bevel being applied.
Offset - Controls the position of the bevel relative to the edge of the
face of the character.
Width - Controls the width of the bevel effect.
Roundness - Determines if the bevel ridges will appear sharp or
rounded.
Clamp - Limits the height of the bevel. This visually looks like the edges have been flattened.
8 / 14
TextMesh Pro!
User Guide / Material Editor & Shader Overview
Lighting Panel
The lighting settings controls the appearance of the bevel, bump and
environmental mapping.
Light Angle - Controls the angle of the light.
Specular Color - Determines the color of the specular highlights.
Specular Power - Controls the strength of the specular highlights.
Reflectivity Power - Controls the amount of light being reflected.
Diffuse Shadow - Increase or decrease the amount of light received
by the object.
Ambient Shadow - Controls how pronounced the light and bevel
edges appear.
BumpMap Panel
Texture - The normal map to be applied to the text object.
Face - Controls the amount of bump mapping to be applied to the
face of the characters.
Outline - The amount of bump mapping applied to the Outline of the
characters.
EnvMap Panel
Color - The color will brighten, darken or tint the environmental map.
Default color is black which leaves the text object unaffected.
Texture - The Cube map to be applied to the text object.
Glow Panel
Color - The color and transparency of the Glow.
Offset - Controls the position of the glow. A value of 0.0 is on the
edge of the face of the character.
Inner - Controls how far the Glow effect extends towards the inside
of the face.
Outer - Controls how far the Glow effect extends towards the outside
of the face.
Power - Controls the amount of Glow.
9 / 14
TextMesh Pro!
User Guide / Font Asset Creator
Font Asset Creator Overview
To access TextMesh Pros Font Asset Creator go to: “Window->TextMeshPro Font Asset
Creator”. The following video provides a detailed overview of the Font Asset Creation Process.
Online documentation is also available on
this topic at this location.
It is also strongly recommended that you
video the following video about Creating &
Working with Material Presets with TextMesh
Pro.
Font Settings
The Font Settings panel is where the font for which a font asset is to be created is selected along
with various settings.
Font Source is where the font for which an asset is to be created is
selected.
Point Size determines at what point size the font will be created.
You can either manually select the size of the font or use the Auto
Sizing mode which will find the largest possible font size to fit in the
given Atlas Resolution. It is recommended to use Auto Sizing.
Font Padding determines how much space in pixel units between
each character. Font Padding also determines the spread used in the
Signed Distance Field Font Render Mode. For an Atlas Resolution of
512 X 512, a value of 5 for padding is generally adequate.
Atlas Resolution determines the size of the Font Atlas. For most fonts
which include the full ASCII character set, a size of 512 X 512 works usually
well for Signed Distance Field Render Mode.
Character Set determines what characters will be included in the font atlas.
10 / 14
TextMesh Pro!
User Guide / Font Asset Creator
Custom Range allows you to define a range that represents
which characters to be included. To define a range the includes
the ASCII set + Latin supplemental characters, a user would enter
32-126, 161-255 in the Custom Range window.
Custom Characters allows the user to specify characters to
include by typing them Custom Character window.
Characters from File enables a user to supply a plain text file that
contains all the characters to be included in the atlas.
Font Style allows the user to select if the characters will be
created as bold, italics or as an outline as well as defining the
thickness of the outline or boldness. Keep in mind that this is
mostly useful for normal bitmap fonts. Since Signed Distance
Field font rendering enables the creation of bold or an outline
dynamically these style options are fun to experiment with but
not essential.
Font Render Mode determines how the characters will be
rendered.
Hinted Smooth is anti-aliased rendering with hinting.
Smooth is the same without hinting.
Raster Hinted renders the characters without anti-aliasing with
hinting.
Raster is no anti-aliasing or hinting.
Signed Distance Field 16 is the standard mode for creating a
SDF Atlas. The font will be up sampled 16X to produce a more
accurate Signed Distance Field Atlas.
Signed Distance Field 32 is the same as above but with 32X up sampling. Using this mode will result in a more
accurate SDF Atlas which although more accurate may deliver only subtle visual improvements. This options should
mostly be used when trying to fit a full ASCII set into a small 256 X 256 atlas or when dealing with a complex shaped
font with high frequency curve changes. Note: This processing mode will be significantly slower than the 16X mode.
Note: Padding represents the spread that will be used in the creation of the SDF Atlas. The larger the spread the longer it will
take to process the atlas. Higher spread provides for better control over outline thickness, bevel and glow “tweak-ability” but will
result in the characters being smaller in the atlas. Smaller point size means potentially less sampling points and perhaps not as
good contour accuracy. It is a trade off or balance between those two. Typically a Spread or padding of 5 is good for normal text
and Spread of 7 for things like titles which typically have larger outline, bevel and glow options.
Get Kerning Pairs determines if the kerning pairs that may exist in the font file will be added to the font asset. In the
event no kerning pairs are found in the font file, new kerning pairs can always be added in the TextMeshPro Font
Asset Editor Panel.
11 / 14
TextMesh Pro!
User Guide / Font Asset Creator
Generate Font Atlas will get the font engine to render the select font / characters.
Save TextMeshPro Font Asset will bring up a file requester allowing you to choose a file location and a name for
the newly created asset. By default the font name will be that of the font name. When using Signed Distance Field
Render Mode, this name will be Font Name with SDF added. We recommend you save your font assets in the
“Assets/Resources/Fonts/...” or create such folder structure if one does not exists. As text objects are frequently
created via scripts which results in font assets not being referenced by any scene objects, this guarantees your fonts
assets will be include in the build and available.
12 / 14
TextMesh Pro!
User Guide / Font Asset
Font Asset
TextMesh Pro uses a custom font asset which contains
information necessary to display the font. The font asset is
divided into five sections which are as follows:
Face Info contains information specific to the font that was
rendered using the Font Asset Creator. This includes the
follow information:
Font Source - The name of the font.
Font Size - The point size at which the font was renderer in the font
atlas.
Line Height - This is the spacing between each lines of text.
Baseline - The position where the characters “sit” on the line.
Ascender - The highest point of any characters in the font.
Descender - The lowest point of any characters in the font.
Underline - The position of the underline.
Width & Height - The width and height of the font atlas.
Font Sub-Assets displays the sub assets that are part of the
custom font.
Font Atlas - Texture which contains all the characters of the font. This
texture is specific to such font.
Font Material - Default material for this font which holds a reference to the Font Atlas texture.
Face Style contains style properties for the font.
Normal & Bold weight - This defines the normal & bold weight of the font.
Italic Style - Defines the slant of italic.
13 / 14
TextMesh Pro!
User Guide / Font Asset
Glyph Info contains specific information about each
character in the font.
ASC II & Char - The ASC II code and Character.
X & Y - The X and Y position of the character in the font atlas.
W & H - The Width and Height of the character in the font atlas.
Offsets - The X Offset is where the character is drawn relative to (0, 0).
The Y offset represents where the top of the character is located relative
to the baseline or (0, 0). The Advance is how far to advance after this
character.
Kerning Table Info contains the kerning information for the
font. Kerning data can either import at font creation time or
added manually using this panel.
Left Char - The left character part of the pair.
Right Char - The right character part of the pair.
Offset - The offset between the left and right character.
14 / 14

View File

@ -0,0 +1,7 @@
fileFormatVersion: 2
guid: 1b8d251f9af63b746bf2f7ffe00ebb9b
DefaultImporter:
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant:

View File

@ -0,0 +1,8 @@
fileFormatVersion: 2
guid: 6ab70aee4d56447429c680537fbf93ed
folderAsset: yes
DefaultImporter:
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant:

View File

@ -0,0 +1,46 @@
Digitized data copyright (c) 2010 Google Corporation
with Reserved Font Arimo, Tinos and Cousine.
Copyright (c) 2012 Red Hat, Inc.
with Reserved Font Name Liberation.
This Font Software is licensed under the SIL Open Font License, Version 1.1.
This license is copied below, and is also available with a FAQ at: http://scripts.sil.org/OFL
-----------------------------------------------------------
SIL OPEN FONT LICENSE Version 1.1 - 26 February 2007
-----------------------------------------------------------
PREAMBLE
The goals of the Open Font License (OFL) are to stimulate worldwide development of collaborative font projects, to support the font creation efforts of academic and linguistic communities, and to provide a free and open framework in which fonts may be shared and improved in partnership with others.
The OFL allows the licensed fonts to be used, studied, modified and redistributed freely as long as they are not sold by themselves. The fonts, including any derivative works, can be bundled, embedded, redistributed and/or sold with any software provided that any reserved names are not used by derivative works. The fonts and derivatives, however, cannot be released under any other type of license. The requirement for fonts to remain under this license does not apply to any document created using the fonts or their derivatives.
DEFINITIONS
"Font Software" refers to the set of files released by the Copyright Holder(s) under this license and clearly marked as such. This may include source files, build scripts and documentation.
"Reserved Font Name" refers to any names specified as such after the copyright statement(s).
"Original Version" refers to the collection of Font Software components as distributed by the Copyright Holder(s).
"Modified Version" refers to any derivative made by adding to, deleting, or substituting -- in part or in whole -- any of the components of the Original Version, by changing formats or by porting the Font Software to a new environment.
"Author" refers to any designer, engineer, programmer, technical writer or other person who contributed to the Font Software.
PERMISSION & CONDITIONS
Permission is hereby granted, free of charge, to any person obtaining a copy of the Font Software, to use, study, copy, merge, embed, modify, redistribute, and sell modified and unmodified copies of the Font Software, subject to the following conditions:
1) Neither the Font Software nor any of its individual components, in Original or Modified Versions, may be sold by itself.
2) Original or Modified Versions of the Font Software may be bundled, redistributed and/or sold with any software, provided that each copy contains the above copyright notice and this license. These can be included either as stand-alone text files, human-readable headers or in the appropriate machine-readable metadata fields within text or binary files as long as those fields can be easily viewed by the user.
3) No Modified Version of the Font Software may use the Reserved Font Name(s) unless explicit written permission is granted by the corresponding Copyright Holder. This restriction only applies to the primary font name as presented to the users.
4) The name(s) of the Copyright Holder(s) or the Author(s) of the Font Software shall not be used to promote, endorse or advertise any Modified Version, except to acknowledge the contribution(s) of the Copyright Holder(s) and the Author(s) or with their explicit written permission.
5) The Font Software, modified or unmodified, in part or in whole, must be distributed entirely under this license, and must not be distributed under any other license. The requirement for fonts to remain under this license does not apply to any document created using the Font Software.
TERMINATION
This license becomes null and void if any of the above conditions are not met.
DISCLAIMER
THE FONT SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO ANY WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT OF COPYRIGHT, PATENT, TRADEMARK, OR OTHER RIGHT. IN NO EVENT SHALL THE COPYRIGHT HOLDER BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, INCLUDING ANY GENERAL, SPECIAL, INDIRECT, INCIDENTAL, OR CONSEQUENTIAL DAMAGES, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF THE USE OR INABILITY TO USE THE FONT SOFTWARE OR FROM OTHER DEALINGS IN THE FONT SOFTWARE.

View File

@ -0,0 +1,8 @@
fileFormatVersion: 2
guid: 6e59c59b81ab47f9b6ec5781fa725d2c
timeCreated: 1484171296
licenseType: Pro
TextScriptImporter:
userData:
assetBundleName:
assetBundleVariant:

Binary file not shown.

Some files were not shown because too many files have changed in this diff Show More