-
-
Save unitycoder/cc16a45b59285fc205ca6c032bff9cd7 to your computer and use it in GitHub Desktop.
Revisions
-
slipster216 revised this gist
Jun 25, 2016 . 1 changed file with 26 additions and 27 deletions.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -2,10 +2,10 @@ hader "Unlit/GridOverlay" { Properties { _GridSize("Grid Size", Float) = 10 _Grid2Size("Grid 2 Size", Float) = 160 _Grid3Size("Grid 3 Size", Float) = 320 _Alpha ("Alpha", Range(0,1)) = 1 } SubShader { @@ -15,8 +15,8 @@ hader "Unlit/GridOverlay" Pass { Blend SrcAlpha OneMinusSrcAlpha Offset -20, -20 CGPROGRAM #pragma vertex vert #pragma fragment frag @@ -25,30 +25,29 @@ hader "Unlit/GridOverlay" float _GridSize; float _Grid2Size; float _Grid3Size; float _Alpha; struct appdata { float4 vertex : POSITION; }; struct v2f { float2 uv : TEXCOORD0; float4 vertex : SV_POSITION; }; v2f vert (appdata v) { v2f o; o.vertex = mul(UNITY_MATRIX_MVP, v.vertex); o.uv = mul(_Object2World, v.vertex).xz; return o; } float DrawGrid(float2 uv, float sz, float aa) -
slipster216 created this gist
Jun 25, 2016 .There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,81 @@ hader "Unlit/GridOverlay" { Properties { _GridSize("Grid Size", Float) = 10 _Grid2Size("Grid 2 Size", Float) = 160 _Grid3Size("Grid 3 Size", Float) = 320 _Alpha ("Alpha", Range(0,1)) = 1 } SubShader { Tags { "RenderType"="Overlay" } LOD 100 ZTest Always Pass { Blend SrcAlpha OneMinusSrcAlpha Offset -20, -20 CGPROGRAM #pragma vertex vert #pragma fragment frag #include "UnityCG.cginc" float _GridSize; float _Grid2Size; float _Grid3Size; float _Alpha; sampler2D _Font; struct appdata { float4 vertex : POSITION; }; struct v2f { float2 uv : TEXCOORD0; float4 vertex : SV_POSITION; }; v2f vert (appdata v) { v2f o; o.vertex = mul(UNITY_MATRIX_MVP, v.vertex); o.uv = mul(_Object2World, v.vertex).xz; return o; } float DrawGrid(float2 uv, float sz, float aa) { float aaThresh = aa; float aaMin = aa*0.1; float2 gUV = uv / sz + aaThresh; float2 fl = floor(gUV); gUV = frac(gUV); gUV -= aaThresh; gUV = smoothstep(aaThresh, aaMin, abs(gUV)); float d = max(gUV.x, gUV.y); return d; } fixed4 frag (v2f i) : SV_Target { fixed r = DrawGrid(i.uv, _GridSize, 0.03); fixed b = DrawGrid(i.uv, _Grid2Size, 0.005); fixed g = DrawGrid(i.uv, _Grid3Size, 0.002); return float4(0.8*r*_Alpha,0.8*g*_Alpha,0.8*b*_Alpha,(r+b+g)*_Alpha); } ENDCG } } }