From 1753a43f6d6f3ce85f483b763b16930715e61fe1 Mon Sep 17 00:00:00 2001 From: excitedneon Date: Fri, 12 May 2017 19:11:19 +0300 Subject: [PATCH] Add scanlines to holograms and make inv icons two-sided --- Assets/Models/Materials/Hologram.mat | 7 +- Assets/Models/Materials/Hologram_Base.mat | 7 +- Assets/Models/Textures/Scanline.png | 3 + Assets/Models/Textures/Scanline.png.meta | 68 +++++++++ Assets/Prefabs/Hologram.prefab | 2 + Assets/Scenes/TestMap.unity | 168 +++++++++++++++++++++- Assets/Scripts/Util/Hologram.cs | 25 +++- 7 files changed, 272 insertions(+), 8 deletions(-) create mode 100644 Assets/Models/Textures/Scanline.png create mode 100644 Assets/Models/Textures/Scanline.png.meta diff --git a/Assets/Models/Materials/Hologram.mat b/Assets/Models/Materials/Hologram.mat index ae5e293..c47d3e4 100644 --- a/Assets/Models/Materials/Hologram.mat +++ b/Assets/Models/Materials/Hologram.mat @@ -8,7 +8,8 @@ Material: m_PrefabInternal: {fileID: 0} m_Name: Hologram m_Shader: {fileID: 46, guid: 0000000000000000f000000000000000, type: 0} - m_ShaderKeywords: _ALPHABLEND_ON _EMISSION _GLOSSYREFLECTIONS_OFF _SPECULARHIGHLIGHTS_OFF + m_ShaderKeywords: _ALPHABLEND_ON _DETAIL_MULX2 _EMISSION _GLOSSYREFLECTIONS_OFF + _SPECULARHIGHLIGHTS_OFF m_LightmapFlags: 1 m_EnableInstancingVariants: 0 m_CustomRenderQueue: 3000 @@ -23,8 +24,8 @@ Material: m_Scale: {x: 1, y: 1} m_Offset: {x: 0, y: 0} - _DetailAlbedoMap: - m_Texture: {fileID: 0} - m_Scale: {x: 1, y: 1} + m_Texture: {fileID: 2800000, guid: 3d845f739c7a64c819f4a6b62b6fced5, type: 3} + m_Scale: {x: 1, y: 50} m_Offset: {x: 0, y: 0} - _DetailMask: m_Texture: {fileID: 0} diff --git a/Assets/Models/Materials/Hologram_Base.mat b/Assets/Models/Materials/Hologram_Base.mat index 9121a27..09219a7 100644 --- a/Assets/Models/Materials/Hologram_Base.mat +++ b/Assets/Models/Materials/Hologram_Base.mat @@ -8,7 +8,8 @@ Material: m_PrefabInternal: {fileID: 0} m_Name: Hologram_Base m_Shader: {fileID: 46, guid: 0000000000000000f000000000000000, type: 0} - m_ShaderKeywords: _ALPHABLEND_ON _EMISSION _GLOSSYREFLECTIONS_OFF _SPECULARHIGHLIGHTS_OFF + m_ShaderKeywords: _ALPHABLEND_ON _DETAIL_MULX2 _EMISSION _GLOSSYREFLECTIONS_OFF + _SPECULARHIGHLIGHTS_OFF m_LightmapFlags: 1 m_EnableInstancingVariants: 0 m_CustomRenderQueue: 3000 @@ -23,8 +24,8 @@ Material: m_Scale: {x: 1, y: 1} m_Offset: {x: 0, y: 0} - _DetailAlbedoMap: - m_Texture: {fileID: 0} - m_Scale: {x: 1, y: 1} + m_Texture: {fileID: 2800000, guid: 3d845f739c7a64c819f4a6b62b6fced5, type: 3} + m_Scale: {x: 1, y: 10} m_Offset: {x: 0, y: 0} - _DetailMask: m_Texture: {fileID: 0} diff --git a/Assets/Models/Textures/Scanline.png b/Assets/Models/Textures/Scanline.png new file mode 100644 index 0000000..7c293eb --- /dev/null +++ b/Assets/Models/Textures/Scanline.png @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:bfee97be2464fce984713eb758fa613776f4838757fa8e1c914be2ba1b0f6b33 +size 194 diff --git a/Assets/Models/Textures/Scanline.png.meta b/Assets/Models/Textures/Scanline.png.meta new file mode 100644 index 0000000..463c757 --- /dev/null +++ b/Assets/Models/Textures/Scanline.png.meta @@ -0,0 +1,68 @@ +fileFormatVersion: 2 +guid: 3d845f739c7a64c819f4a6b62b6fced5 +timeCreated: 1494604080 +licenseType: Free +TextureImporter: + fileIDToRecycleName: {} + serializedVersion: 4 + mipmaps: + mipMapMode: 0 + enableMipMap: 1 + 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: 0 + 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 + spriteSheet: + serializedVersion: 2 + sprites: [] + outline: [] + spritePackingTag: + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/Prefabs/Hologram.prefab b/Assets/Prefabs/Hologram.prefab index c50f8d9..92ee1bf 100644 --- a/Assets/Prefabs/Hologram.prefab +++ b/Assets/Prefabs/Hologram.prefab @@ -166,5 +166,7 @@ MonoBehaviour: m_Script: {fileID: 11500000, guid: b128d3bedf18c46f6b23cf529a954f59, type: 3} m_Name: m_EditorClassIdentifier: + HologramMesh: {fileID: 23583528089297200} Visible: 0 Text: {fileID: 114171175549544602} + HologramScanlineScrollingSpeed: 1 diff --git a/Assets/Scenes/TestMap.unity b/Assets/Scenes/TestMap.unity index 851124c..219ebf9 100644 --- a/Assets/Scenes/TestMap.unity +++ b/Assets/Scenes/TestMap.unity @@ -221,6 +221,11 @@ MeshFilter: m_PrefabInternal: {fileID: 0} m_GameObject: {fileID: 100803251} m_Mesh: {fileID: 10202, guid: 0000000000000000e000000000000000, type: 0} +--- !u!23 &122895534 stripped +MeshRenderer: + m_PrefabParentObject: {fileID: 23929481531100956, guid: e8761b9491a974d1780e60dafbd372a2, + type: 2} + m_PrefabInternal: {fileID: 2139315739} --- !u!1 &132238581 GameObject: m_ObjectHideFlags: 0 @@ -235,7 +240,7 @@ GameObject: m_Icon: {fileID: 0} m_NavMeshLayer: 0 m_StaticEditorFlags: 0 - m_IsActive: 0 + m_IsActive: 1 --- !u!4 &132238582 Transform: m_ObjectHideFlags: 0 @@ -2900,6 +2905,167 @@ Prefab: propertyPath: m_RootOrder value: 0 objectReference: {fileID: 0} + - target: {fileID: 4099946104317490, guid: e8761b9491a974d1780e60dafbd372a2, type: 2} + propertyPath: m_LocalPosition.z + value: 0.7 + objectReference: {fileID: 0} + - target: {fileID: 114633016952828368, guid: e8761b9491a974d1780e60dafbd372a2, + type: 2} + propertyPath: HologramMesh + value: + objectReference: {fileID: 122895534} + - target: {fileID: 4164543123855502, guid: e8761b9491a974d1780e60dafbd372a2, type: 2} + propertyPath: m_LocalScale.x + value: 0.115 + objectReference: {fileID: 0} + - target: {fileID: 4164543123855502, guid: e8761b9491a974d1780e60dafbd372a2, type: 2} + propertyPath: m_LocalScale.z + value: 0.115 + objectReference: {fileID: 0} + - target: {fileID: 33337063842811222, guid: e8761b9491a974d1780e60dafbd372a2, + type: 2} + propertyPath: m_Mesh + value: + objectReference: {fileID: 4300000, guid: 8d9188969010c44ce935ad4421c967df, type: 3} + - target: {fileID: 64730419328261050, guid: e8761b9491a974d1780e60dafbd372a2, + type: 2} + propertyPath: m_Mesh + value: + objectReference: {fileID: 4300000, guid: 8d9188969010c44ce935ad4421c967df, type: 3} + - target: {fileID: 4508297394169232, guid: e8761b9491a974d1780e60dafbd372a2, type: 2} + propertyPath: m_LocalScale.x + value: 0.115 + objectReference: {fileID: 0} + - target: {fileID: 4508297394169232, guid: e8761b9491a974d1780e60dafbd372a2, type: 2} + propertyPath: m_LocalScale.z + value: 0.115 + objectReference: {fileID: 0} + - target: {fileID: 33540133742758052, guid: e8761b9491a974d1780e60dafbd372a2, + type: 2} + propertyPath: m_Mesh + value: + objectReference: {fileID: 4300000, guid: 8d9188969010c44ce935ad4421c967df, type: 3} + - target: {fileID: 64705548599298680, guid: e8761b9491a974d1780e60dafbd372a2, + type: 2} + propertyPath: m_Mesh + value: + objectReference: {fileID: 4300000, guid: 8d9188969010c44ce935ad4421c967df, type: 3} + - target: {fileID: 4530634180654324, guid: e8761b9491a974d1780e60dafbd372a2, type: 2} + propertyPath: m_LocalScale.x + value: 0.115 + objectReference: {fileID: 0} + - target: {fileID: 4530634180654324, guid: e8761b9491a974d1780e60dafbd372a2, type: 2} + propertyPath: m_LocalScale.z + value: 0.115 + objectReference: {fileID: 0} + - target: {fileID: 64013687062017004, guid: e8761b9491a974d1780e60dafbd372a2, + type: 2} + propertyPath: m_Mesh + value: + objectReference: {fileID: 4300000, guid: 8d9188969010c44ce935ad4421c967df, type: 3} + - target: {fileID: 33683376200718996, guid: e8761b9491a974d1780e60dafbd372a2, + type: 2} + propertyPath: m_Mesh + value: + objectReference: {fileID: 4300000, guid: 8d9188969010c44ce935ad4421c967df, type: 3} + - target: {fileID: 4638548974480200, guid: e8761b9491a974d1780e60dafbd372a2, type: 2} + propertyPath: m_LocalScale.x + value: 0.115 + objectReference: {fileID: 0} + - target: {fileID: 4638548974480200, guid: e8761b9491a974d1780e60dafbd372a2, type: 2} + propertyPath: m_LocalScale.z + value: 0.115 + objectReference: {fileID: 0} + - target: {fileID: 33521042049071656, guid: e8761b9491a974d1780e60dafbd372a2, + type: 2} + propertyPath: m_Mesh + value: + objectReference: {fileID: 4300000, guid: 8d9188969010c44ce935ad4421c967df, type: 3} + - target: {fileID: 64624223168060348, guid: e8761b9491a974d1780e60dafbd372a2, + type: 2} + propertyPath: m_Mesh + value: + objectReference: {fileID: 4300000, guid: 8d9188969010c44ce935ad4421c967df, type: 3} + - target: {fileID: 4508297394169232, guid: e8761b9491a974d1780e60dafbd372a2, type: 2} + propertyPath: m_LocalRotation.x + value: -0.5 + objectReference: {fileID: 0} + - target: {fileID: 4508297394169232, guid: e8761b9491a974d1780e60dafbd372a2, type: 2} + propertyPath: m_LocalRotation.y + value: 0.5 + objectReference: {fileID: 0} + - target: {fileID: 4508297394169232, guid: e8761b9491a974d1780e60dafbd372a2, type: 2} + propertyPath: m_LocalRotation.z + value: 0.5 + objectReference: {fileID: 0} + - target: {fileID: 4508297394169232, guid: e8761b9491a974d1780e60dafbd372a2, type: 2} + propertyPath: m_LocalRotation.w + value: 0.5 + objectReference: {fileID: 0} + - target: {fileID: 4508297394169232, guid: e8761b9491a974d1780e60dafbd372a2, type: 2} + propertyPath: m_LocalEulerAnglesHint.x + value: -90 + objectReference: {fileID: 0} + - target: {fileID: 4530634180654324, guid: e8761b9491a974d1780e60dafbd372a2, type: 2} + propertyPath: m_LocalRotation.x + value: -0.5 + objectReference: {fileID: 0} + - target: {fileID: 4530634180654324, guid: e8761b9491a974d1780e60dafbd372a2, type: 2} + propertyPath: m_LocalRotation.y + value: 0.5 + objectReference: {fileID: 0} + - target: {fileID: 4530634180654324, guid: e8761b9491a974d1780e60dafbd372a2, type: 2} + propertyPath: m_LocalRotation.z + value: 0.5 + objectReference: {fileID: 0} + - target: {fileID: 4530634180654324, guid: e8761b9491a974d1780e60dafbd372a2, type: 2} + propertyPath: m_LocalRotation.w + value: 0.5 + objectReference: {fileID: 0} + - target: {fileID: 4530634180654324, guid: e8761b9491a974d1780e60dafbd372a2, type: 2} + propertyPath: m_LocalEulerAnglesHint.x + value: -90 + objectReference: {fileID: 0} + - target: {fileID: 4164543123855502, guid: e8761b9491a974d1780e60dafbd372a2, type: 2} + propertyPath: m_LocalRotation.x + value: -0.5 + objectReference: {fileID: 0} + - target: {fileID: 4164543123855502, guid: e8761b9491a974d1780e60dafbd372a2, type: 2} + propertyPath: m_LocalRotation.y + value: 0.5 + objectReference: {fileID: 0} + - target: {fileID: 4164543123855502, guid: e8761b9491a974d1780e60dafbd372a2, type: 2} + propertyPath: m_LocalRotation.z + value: 0.5 + objectReference: {fileID: 0} + - target: {fileID: 4164543123855502, guid: e8761b9491a974d1780e60dafbd372a2, type: 2} + propertyPath: m_LocalRotation.w + value: 0.5 + objectReference: {fileID: 0} + - target: {fileID: 4164543123855502, guid: e8761b9491a974d1780e60dafbd372a2, type: 2} + propertyPath: m_LocalEulerAnglesHint.x + value: -90 + objectReference: {fileID: 0} + - target: {fileID: 4638548974480200, guid: e8761b9491a974d1780e60dafbd372a2, type: 2} + propertyPath: m_LocalRotation.x + value: -0.5 + objectReference: {fileID: 0} + - target: {fileID: 4638548974480200, guid: e8761b9491a974d1780e60dafbd372a2, type: 2} + propertyPath: m_LocalRotation.y + value: 0.5 + objectReference: {fileID: 0} + - target: {fileID: 4638548974480200, guid: e8761b9491a974d1780e60dafbd372a2, type: 2} + propertyPath: m_LocalRotation.z + value: 0.5 + objectReference: {fileID: 0} + - target: {fileID: 4638548974480200, guid: e8761b9491a974d1780e60dafbd372a2, type: 2} + propertyPath: m_LocalRotation.w + value: 0.5 + objectReference: {fileID: 0} + - target: {fileID: 4638548974480200, guid: e8761b9491a974d1780e60dafbd372a2, type: 2} + propertyPath: m_LocalEulerAnglesHint.x + value: -90 + objectReference: {fileID: 0} m_RemovedComponents: [] m_ParentPrefab: {fileID: 100100000, guid: e8761b9491a974d1780e60dafbd372a2, type: 2} m_IsPrefabParent: 0 diff --git a/Assets/Scripts/Util/Hologram.cs b/Assets/Scripts/Util/Hologram.cs index 8141a6d..d985949 100644 --- a/Assets/Scripts/Util/Hologram.cs +++ b/Assets/Scripts/Util/Hologram.cs @@ -1,4 +1,5 @@ -using UnityEngine; +using System.Collections.Generic; +using UnityEngine; using Cyber.Util; namespace Cyber.Util { @@ -8,6 +9,11 @@ namespace Cyber.Util { /// public class Hologram : MonoBehaviour { + /// + /// The Hologram mesh. + /// + public MeshRenderer HologramMesh; + /// /// Whether the hologram is visible or not. /// @@ -19,17 +25,34 @@ namespace Cyber.Util { /// public TextTextureApplier Text; + /// + /// How fast the scanlines scroll. 1 = the scanlines will scroll the + /// height of a line per second. + /// + public float HologramScanlineScrollingSpeed = 1f; + private float CurrentScale; + private List ScanlineMaterials = new List(); private void Start() { CurrentScale = GetTargetScale(); UpdateScale(); + foreach (Material Mat in HologramMesh.materials) { + if (!Mat.name.Contains("Screen")) { + ScanlineMaterials.Add(Mat); + } + } } private void Update() { if (GetTargetScale() != CurrentScale) { UpdateScale(); } + float ScaledTime = Time.time * HologramScanlineScrollingSpeed; + float UVScroll = (ScaledTime - (int) ScaledTime); + foreach (Material Mat in ScanlineMaterials) { + Mat.SetTextureOffset("_DetailAlbedoMap", new Vector2(0, UVScroll)); + } } private void UpdateScale() {