From 3e9752dcada96108c192d6a5cb644450ef3554ce Mon Sep 17 00:00:00 2001 From: klemek Date: Fri, 11 Dec 2020 00:06:31 +0100 Subject: [PATCH] dat shader --- Assets/Materials/Background Material.mat | 87 +++++++++++++++++ Assets/Materials/Background Material.mat.meta | 8 ++ Assets/Shaders.meta | 8 ++ Assets/Shaders/Gridshader.shader | 93 +++++++++++++++++++ Assets/Shaders/Gridshader.shader.meta | 9 ++ 5 files changed, 205 insertions(+) create mode 100755 Assets/Materials/Background Material.mat create mode 100755 Assets/Materials/Background Material.mat.meta create mode 100755 Assets/Shaders.meta create mode 100755 Assets/Shaders/Gridshader.shader create mode 100755 Assets/Shaders/Gridshader.shader.meta diff --git a/Assets/Materials/Background Material.mat b/Assets/Materials/Background Material.mat new file mode 100755 index 0000000..9e55168 --- /dev/null +++ b/Assets/Materials/Background Material.mat @@ -0,0 +1,87 @@ +%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: Background Material + m_Shader: {fileID: 4800000, guid: e56d41d82638fac4db3047c82137e7eb, type: 3} + m_ShaderKeywords: ETC1_EXTERNAL_ALPHA + 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: + - _Background: 0.2 + - _BumpScale: 1 + - _Cutoff: 0.5 + - _DetailNormalMapScale: 1 + - _DstBlend: 0 + - _Foreground: 0.553 + - _GlossMapScale: 1 + - _Glossiness: 0.5 + - _GlossyReflections: 1 + - _Metallic: 0 + - _MiddlePoint: 0.3 + - _Mode: 0 + - _OcclusionStrength: 1 + - _Parallax: 0.02 + - _Size: 100 + - _SmoothnessTextureChannel: 0 + - _SpecularHighlights: 1 + - _SrcBlend: 1 + - _Step: 5 + - _UVSec: 0 + - _WaveScale: 100 + - _Width: 0.001 + - _ZWrite: 1 + m_Colors: + - _Background: {r: 0.3, g: 0.3, b: 0.3, a: 1} + - _Color: {r: 1, g: 1, b: 1, a: 1} + - _EmissionColor: {r: 0, g: 0, b: 0, a: 1} + - _Foreground: {r: 0.5, g: 0.5, b: 0.5, a: 1} + m_BuildTextureStacks: [] diff --git a/Assets/Materials/Background Material.mat.meta b/Assets/Materials/Background Material.mat.meta new file mode 100755 index 0000000..6428229 --- /dev/null +++ b/Assets/Materials/Background Material.mat.meta @@ -0,0 +1,8 @@ +fileFormatVersion: 2 +guid: 7f247c265d325694a96c63ce0be3b314 +NativeFormatImporter: + externalObjects: {} + mainObjectFileID: 0 + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/Shaders.meta b/Assets/Shaders.meta new file mode 100755 index 0000000..5735335 --- /dev/null +++ b/Assets/Shaders.meta @@ -0,0 +1,8 @@ +fileFormatVersion: 2 +guid: bd01bee9f19c27b489ede65e7df4d9bd +folderAsset: yes +DefaultImporter: + externalObjects: {} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/Shaders/Gridshader.shader b/Assets/Shaders/Gridshader.shader new file mode 100755 index 0000000..6a7aa71 --- /dev/null +++ b/Assets/Shaders/Gridshader.shader @@ -0,0 +1,93 @@ +Shader "Shaders101/Colored UV" +{ + Properties + { + _Width("Width", Range(0.0001,0.05)) = 0.001 + _Size("Object Size", Range(0.01,1000)) = 100 + _MiddlePoint("Middle Point", Range(0, 1)) = 0.6 + _Background("Background Color", Color) = (.2, .2, .2, 1) + _Foreground("Foreground Color", Color) = (.5, .5, .5, 1) + _Step("Step", Int) = 5 + _MainTex("Texture", 2D) = "white" {} + } + SubShader + { + Tags + { + "PreviewType" = "Plane" + } + Pass + { + CGPROGRAM + + #pragma vertex vert + #pragma fragment frag + + #include "UnityCG.cginc" + + struct appdata + { + float4 vertex : POSITION; + float2 uv : TEXCOORD0; + }; + + struct v2f + { + float4 vertex : SV_POSITION; + float2 uv : TEXCOORD0; + float4 scrPos : TEXCOORD1; + }; + + sampler2D _MainTex; + + v2f vert(appdata v) + { + v2f o; + o.vertex = UnityObjectToClipPos(v.vertex); + o.scrPos = ComputeScreenPos(v.vertex); + o.uv = v.uv; + return o; + } + + float _Width; + float _Size; + float4 _Background; + float _MiddlePoint; + float4 _Foreground; + int _Step; + + float4 frag(v2f i) : SV_Target + { + float d = length(ObjSpaceViewDir(i.scrPos)); + float w = d * _Width; + i.uv *= _Size; + + float k = log(d) / log(_Step); + float k0 = floor(k); + + float x = d / pow(_Step, k0); + + float s1 = pow(_Step, k0) * .1 / _Step; + float c1 = clamp(_MiddlePoint * (_Step - x) / (_Step - 1), 0, 1); + + float s2 = s1 * _Step; + float c2 = clamp((1 - _MiddlePoint) * (_Step - x) / (_Step - 1) + _MiddlePoint, 0, 1); + + float s3 = s2 * _Step; + + float2 uv = i.uv; + + float grid1 = clamp(1 - step(w, fmod(uv.x + w * .5, s1)) + 1 - step(w, fmod(uv.y + w * .5, s1)), 0, 1); + float grid2 = clamp(1 - step(w, fmod(uv.x + w * .5, s2)) + 1 - step(w, fmod(uv.y + w * .5, s2)), 0, 1); + float grid3 = clamp(1 - step(w, fmod(uv.x + w * .5, s3)) + 1 - step(w, fmod(uv.y + w * .5, s3)), 0, 1); + grid2 = clamp(grid2 - grid3, 0, 1); + grid1 = clamp(grid1 - grid2, 0, 1); + + float a = (grid1 * c1 + grid2 * c2 + grid3); + + return (1 - a) * _Background + a * _Foreground; + } + ENDCG + } + } +} \ No newline at end of file diff --git a/Assets/Shaders/Gridshader.shader.meta b/Assets/Shaders/Gridshader.shader.meta new file mode 100755 index 0000000..cbfd315 --- /dev/null +++ b/Assets/Shaders/Gridshader.shader.meta @@ -0,0 +1,9 @@ +fileFormatVersion: 2 +guid: e56d41d82638fac4db3047c82137e7eb +ShaderImporter: + externalObjects: {} + defaultTextures: [] + nonModifiableTextures: [] + userData: + assetBundleName: + assetBundleVariant: