From 3dc83774af4e12725bb56125a163ac1a58ce432e Mon Sep 17 00:00:00 2001 From: Jean Lamarre Date: Fri, 28 Oct 2022 14:41:09 -0400 Subject: [PATCH] wip visual #learningstuff --- Assets/Material/Retroed.mat | 131 ++++++++++++++++ .../Retroed.mat.meta} | 4 +- Assets/Readme.asset | 34 ---- Assets/Scripts/Visual.meta | 3 + Assets/Scripts/Visual/RetroPostProcess.cs | 35 +++++ .../Scripts/Visual/RetroPostProcess.cs.meta | 11 ++ .../Settings/URP-HighFidelity-Renderer.asset | 42 ++++- Assets/Settings/URP-HighFidelity.asset | 5 + Assets/Shaders.meta | 8 + Assets/Shaders/Retroed.shader | 62 ++++++++ Assets/Shaders/Retroed.shader.meta | 10 ++ Assets/Sprites/transparence.png | Bin 0 -> 4390 bytes Assets/Sprites/transparence.png.meta | 147 ++++++++++++++++++ ProjectSettings/TagManager.asset | 2 +- 14 files changed, 456 insertions(+), 38 deletions(-) create mode 100644 Assets/Material/Retroed.mat rename Assets/{Readme.asset.meta => Material/Retroed.mat.meta} (64%) delete mode 100644 Assets/Readme.asset create mode 100644 Assets/Scripts/Visual.meta create mode 100644 Assets/Scripts/Visual/RetroPostProcess.cs create mode 100644 Assets/Scripts/Visual/RetroPostProcess.cs.meta create mode 100644 Assets/Shaders.meta create mode 100644 Assets/Shaders/Retroed.shader create mode 100644 Assets/Shaders/Retroed.shader.meta create mode 100644 Assets/Sprites/transparence.png create mode 100644 Assets/Sprites/transparence.png.meta diff --git a/Assets/Material/Retroed.mat b/Assets/Material/Retroed.mat new file mode 100644 index 0000000..698b0fe --- /dev/null +++ b/Assets/Material/Retroed.mat @@ -0,0 +1,131 @@ +%YAML 1.1 +%TAG !u! tag:unity3d.com,2011: +--- !u!114 &-4790970344126815099 +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: 5 +--- !u!21 &2100000 +Material: + serializedVersion: 8 + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_Name: Retroed + m_Shader: {fileID: 4800000, guid: c4d7011496fb8f34ead8b47276ae3f0a, type: 3} + m_ValidKeywords: [] + m_InvalidKeywords: [] + 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} + - _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: 4.49, 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} + - _SpecGlossMap: + m_Texture: {fileID: 0} + m_Scale: {x: 1, y: 1} + m_Offset: {x: 0, y: 0} + - unity_Lightmaps: + m_Texture: {fileID: 0} + m_Scale: {x: 1, y: 1} + m_Offset: {x: 0, y: 0} + - unity_LightmapsInd: + m_Texture: {fileID: 0} + m_Scale: {x: 1, y: 1} + m_Offset: {x: 0, y: 0} + - unity_ShadowMasks: + m_Texture: {fileID: 0} + m_Scale: {x: 1, y: 1} + m_Offset: {x: 0, y: 0} + m_Ints: [] + m_Floats: + - _AlphaClip: 0 + - _Blend: 0 + - _BlendOp: 0 + - _BumpScale: 1 + - _CellSizeX: 4 + - _CellSizeY: 4 + - _ClearCoatMask: 0 + - _ClearCoatSmoothness: 0 + - _Cull: 2 + - _Cutoff: 0.5 + - _DetailAlbedoMapScale: 1 + - _DetailNormalMapScale: 1 + - _DstBlend: 0 + - _EnvironmentReflections: 1 + - _GlossMapScale: 0 + - _Glossiness: 0 + - _GlossyReflections: 0 + - _Metallic: 0 + - _OcclusionStrength: 1 + - _Parallax: 0.005 + - _QueueOffset: 0 + - _ReceiveShadows: 1 + - _SampleGI: 0 + - _ScreenHeight: 240 + - _ScreenWidth: 320 + - _Smoothness: 0.5 + - _SmoothnessTextureChannel: 0 + - _SpecularHighlights: 1 + - _SrcBlend: 1 + - _Surface: 0 + - _WorkflowMode: 1 + - _ZWrite: 1 + m_Colors: + - _BaseColor: {r: 1, g: 1, b: 1, a: 1} + - _Color: {r: 1, g: 1, b: 1, a: 1} + - _EmissionColor: {r: 0, g: 0, b: 0, a: 1} + - _SpecColor: {r: 0.19999996, g: 0.19999996, b: 0.19999996, a: 1} + m_BuildTextureStacks: [] diff --git a/Assets/Readme.asset.meta b/Assets/Material/Retroed.mat.meta similarity index 64% rename from Assets/Readme.asset.meta rename to Assets/Material/Retroed.mat.meta index ab3ad45..86b1fe0 100644 --- a/Assets/Readme.asset.meta +++ b/Assets/Material/Retroed.mat.meta @@ -1,8 +1,8 @@ fileFormatVersion: 2 -guid: 8105016687592461f977c054a80ce2f2 +guid: bc45e5f0151133446b26221ec8ea680c NativeFormatImporter: externalObjects: {} - mainObjectFileID: 0 + mainObjectFileID: 2100000 userData: assetBundleName: assetBundleVariant: diff --git a/Assets/Readme.asset b/Assets/Readme.asset deleted file mode 100644 index 77c2f83..0000000 --- a/Assets/Readme.asset +++ /dev/null @@ -1,34 +0,0 @@ -%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: fcf7219bab7fe46a1ad266029b2fee19, type: 3} - m_Name: Readme - m_EditorClassIdentifier: - icon: {fileID: 2800000, guid: 727a75301c3d24613a3ebcec4a24c2c8, type: 3} - title: URP Empty Template - sections: - - heading: Welcome to the Universal Render Pipeline - text: This template includes the settings and assets you need to start creating with the Universal Render Pipeline. - linkText: - url: - - heading: URP Documentation - text: - linkText: Read more about URP - url: https://docs.unity3d.com/Packages/com.unity.render-pipelines.universal@latest - - heading: Forums - text: - linkText: Get answers and support - url: https://forum.unity.com/forums/universal-render-pipeline.383/ - - heading: Report bugs - text: - linkText: Submit a report - url: https://unity3d.com/unity/qa/bug-reporting - loadedLayout: 1 diff --git a/Assets/Scripts/Visual.meta b/Assets/Scripts/Visual.meta new file mode 100644 index 0000000..1fc18fc --- /dev/null +++ b/Assets/Scripts/Visual.meta @@ -0,0 +1,3 @@ +fileFormatVersion: 2 +guid: 1f823cbc83e54d88a90cd594398385d1 +timeCreated: 1666894558 \ No newline at end of file diff --git a/Assets/Scripts/Visual/RetroPostProcess.cs b/Assets/Scripts/Visual/RetroPostProcess.cs new file mode 100644 index 0000000..4c6999f --- /dev/null +++ b/Assets/Scripts/Visual/RetroPostProcess.cs @@ -0,0 +1,35 @@ +using UnityEngine; +using UnityEngine.Serialization; + +namespace Visual +{ + /// + /// https://luka712.github.io/2018/07/01/Pixelate-it-Shadertoy-Unity/#:~:text=First%20I%E2%80%99m%20going%20to%20create%20script%20for%20loading%20shader. + /// + [ExecuteInEditMode] + public class RetroPostProcess : MonoBehaviour + { + [FormerlySerializedAs("cellSize")] [SerializeField] + private Vector2 m_CellSize = new Vector2(4, 4); + + private Material _material; + private static readonly int ScreenWidth = Shader.PropertyToID("_ScreenWidth"); + private static readonly int ScreenHeight = Shader.PropertyToID("_ScreenHeight"); + private static readonly int CellSizeX = Shader.PropertyToID("_CellSizeX"); + private static readonly int CellSizeY = Shader.PropertyToID("_CellSizeY"); + + private void Awake() + { + _material = new Material(Shader.Find("Retroed")); + } + + private void OnRenderImage(RenderTexture source, RenderTexture destination) + { + _material.SetFloat(ScreenWidth, Screen.width); + _material.SetFloat(ScreenHeight, Screen.height); + _material.SetFloat(CellSizeX, m_CellSize.x); + _material.SetFloat(CellSizeY, m_CellSize.y); + Graphics.Blit(source, destination, _material); + } + } +} diff --git a/Assets/Scripts/Visual/RetroPostProcess.cs.meta b/Assets/Scripts/Visual/RetroPostProcess.cs.meta new file mode 100644 index 0000000..6a86493 --- /dev/null +++ b/Assets/Scripts/Visual/RetroPostProcess.cs.meta @@ -0,0 +1,11 @@ +fileFormatVersion: 2 +guid: 0a44d4a4a2fcf4a49a34c1fe7813509b +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 90883f9..db0b805 100644 --- a/Assets/Settings/URP-HighFidelity-Renderer.asset +++ b/Assets/Settings/URP-HighFidelity-Renderer.asset @@ -1,5 +1,44 @@ %YAML 1.1 %TAG !u! tag:unity3d.com,2011: +--- !u!114 &-3191591094449869079 +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: 6b3d386ba5cd94485973aee1479b272e, type: 3} + m_Name: Retroed + m_EditorClassIdentifier: + m_Active: 1 + settings: + passTag: Retroed + Event: 300 + filterSettings: + RenderQueueType: 0 + LayerMask: + serializedVersion: 2 + m_Bits: 8192 + PassNames: [] + overrideMaterial: {fileID: 2100000, guid: bc45e5f0151133446b26221ec8ea680c, type: 2} + overrideMaterialPassIndex: 0 + overrideDepthState: 0 + depthCompareFunction: 4 + enableWrite: 1 + stencilSettings: + overrideStencilState: 0 + stencilReference: 0 + stencilCompareFunction: 8 + passOperation: 0 + failOperation: 0 + zFailOperation: 0 + cameraSettings: + overrideCamera: 0 + restoreCamera: 1 + offset: {x: 0, y: 0, z: 0, w: 0} + cameraFieldOfView: 60 --- !u!114 &-1878332245247344467 MonoBehaviour: m_ObjectHideFlags: 0 @@ -40,7 +79,8 @@ MonoBehaviour: type: 3} m_RendererFeatures: - {fileID: -1878332245247344467} - m_RendererFeatureMap: adc0de57c6d2eee5 + - {fileID: -3191591094449869079} + m_RendererFeatureMap: adc0de57c6d2eee5e9ee0333cf30b5d3 m_UseNativeRenderPass: 0 postProcessData: {fileID: 11400000, guid: 41439944d30ece34e96484bdb6645b55, type: 2} xrSystemData: {fileID: 11400000, guid: 60e1133243b97e347b653163a8c01b64, type: 2} diff --git a/Assets/Settings/URP-HighFidelity.asset b/Assets/Settings/URP-HighFidelity.asset index 6248100..40e1106 100644 --- a/Assets/Settings/URP-HighFidelity.asset +++ b/Assets/Settings/URP-HighFidelity.asset @@ -27,6 +27,9 @@ MonoBehaviour: m_SupportsHDR: 1 m_MSAA: 4 m_RenderScale: 1 + m_UpscalingFilter: 0 + m_FsrOverrideSharpness: 0 + m_FsrSharpness: 0.92 m_MainLightRenderingMode: 1 m_MainLightShadowsSupported: 1 m_MainLightShadowmapResolution: 4096 @@ -48,6 +51,8 @@ MonoBehaviour: m_ShadowDepthBias: 1 m_ShadowNormalBias: 1 m_SoftShadowsSupported: 1 + m_ConservativeEnclosingSphere: 0 + m_NumIterationsEnclosingSphere: 64 m_AdditionalLightsCookieResolution: 4096 m_AdditionalLightsCookieFormat: 4 m_UseSRPBatcher: 1 diff --git a/Assets/Shaders.meta b/Assets/Shaders.meta new file mode 100644 index 0000000..4bab949 --- /dev/null +++ b/Assets/Shaders.meta @@ -0,0 +1,8 @@ +fileFormatVersion: 2 +guid: 0af3415c87b444145affb5364f460618 +folderAsset: yes +DefaultImporter: + externalObjects: {} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/Shaders/Retroed.shader b/Assets/Shaders/Retroed.shader new file mode 100644 index 0000000..727ac91 --- /dev/null +++ b/Assets/Shaders/Retroed.shader @@ -0,0 +1,62 @@ +Shader "Retroed" +{ + Properties + { + _MainTex("Texture", 2D) = "white" {} + _ScreenWidth("screen width", float) = 320.0 + _ScreenHeight("screen height", float) = 240.0 + _CellSizeX("size of x cell", float) = 4.0 + _CellSizeY("size of y cell", float) = 4.0 + } + SubShader + { + // No culling or depth + Cull Off ZWrite Off ZTest Always + + Pass + { + CGPROGRAM + #pragma vertex vert + #pragma fragment frag + + #include "UnityCG.cginc" + + struct appdata + { + float4 vertex : POSITION; + float2 uv : TEXCOORD0; + }; + + struct v2f + { + float2 uv : TEXCOORD0; + float4 vertex : SV_POSITION; + }; + + v2f vert(appdata v) + { + v2f o; + o.vertex = UnityObjectToClipPos(v.vertex); + o.uv = v.uv; + return o; + } + + sampler2D _MainTex; + float _ScreenWidth; + float _ScreenHeight; + float _CellSizeX; + float _CellSizeY; + + fixed4 frag(v2f i) : SV_Target + { + float2 uv = i.uv; + + float pixelX = _ScreenWidth / _CellSizeX; + float pixelY = _ScreenHeight / _CellSizeY; + + return tex2D(_MainTex, float2(floor(pixelX * uv.x) / pixelX, floor(pixelY * uv.y) / pixelY)); + } + ENDCG + } + } +} \ No newline at end of file diff --git a/Assets/Shaders/Retroed.shader.meta b/Assets/Shaders/Retroed.shader.meta new file mode 100644 index 0000000..16c238b --- /dev/null +++ b/Assets/Shaders/Retroed.shader.meta @@ -0,0 +1,10 @@ +fileFormatVersion: 2 +guid: c4d7011496fb8f34ead8b47276ae3f0a +ShaderImporter: + externalObjects: {} + defaultTextures: [] + nonModifiableTextures: [] + preprocessorOverride: 0 + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/Sprites/transparence.png b/Assets/Sprites/transparence.png new file mode 100644 index 0000000000000000000000000000000000000000..20938b8e74b8cbde021daf758f8ffb5ebf331984 GIT binary patch literal 4390 zcmeAS@N?(olHy`uVBq!ia0y~yV0s6_9Be?5kFt|b0V&4fAa^H*b?0PW0y!+{j=qiz z3>*8o|0J>k`J4qFk;M!Qe1}1p@p%4<6b1%?-JULvAr*0N@7~V49VXxqxcvWr#lJhh zOuKh!OQB^er-<8xBZ9s~-Pw%nlj6SYv6PVATUk@{=N}^jgT>bO^Wqp88ia*`&Ja+z z!^oiEu!EVwp`n1Cp@HEcAJ8?2WPuKBu?9MYqnv?(Lts?lXz+|CiqWhvT2hRbkE6B1 zXr(#YR2Xd_jW!EMTg{_=h0z`o!470Y-~Q>JUl-Z^`_9?mE%=V%`S%@j?oa=Gxu`Ds zT>NRq2T3i~2X>yF^7r`DJ<;ddpPt$B_x$p320fP@%yX{GpZ=L>X`J}Ke#QRyb3P9l zcL+S>E3o^olYT9!uCnUC%_a3mYfm%8^c1jLOrN>z{FJ}muMLcQ%}d$A3i*UzZa!`| z`P>Yv($=lxUmrA_}^{H%TTwNwT@ryb01vYl$1YX5n>3^qTu=ZMSi8g>S8 zU>JNe{QW}s&HY_spEWHW3;{+8_JOj~_p-uqjRfc}-_c<%5IiKC5WQJx zbGpa-uMG?b4g#H4rncZa-}jvh-GHirwegK}F2C27Z{B~!MkQh@;|`z|8|Hr9b=>x> zbCYd(12?b(e>>uON?%0uMm^>NU{5YV`t__cf|K9xy^trXZa-<0{)(^QIneI6eRH<0@B5Xg!(a`J&h0Zjze^sv zdqfr-xVQJjpIdWMCiiZ!_