diff --git a/Assets/Material/CRTBlit.mat b/Assets/Material/CRTBlit.mat index ca98651..706496e 100644 --- a/Assets/Material/CRTBlit.mat +++ b/Assets/Material/CRTBlit.mat @@ -117,7 +117,7 @@ Material: - _Surface: 0 - _WorkflowMode: 1 - _ZWrite: 1 - - u_bend: 3.15 + - u_bend: 3.03 - u_blue_offset_y: 0.00403 - u_green_offset_y: 0 - u_noise_amount: 0.012 @@ -126,10 +126,11 @@ Material: - u_scanlin_transparence1: 0.194 - u_scanlin_transparence2: 0.098 - u_scanline_amount: 0.019 - - u_scanline_size_1: 308 + - u_scanline_size_1: 277 - u_scanline_size_2: 521 - u_scanline_speed_1: 94.13 - u_scanline_speed_2: 30 + - u_space_bend: 2.107 - u_time: 15.95 - u_vignette_edge_round: 8.5 - u_vignette_size: 1.89 diff --git a/Assets/Prefabs/MainMenuButtons.prefab b/Assets/Prefabs/MainMenuButtons.prefab index 466c398..d6fb153 100644 --- a/Assets/Prefabs/MainMenuButtons.prefab +++ b/Assets/Prefabs/MainMenuButtons.prefab @@ -149,6 +149,7 @@ GameObject: - component: {fileID: 5917528464644539592} - component: {fileID: 5917528464644539593} - component: {fileID: 5917528464644539590} + - component: {fileID: 8804319104594876336} m_Layer: 5 m_Name: MainMenuButtons m_TagString: Untagged @@ -258,4 +259,28 @@ MonoBehaviour: m_TargetGraphic: {fileID: 5917528464644539593} m_OnClick: m_PersistentCalls: - m_Calls: [] + m_Calls: + - m_Target: {fileID: 8804319104594876336} + m_TargetAssemblyTypeName: SceneChanger, Assembly-CSharp + m_MethodName: LoadScene + m_Mode: 5 + m_Arguments: + m_ObjectArgument: {fileID: 0} + m_ObjectArgumentAssemblyTypeName: UnityEngine.Object, UnityEngine + m_IntArgument: 0 + m_FloatArgument: 0 + m_StringArgument: + m_BoolArgument: 0 + m_CallState: 2 +--- !u!114 &8804319104594876336 +MonoBehaviour: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 5917528464644539588} + m_Enabled: 1 + m_EditorHideFlags: 0 + m_Script: {fileID: 11500000, guid: 5383d580c7e5c0d41a73c7791506ead1, type: 3} + m_Name: + m_EditorClassIdentifier: diff --git a/Assets/Scenes/MainMenu.unity b/Assets/Scenes/MainMenu.unity index 15dbccc..4413e9d 100644 --- a/Assets/Scenes/MainMenu.unity +++ b/Assets/Scenes/MainMenu.unity @@ -596,7 +596,7 @@ RectTransform: m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} m_AnchorMin: {x: 0, y: 0} m_AnchorMax: {x: 0, y: 0} - m_AnchoredPosition: {x: -0.000030517578, y: 0} + m_AnchoredPosition: {x: -0.000061035156, y: 0} m_SizeDelta: {x: 165.09, y: 133.04} m_Pivot: {x: 0, y: 0} --- !u!114 &574174950 @@ -674,7 +674,7 @@ GameObject: - component: {fileID: 753457328} - component: {fileID: 753457327} - component: {fileID: 753457326} - - component: {fileID: 753457325} + - component: {fileID: 753457329} m_Layer: 5 m_Name: Main Canvas m_TagString: Untagged @@ -682,23 +682,6 @@ GameObject: m_NavMeshLayer: 0 m_StaticEditorFlags: 0 m_IsActive: 1 ---- !u!114 &753457325 -MonoBehaviour: - m_ObjectHideFlags: 0 - m_CorrespondingSourceObject: {fileID: 0} - m_PrefabInstance: {fileID: 0} - m_PrefabAsset: {fileID: 0} - m_GameObject: {fileID: 753457324} - m_Enabled: 1 - m_EditorHideFlags: 0 - m_Script: {fileID: 11500000, guid: dc42784cf147c0c48a680349fa168899, type: 3} - m_Name: - m_EditorClassIdentifier: - m_IgnoreReversedGraphics: 1 - m_BlockingObjects: 0 - m_BlockingMask: - serializedVersion: 2 - m_Bits: 255 --- !u!114 &753457326 MonoBehaviour: m_ObjectHideFlags: 0 @@ -767,6 +750,23 @@ RectTransform: m_AnchoredPosition: {x: 0, y: 0} m_SizeDelta: {x: 0, y: 0} m_Pivot: {x: 0, y: 0} +--- !u!114 &753457329 +MonoBehaviour: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 753457324} + m_Enabled: 1 + m_EditorHideFlags: 0 + m_Script: {fileID: 11500000, guid: c1e09fff2a59d384da651e8d0ddfd50c, type: 3} + m_Name: + m_EditorClassIdentifier: + m_IgnoreReversedGraphics: 1 + m_BlockingObjects: 0 + m_BlockingMask: + serializedVersion: 2 + m_Bits: 4294967295 --- !u!1 &779369315 GameObject: m_ObjectHideFlags: 0 @@ -925,6 +925,36 @@ PrefabInstance: propertyPath: m_Name value: Button-Options objectReference: {fileID: 0} + - target: {fileID: 5917528464644539590, guid: 0bdc45a9254ade843b7ba60aaab62301, + type: 3} + propertyPath: m_OnClick.m_PersistentCalls.m_Calls.Array.size + value: 1 + objectReference: {fileID: 0} + - target: {fileID: 5917528464644539590, guid: 0bdc45a9254ade843b7ba60aaab62301, + type: 3} + propertyPath: m_OnClick.m_PersistentCalls.m_Calls.Array.data[0].m_Mode + value: 1 + objectReference: {fileID: 0} + - target: {fileID: 5917528464644539590, guid: 0bdc45a9254ade843b7ba60aaab62301, + type: 3} + propertyPath: m_OnClick.m_PersistentCalls.m_Calls.Array.data[0].m_Target + value: + objectReference: {fileID: 815245104} + - target: {fileID: 5917528464644539590, guid: 0bdc45a9254ade843b7ba60aaab62301, + type: 3} + propertyPath: m_OnClick.m_PersistentCalls.m_Calls.Array.data[0].m_MethodName + value: Quit + objectReference: {fileID: 0} + - target: {fileID: 5917528464644539590, guid: 0bdc45a9254ade843b7ba60aaab62301, + type: 3} + propertyPath: m_OnClick.m_PersistentCalls.m_Calls.Array.data[0].m_TargetAssemblyTypeName + value: ButtonAction, Assembly-CSharp + objectReference: {fileID: 0} + - target: {fileID: 5917528464644539590, guid: 0bdc45a9254ade843b7ba60aaab62301, + type: 3} + propertyPath: m_OnClick.m_PersistentCalls.m_Calls.Array.data[0].m_Arguments.m_ObjectArgumentAssemblyTypeName + value: UnityEngine.Object, UnityEngine + objectReference: {fileID: 0} - target: {fileID: 5917528464644539591, guid: 0bdc45a9254ade843b7ba60aaab62301, type: 3} propertyPath: m_Pivot.x @@ -1038,6 +1068,18 @@ RectTransform: type: 3} m_PrefabInstance: {fileID: 815245102} m_PrefabAsset: {fileID: 0} +--- !u!114 &815245104 stripped +MonoBehaviour: + m_CorrespondingSourceObject: {fileID: 8804319104594876336, guid: 0bdc45a9254ade843b7ba60aaab62301, + type: 3} + m_PrefabInstance: {fileID: 815245102} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 0} + m_Enabled: 1 + m_EditorHideFlags: 0 + m_Script: {fileID: 11500000, guid: 5383d580c7e5c0d41a73c7791506ead1, type: 3} + m_Name: + m_EditorClassIdentifier: --- !u!1 &1281004660 GameObject: m_ObjectHideFlags: 0 @@ -1299,7 +1341,7 @@ RectTransform: m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} m_AnchorMin: {x: 0, y: 0} m_AnchorMax: {x: 1, y: 1} - m_AnchoredPosition: {x: 82.547, y: -53.407013} + m_AnchoredPosition: {x: 82.547, y: -53.407005} m_SizeDelta: {x: -165.09, y: -106.81} m_Pivot: {x: 0.5, y: 0.5} --- !u!114 &1703051055 @@ -1493,6 +1535,27 @@ PrefabInstance: propertyPath: m_Name value: Button-Play objectReference: {fileID: 0} + - target: {fileID: 5917528464644539590, guid: 0bdc45a9254ade843b7ba60aaab62301, + type: 3} + propertyPath: m_OnClick.m_PersistentCalls.m_Calls.Array.data[0].m_Mode + value: 2 + objectReference: {fileID: 0} + - target: {fileID: 5917528464644539590, guid: 0bdc45a9254ade843b7ba60aaab62301, + type: 3} + propertyPath: m_OnClick.m_PersistentCalls.m_Calls.Array.data[0].m_Arguments.m_ObjectArgument + value: + objectReference: {fileID: 102900000, guid: 4b213b8915c09ca49873cfadc143c61b, + type: 3} + - target: {fileID: 5917528464644539590, guid: 0bdc45a9254ade843b7ba60aaab62301, + type: 3} + propertyPath: m_OnClick.m_PersistentCalls.m_Calls.Array.data[0].m_Arguments.m_StringArgument + value: + objectReference: {fileID: 0} + - target: {fileID: 5917528464644539590, guid: 0bdc45a9254ade843b7ba60aaab62301, + type: 3} + propertyPath: m_OnClick.m_PersistentCalls.m_Calls.Array.data[0].m_Arguments.m_ObjectArgumentAssemblyTypeName + value: UnityEditor.SceneAsset, UnityEditor.CoreModule + objectReference: {fileID: 0} - target: {fileID: 5917528464644539591, guid: 0bdc45a9254ade843b7ba60aaab62301, type: 3} propertyPath: m_Pivot.x diff --git a/Assets/Scripts/ButtonAction.cs b/Assets/Scripts/ButtonAction.cs new file mode 100644 index 0000000..b556a02 --- /dev/null +++ b/Assets/Scripts/ButtonAction.cs @@ -0,0 +1,28 @@ +using System; +using System.Collections; +using System.Collections.Generic; +using Unity.VisualScripting; +using UnityEditor; +using UnityEngine; +using UnityEngine.SceneManagement; + +public class ButtonAction : MonoBehaviour +{ + public void LoadScene(SceneAsset sceneAsset) + { + SceneManager.LoadScene(sceneAsset.name); + } + + public void OpenOption() + { + throw new NotImplementedException(); + } + + public void Quit() + { + #if UNITY_EDITOR + UnityEditor.EditorApplication.isPlaying = false; + #endif + Application.Quit(); + } +} diff --git a/Assets/Scripts/ButtonAction.cs.meta b/Assets/Scripts/ButtonAction.cs.meta new file mode 100644 index 0000000..5869770 --- /dev/null +++ b/Assets/Scripts/ButtonAction.cs.meta @@ -0,0 +1,11 @@ +fileFormatVersion: 2 +guid: 5383d580c7e5c0d41a73c7791506ead1 +MonoImporter: + externalObjects: {} + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/Scripts/GraphicRaycasterBend.cs b/Assets/Scripts/GraphicRaycasterBend.cs new file mode 100644 index 0000000..eb8d083 --- /dev/null +++ b/Assets/Scripts/GraphicRaycasterBend.cs @@ -0,0 +1,356 @@ +using System; +using System.Collections; +using System.Collections.Generic; +using UnityEngine; +using UnityEngine.EventSystems; +using UnityEngine.Serialization; +using UnityEngine.UI; + +public class GraphicRaycasterBend : GraphicRaycaster +{ + Vector2 Bend(Vector2 uv, float bend) + { + uv -= new Vector2(0.5f, 0.5f); + uv *= new Vector2(2, 2); + + uv.x *= (float)(1 + Math.Pow(Math.Abs(uv.y) / bend, 2)); + uv.y *= (float)(1 + Math.Pow(Math.Abs(uv.x) / bend, 2)); + + uv /= new Vector2(2.107f, 2.107f); + return uv + new Vector2(0.5f, 0.5f); + } + + private Canvas m_Canvas; + + private Canvas canvas + { + get + { + if (m_Canvas != null) + return m_Canvas; + + m_Canvas = GetComponent(); + return m_Canvas; + } + } + + [NonSerialized] private List m_RaycastResults = new List(); + + /// + /// Perform the raycast against the list of graphics associated with the Canvas. + /// + /// Current event data + /// List of hit objects to append new results to. + public override void Raycast(PointerEventData eventData, List resultAppendList) + { + if (canvas == null) + return; + + var canvasGraphics = GraphicRegistry.GetRaycastableGraphicsForCanvas(canvas); + if (canvasGraphics == null || canvasGraphics.Count == 0) + return; + + int displayIndex; + var currentEventCamera = eventCamera; // Property can call Camera.main, so cache the reference + + if (canvas.renderMode == RenderMode.ScreenSpaceOverlay || currentEventCamera == null) + displayIndex = canvas.targetDisplay; + else + displayIndex = currentEventCamera.targetDisplay; + + var eventPosition = RelativeMouseAtScaled(eventData.position); + if (eventPosition != Vector3.zero) + { + // We support multiple display and display identification based on event position. + + int eventDisplayIndex = (int)eventPosition.z; + + // Discard events that are not part of this display so the user does not interact with multiple displays at once. + if (eventDisplayIndex != displayIndex) + return; + } + else + { + // The multiple display system is not supported on all platforms, when it is not supported the returned position + // will be all zeros so when the returned index is 0 we will default to the event data to be safe. + eventPosition = eventData.position; + +#if UNITY_EDITOR + if (Display.activeEditorGameViewTarget != displayIndex) + return; + eventPosition.z = Display.activeEditorGameViewTarget; +#endif + + // We dont really know in which display the event occured. We will process the event assuming it occured in our display. + } + + // Convert to view space + Vector2 pos; + if (currentEventCamera == null) + { + // Multiple display support only when not the main display. For display 0 the reported + // resolution is always the desktops resolution since its part of the display API, + // so we use the standard none multiple display method. (case 741751) + float w = Screen.width; + float h = Screen.height; + if (displayIndex > 0 && displayIndex < Display.displays.Length) + { + w = Display.displays[displayIndex].systemWidth; + h = Display.displays[displayIndex].systemHeight; + } + + pos = new Vector2(eventPosition.x / w, eventPosition.y / h); + } + else + pos = currentEventCamera.ScreenToViewportPoint(eventPosition); + + // If it's outside the camera's viewport, do nothing + if (pos.x < 0f || pos.x > 1f || pos.y < 0f || pos.y > 1f) + return; + + pos = Bend(pos, 3.03f); + + float hitDistance = float.MaxValue; + + Ray ray = new Ray(); + + if (currentEventCamera != null) + ray = currentEventCamera.ScreenPointToRay(eventPosition); + + if (canvas.renderMode != RenderMode.ScreenSpaceOverlay && blockingObjects != BlockingObjects.None) + { + float distanceToClipPlane = 100.0f; + + if (currentEventCamera != null) + { + float projectionDirection = ray.direction.z; + distanceToClipPlane = Mathf.Approximately(0.0f, projectionDirection) + ? Mathf.Infinity + : Mathf.Abs((currentEventCamera.farClipPlane - currentEventCamera.nearClipPlane) / + projectionDirection); + } +#if PACKAGE_PHYSICS + if (blockingObjects == BlockingObjects.ThreeD || blockingObjects == BlockingObjects.All) + { + if (ReflectionMethodsCache.Singleton.raycast3D != null) + { + var hits = + ReflectionMethodsCache.Singleton.raycast3DAll(ray, distanceToClipPlane, (int)m_BlockingMask); + if (hits.Length > 0) + hitDistance = hits[0].distance; + } + } +#endif +#if PACKAGE_PHYSICS2D + if (blockingObjects == BlockingObjects.TwoD || blockingObjects == BlockingObjects.All) + { + if (ReflectionMethodsCache.Singleton.raycast2D != null) + { + var hits = + ReflectionMethodsCache.Singleton.getRayIntersectionAll(ray, distanceToClipPlane, (int)m_BlockingMask); + if (hits.Length > 0) + hitDistance = hits[0].distance; + } + } +#endif + } + + m_RaycastResults.Clear(); + + Raycast(canvas, currentEventCamera, eventPosition, canvasGraphics, m_RaycastResults); + + int totalCount = m_RaycastResults.Count; + for (var index = 0; index < totalCount; index++) + { + var go = m_RaycastResults[index].gameObject; + bool appendGraphic = true; + + if (ignoreReversedGraphics) + { + if (currentEventCamera == null) + { + // If we dont have a camera we know that we should always be facing forward + var dir = go.transform.rotation * Vector3.forward; + appendGraphic = Vector3.Dot(Vector3.forward, dir) > 0; + } + else + { + // If we have a camera compare the direction against the cameras forward. + var cameraForward = currentEventCamera.transform.rotation * Vector3.forward * + currentEventCamera.nearClipPlane; + appendGraphic = + Vector3.Dot(go.transform.position - currentEventCamera.transform.position - cameraForward, + go.transform.forward) >= 0; + } + } + + if (appendGraphic) + { + float distance = 0; + Transform trans = go.transform; + Vector3 transForward = trans.forward; + + if (currentEventCamera == null || canvas.renderMode == RenderMode.ScreenSpaceOverlay) + distance = 0; + else + { + // http://geomalgorithms.com/a06-_intersect-2.html + distance = (Vector3.Dot(transForward, trans.position - ray.origin) / + Vector3.Dot(transForward, ray.direction)); + + // Check to see if the go is behind the camera. + if (distance < 0) + continue; + } + + if (distance >= hitDistance) + continue; + + var castResult = new RaycastResult + { + gameObject = go, + module = this, + distance = distance, + screenPosition = eventPosition, + displayIndex = displayIndex, + index = resultAppendList.Count, + depth = m_RaycastResults[index].depth, + sortingLayer = canvas.sortingLayerID, + sortingOrder = canvas.sortingOrder, + worldPosition = ray.origin + ray.direction * distance, + worldNormal = -transForward + }; + resultAppendList.Add(castResult); + } + } + } + + private static Vector3 RelativeMouseAtScaled(Vector2 position) + { +#if !UNITY_EDITOR && !UNITY_WSA + // If the main display is now the same resolution as the system then we need to scale the mouse position. (case 1141732) + if (Display.main.renderingWidth != Display.main.systemWidth || Display.main.renderingHeight != Display.main.systemHeight) + { + // The system will add padding when in full-screen and using a non-native aspect ratio. (case UUM-7893) + // For example Rendering 1920x1080 with a systeem resolution of 3440x1440 would create black bars on each side that are 330 pixels wide. + // we need to account for this or it will offset our coordinates when we are not on the main display. + var systemAspectRatio = Display.main.systemWidth / (float)Display.main.systemHeight; + + var sizePlusPadding = new Vector2(Display.main.renderingWidth, Display.main.renderingHeight); + var padding = Vector2.zero; + if (Screen.fullScreen) + { + var aspectRatio = Screen.width / (float)Screen.height; + if (Display.main.systemHeight * aspectRatio < Display.main.systemWidth) + { + // Horizontal padding + sizePlusPadding.x = Display.main.renderingHeight * systemAspectRatio; + padding.x = (sizePlusPadding.x - Display.main.renderingWidth) * 0.5f; + } + else + { + // Vertical padding + sizePlusPadding.y = Display.main.renderingWidth / systemAspectRatio; + padding.y = (sizePlusPadding.y - Display.main.renderingHeight) * 0.5f; + } + } + + var sizePlusPositivePadding = sizePlusPadding - padding; + + // If we are not inside of the main display then we must adjust the mouse position so it is scaled by + // the main display and adjusted for any padding that may have been added due to different aspect ratios. + if (position.y < -padding.y || position.y > sizePlusPositivePadding.y || + position.x < -padding.x || position.x > sizePlusPositivePadding.x) + { + var adjustedPosition = position; + + if (!Screen.fullScreen) + { + // When in windowed mode, the window will be centered with the 0,0 coordinate at the top left, we need to adjust so it is relative to the screen instead. + adjustedPosition.x -= (Display.main.renderingWidth - Display.main.systemWidth) * 0.5f; + adjustedPosition.y -= (Display.main.renderingHeight - Display.main.systemHeight) * 0.5f; + } + else + { + // Scale the mouse position to account for the black bars when in a non-native aspect ratio. + adjustedPosition += padding; + adjustedPosition.x *= Display.main.systemWidth / sizePlusPadding.x; + adjustedPosition.y *= Display.main.systemHeight / sizePlusPadding.y; + } + + var relativePos = Display.RelativeMouseAt(adjustedPosition); + + // If we are not on the main display then return the adjusted position. + if (relativePos.z != 0) + return relativePos; + } + + // We are using the main display. + return new Vector3(position.x, position.y, 0); + } +#endif + return Display.RelativeMouseAt(position); + } + + /// + /// The camera that will generate rays for this raycaster. + /// + /// + /// - Null if Camera mode is ScreenSpaceOverlay or ScreenSpaceCamera and has no camera. + /// - canvas.worldCanvas if not null + /// - Camera.main. + /// + public override Camera eventCamera + { + get + { + var canvas = this.canvas; + var renderMode = canvas.renderMode; + if (renderMode == RenderMode.ScreenSpaceOverlay + || (renderMode == RenderMode.ScreenSpaceCamera && canvas.worldCamera == null)) + return null; + + return canvas.worldCamera ?? Camera.main; + } + } + + /// + /// Perform a raycast into the screen and collect all graphics underneath it. + /// + [NonSerialized] static readonly List s_SortedGraphics = new List(); + + private static void Raycast(Canvas canvas, Camera eventCamera, Vector2 pointerPosition, + IList foundGraphics, List results) + { + // Necessary for the event system + int totalCount = foundGraphics.Count; + for (int i = 0; i < totalCount; ++i) + { + Graphic graphic = foundGraphics[i]; + + // -1 means it hasn't been processed by the canvas, which means it isn't actually drawn + if (!graphic.raycastTarget || graphic.canvasRenderer.cull || graphic.depth == -1) + continue; + + if (!RectTransformUtility.RectangleContainsScreenPoint(graphic.rectTransform, pointerPosition, eventCamera, + graphic.raycastPadding)) + continue; + + if (eventCamera != null && eventCamera.WorldToScreenPoint(graphic.rectTransform.position).z > + eventCamera.farClipPlane) + continue; + + if (graphic.Raycast(pointerPosition, eventCamera)) + { + s_SortedGraphics.Add(graphic); + } + } + + s_SortedGraphics.Sort((g1, g2) => g2.depth.CompareTo(g1.depth)); + totalCount = s_SortedGraphics.Count; + for (int i = 0; i < totalCount; ++i) + results.Add(s_SortedGraphics[i]); + + s_SortedGraphics.Clear(); + } +} \ No newline at end of file diff --git a/Assets/Scripts/GraphicRaycasterBend.cs.meta b/Assets/Scripts/GraphicRaycasterBend.cs.meta new file mode 100644 index 0000000..7b63ab8 --- /dev/null +++ b/Assets/Scripts/GraphicRaycasterBend.cs.meta @@ -0,0 +1,11 @@ +fileFormatVersion: 2 +guid: c1e09fff2a59d384da651e8d0ddfd50c +MonoImporter: + externalObjects: {} + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/Settings/URP-HighFidelity-Renderer.asset b/Assets/Settings/URP-HighFidelity-Renderer.asset index 21757e6..907ec01 100644 --- a/Assets/Settings/URP-HighFidelity-Renderer.asset +++ b/Assets/Settings/URP-HighFidelity-Renderer.asset @@ -97,7 +97,7 @@ MonoBehaviour: settings: Event: 550 blitMaterial: {fileID: 2100000, guid: a110daba21b580f4898ccf841727c0c2, type: 2} - blitMaterialPassIndex: 0 + blitMaterialPassIndex: -1 destination: 0 textureId: _BlitPassTexture alwaysRender: 1 diff --git a/Assets/Shaders/CRTShader.shader b/Assets/Shaders/CRTShader.shader index 8ae1136..19694ee 100644 --- a/Assets/Shaders/CRTShader.shader +++ b/Assets/Shaders/CRTShader.shader @@ -1,10 +1,11 @@ - Shader "CRTShader" +Shader "CRTShader" { Properties { _MainTex("Texture", 2D) = "Transparent" {} u_time("Time",float) = 0.5 - u_bend("Bend",range(0.5, 5.0)) = 0.5 + u_bend("Bend",range(0.5, 10.0)) = 0.5 + u_space_bend("Space Bend",range(1.5, 2.5)) = 2.5 u_scanlin_transparence1("Scanline 1 Transparence",range(0, 1)) = 0.5 u_scanline_size_1("Scanline Size 1",range(0, 750)) = 0.5 u_scanline_speed_1("Scanline Speed 1",float) = 0.5 @@ -15,16 +16,16 @@ u_vignette_size("Vignette Size",range(0, 10)) = 0.5 u_vignette_smoothness("Vignette Smoothness",range(0, 2)) = 0.5 u_vignette_edge_round("Vignette Edge Round",range(0, 100)) = 0.5 - u_noise_size("Noise Size",range(0, 500 )) = 0.5 + u_noise_size("Noise Size",range(0, 500 )) = 0.5 u_noise_amount("Noise Amount",range(0, 0.3)) = 0.5 u_red_offset_y("Red Offset",range(-0.01,0.01)) = 0 u_green_offset_y("Green Offset",range(-0.01,0.01)) = 0 u_blue_offset_y("Blue Offset",range(-0.01,0.01)) = 0 } - - // The Unity Editor uses the class ExampleCustomEditor to configure the Inspector for this shader asset + + // The Unity Editor uses the class ExampleCustomEditor to configure the Inspector for this shader asset CustomEditor "Shaders.BlitShaderGUI" - + SubShader { // No culling or depth @@ -59,9 +60,10 @@ } sampler2D _MainTex; - + uniform float u_time; uniform float u_bend; + uniform float u_space_bend; uniform float u_scanlin_transparence1; uniform float u_scanline_size_1; uniform float u_scanline_speed_1; @@ -80,23 +82,19 @@ half2 u_color_offset(float offset) { - return half2(0,offset); + return half2(0, offset); } half2 crt_coords(half2 uv, float bend) { - // By subtracting 0.5, we go from 0 to 1 into -0.5 to 0.5 uv -= 0.5; - // Multiplying by puts us in -1 to 1 space. uv *= 2.; - - // Curves lines + uv.x *= 1. + pow(abs(uv.y) / bend, 2.); uv.y *= 1. + pow(abs(uv.x) / bend, 2.); - //return coordinates to 0 to 1 space. - uv /= 2; - return uv + 0.5; + uv /= u_space_bend; + return uv + .5; } float vignette(half2 uv, float size, float smoothness, float edgeRounding) @@ -115,7 +113,6 @@ float random(half2 uv) { - return frac(sin(dot(uv, half2(15.1511, 42.5225))) * 12341.51611 * sin(u_time * 0.03)); } @@ -145,7 +142,7 @@ col.a = tex2D(_MainTex, crt_uv).a; float s1 = scanline(i.uv, u_scanline_size_1, u_scanline_speed_1, u_scanlin_transparence1); - float s2 = scanline(i.uv, u_scanline_size_2, u_scanline_speed_2,u_scanlin_transparence2); + float s2 = scanline(i.uv, u_scanline_size_2, u_scanline_speed_2, u_scanlin_transparence2); col = lerp(col, fixed(s1 + s2), u_scanline_amount); diff --git a/ProjectSettings/EditorBuildSettings.asset b/ProjectSettings/EditorBuildSettings.asset index 9eea490..85b67c8 100644 --- a/ProjectSettings/EditorBuildSettings.asset +++ b/ProjectSettings/EditorBuildSettings.asset @@ -8,6 +8,9 @@ EditorBuildSettings: - enabled: 1 path: Assets/Scenes/SampleScene.unity guid: 99c9720ab356a0642a771bea13969a05 + - enabled: 1 + path: Assets/Scenes/MainMenu.unity + guid: af63aef6e17277b44ade3df35992db53 m_configObjects: com.unity.input.settings: {fileID: 11400000, guid: 83b4255e269437642ad0474a7bdb56b5, type: 2}