├── BRDFTranslucentSSS.shader ├── BurningEffect.shader ├── BurningOutlineShader.shader ├── FakedAudioVisualizer.shader ├── FireShader.shader ├── HologramIllumination.shader ├── IceShader.shader ├── LCDShader.shader ├── OutlineShader.shader ├── PlasticShader.shader ├── PolyFlash.shader ├── README.md ├── RimLighting.shader ├── RotateMesh.shader ├── RotateWireVoxel.shader ├── ToonShading.shader ├── UVScrollShader.shader ├── UnlitWater.shader ├── UnlitWaterFallShader.Shader ├── images ├── ApplicationFrameHost_2018-09-04_18-05-22.jpg ├── ApplicationFrameHost_2018-09-04_18-06-24.jpg ├── ApplicationFrameHost_2018-09-04_18-07-26.png ├── ApplicationFrameHost_2018-09-04_18-31-54.jpg ├── ApplicationFrameHost_2018-09-04_19-19-38.jpg ├── ApplicationFrameHost_2018-09-04_19-21-57.png ├── ApplicationFrameHost_2018-09-04_20-06-33.jpg ├── ApplicationFrameHost_2018-09-07_13-21-09.jpg ├── BRDFTranslucentSSS.gif ├── BRDFTranslucentSSS_2.gif ├── PlasticShader.gif ├── UnlitWaterFall.gif ├── bandicam_2018-08-23_19-07-47-604.gif ├── bandicam_2018-09-01_08-50-44-304.gif ├── bandicam_2018-09-01_08-56-24-256.gif ├── bandicam_2018-09-01_09-03-54-539.gif ├── bandicam_2018-09-03_22-59-01-611.gif ├── bandicam_2018-09-06_23-28-09-416.gif ├── bandicam_2018-09-07_13-06-44-810.gif ├── bandicam_2018-09-07_13-19-37-498.gif ├── bandicam_2018-09-10_07-27-13-144.gif ├── bandicam_2018-09-10_12-56-15-356.gif ├── bandicam_2018-09-12_01-08-48-646.gif ├── bandicam_2018-09-12_03-46-10-580.gif └── bandicam_2018-09-15_17-39-52-972.gif └── marimo.shader /BRDFTranslucentSSS.shader: -------------------------------------------------------------------------------- 1 | Shader "Custom/BRDFTranslucentSSS" 2 | { 3 | Properties 4 | { 5 | _MainTex ("Main Texture", 2D) = "black" { } 6 | [Normal] _NormalTex ("Normal Texture", 2D) = "bump" { } 7 | _BrdfTex ("BRDF Texture", 2D) = "white" { } 8 | _ThicknessTex ("Thickness Map", 2D) = "white" { } 9 | _MainCol ("Main Color", Color) = (1, 1, 1, 1) 10 | _Ambient ("Ambient", Color) = (1, 1, 1, 1) 11 | _TranslucentColor ("Translucent Color", Color) = (1, 1, 1, 1) 12 | _Thickness ("Object Thickness", Float) = 1.0 13 | _Distortion ("Light Distortion", Float) = 1.0 14 | _BrdfShininess ("BRDF Shininess", Float) = 1.0 15 | _Power ("Light Power", Float) = 1.0 16 | _Scale ("Total Light Strength", Float) = 1.0 17 | _LightShininess ("Light Shininess", Float) = 1.0 18 | _SpecCol ("Specular Color", Color) = (1, 1, 1, 1) 19 | _SpecShininess ("Specular Shininess", Float) = 1.0 20 | _SpecShininessScale ("Total Specular Shininess Strength", Float) = 1.0 21 | _BackLightSpecShininess ("Back Light Specular Shininess", Float) = 1.0 22 | [Enum(OFF, 0, FRONT, 1, BACK, 2)] _CullMode ("Cull Mode", int) = 0 23 | } 24 | SubShader 25 | { 26 | Tags { "Queue" = "Transparent" } 27 | LOD 100 28 | Cull[_CullMode] 29 | 30 | Pass 31 | { 32 | Tags { "LightMode" = "ForwardBase" } 33 | CGPROGRAM 34 | 35 | #pragma target 3.0 36 | #pragma vertex vert 37 | #pragma fragment frag 38 | #pragma multi_compile_fog 39 | #pragma multi_compile_fwdbase 40 | #pragma multi_compile _ VERTEXLIGHT_ON 41 | 42 | #include "UnityCG.cginc" 43 | #include "AutoLight.cginc" 44 | #include "UnityPBSLighting.cginc" 45 | 46 | struct appdata 47 | { 48 | float4 vertex: POSITION; 49 | float2 uv: TEXCOORD0; 50 | float3 normal: NORMAL; 51 | float3 tangent: TANGENT; 52 | }; 53 | 54 | struct v2f 55 | { 56 | float2 uv: TEXCOORD0; 57 | UNITY_FOG_COORDS(1) 58 | float4 vertex: SV_POSITION; 59 | float3 normal: TEXCOORD2; 60 | float4 wpos: TEXCOORD3; 61 | LIGHTING_COORDS(4, 5) 62 | #if defined(VERTEXLIGHT_ON) 63 | fixed3 vertexLightColor: TEXCOORD6; 64 | #endif 65 | float3 tangent: TEXCOORD7; 66 | float3 binormal: TEXCOORD8; 67 | }; 68 | 69 | uniform sampler2D _MainTex; uniform float4 _MainTex_ST; 70 | uniform sampler2D _NormalTex; uniform float4 _NormalTex_ST; 71 | uniform sampler2D _BrdfTex; uniform float4 _BrdfTex_ST; 72 | uniform sampler2D _ThicknessTex; uniform float4 _ThicknessTex_ST; 73 | uniform fixed4 _MainCol; 74 | uniform fixed4 _Ambient; 75 | uniform fixed4 _TranslucentColor; 76 | uniform float _Thickness; 77 | uniform float _Distortion; 78 | uniform float _BrdfShininess; 79 | uniform float _Power; 80 | uniform float _Scale; 81 | uniform float _LightShininess; 82 | uniform fixed4 _SpecCol; 83 | uniform float _SpecShininess; 84 | uniform float _SpecShininessScale; 85 | uniform float _BackLightSpecShininess; 86 | 87 | void ComputeVertexLightColor(inout v2f i) 88 | { 89 | #if defined(VERTEXLIGHT_ON) 90 | i.vertexLightColor = Shade4PointLights( 91 | unity_4LightPosX0, unity_4LightPosY0, unity_4LightPosZ0, 92 | unity_LightColor[0].rgb, unity_LightColor[1].rgb, 93 | unity_LightColor[2].rgb, unity_LightColor[3].rgb, 94 | unity_4LightAtten0, i.wpos, i.normal 95 | ); 96 | #endif 97 | } 98 | 99 | v2f vert(appdata v) 100 | { 101 | v2f o = (v2f)0; 102 | o.vertex = UnityObjectToClipPos(v.vertex); 103 | o.uv = TRANSFORM_TEX(v.uv, _MainTex); 104 | o.normal = UnityObjectToWorldNormal(v.normal); 105 | o.wpos = mul(unity_ObjectToWorld, v.vertex); 106 | o.tangent = UnityObjectToWorldNormal(v.tangent); 107 | o.binormal = normalize(cross(o.tangent, o.normal)); 108 | ComputeVertexLightColor(o); 109 | UNITY_TRANSFER_FOG(o, o.vertex); 110 | return o; 111 | } 112 | 113 | fixed4 frag(v2f i): SV_Target 114 | { 115 | float3 tangentNormal = float4(UnpackNormal(tex2D(_NormalTex, i.uv)), 1); 116 | float3x3 TBN = float3x3(i.tangent, i.binormal, i.normal); 117 | TBN = transpose(TBN); 118 | float3 worldNormal = mul(TBN, tangentNormal); 119 | float3 normal = lerp(i.normal, worldNormal, saturate(length(tangentNormal) * 100)); 120 | 121 | fixed4 mainTex = tex2D(_MainTex, i.uv); 122 | 123 | float3 lightDir; 124 | #if defined(POINT) || defined(POINT_COOKIE) || defined(SPOT) 125 | lightDir = normalize(_WorldSpaceLightPos0.xyz - i.wpos.xyz); 126 | #else 127 | lightDir = _WorldSpaceLightPos0.xyz; 128 | #endif 129 | 130 | fixed4 lightCol; 131 | #if defined(VERTEXLIGHT_ON) 132 | lightCol = fixed4(i.vertexLightColor, 1); 133 | #else 134 | lightCol = _LightColor0; 135 | #endif 136 | 137 | lightCol.rgb += max(0, ShadeSH9(float4(normal, 1))); 138 | 139 | float3 viewDir = normalize(_WorldSpaceCameraPos - i.wpos).xyz; 140 | float VdotL = saturate(dot(viewDir, lightDir)); 141 | 142 | float3 a = lightDir + normal * max(0, _Distortion); 143 | float b = pow(saturate(dot(viewDir, -a)), max(0, _Power)) * max(0, _Scale); 144 | UNITY_LIGHT_ATTENUATION(atten, i, i.wpos.xyz); 145 | float thickness = pow(tex2D(_ThicknessTex, i.uv).r, max(0, _Thickness)); 146 | float3 c = atten * (b + _Ambient.rgb) * thickness; 147 | 148 | float NdotL = saturate(dot(normal, lightDir)); 149 | //NdotL = length(lightDir) != 0 ? (NdotL * 0.5) + 0.5 : 0; 150 | NdotL = (NdotL * 0.5) + 0.5; 151 | fixed4 col = lerp(_MainCol, mainTex, saturate(length(mainTex) * 100)); 152 | col.rgb *= NdotL; 153 | 154 | float NdotV = saturate(dot(normal, viewDir)); 155 | float2 brdfUV = float2(NdotV, NdotL); 156 | float3 brdf = tex2D(_BrdfTex, brdfUV.xy).rgb; 157 | 158 | float3 specRef = atten * _LightColor0.rgb * _SpecCol.rgb * pow(max(0, dot(reflect(-lightDir, normal), viewDir)), 10 * max(0, _SpecShininess)) * 10 * max(0, _SpecShininessScale) * VdotL; 159 | specRef += atten * _LightColor0.rgb * _SpecCol.rgb * pow(max(0, dot(reflect(-lightDir, normal), viewDir)), max(0, _SpecShininess)) * max(0, _SpecShininessScale) * b * 0.1 * max(0, _BackLightSpecShininess); 160 | 161 | col.rgb += lerp(fixed3(0, 0, 0), lightCol.rgb * max(0, _LightShininess) * _TranslucentColor, smoothstep(0, 1, thickness)) * lerp(NdotL, c, smoothstep(0, 1, 1 - dot(normal, lightDir))) * brdf * max(0, _BrdfShininess) + specRef; 162 | 163 | UNITY_APPLY_FOG(i.fogCoord, col); 164 | return col; 165 | } 166 | ENDCG 167 | 168 | } 169 | Pass 170 | { 171 | Tags { "LightMode" = "ForwardAdd" } 172 | Blend One One 173 | ZWrite Off 174 | CGPROGRAM 175 | 176 | #pragma target 3.0 177 | #pragma vertex vert 178 | #pragma fragment frag 179 | #pragma multi_compile_fog 180 | #pragma multi_compile_fwdadd 181 | 182 | #include "UnityCG.cginc" 183 | #include "AutoLight.cginc" 184 | #include "UnityPBSLighting.cginc" 185 | 186 | struct appdata 187 | { 188 | float4 vertex: POSITION; 189 | float2 uv: TEXCOORD0; 190 | float3 normal: NORMAL; 191 | float3 tangent: TANGENT; 192 | }; 193 | 194 | struct v2f 195 | { 196 | float2 uv: TEXCOORD0; 197 | UNITY_FOG_COORDS(1) 198 | float4 vertex: SV_POSITION; 199 | float3 normal: TEXCOORD2; 200 | float4 wpos: TEXCOORD3; 201 | LIGHTING_COORDS(4, 5) 202 | float3 tangent: TEXCOORD6; 203 | float3 binormal: TEXCOORD7; 204 | }; 205 | 206 | uniform sampler2D _MainTex; uniform float4 _MainTex_ST; 207 | uniform sampler2D _NormalTex; uniform float4 _NormalTex_ST; 208 | uniform sampler2D _BrdfTex; uniform float4 _BrdfTex_ST; 209 | uniform sampler2D _ThicknessTex; uniform float4 _ThicknessTex_ST; 210 | uniform fixed4 _MainCol; 211 | uniform fixed4 _Ambient; 212 | uniform fixed4 _TranslucentColor; 213 | uniform float _Thickness; 214 | uniform float _Distortion; 215 | uniform float _BrdfShininess; 216 | uniform float _Power; 217 | uniform float _Scale; 218 | uniform float _LightShininess; 219 | uniform fixed4 _SpecCol; 220 | uniform float _SpecShininess; 221 | uniform float _SpecShininessScale; 222 | uniform float _BackLightSpecShininess; 223 | 224 | v2f vert(appdata v) 225 | { 226 | v2f o = (v2f)0; 227 | o.vertex = UnityObjectToClipPos(v.vertex); 228 | o.uv = TRANSFORM_TEX(v.uv, _MainTex); 229 | o.normal = UnityObjectToWorldNormal(v.normal); 230 | o.wpos = mul(unity_ObjectToWorld, v.vertex); 231 | o.tangent = UnityObjectToWorldNormal(v.tangent); 232 | o.binormal = normalize(cross(o.tangent, o.normal)); 233 | UNITY_TRANSFER_FOG(o, o.vertex); 234 | return o; 235 | } 236 | 237 | fixed4 frag(v2f i): SV_Target 238 | { 239 | float3 tangentNormal = float4(UnpackNormal(tex2D(_NormalTex, i.uv)), 1); 240 | float3x3 TBN = float3x3(i.tangent, i.binormal, i.normal); 241 | TBN = transpose(TBN); 242 | float3 worldNormal = mul(TBN, tangentNormal); 243 | float3 normal = lerp(i.normal, worldNormal, saturate(length(tangentNormal) * 100)); 244 | 245 | fixed4 mainTex = tex2D(_MainTex, i.uv); 246 | 247 | float3 lightDir; 248 | #if defined(POINT) || defined(POINT_COOKIE) || defined(SPOT) 249 | lightDir = normalize(_WorldSpaceLightPos0.xyz - i.wpos.xyz); 250 | #else 251 | lightDir = _WorldSpaceLightPos0.xyz; 252 | #endif 253 | 254 | fixed4 lightCol = _LightColor0; 255 | lightCol.rgb += max(0, ShadeSH9(float4(normal, 1))); 256 | 257 | float3 viewDir = normalize(_WorldSpaceCameraPos - i.wpos).xyz; 258 | float VdotL = saturate(dot(viewDir, lightDir)); 259 | 260 | float3 a = lightDir + normal * max(0, _Distortion); 261 | float b = pow(saturate(dot(viewDir, -a)), max(0, _Power)) * max(0, _Scale); 262 | UNITY_LIGHT_ATTENUATION(atten, i, i.wpos.xyz); 263 | float thickness = pow(tex2D(_ThicknessTex, i.uv).r, max(0, _Thickness)); 264 | float3 c = atten * (b + _Ambient.rgb) * thickness; 265 | 266 | float NdotL = saturate(dot(normal, lightDir)); 267 | //NdotL = length(lightDir) != 0 ? (NdotL * 0.5) + 0.5 : 0; 268 | NdotL = (NdotL * 0.5) + 0.5; 269 | fixed4 col = lerp(_MainCol, mainTex, saturate(length(mainTex) * 100)); 270 | col.rgb *= NdotL; 271 | 272 | float NdotV = saturate(dot(normal, viewDir)); 273 | float2 brdfUV = float2(NdotV, NdotL); 274 | float3 brdf = tex2D(_BrdfTex, brdfUV.xy).rgb; 275 | 276 | float3 specRef = atten * _LightColor0.rgb * _SpecCol.rgb * pow(max(0, dot(reflect(-lightDir, normal), viewDir)), 10 * max(0, _SpecShininess)) * 10 * max(0, _SpecShininessScale) * VdotL; 277 | specRef += atten * _LightColor0.rgb * _SpecCol.rgb * pow(max(0, dot(reflect(-lightDir, normal), viewDir)), max(0, _SpecShininess)) * max(0, _SpecShininessScale) * b * 0.1 * max(0, _BackLightSpecShininess); 278 | 279 | col.rgb += lerp(fixed3(0, 0, 0), lightCol.rgb * max(0, _LightShininess) * _TranslucentColor, smoothstep(0, 1, thickness)) * lerp(NdotL, c, smoothstep(0, 1, 1 - dot(normal, lightDir))) * brdf * max(0, _BrdfShininess) + specRef; 280 | 281 | UNITY_APPLY_FOG(i.fogCoord, col); 282 | return col; 283 | } 284 | ENDCG 285 | 286 | } 287 | } 288 | Fallback "Diffuse" 289 | } 290 | -------------------------------------------------------------------------------- /BurningEffect.shader: -------------------------------------------------------------------------------- 1 | Shader "Custom/BurningEffect" 2 | { 3 | Properties 4 | { 5 | _MainTex ("Main Texture", 2D) = "white" { } 6 | _NoiseTex ("Noise Texture", 2D) = "white" { } 7 | _FireTex ("Fire Texture", 2D) = "black" { } 8 | _Color ("Dissolve Color(only available when no Fire Texture)", Color) = (1, 1, 1, 1) 9 | _DissolveSpeed ("Dissolve Speed", Float) = 1.0 10 | [MaterialToggle] _Hoge ("Toggle Automatic Dissolve", int) = 0 11 | _BurnThreshold ("Dissolve Threshold", Range(0.0, 1.0)) = 0.0 12 | _Shininess ("Shininess", Float) = 10 13 | [Enum(OFF, 0, FRONT, 1, BACK, 2)] _CullMode ("Cull Mode", int) = 0 14 | } 15 | SubShader 16 | { 17 | Tags { "Queue" = "Transparent" } 18 | LOD 100 19 | Cull[_CullMode] 20 | 21 | Pass 22 | { 23 | CGPROGRAM 24 | 25 | #pragma vertex vert 26 | #pragma fragment frag 27 | #pragma multi_compile_fog 28 | 29 | #include "UnityCG.cginc" 30 | 31 | struct appdata 32 | { 33 | float4 vertex: POSITION; 34 | float2 uv: TEXCOORD0; 35 | }; 36 | 37 | struct v2f 38 | { 39 | float2 uv: TEXCOORD0; 40 | UNITY_FOG_COORDS(1) 41 | float4 vertex: SV_POSITION; 42 | }; 43 | 44 | uniform sampler2D _MainTex; uniform float4 _MainTex_ST; 45 | uniform sampler2D _NoiseTex; uniform float4 _NoiseTex_ST; 46 | uniform sampler2D _FireTex; uniform float4 _FireTex_ST; 47 | uniform fixed4 _Color; 48 | uniform int _Hoge; 49 | uniform float _DissolveSpeed; 50 | uniform float _ColorThreshold1; 51 | uniform float _ColorThreshold2; 52 | uniform float _BurnThreshold; 53 | uniform float _Shininess; 54 | 55 | v2f vert(appdata v) 56 | { 57 | v2f o; 58 | o.vertex = UnityObjectToClipPos(v.vertex); 59 | o.uv = TRANSFORM_TEX(v.uv, _MainTex); 60 | UNITY_TRANSFER_FOG(o, o.vertex); 61 | return o; 62 | } 63 | 64 | fixed4 frag(v2f i): SV_Target 65 | { 66 | fixed4 mainTex = tex2D(_MainTex, i.uv); 67 | float4 noiseTex = tex2D(_NoiseTex, i.uv); 68 | fixed4 fireTex = tex2D(_FireTex, i.uv); 69 | fireTex = lerp(_Color, fireTex, saturate(length(fireTex) * 100)); 70 | 71 | float t = lerp(_BurnThreshold, _Time.x, _Hoge); 72 | 73 | float a = t * (_DissolveSpeed + 0.9); 74 | float dissolve1 = noiseTex.r - a > 0; 75 | fixed4 col = (1 - dissolve1) * fixed4(0, 0, 0, 1) + dissolve1 * fireTex * _Shininess; 76 | 77 | float b = t * (_DissolveSpeed + 1.3); 78 | float dissolve2 = noiseTex.r - b > 0; 79 | col = (1 - dissolve2) * col + dissolve2 * mainTex; 80 | 81 | float c = t * _DissolveSpeed; 82 | if(noiseTex.r - c < 0) discard; 83 | 84 | UNITY_APPLY_FOG(i.fogCoord, col); 85 | return col; 86 | } 87 | ENDCG 88 | 89 | } 90 | } 91 | Fallback "Diffuse" 92 | } 93 | -------------------------------------------------------------------------------- /BurningOutlineShader.shader: -------------------------------------------------------------------------------- 1 | Shader "Custom/BurningOutlineShader" 2 | { 3 | Properties 4 | { 5 | _MainTex ("Main Texture", 2D) = "white" 6 | _NoiseTex ("Noise Texture", 2D) = "white" { } 7 | _DistortTex ("Distortion Texture", 2D) = "white" { } 8 | _Color ("Main Flame Color", Color) = (0, 0, 0, 1) 9 | _Color2 ("Flame Rim Color", Color) = (1, 1, 1, 1) 10 | _OutlineWidth ("Outline Width",Float) = 0.0 11 | _Strength ("Strength", Float) = 0.0 12 | _GradientPow ("Gradient Power", Float) = 0.0 13 | _GradientThickness ("Gradient Thickness", Float) = 0.0 14 | _EdgePow ("Edge Power", Float) = 0.0 15 | _Hight ("Flame Hight", Float) = 0.0 16 | _Edge ("Rim Strength", Float) = 0.0 17 | _Shininess ("Rim Shininess", Float) = 0.0 18 | _Distort ("Distortion", Float) = 0.0 19 | _SpeedX ("Speed X", Float) = 0.0 20 | _SpeedY ("Speed Y", Float) = 0.0 21 | _PushX ("Push X", Float) = 0.0 22 | _PushY ("Push Y", Float) = 0.0 23 | _PushZ ("Push Z", Float) = 0.0 24 | [Enum(OFF, 0, FRONT, 1, BACK, 2)] _CullMode ("Cull Mode", int) = 0 25 | } 26 | SubShader 27 | { 28 | Tags { "Queue" = "Transparent" } 29 | LOD 100 30 | 31 | Pass 32 | { 33 | Blend SrcAlpha OneMinusSrcAlpha 34 | ZWrite Off 35 | Cull Off 36 | CGPROGRAM 37 | 38 | #pragma vertex vert 39 | #pragma fragment frag 40 | #pragma multi_compile_fog 41 | 42 | #include "UnityCG.cginc" 43 | 44 | struct appdata 45 | { 46 | float4 vertex: POSITION; 47 | float2 uv: TEXCOORD0; 48 | float3 normal: NORMAL; 49 | }; 50 | 51 | struct v2f 52 | { 53 | float2 uv: TEXCOORD0; 54 | UNITY_FOG_COORDS(1) 55 | float4 vertex: SV_POSITION; 56 | float3 viewDir: TEXCOORD2; 57 | float3 normal: TEXCOORD3; 58 | }; 59 | 60 | uniform sampler2D _MainTex; uniform float4 _MainTex_ST; 61 | uniform sampler2D _NoiseTex; uniform float4 _NoiseTex_ST; 62 | uniform sampler2D _DistortTex; uniform float4 _DistortTex_ST; 63 | uniform float _OutlineWidth; 64 | uniform float _GradientPow; 65 | uniform float _GradientThickness; 66 | uniform float _EdgePow; 67 | uniform fixed4 _Color; 68 | uniform float _Hight; 69 | uniform fixed4 _Color2; 70 | uniform float _Edge; 71 | uniform float _Shininess; 72 | uniform float _Distort; 73 | uniform float _SpeedX; 74 | uniform float _SpeedY; 75 | uniform float _Strength; 76 | uniform float _PushX; 77 | uniform float _PushY; 78 | uniform float _PushZ; 79 | 80 | v2f vert(appdata v) 81 | { 82 | v2f o; 83 | //v.vertex.xyz += v.normal * _OutlineWidth; 84 | o.vertex = mul(UNITY_MATRIX_MVP, v.vertex); 85 | o.normal = UnityObjectToWorldNormal(v.normal); 86 | o.viewDir = normalize(_WorldSpaceCameraPos - mul(unity_ObjectToWorld, v.vertex)).xyz; 87 | float4 normalP = mul(UNITY_MATRIX_MVP, float4(v.normal, 0)); 88 | normalP = normalize(normalP); 89 | o.vertex.xy += normalP.xy * _OutlineWidth; 90 | o.vertex.x += 0.01 * _PushX; 91 | o.vertex.y += 0.1 * _PushY; 92 | o.vertex.z += 0.01 * normalP.z * _PushZ; 93 | UNITY_TRANSFER_FOG(o, o.vertex); 94 | return o; 95 | } 96 | 97 | fixed4 frag(v2f i): SV_Target 98 | { 99 | float2 uv = i.vertex.xy / _ScreenParams.xy; 100 | 101 | float NdotV = 1 - max(0, dot(i.normal, i.viewDir)); 102 | 103 | NdotV = pow(NdotV, max(0, _Strength)); 104 | 105 | float4 gradient = lerp(fixed4(1, 1, 1, 1), fixed4(0, 0, 0, 0), NdotV); 106 | 107 | float2 uvD = float2(uv.x, uv.y) * _Distort; 108 | fixed4 distort = tex2D(_DistortTex, uvD); 109 | 110 | float2 uvN = float2(uv.x * _SpeedX - distort.r, uv.y - distort.g - _Time.x * _SpeedY); 111 | fixed4 noise = tex2D(_NoiseTex, uvN); 112 | 113 | float a = saturate(pow(gradient.x, _GradientPow) * _GradientThickness); 114 | gradient = float4(a, a, a, a); 115 | noise += gradient; 116 | noise.a = (noise.r + noise.g + noise.b) / 3.0; 117 | float b = max(0, _EdgePow * 20); 118 | float edgePow = saturate(pow(noise.a, b)); 119 | float edgePow2 = saturate(pow(noise.a + lerp(_Edge, 0, NdotV), b)) - edgePow; 120 | 121 | fixed4 col = edgePow * _Color + edgePow2 * _Color2 * _Shininess; 122 | 123 | UNITY_APPLY_FOG(i.fogCoord, col); 124 | return col; 125 | } 126 | ENDCG 127 | 128 | } 129 | Pass 130 | { 131 | Cull[_CullMode] 132 | CGPROGRAM 133 | 134 | #pragma vertex vert 135 | #pragma fragment frag 136 | #pragma multi_compile_fog 137 | 138 | #include "UnityCG.cginc" 139 | 140 | struct appdata 141 | { 142 | float4 vertex: POSITION; 143 | float2 uv: TEXCOORD0; 144 | }; 145 | 146 | struct v2f 147 | { 148 | float2 uv: TEXCOORD0; 149 | UNITY_FOG_COORDS(1) 150 | float4 vertex: SV_POSITION; 151 | }; 152 | 153 | uniform sampler2D _MainTex; uniform float4 _MainTex_ST; 154 | 155 | v2f vert(appdata v) 156 | { 157 | v2f o; 158 | o.vertex = UnityObjectToClipPos(v.vertex); 159 | o.uv = TRANSFORM_TEX(v.uv, _MainTex); 160 | UNITY_TRANSFER_FOG(o, o.vertex); 161 | return o; 162 | } 163 | 164 | fixed4 frag(v2f i): SV_Target 165 | { 166 | fixed4 col = tex2D(_MainTex, i.uv); 167 | UNITY_APPLY_FOG(i.fogCoord, col); 168 | return col; 169 | } 170 | ENDCG 171 | 172 | } 173 | } 174 | Fallback "Diffuse" 175 | } 176 | -------------------------------------------------------------------------------- /FakedAudioVisualizer.shader: -------------------------------------------------------------------------------- 1 | Shader "Custom/FakedAudioVisualizer" 2 | { 3 | Properties 4 | { 5 | [Header(Noise)] 6 | _MainTex ("Noise Texture", 2D) = "white" { } 7 | [MaterialToggle] _Hoge ("Use Perlin Noise", Float) = 0 8 | _ColorTop ("Color Top", Color) = (0.226, 0.000, 0.615, 1.) 9 | _ColorBot ("Color Bottom", Color) = (1.9, 0.55, 0., 1.) 10 | _Factor ("Factor", Float) = 0. 11 | _NoiseSpeed ("Noise Speed", Float) = 1. 12 | _NoisePower ("Noise Power", Float) = 5. 13 | _ClipRange ("Clipping Range", Range(0., 4.)) = 0. 14 | [Header(Compression)] 15 | _Xcomp ("X-axis direction", Range(0., 1.)) = 0. 16 | _Ycomp ("Y-axis direction", Range(0., 1.)) = 0. 17 | _Zcomp ("Z-axis direction", Range(0., 1.)) = 0. 18 | [Header(Rainbow Shading)] 19 | _Switch ("Switch", Range(0., 1.)) = 0. 20 | [MaterialToggle] _Hoge2 ("X-axis direction", Float) = 0 21 | [MaterialToggle] _Hoge3 ("Y-axis direction", Float) = 0 22 | _Saturation ("Saturation", Range(0.0, 1.0)) = 0.8 23 | _Luminosity ("Luminosity", Range(0.0, 1.0)) = 0.57 24 | _Spread ("Spread", Range(0.5, 10.0)) = 2.36 25 | _SpeedRainbow ("Speed", Range(-10.0, 10.0)) = 0.2 26 | } 27 | 28 | CGINCLUDE 29 | inline fixed hueToRGB(float v1, float v2, float vH) 30 | { 31 | if (vH < 0.0) vH += 1.0; 32 | if(vH > 1.0) vH -= 1.0; 33 | if((6.0 * vH) < 1.0) return(v1 + (v2 - v1) * 6.0 * vH); 34 | if((2.0 * vH) < 1.0) return(v2); 35 | if((3.0 * vH) < 2.0) return(v1 + (v2 - v1) * ((2.0 / 3.0) - vH) * 6.0); 36 | return v1; 37 | } 38 | 39 | inline fixed4 HSLtoRGB(fixed4 hsl) 40 | { 41 | fixed4 rgb = fixed4(0.0, 0.0, 0.0, hsl.w); 42 | 43 | if(hsl.y == 0) 44 | { 45 | rgb.xyz = hsl.zzz; 46 | } 47 | else 48 | { 49 | float v1; 50 | float v2; 51 | if(hsl.z < 0.5) v2 = hsl.z * (1 + hsl.y); 52 | else v2 = (hsl.z + hsl.y) - (hsl.y * hsl.z); 53 | v1 = 2.0 * hsl.z - v2; 54 | rgb.x = hueToRGB(v1, v2, hsl.x + (1.0 / 3.0)); 55 | rgb.y = hueToRGB(v1, v2, hsl.x); 56 | rgb.z = hueToRGB(v1, v2, hsl.x - (1.0 / 3.0)); 57 | } 58 | return rgb; 59 | } 60 | 61 | float C2F(float3 Color) 62 | { 63 | int c1 = 255; 64 | int c2 = 255 * 255; 65 | int c3 = 255 * 255 * 255; 66 | return(Color.x * 255 + Color.y * 255 * c1 + Color.z * 255 * c2) / c3; 67 | } 68 | 69 | fixed2 rand(fixed2 st) 70 | { 71 | st = fixed2(dot(st, fixed2(127.1, 311.7)), dot(st, fixed2(269.5, 183.3))); 72 | return - 1.0 + 2.0 * frac(sin(st) * 43758.5453123); 73 | } 74 | 75 | float perlinNoise(fixed2 st) 76 | { 77 | fixed2 p = floor(st); 78 | fixed2 f = frac(st); 79 | fixed2 u = f * f * (3.0 - 2.0 * f); 80 | float v00 = rand(p + fixed2(0, 0)); 81 | float v10 = rand(p + fixed2(1, 0)); 82 | float v01 = rand(p + fixed2(0, 1)); 83 | float v11 = rand(p + fixed2(1, 1)); 84 | return lerp(lerp(dot(v00, f - fixed2(0, 0)), dot(v10, f - fixed2(1, 0)), u.x), lerp(dot(v01, f - fixed2(0, 1)), dot(v11, f - fixed2(1, 1)), u.x), u.y) + 0.5f; 85 | } 86 | 87 | float fBm(fixed2 st) 88 | { 89 | float f = 0; 90 | fixed2 q = st; 91 | f += 0.5000 * perlinNoise(q); q = q * 2.01; 92 | f += 0.2500 * perlinNoise(q); q = q * 2.02; 93 | f += 0.1250 * perlinNoise(q); q = q * 2.03; 94 | f += 0.0625 * perlinNoise(q); q = q * 2.01; 95 | return f; 96 | } 97 | ENDCG 98 | 99 | SubShader 100 | { 101 | Tags { "Queue" = "Transparent" } 102 | Cull Off 103 | LOD 100 104 | 105 | Pass 106 | { 107 | Tags { "LightMode" = "ShadowCaster" } 108 | 109 | CGPROGRAM 110 | 111 | #pragma vertex vert 112 | #pragma fragment frag 113 | #pragma multi_compile_shadowcaster 114 | #pragma shader_feature TOGGLE_SHADOW_CASTING 115 | 116 | #include "UnityCG.cginc" 117 | 118 | struct v2f 119 | { 120 | V2F_SHADOW_CASTER; 121 | }; 122 | 123 | v2f vert(appdata_base v) 124 | { 125 | v2f o; 126 | TRANSFER_SHADOW_CASTER_NORMALOFFSET(o) 127 | return o; 128 | } 129 | 130 | float4 frag(v2f i): SV_Target 131 | { 132 | SHADOW_CASTER_FRAGMENT(i) 133 | } 134 | ENDCG 135 | 136 | } 137 | 138 | Pass 139 | { 140 | CGPROGRAM 141 | 142 | #pragma vertex vert 143 | #pragma fragment frag 144 | #pragma geometry geom 145 | 146 | #include "UnityCG.cginc" 147 | 148 | struct v2g 149 | { 150 | float4 vertex: POSITION; 151 | float3 normal: NORMAL; 152 | float2 uv: TEXCOORD0; 153 | float4 localvertex: TEXCOORD1; 154 | }; 155 | 156 | struct g2f 157 | { 158 | float4 pos: SV_POSITION; 159 | float2 uv: TEXCOORD0; 160 | fixed4 col: COLOR; 161 | float4 localvertex: TEXCOORD1; 162 | UNITY_FOG_COORDS(2) 163 | }; 164 | 165 | uniform sampler2D _MainTex; uniform float4 _MainTex_ST; 166 | uniform fixed4 _ColorTop; 167 | uniform fixed4 _ColorBot; 168 | uniform float _NoiseSpeed; 169 | uniform float _NoisePower; 170 | uniform float _Factor; 171 | uniform float _ClipRange; 172 | uniform float _Xcomp; 173 | uniform float _Ycomp; 174 | uniform float _Zcomp; 175 | uniform float _Switch; 176 | uniform fixed _Saturation; 177 | uniform fixed _Luminosity; 178 | uniform half _Spread; 179 | uniform half _SpeedRainbow; 180 | uniform float _Hoge; 181 | uniform float _Hoge2; 182 | uniform float _Hoge3; 183 | 184 | v2g vert(appdata_base v) 185 | { 186 | v2g o; 187 | v.vertex.xyz = v.vertex.xyz - v.vertex.xyz * float3(_Xcomp, _Ycomp, _Zcomp); 188 | o.vertex = v.vertex; 189 | o.uv = TRANSFORM_TEX(v.texcoord, _MainTex); 190 | o.normal = v.normal; 191 | o.localvertex = v.vertex; 192 | return o; 193 | } 194 | 195 | [maxvertexcount(24)] 196 | void geom(triangle v2g v[3], inout TriangleStream < g2f > tristream) 197 | { 198 | g2f o; 199 | o.localvertex = v[0].localvertex; 200 | 201 | float3 a = v[1].vertex - v[0].vertex; 202 | float3 b = v[2].vertex - v[0].vertex; 203 | float3 normalFace = normalize(cross(a, b)); 204 | float2 uv = v[0].uv; 205 | float angle = 180 * UNITY_PI * (_Time.x / 100 * _NoiseSpeed); 206 | float pivot = 0.5; 207 | float x = (uv.x - pivot) * cos(angle) - (uv.y - pivot) * sin(angle) + pivot; 208 | float y = (uv.x - pivot) * sin(angle) + (uv.y - pivot) * cos(angle) + pivot; 209 | uv = float2(x, y); 210 | fixed4 noiseTex = tex2Dlod(_MainTex, float4(uv, 0, 0)); 211 | float c2f = pow(pow(_NoisePower, _NoisePower), C2F(noiseTex.rgb)); 212 | float c = fBm(v[0].uv * _Time.x * _NoiseSpeed); 213 | fixed4 prlNoise = fixed4(c, c, c, 1); 214 | float prln = pow(pow(_NoisePower, _NoisePower), C2F(prlNoise.rgb)); 215 | float4 normalNoise = lerp(float4(c2f, c2f, c2f, 1), float4(prln, prln, prln, 1), _Hoge); 216 | _Factor /= 50; 217 | 218 | for (int i = 0; i < 3; i ++) 219 | { 220 | int inext = (i + 1) % 3; 221 | 222 | o.pos = UnityObjectToClipPos(v[i].vertex); 223 | o.uv = v[i].uv; 224 | o.col = _ColorBot; 225 | UNITY_TRANSFER_FOG(o, o.pos); 226 | tristream.Append(o); 227 | 228 | o.pos = UnityObjectToClipPos(v[i].vertex + float4(normalFace, 0) * _Factor * normalNoise); 229 | o.uv = v[i].uv; 230 | o.col = _ColorTop; 231 | UNITY_TRANSFER_FOG(o, o.pos); 232 | tristream.Append(o); 233 | 234 | o.pos = UnityObjectToClipPos(v[inext].vertex); 235 | o.uv = v[inext].uv; 236 | o.col = _ColorBot; 237 | UNITY_TRANSFER_FOG(o, o.pos); 238 | tristream.Append(o); 239 | 240 | tristream.RestartStrip(); 241 | 242 | o.pos = UnityObjectToClipPos(v[i].vertex + float4(normalFace, 0) * _Factor * normalNoise); 243 | o.uv = v[i].uv; 244 | o.col = _ColorTop; 245 | UNITY_TRANSFER_FOG(o, o.pos); 246 | tristream.Append(o); 247 | 248 | o.pos = UnityObjectToClipPos(v[inext].vertex); 249 | o.uv = v[inext].uv; 250 | o.col = _ColorBot; 251 | UNITY_TRANSFER_FOG(o, o.pos); 252 | tristream.Append(o); 253 | 254 | o.pos = UnityObjectToClipPos(v[inext].vertex + float4(normalFace, 0) * _Factor * normalNoise); 255 | o.uv = v[inext].uv; 256 | o.col = _ColorTop; 257 | UNITY_TRANSFER_FOG(o, o.pos); 258 | tristream.Append(o); 259 | 260 | tristream.RestartStrip(); 261 | } 262 | 263 | for (int j = 0; j < 3; j ++) 264 | { 265 | o.pos = UnityObjectToClipPos(v[j].vertex + float4(normalFace, 0) * _Factor * normalNoise); 266 | o.uv = v[j].uv; 267 | o.col = _ColorTop; 268 | UNITY_TRANSFER_FOG(o, o.pos); 269 | tristream.Append(o); 270 | } 271 | 272 | tristream.RestartStrip(); 273 | 274 | for (int k = 0; k < 3; k ++) 275 | { 276 | o.pos = UnityObjectToClipPos(v[k].vertex); 277 | o.uv = v[k].uv; 278 | o.col = _ColorBot; 279 | UNITY_TRANSFER_FOG(o, o.pos); 280 | tristream.Append(o); 281 | } 282 | 283 | tristream.RestartStrip(); 284 | } 285 | 286 | fixed4 frag(g2f i): SV_Target 287 | { 288 | fixed4 lPos = i.localvertex / _Spread; 289 | half time = _Time.y * _SpeedRainbow / _Spread; 290 | fixed hue = 0; 291 | hue += lerp(0, (-lPos.x) / 2., _Hoge2); 292 | hue += lerp(0, (-lPos.y) / 2., _Hoge3); 293 | hue += lerp(((-lPos.x - lPos.y - lPos.z) / 3.) / 2., 0, hue); 294 | hue += time; 295 | while(hue < 0.0) hue += 1.0; 296 | while(hue > 1.0) hue -= 1.0; 297 | fixed4 hsl = fixed4(hue, _Saturation, _Luminosity, 1.0); 298 | fixed4 col = lerp(i.col, HSLtoRGB(hsl), _Switch); 299 | UNITY_APPLY_FOG(i.fogCoord, col); 300 | clip((5 - _ClipRange) - i.col); 301 | return col; 302 | } 303 | ENDCG 304 | 305 | } 306 | } 307 | } -------------------------------------------------------------------------------- /FireShader.shader: -------------------------------------------------------------------------------- 1 | Shader "Custom/FireShader" 2 | { 3 | Properties 4 | { 5 | _NoiseTex ("Noise Texture", 2D) = "white" { } 6 | _DistortTex ("Distortion Texture", 2D) = "white" { } 7 | _Color ("Main Flame Color", Color) = (1, 1, 1, 1) 8 | _Color2 ("Flame Rim Color", Color) = (1, 1, 1, 1) 9 | _GradientPow ("Gradient Power", Float) = 1.0 10 | _GradientThickness ("Gradient Thickness", Float) = 1.0 11 | _EdgePow ("Edge Power", Range(0.0, 10)) = 1.0 12 | _Hight ("Flame Hight", Range(-0.4, 1.0)) = 0.0 13 | _Edge ("Rim Strength", Range(-1.0, 1.0)) = 0.0 14 | _Shininess ("Rim Shininess", Float) = 1.0 15 | _Distort ("Distortion", Float) = 1.0 16 | _SpeedX ("Speed X", Float) = 1.0 17 | _SpeedY ("Speed Y", Float) = 1.0 18 | [Enum(OFF, 0, ON, 1)] _Hoge ("Toggle Billboard", int) = 0 19 | [Enum(OFF, 0, FRONT, 1, BACK, 2)] _CullMode ("Cull Mode", int) = 0 20 | } 21 | SubShader 22 | { 23 | Tags { "Queue" = "Transparent" } 24 | LOD 100 25 | Blend SrcAlpha OneMinusSrcAlpha 26 | ZWrite Off 27 | Cull[_CullMode] 28 | 29 | Pass 30 | { 31 | CGPROGRAM 32 | 33 | #pragma vertex vert 34 | #pragma fragment frag 35 | #pragma multi_compile_fog 36 | 37 | #include "UnityCG.cginc" 38 | 39 | struct appdata 40 | { 41 | float4 vertex: POSITION; 42 | float2 uv: TEXCOORD0; 43 | }; 44 | 45 | struct v2f 46 | { 47 | float2 uv: TEXCOORD0; 48 | UNITY_FOG_COORDS(1) 49 | float4 vertex: SV_POSITION; 50 | float2 uvN: TEXCOORD2; 51 | float2 uvD: TEXCOORD3; 52 | }; 53 | 54 | uniform sampler2D _MainTex; uniform float4 _MainTex_ST; 55 | uniform sampler2D _NoiseTex; uniform float4 _NoiseTex_ST; 56 | uniform sampler2D _DistortTex; uniform float4 _DistortTex_ST; 57 | uniform float _GradientPow; 58 | uniform float _GradientThickness; 59 | uniform float _EdgePow; 60 | uniform fixed4 _Color; 61 | uniform float _Hight; 62 | uniform fixed4 _Color2; 63 | uniform float _Edge; 64 | uniform float _Shininess; 65 | uniform float _Distort; 66 | uniform float _SpeedX; 67 | uniform float _SpeedY; 68 | uniform int _Hoge; 69 | 70 | v2f vert(appdata v) 71 | { 72 | v2f o; 73 | float4 pos = mul(UNITY_MATRIX_P, mul(UNITY_MATRIX_MV, float4(0, 0, 0, 1)) + float4(v.vertex.x, v.vertex.y, v.vertex.z, 0)); 74 | o.vertex = lerp(UnityObjectToClipPos(v.vertex), pos, _Hoge); 75 | o.uv = TRANSFORM_TEX(v.uv, _MainTex); 76 | o.uvN = TRANSFORM_TEX(v.uv, _NoiseTex); 77 | o.uvD = TRANSFORM_TEX(v.uv, _DistortTex); 78 | UNITY_TRANSFER_FOG(o, o.vertex); 79 | return o; 80 | } 81 | 82 | fixed4 frag(v2f i): SV_Target 83 | { 84 | float4 gradient = lerp(fixed4(1, 1, 1, 1) * 2, fixed4(0, 0, 0, 0), i.uv.y + _Hight); 85 | 86 | float2 uvD = float2(i.uvD.x, i.uvD.y) * _Distort; 87 | fixed4 distort = tex2D(_DistortTex, uvD); 88 | 89 | float2 uvN = float2(i.uvN.x * _SpeedX - distort.r, i.uvN.y - distort.g - _Time.x * _SpeedY); 90 | fixed4 noise = tex2D(_NoiseTex, uvN); 91 | 92 | float a = saturate(pow(gradient.x, _GradientPow) * _GradientThickness); 93 | gradient = float4(a, a, a, a); 94 | noise += gradient; 95 | noise.a = (noise.r + noise.g + noise.b) / 3.0; 96 | float b = max(0, _EdgePow * 20); 97 | float edgePow = saturate(pow(noise.a, b)); 98 | float edgePow2 = saturate(pow(noise.a + lerp(_Edge, 0, i.uv.y), b)) - edgePow; 99 | 100 | fixed4 col = edgePow * _Color + edgePow2 * _Color2 * _Shininess; 101 | 102 | UNITY_APPLY_FOG(i.fogCoord, col); 103 | return col; 104 | } 105 | ENDCG 106 | 107 | } 108 | } 109 | Fallback "Diffuse" 110 | } 111 | -------------------------------------------------------------------------------- /HologramIllumination.shader: -------------------------------------------------------------------------------- 1 | Shader "Custom/HologramIllumination" 2 | { 3 | Properties 4 | { 5 | _MainTex ("Texture", 2D) = "white" { } 6 | _Color ("Color", Color) = (1, 1, 1, 1) 7 | _Saturation ("Saturation", Range(0.0, 1.0)) = 0.8 8 | _Luminosity ("Luminosity", Range(0.0, 1.0)) = 0.57 9 | _Spread ("Spread", Range(0.5, 10.0)) = 2.36 10 | _SpeedRainbow ("Rainbow Speed", Range(-10.0, 10.0)) = 0.2 11 | _Speed ("Scanline Speed", Range(1.0, 30)) = 1.0 12 | _Frequency ("Scanline Frequency", Range(1.0, 30)) = 1.0 13 | [Enum(OFF, 0, ON, 1)] _Hoge("Toggle fBm Noise", int) = 0 14 | } 15 | SubShader 16 | { 17 | Tags { "Queue" = "Transparent" } 18 | LOD 100 19 | Blend SrcColor One 20 | ZWrite Off 21 | Cull Off 22 | 23 | CGINCLUDE 24 | inline fixed hueToRGB(float v1, float v2, float vH) 25 | { 26 | if (vH < 0.0) vH += 1.0; 27 | if(vH > 1.0) vH -= 1.0; 28 | if((6.0 * vH) < 1.0) return(v1 + (v2 - v1) * 6.0 * vH); 29 | if((2.0 * vH) < 1.0) return(v2); 30 | if((3.0 * vH) < 2.0) return(v1 + (v2 - v1) * ((2.0 / 3.0) - vH) * 6.0); 31 | return v1; 32 | } 33 | 34 | inline fixed4 HSLtoRGB(fixed4 hsl) 35 | { 36 | fixed4 rgb = fixed4(0.0, 0.0, 0.0, hsl.w); 37 | 38 | if(hsl.y == 0) 39 | { 40 | rgb.xyz = hsl.zzz; 41 | } 42 | else 43 | { 44 | float v1; 45 | float v2; 46 | if(hsl.z < 0.5) v2 = hsl.z * (1 + hsl.y); 47 | else v2 = (hsl.z + hsl.y) - (hsl.y * hsl.z); 48 | v1 = 2.0 * hsl.z - v2; 49 | rgb.x = hueToRGB(v1, v2, hsl.x + (1.0 / 3.0)); 50 | rgb.y = hueToRGB(v1, v2, hsl.x); 51 | rgb.z = hueToRGB(v1, v2, hsl.x - (1.0 / 3.0)); 52 | } 53 | return rgb; 54 | } 55 | 56 | fixed2 rand(fixed2 st) 57 | { 58 | st = fixed2(dot(st, fixed2(127.1, 311.7)), dot(st, fixed2(269.5, 183.3))); 59 | return - 1.0 + 2.0 * frac(sin(st) * 43758.5453123); 60 | } 61 | 62 | float perlinNoise(fixed2 st) 63 | { 64 | fixed2 p = floor(st); 65 | fixed2 f = frac(st); 66 | fixed2 u = f * f * (3.0 - 2.0 * f); 67 | float v00 = rand(p + fixed2(0, 0)); 68 | float v10 = rand(p + fixed2(1, 0)); 69 | float v01 = rand(p + fixed2(0, 1)); 70 | float v11 = rand(p + fixed2(1, 1)); 71 | return lerp(lerp(dot(v00, f - fixed2(0, 0)), dot(v10, f - fixed2(1, 0)), u.x), lerp(dot(v01, f - fixed2(0, 1)), dot(v11, f - fixed2(1, 1)), u.x), u.y) + 0.5f; 72 | } 73 | 74 | float fBm(fixed2 st) 75 | { 76 | float f = 0; 77 | fixed2 q = st; 78 | f += 0.5000 * perlinNoise(q); q = q * 2.01; 79 | f += 0.2500 * perlinNoise(q); q = q * 2.02; 80 | f += 0.1250 * perlinNoise(q); q = q * 2.03; 81 | f += 0.0625 * perlinNoise(q); q = q * 2.01; 82 | return f; 83 | } 84 | ENDCG 85 | 86 | Pass 87 | { 88 | CGPROGRAM 89 | 90 | #pragma vertex vert 91 | #pragma fragment frag 92 | // make fog work 93 | #pragma multi_compile_fog 94 | 95 | #include "UnityCG.cginc" 96 | 97 | struct appdata 98 | { 99 | float4 vertex: POSITION; 100 | float2 uv: TEXCOORD0; 101 | }; 102 | 103 | struct v2f 104 | { 105 | float2 uv: TEXCOORD0; 106 | UNITY_FOG_COORDS(1) 107 | float4 vertex: SV_POSITION; 108 | float4 wpos: TEXCOORD2; 109 | float4 localvertex: TEXCOORD3; 110 | }; 111 | 112 | uniform sampler2D _MainTex; 113 | uniform float4 _MainTex_ST; 114 | uniform fixed4 _Color; 115 | uniform fixed _Saturation; 116 | uniform fixed _Luminosity; 117 | uniform half _Spread; 118 | uniform half _SpeedRainbow; 119 | uniform float _Speed; 120 | uniform float _Frequency; 121 | uniform int _Hoge; 122 | 123 | v2f vert(appdata v) 124 | { 125 | v2f o; 126 | o.vertex = UnityObjectToClipPos(v.vertex); 127 | o.wpos = mul(unity_ObjectToWorld, v.vertex); 128 | o.uv = TRANSFORM_TEX(v.uv, _MainTex); 129 | o.localvertex = v.vertex; 130 | UNITY_TRANSFER_FOG(o, o.vertex); 131 | return o; 132 | } 133 | 134 | fixed4 frag(v2f i): SV_Target 135 | { 136 | fixed4 lPos = i.localvertex / _Spread; 137 | half time = _Time.y * _SpeedRainbow / _Spread; 138 | fixed hue = ((-lPos.x - lPos.y - lPos.z) / 3.) / 2.; 139 | hue += time; 140 | while(hue < 0.0) hue += 1.0; 141 | while(hue > 1.0) hue -= 1.0; 142 | fixed4 hsl = fixed4(hue, _Saturation, _Luminosity, 1.0); 143 | 144 | fixed4 col = tex2D(_MainTex, i.uv) * _Color * HSLtoRGB(hsl) * max(0, sin(i.wpos.y * 100 * _Frequency + _Time.x * 100 * _Speed) * 10) * 1.0; 145 | col *= max(0, sin(i.wpos.x * 100 * _Frequency + _Time.x * 100 * _Speed)) * 0.9; 146 | col *= max(0, sin(i.wpos.z * 100 * _Frequency + _Time.x * 100 * _Speed)) * 0.8; 147 | col *= lerp(fixed4(1, 1, 1, 1), fBm(float2(dot(col.rg, col.gb), dot(col.gb, col.br))) * 2, _Hoge); 148 | 149 | // apply fog 150 | UNITY_APPLY_FOG(i.fogCoord, col); 151 | return col; 152 | } 153 | ENDCG 154 | 155 | } 156 | } 157 | Fallback "Diffuse" 158 | } 159 | -------------------------------------------------------------------------------- /IceShader.shader: -------------------------------------------------------------------------------- 1 | // https://lindseyreidblog.wordpress.com/2017/12/30/ice-shader-in-unity/ 2 | Shader "Custom/IceShader" 3 | { 4 | Properties 5 | { 6 | _MainTex ("Main Tex", 2D) = "white" { } 7 | _RampTex ("Ramp Texture", 2D) = "white" { } 8 | _BumpTex ("Bump Texture", 2D) = "white" { } 9 | _Color ("Color", Color) = (1, 1, 1, 1) 10 | _DistortStrength ("Distort Strength", Float) = 1.0 11 | _EdgeThickness ("Edge Thickness", Float) = 1.0 12 | _SpecSize ("Specular Circle Size", Range(0.0, 10.0)) = 3.50 13 | _Shininess ("Shininess", Range(0.1, 1.00)) = 0.50 14 | } 15 | SubShader 16 | { 17 | Tags { "Queue" = "Transparent" } 18 | LOD 100 19 | 20 | GrabPass 21 | { 22 | "_BackgroundTexture" 23 | } 24 | 25 | Pass 26 | { 27 | Cull Off 28 | CGPROGRAM 29 | 30 | #pragma vertex vert 31 | #pragma fragment frag 32 | #pragma multi_compile_fog 33 | 34 | #include "UnityCG.cginc" 35 | 36 | struct appdata 37 | { 38 | float4 vertex: POSITION; 39 | float2 uv: TEXCOORD0; 40 | float3 normal: NORMAL; 41 | }; 42 | 43 | struct v2f 44 | { 45 | float4 grabPos: TEXCOORD0; 46 | UNITY_FOG_COORDS(1) 47 | float4 vertex: SV_POSITION; 48 | float3 normal: TEXCOORD2; 49 | float3 viewDir: TEXCOORD3; 50 | float3 spec: COLOR; 51 | }; 52 | 53 | uniform sampler2D _RampTex; 54 | uniform sampler2D _BumpTex; 55 | uniform sampler2D _BackgroundTexture; 56 | uniform float _DistortStrength; 57 | uniform float _EdgeThickness; 58 | uniform fixed4 _Color; 59 | uniform float4 _LightColor0; 60 | uniform float _SpecSize; 61 | uniform float _Shininess; 62 | 63 | v2f vert(appdata v) 64 | { 65 | v2f o; 66 | o.vertex = UnityObjectToClipPos(v.vertex); 67 | o.normal = normalize(mul(unity_ObjectToWorld, float4(v.normal, 0))).xyz; 68 | o.viewDir = normalize(_WorldSpaceCameraPos - mul(unity_ObjectToWorld, v.vertex)).xyz; 69 | o.grabPos = ComputeGrabScreenPos(o.vertex); 70 | float2 bump = tex2Dlod(_BumpTex, float4(v.uv, 0, 0)).rg; 71 | o.grabPos.xy += bump * _DistortStrength; 72 | UNITY_TRANSFER_FOG(o, o.vertex); 73 | return o; 74 | } 75 | 76 | fixed4 frag(v2f i): SV_TARGET 77 | { 78 | float edgeFactor = abs(dot(i.viewDir, i.normal)); 79 | float oneMinusEdgeFactor = 1 - abs(dot(i.viewDir, i.normal)); 80 | float opacity = smoothstep(0, 1, oneMinusEdgeFactor); 81 | opacity = pow(opacity, _EdgeThickness); 82 | fixed4 ramp = tex2D(_RampTex, float2(oneMinusEdgeFactor, 0.5)) * _Color; 83 | 84 | float3 half = normalize(_WorldSpaceLightPos0 + i.viewDir); 85 | float NdotH = dot(half, i.normal); 86 | float3 spec; 87 | if (NdotH > 0.89 + 0.01 * (10.0 - _SpecSize)) spec = fixed3(1, 1, 1) * _LightColor0.rgb / 0.05 * _Shininess; 88 | else spec = fixed3(0, 0, 0); 89 | 90 | fixed4 col = lerp(tex2Dproj(_BackgroundTexture, i.grabPos) + fixed4(spec, 0), ramp, opacity); 91 | UNITY_APPLY_FOG(i.fogCoord, col); 92 | return col; 93 | } 94 | ENDCG 95 | 96 | } 97 | } 98 | Fallback "Diffuse" 99 | } 100 | -------------------------------------------------------------------------------- /LCDShader.shader: -------------------------------------------------------------------------------- 1 | // https://www.alanzucconi.com/2016/05/04/lcd-shader/ 2 | Shader "Custom/LCDShader" 3 | { 4 | Properties 5 | { 6 | _MainTex ("Texture", 2D) = "white" { } 7 | _LCDTex ("LCD Texture", 2D) = "white" { } 8 | _Pixels ("Pixels", Vector) = (10, 10, 0, 0) 9 | _LCDPixels ("LCD Pixels", Vector) = (3, 3, 0, 0) 10 | //_DistanceOne ("Distance of full effect", Float) = 0.5 11 | //_DistanceZero ("Distance of zero effect", Float) = 1 12 | } 13 | SubShader 14 | { 15 | Tags { "Queue" = "Transparent" } 16 | LOD 100 17 | 18 | Pass 19 | { 20 | CGPROGRAM 21 | 22 | #pragma vertex vert 23 | #pragma fragment frag 24 | #pragma multi_compile_fog 25 | 26 | #include "UnityCG.cginc" 27 | 28 | struct appdata 29 | { 30 | float4 vertex: POSITION; 31 | float2 uv: TEXCOORD0; 32 | }; 33 | 34 | struct v2f 35 | { 36 | float2 uv: TEXCOORD0; 37 | UNITY_FOG_COORDS(1) 38 | float4 vertex: SV_POSITION; 39 | float4 wpos: TEXCOORD2; 40 | }; 41 | 42 | uniform sampler2D _MainTex; uniform float4 _MainTex_ST; 43 | uniform sampler2D _LCDTex; uniform float4 _LCDTex_ST; 44 | uniform float4 _Pixels; 45 | uniform float4 _LCDPixels; 46 | //uniform float _DistanceOne; 47 | //uniform float _DistanceZero; 48 | 49 | v2f vert(appdata v) 50 | { 51 | v2f o; 52 | o.vertex = UnityObjectToClipPos(v.vertex); 53 | o.uv = TRANSFORM_TEX(v.uv, _MainTex); 54 | o.wpos = mul(unity_ObjectToWorld, v.vertex); 55 | UNITY_TRANSFER_FOG(o, o.vertex); 56 | return o; 57 | } 58 | 59 | fixed4 frag(v2f i): SV_Target 60 | { 61 | float2 uv = round(i.uv * _Pixels.xy + 0.5) / _Pixels.xy; 62 | float2 uv_lcd = i.uv * _Pixels.xy / _LCDPixels; 63 | fixed4 a = tex2D(_MainTex, uv); 64 | fixed4 d = tex2D(_LCDTex, uv_lcd); 65 | //float dist = distance(_WorldSpaceCameraPos, i.wpos); 66 | //float alpha = saturate 67 | //( 68 | // (dist - _DistanceOne) / (_DistanceZero - _DistanceOne) 69 | //); 70 | //fixed4 col = lerp(a * d, a, alpha); 71 | fixed4 col = a * d; 72 | col.a = 1; 73 | UNITY_APPLY_FOG(i.fogCoord, col); 74 | return col; 75 | } 76 | ENDCG 77 | 78 | } 79 | } 80 | Fallback "Diffuse" 81 | } 82 | -------------------------------------------------------------------------------- /OutlineShader.shader: -------------------------------------------------------------------------------- 1 | Shader "Custom/OutlineShader_Ver3.3" 2 | { 3 | Properties 4 | { 5 | [Header(Main Content)] 6 | _Switch ("Switch", Range(0.0, 1.0)) = 0 7 | _MainTex ("Texture", 2D) = "white" { } 8 | _MainColor ("Main Color", Color) = (0, 0, 0, 0) 9 | _Cutoff ("Alpha Cutoff", Range(0.0, 1.0)) = 0.0 10 | _Switch3 ("Transparency", Range(0.0, 1.0)) = 0 11 | [Header(Rim lighting)] 12 | _Switch4 ("Switch", Range(0.0, 1.0)) = 0 13 | _RimTint ("Rim Tint", Color) = (1, 1, 1, 1) 14 | _RimPower ("Rim Power", Float) = 1 15 | _RimAmplitude ("Rim Amplitude", Float) = 1 16 | [Header(Outline)] 17 | _Switch2 ("Switch", Range(0.0, 1.0)) = 0 18 | _OutlineColor ("Outline Color", Color) = (1, 1, 1, 1) 19 | _OutlineWidth ("Outline Width", Float) = 0.1 20 | [MaterialToggle] _Hoge ("Toggle Outline Mask", Float) = 0 21 | _OutlineMask ("Outline Mask Texture", 2D) = "white" { } 22 | [Header(Outline Texture)] 23 | _Switch5 ("Switch", Range(0.0, 1.0)) = 0 24 | _OutlineTex ("Outline Texture", 2D) = "white" { } 25 | [Header(Rainbow Shading)] 26 | [MaterialToggle] _Hoge3 ("X-axis direction", Float) = 0 27 | [MaterialToggle] _Hoge4 ("Y-axis direction", Float) = 0 28 | _Saturation ("Saturation", Range(0.0, 1.0)) = 0.8 29 | _Luminosity ("Luminosity", Range(0.0, 1.0)) = 0.57 30 | _Spread ("Spread", Range(0.5, 10.0)) = 2.36 31 | _SpeedRainbow ("Speed", Range(-10.0, 10.0)) = 0.2 32 | [Header(Glitch)] 33 | [Toggle(TOGGLE_GLITCH)] _Hoge2 ("Toggle Glitch", Float) = 0 34 | _GlitchIntensity ("Glitch Intensity", Float) = 0.1 35 | _GlitchSpeed ("Glitch Speed", Range(0.01, 100)) = 5.0 36 | [Header(Surface Waving)] 37 | [Toggle(TOGGLE_YURAYURA_OUTLINE)] _Hoge5 ("Toggle waving movement(Outline)", Float) = 0 38 | [Toggle(TOGGLE_YURAYURA_MESH)] _Hoge6 ("Toggle waving movement(Mesh)", Float) = 0 39 | _WaveScale ("Wave Scale", Float) = 1.0 40 | } 41 | 42 | CGINCLUDE 43 | inline fixed hueToRGB(float v1, float v2, float vH) 44 | { 45 | if (vH < 0.0) vH += 1.0; 46 | if(vH > 1.0) vH -= 1.0; 47 | if((6.0 * vH) < 1.0) return(v1 + (v2 - v1) * 6.0 * vH); 48 | if((2.0 * vH) < 1.0) return(v2); 49 | if((3.0 * vH) < 2.0) return(v1 + (v2 - v1) * ((2.0 / 3.0) - vH) * 6.0); 50 | return v1; 51 | } 52 | 53 | inline fixed4 HSLtoRGB(fixed4 hsl) 54 | { 55 | fixed4 rgb = fixed4(0.0, 0.0, 0.0, hsl.w); 56 | 57 | if(hsl.y == 0) 58 | { 59 | rgb.xyz = hsl.zzz; 60 | } 61 | else 62 | { 63 | float v1; 64 | float v2; 65 | if(hsl.z < 0.5) v2 = hsl.z * (1 + hsl.y); 66 | else v2 = (hsl.z + hsl.y) - (hsl.y * hsl.z); 67 | v1 = 2.0 * hsl.z - v2; 68 | rgb.x = hueToRGB(v1, v2, hsl.x + (1.0 / 3.0)); 69 | rgb.y = hueToRGB(v1, v2, hsl.x); 70 | rgb.z = hueToRGB(v1, v2, hsl.x - (1.0 / 3.0)); 71 | } 72 | return rgb; 73 | } 74 | 75 | float rand(float3 co) 76 | { 77 | return frac(sin(dot(co.xyz, float3(12.9898, 78.233, 45.5432))) * 43758.5453); 78 | } 79 | ENDCG 80 | 81 | SubShader 82 | { 83 | Tags { "Queue" = "Transparent" "IgnoreProjector" = "True" "RenderType" = "TransparentCutout" } 84 | LOD 100 85 | 86 | GrabPass 87 | { 88 | "_BackgroundTexture" 89 | } 90 | 91 | Pass 92 | { 93 | Tags { "LightMode" = "ShadowCaster" } 94 | 95 | CGPROGRAM 96 | 97 | #pragma vertex vert 98 | #pragma fragment frag 99 | 100 | #include "UnityCG.cginc" 101 | 102 | struct v2f 103 | { 104 | V2F_SHADOW_CASTER; 105 | }; 106 | 107 | v2f vert(appdata_base v) 108 | { 109 | v2f o; 110 | TRANSFER_SHADOW_CASTER_NORMALOFFSET(o) 111 | return o; 112 | } 113 | 114 | float4 frag(v2f i): SV_Target 115 | { 116 | SHADOW_CASTER_FRAGMENT(i) 117 | } 118 | ENDCG 119 | 120 | } 121 | 122 | Pass 123 | { 124 | Tags { "LightMode" = "ForwardBase" } 125 | Cull Front 126 | 127 | CGPROGRAM 128 | 129 | #pragma vertex vert 130 | #pragma fragment frag 131 | // make fog work 132 | #pragma multi_compile_fog 133 | #pragma multi_compile_fwdbase 134 | #pragma shader_feature TOGGLE_GLITCH 135 | #pragma shader_feature TOGGLE_YURAYURA_OUTLINE 136 | #pragma shader_feature TOGGLE_YURAYURA_MESH 137 | 138 | #include "UnityCG.cginc" 139 | #include "AutoLight.cginc" 140 | 141 | struct appdata 142 | { 143 | float4 vertex: POSITION; 144 | float3 normal: NORMAL; 145 | float2 uv: TEXCOORD0; 146 | float2 uvM: TEXCOORD1; 147 | float4 color: COLOR; 148 | }; 149 | 150 | struct v2f 151 | { 152 | float4 vertex: SV_POSITION; 153 | float3 normal: NORMAL; 154 | float2 uv: TEXCOORD0; 155 | float2 uvM: TEXCOORD1; 156 | float4 color: TEXCOORD2; 157 | float4 localvertex: TEXCOORD3; 158 | float4 pos: TEXCOORD4; 159 | UNITY_FOG_COORDS(5) 160 | SHADOW_COORDS(6) 161 | }; 162 | 163 | uniform float _Cutoff; 164 | uniform float _OutlineWidth; 165 | uniform float _Hoge; 166 | uniform float _Hoge3; 167 | uniform float _Hoge4; 168 | uniform float _Switch2; 169 | uniform float _Switch5; 170 | uniform fixed4 _OutlineColor; 171 | uniform fixed _Saturation; 172 | uniform fixed _Luminosity; 173 | uniform half _Spread; 174 | uniform half _SpeedRainbow; 175 | uniform float _WaveScale; 176 | uniform float _GlitchIntensity; 177 | uniform float _GlitchSpeed; 178 | uniform sampler2D _MainTex; uniform float4 _MainTex_ST; 179 | uniform sampler2D _OutlineTex; uniform float4 _OutlineTex_ST; 180 | uniform sampler2D _OutlineMask; uniform float4 _OutlineMask_ST; 181 | 182 | v2f vert(appdata v) 183 | { 184 | v2f o; 185 | _OutlineWidth /= 1000; 186 | o.uvM = v.uvM; 187 | float3 outlineMask = lerp(0, tex2Dlod(_OutlineMask, float4(TRANSFORM_TEX(o.uvM, _OutlineMask), 0.0, 0)).rgb, _Hoge); 188 | #ifdef TOGGLE_YURAYURA_OUTLINE 189 | v.vertex.xyz += v.normal * rand(normalize(v.normal) * (_Time.w / 8000000)) / (1000. * _WaveScale); 190 | #else 191 | v.vertex.xyz += v.normal * (1.0 - outlineMask.rgb) * _OutlineWidth; 192 | #endif 193 | #ifdef TOGGLE_GLITCH 194 | v.vertex.x += _GlitchIntensity * (step(0.5, sin(_Time.y * 2.0 + v.vertex.y * 1.0)) * step(0.99, sin(_Time.y * _GlitchSpeed * 0.5))); 195 | #endif 196 | o.vertex = UnityObjectToClipPos(v.vertex); 197 | o.uv = v.uv; 198 | o.normal = v.normal; 199 | o.color = v.color; 200 | o.localvertex = v.vertex; 201 | o.pos = mul(UNITY_MATRIX_MVP, v.vertex); 202 | UNITY_TRANSFER_FOG(o, o.vertex); 203 | TRANSFER_SHADOW(o) 204 | return o; 205 | }; 206 | 207 | fixed4 frag(v2f i): SV_Target 208 | { 209 | fixed4 lPos = i.localvertex / _Spread; 210 | half time = _Time.y * _SpeedRainbow / _Spread; 211 | fixed hue = 0; 212 | hue += lerp(0, (-lPos.x) / 2., _Hoge3); 213 | hue += lerp(0, (-lPos.y) / 2., _Hoge4); 214 | hue += lerp(((-lPos.x - lPos.y - lPos.z) / 3.) / 2., 0, hue); 215 | hue += time; 216 | while(hue < 0.0) hue += 1.0; 217 | while(hue > 1.0) hue -= 1.0; 218 | fixed4 hsl = fixed4(hue, _Saturation, _Luminosity, 1.0); 219 | fixed4 OutlineTex = tex2D(_OutlineTex, i.uv); 220 | fixed4 col = lerp(lerp(_OutlineColor, HSLtoRGB(hsl), _Switch2), OutlineTex, _Switch5); 221 | col.rgb *= SHADOW_ATTENUATION(i); 222 | clip(col.a - _Cutoff); 223 | // apply fog 224 | UNITY_APPLY_FOG(i.fogCoord, col); 225 | return col; 226 | } 227 | ENDCG 228 | 229 | } 230 | 231 | Pass 232 | { 233 | Tags { "LightMode" = "ForwardBase" } 234 | Cull Off 235 | 236 | CGPROGRAM 237 | 238 | #pragma vertex vert 239 | #pragma fragment frag 240 | // make fog work 241 | #pragma multi_compile_fog 242 | #pragma multi_compile_fwdbase 243 | #pragma shader_feature TOGGLE_GLITCH 244 | #pragma shader_feature TOGGLE_YURAYURA_OUTLINE 245 | #pragma shader_feature TOGGLE_YURAYURA_MESH 246 | 247 | #include "UnityCG.cginc" 248 | #include "AutoLight.cginc" 249 | 250 | struct appdata 251 | { 252 | float4 vertex: POSITION; 253 | float3 normal: NORMAL; 254 | float2 uv: TEXCOORD0; 255 | float4 color: COLOR; 256 | }; 257 | 258 | struct v2f 259 | { 260 | float4 vertex: SV_POSITION; 261 | float2 uv: TEXCOORD0; 262 | float4 color: TEXCOORD1; 263 | float4 grabPos: TEXCOORD2; 264 | float3 normal: TEXCOORD3; 265 | float4 wpos: TEXCOORD4; 266 | float4 pos: TEXCOORD5; 267 | UNITY_FOG_COORDS(6) 268 | SHADOW_COORDS(7) 269 | }; 270 | 271 | uniform float4 _MainColor; 272 | uniform float _Cutoff; 273 | uniform float _Switch; 274 | uniform float _Switch3; 275 | uniform float _Switch4; 276 | uniform float _RimPower; 277 | uniform float _RimAmplitude; 278 | uniform float4 _RimTint; 279 | uniform float _WaveScale; 280 | uniform float _GlitchIntensity; 281 | uniform float _GlitchSpeed; 282 | uniform sampler2D _MainTex; float4 _MainTex_ST; 283 | uniform sampler2D _BackgroundTexture; 284 | 285 | v2f vert(appdata v) 286 | { 287 | #ifdef TOGGLE_YURAYURA_MESH 288 | v.vertex.xyz += v.normal * rand(normalize(v.normal) * (_Time.w / 8000000)) / (1000. * _WaveScale); 289 | #endif 290 | #ifdef TOGGLE_GLITCH 291 | v.vertex.x += _GlitchIntensity * (step(0.5, sin(_Time.y * 2.0 + v.vertex.y * 1.0)) * step(0.99, sin(_Time.y * _GlitchSpeed * 0.5))); 292 | #endif 293 | v2f o; 294 | o.vertex = UnityObjectToClipPos(v.vertex); 295 | o.grabPos = ComputeGrabScreenPos(o.vertex); 296 | o.uv = v.uv; 297 | o.normal = v.normal; 298 | o.wpos = mul(unity_ObjectToWorld, v.vertex); 299 | fixed4 MainColor = _MainColor; 300 | fixed4 stColor = v.color; 301 | o.color = lerp(MainColor, stColor, _Switch); 302 | o.pos = mul(UNITY_MATRIX_MVP, v.vertex); 303 | TRANSFER_SHADOW(o) 304 | UNITY_TRANSFER_FOG(o, o.vertex); 305 | return o; 306 | }; 307 | 308 | fixed4 frag(v2f i): SV_Target 309 | { 310 | float3 normalDir = normalize(i.normal); 311 | float3 viewDir = normalize(_WorldSpaceCameraPos.xyz - i.wpos.xyz); 312 | float NNdotV = 1 - dot(normalDir, viewDir); 313 | float rim = pow(NNdotV, _RimPower) * _RimAmplitude; 314 | fixed4 Color = i.color; 315 | fixed4 MainTex = tex2D(_MainTex, i.uv) * Color; 316 | half4 bgcolor = tex2Dproj(_BackgroundTexture, i.grabPos) * Color; 317 | fixed4 col = lerp(lerp(Color, MainTex, _Switch), bgcolor, _Switch3); 318 | fixed3 colRim = col.rgb * _RimTint.a + rim * _RimTint.rgb; 319 | col.rgb = lerp(col.rgb, colRim, _Switch4); 320 | col.rgb *= SHADOW_ATTENUATION(i); 321 | clip(col.a - _Cutoff); 322 | // apply fog 323 | UNITY_APPLY_FOG(i.fogCoord, col); 324 | return col; 325 | } 326 | ENDCG 327 | 328 | } 329 | } 330 | Fallback "Diffuse" 331 | } -------------------------------------------------------------------------------- /PlasticShader.shader: -------------------------------------------------------------------------------- 1 | Shader "Custom/PlasticShader" 2 | { 3 | Properties 4 | { 5 | _RampTex ("Ramp Texture", 2D) = "white" { } 6 | _Color ("Color", Color) = (1, 1, 1, 1) 7 | _Density ("Density", Float) = 1.0 8 | _Thickness ("Thickness", Float) = 1.0 9 | _SpecSize ("Spec Size", Float) = 1.0 10 | _Shininess ("Shininess", Float) = 1.0 11 | [Enum(OFF, 0, FRONT, 1, BACK, 2)] _CullMode ("Cull Mode", int) = 0 12 | } 13 | SubShader 14 | { 15 | Tags { "Queue" = "Transparent" } 16 | LOD 100 17 | Blend SrcAlpha OneMinusSrcAlpha 18 | ZWrite Off 19 | Cull[_CullMode] 20 | 21 | Pass 22 | { 23 | CGPROGRAM 24 | 25 | #pragma vertex vert 26 | #pragma fragment frag 27 | #pragma multi_compile_fog 28 | 29 | #include "UnityCG.cginc" 30 | 31 | struct appdata 32 | { 33 | float4 vertex: POSITION; 34 | float2 uv: TEXCOORD0; 35 | float3 normal: NORMAL; 36 | }; 37 | 38 | struct v2f 39 | { 40 | float2 uv: TEXCOORD0; 41 | UNITY_FOG_COORDS(1) 42 | float4 vertex: SV_POSITION; 43 | float4 wpos: TEXCOORD2; 44 | float3 normal: TEXCOORD3; 45 | }; 46 | 47 | uniform sampler2D _RampTex; uniform float4 _RampTex_ST; 48 | uniform float _Density; 49 | uniform float _Thickness; 50 | uniform fixed4 _Color; 51 | uniform float _SpecSize; 52 | uniform float4 _LightColor0; 53 | uniform float _Shininess; 54 | 55 | v2f vert(appdata v) 56 | { 57 | v2f o; 58 | o.vertex = UnityObjectToClipPos(v.vertex); 59 | o.uv = TRANSFORM_TEX(v.uv, _RampTex); 60 | o.wpos = mul(unity_ObjectToWorld, v.vertex); 61 | o.normal = UnityObjectToWorldNormal(v.normal); 62 | UNITY_TRANSFER_FOG(o, o.vertex); 63 | return o; 64 | } 65 | 66 | fixed4 frag(v2f i): SV_Target 67 | { 68 | float3 viewDir = normalize(_WorldSpaceCameraPos - i.wpos).xyz; 69 | float NdotV = saturate(dot(i.normal, viewDir)); 70 | float NNdotV = 1 - NdotV; 71 | NNdotV = (NNdotV * 0.5) + 0.5; 72 | float opacity = smoothstep(0, 1, NNdotV); 73 | opacity = pow(NNdotV, max(0, _Density)) * _Thickness; 74 | fixed4 ramp = tex2D(_RampTex, float2(NNdotV, 0.5)) * _Color; 75 | 76 | float3 half = normalize(_WorldSpaceLightPos0 + viewDir); 77 | float NdotH = dot(half, i.normal); 78 | float3 spec; 79 | if (NdotH > 0.89 + 0.01 * (10.0 - _SpecSize)) spec = fixed3(1, 1, 1) * _LightColor0.rgb / 0.05 * _Shininess; 80 | else spec = fixed3(0, 0, 0); 81 | 82 | fixed4 col = lerp(fixed4(0, 0, 0, 0), ramp, opacity) + fixed4(spec, 0); 83 | 84 | UNITY_APPLY_FOG(i.fogCoord, col); 85 | return col; 86 | } 87 | ENDCG 88 | 89 | } 90 | } 91 | Fallback "Diffuse" 92 | } 93 | -------------------------------------------------------------------------------- /PolyFlash.shader: -------------------------------------------------------------------------------- 1 | Shader "Custom/PolyFlash_ver2.2" 2 | { 3 | Properties 4 | { 5 | _MainTex ("Texture", 2D) = "white" { } 6 | _Color ("Color", Color) = (1, 1, 1, 1) 7 | [Header(Rainbow Shading Settings)] 8 | _Switch ("Switch", Range(0., 1.)) = 0. 9 | [Toggle] _Switch2 ("X-axis direction", Float) = 0 10 | [Toggle] _Switch3 ("Y-axis direction", Float) = 0 11 | _Saturation ("Saturation", Range(0.0, 1.0)) = 0.8 12 | _Luminosity ("Luminosity", Range(0.0, 1.0)) = 0.57 13 | _Spread ("Spread", Range(0.5, 10.0)) = 2.36 14 | _SpeedRainbow ("Speed", Range(-10.0, 10.0)) = 0.2 15 | [Header(UV Scroll Settings)] 16 | _ScrollSpeeds ("Scroll Speed", Float) = 0.1 17 | _Speed ("Rotation Speed", Float) = 1.0 18 | [Toggle]_uvScroll ("Scroll UV", Float) = 0 19 | [Toggle]_SwitchX ("Rotate around X axis", Float) = 0 20 | [Toggle]_SwitchY ("Rotate around Y axis", Float) = 0 21 | [Toggle]_SwitchZ ("Rotate around Z axis", Float) = 0 22 | [Toggle]_SwitchR ("Rotate randomly", Float) = 0 23 | } 24 | SubShader 25 | { 26 | Tags { "Queue" = "Geometry" "RenderType" = "Opaque" "LightMode" = "ForwardBase" } 27 | LOD 100 28 | 29 | Pass 30 | { 31 | Cull Off 32 | CGPROGRAM 33 | 34 | #pragma vertex vert 35 | #pragma geometry geom 36 | #pragma fragment frag 37 | // make fog work 38 | #pragma multi_compile_fog 39 | 40 | #include "UnityCG.cginc" 41 | 42 | struct v2g 43 | { 44 | float4 pos: SV_POSITION; 45 | float2 uv: TEXCOORD0; 46 | float4 vertex: TEXCOORD1; 47 | float3 normal: TEXCOORD2; 48 | }; 49 | 50 | struct g2f 51 | { 52 | float2 uv: TEXCOORD0; 53 | UNITY_FOG_COORDS(1) 54 | float4 pos: SV_POSITION; 55 | float4 localvertex: TEXCOORD3; 56 | }; 57 | 58 | float rand(float3 co) 59 | { 60 | return frac(sin(dot(co.xyz, float3(12.9898, 78.233, 45.5432))) * 43758.5453); 61 | } 62 | 63 | uniform float4 _Color; 64 | uniform float _Switch; 65 | uniform float _Switch2; 66 | uniform float _Switch3; 67 | uniform fixed _Saturation; 68 | uniform fixed _Luminosity; 69 | uniform half _Spread; 70 | uniform half _SpeedRainbow; 71 | uniform float _ScrollSpeeds; 72 | uniform float _Speed; 73 | uniform float _uvScroll; 74 | uniform float _SwitchX; 75 | uniform float _SwitchY; 76 | uniform float _SwitchZ; 77 | uniform float _SwitchR; 78 | uniform sampler2D _MainTex; uniform float4 _MainTex_ST; 79 | 80 | inline fixed hueToRGB(float v1, float v2, float vH) 81 | { 82 | if (vH < 0.0) vH += 1.0; 83 | if(vH > 1.0) vH -= 1.0; 84 | if((6.0 * vH) < 1.0) return(v1 + (v2 - v1) * 6.0 * vH); 85 | if((2.0 * vH) < 1.0) return(v2); 86 | if((3.0 * vH) < 2.0) return(v1 + (v2 - v1) * ((2.0 / 3.0) - vH) * 6.0); 87 | return v1; 88 | } 89 | 90 | inline fixed4 HSLtoRGB(fixed4 hsl) 91 | { 92 | fixed4 rgb = fixed4(0.0, 0.0, 0.0, hsl.w); 93 | 94 | if(hsl.y == 0) 95 | { 96 | rgb.xyz = hsl.zzz; 97 | } 98 | else 99 | { 100 | float v1; 101 | float v2; 102 | 103 | if(hsl.z < 0.5) v2 = hsl.z * (1 + hsl.y); 104 | else v2 = (hsl.z + hsl.y) - (hsl.y * hsl.z); 105 | 106 | v1 = 2.0 * hsl.z - v2; 107 | 108 | rgb.x = hueToRGB(v1, v2, hsl.x + (1.0 / 3.0)); 109 | rgb.y = hueToRGB(v1, v2, hsl.x); 110 | rgb.z = hueToRGB(v1, v2, hsl.x - (1.0 / 3.0)); 111 | } 112 | return rgb; 113 | } 114 | 115 | float2x2 rotateFnc(float degrees) 116 | { 117 | float alpha = degrees * UNITY_PI / 180.0; 118 | float sina, cosa; 119 | sincos(alpha, sina, cosa); 120 | return float2x2(cosa, -sina, sina, cosa); 121 | } 122 | 123 | float4 RotateX(float4 a, float degrees) 124 | { 125 | float2x2 m = rotateFnc(degrees); 126 | return float4(mul(m, a.xz), a.yw).xzyw; 127 | } 128 | 129 | float4 RotateY(float4 a, float degrees) 130 | { 131 | float2x2 m = rotateFnc(degrees); 132 | return float4(a.x, mul(m, a.yz), a.w).xyzw; 133 | } 134 | 135 | float4 RotateZ(float4 a, float degrees) 136 | { 137 | float2x2 m = rotateFnc(degrees); 138 | return float4(mul(m, a.xy), a.zw).xyzw; 139 | } 140 | 141 | float4 RotateR(float4 a, float degrees) 142 | { 143 | float2x2 m = rotateFnc(degrees); 144 | float4 a2 = float4(mul(m, a.xz), a.yw).xzyw; 145 | float4 a3 = float4(a2.x, mul(m, a2.yz), a2.w).xyzw; 146 | return float4(mul(m, a3.xy), a3.zw).xyzw; 147 | } 148 | 149 | float4 allInOne(float4 a) 150 | { 151 | float4 aRotate = 0; 152 | aRotate += lerp(0, RotateX(a, _Time.z * _Speed * 10), _SwitchX); 153 | aRotate += lerp(0, RotateY(a, _Time.z * _Speed * 10), _SwitchY); 154 | aRotate += lerp(0, RotateZ(a, _Time.z * _Speed * 10), _SwitchZ); 155 | aRotate += lerp(0, RotateR(a, _Time.z * _Speed * 10), _SwitchR); 156 | return aRotate; 157 | } 158 | 159 | v2g vert(appdata_full v) 160 | { 161 | v2g o; 162 | o.vertex = v.vertex; 163 | o.pos = UnityObjectToClipPos(v.vertex); 164 | o.uv = v.texcoord; 165 | o.normal = v.normal; 166 | UNITY_TRANSFER_FOG(o, o.vertex); 167 | return o; 168 | } 169 | 170 | [maxvertexcount(3)] 171 | void geom(triangle v2g v[3], inout TriangleStream < g2f > tristream) 172 | { 173 | g2f o; 174 | 175 | o.uv = (v[0].uv + v[1].uv + v[2].uv) / 3; 176 | 177 | for (int i = 0; i < 3; i ++) 178 | { 179 | o.pos = v[i].pos; 180 | o.localvertex = v[i].vertex; 181 | tristream.Append(o); 182 | } 183 | } 184 | 185 | fixed4 frag(g2f i): SV_Target 186 | { 187 | fixed4 lPos = i.localvertex / _Spread; 188 | half time = _Time.y * _SpeedRainbow / _Spread; 189 | fixed hue = 0; 190 | hue += lerp(0, (-lPos.x) / 2., _Switch2); 191 | hue += lerp(0, (-lPos.y) / 2., _Switch3); 192 | if(hue == 0) 193 | { 194 | hue += ((-lPos.x - lPos.y - lPos.z) / 3.) / 2.; 195 | } 196 | hue += time; 197 | while(hue < 0.0) hue += 1.0; 198 | while(hue > 1.0) hue -= 1.0; 199 | fixed4 hsl = fixed4(hue, _Saturation, _Luminosity, 1.0); 200 | // sample the texture 201 | fixed4 col = tex2D(_MainTex, lerp(allInOne(float4(i.uv, 0, 0)), i.uv + _ScrollSpeeds * _Time.z, _uvScroll)); 202 | col.rgb *= lerp(_Color, HSLtoRGB(hsl), _Switch); 203 | // apply fog 204 | UNITY_APPLY_FOG(i.fogCoord, col); 205 | return col; 206 | } 207 | ENDCG 208 | 209 | } 210 | } 211 | Fallback "Deffuse" 212 | } 213 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # Everyday One Shader - For Study Purpose 2 | 3 | USING POST PROCCESSING STACK MAKES MY SHADERS MUCH BETTER 4 | 5 | ### HologramIllumination.shader 6 | 7 | ![HologramIllumination.shader](https://github.com/nkihrk/everyday-one-shader/blob/master/images/bandicam_2018-09-01_08-50-44-304.gif) 8 | 9 | ### IceShader.shader 10 | 11 | ![IceShader.shader](https://github.com/nkihrk/everyday-one-shader/blob/master/images/bandicam_2018-09-03_22-59-01-611.gif) 12 | 13 | ### PlasticShader.shader 14 | 15 | ![PlasticShader.shader](https://github.com/nkihrk/everyday-one-shader/blob/master/images/PlasticShader.gif) 16 | 17 | ### BurningEffect.shader 18 | 19 | ![BurningEffect.shader_1](https://github.com/nkihrk/everyday-one-shader/blob/master/images/bandicam_2018-09-06_23-28-09-416.gif) 20 | 21 | ### FireShader.shader 22 | 23 | ![FireShader.shader_1](https://github.com/nkihrk/everyday-one-shader/blob/master/images/bandicam_2018-09-12_01-08-48-646.gif) 24 | 25 | ### BurningOutlineShader.shader 26 | 27 | ![BurningOutlineShader.shader_2](https://github.com/nkihrk/everyday-one-shader/blob/master/images/bandicam_2018-09-15_17-39-52-972.gif) 28 | 29 | ### BRDFTranslucentSSS.shader 30 | 31 | ![BRDFTranslucentSSS.shader_1](https://github.com/nkihrk/everyday-one-shader/blob/master/images/BRDFTranslucentSSS.gif) 32 | 33 | ### UnlitWaterFallShader.shader / UnlitWater.shader 34 | 35 | ![UnlitWaterFallShader.shader / UnlitWater.shader](https://github.com/nkihrk/everyday-one-shader/blob/master/images/UnlitWaterFall.gif) 36 | -------------------------------------------------------------------------------- /RimLighting.shader: -------------------------------------------------------------------------------- 1 | Shader "Custom/RimLighting" 2 | { 3 | Properties 4 | { 5 | _MainTex ("Texture", 2D) = "white" { } 6 | [Header(Rim lighting Settings)] 7 | _RimTint ("Rim Tint", Color) = (1, 1, 1, 1) 8 | _RimPower ("Rim Power", Float) = 1 9 | _RimAmplitude ("Rim Amplitude", Float) = 1 10 | } 11 | SubShader 12 | { 13 | Tags { "Queue" = "Transparent" "RenderType" = "Transparent" } 14 | LOD 100 15 | 16 | Pass 17 | { 18 | CGPROGRAM 19 | 20 | #pragma vertex vert 21 | #pragma fragment frag 22 | // make fog work 23 | #pragma multi_compile_fog 24 | 25 | #include "UnityCG.cginc" 26 | 27 | struct appdata 28 | { 29 | float4 vertex: POSITION; 30 | float3 normal: NORMAL; 31 | float2 uv: TEXCOORD0; 32 | float4 color: COLOR; 33 | }; 34 | 35 | struct v2f 36 | { 37 | float4 vertex: SV_POSITION; 38 | float2 uv: TEXCOORD0; 39 | float4 color: TEXCOORD1; 40 | float3 normal: TEXCOORD2; 41 | float4 wpos: TEXCOORD3; 42 | UNITY_FOG_COORDS(4) 43 | }; 44 | 45 | uniform float _RimPower; 46 | uniform float _RimAmplitude; 47 | uniform float4 _RimTint; 48 | uniform sampler2D _MainTex; uniform float4 _MainTex_ST; 49 | 50 | v2f vert(appdata v) 51 | { 52 | v2f o; 53 | 54 | o.vertex = UnityObjectToClipPos(v.vertex); 55 | o.uv = v.uv; 56 | o.normal = v.normal; 57 | o.wpos = mul(unity_ObjectToWorld, v.vertex); 58 | o.color = v.color; 59 | UNITY_TRANSFER_FOG(o, o.vertex); 60 | return o; 61 | }; 62 | 63 | fixed4 frag(v2f i): SV_Target 64 | { 65 | fixed4 col = tex2D(_MainTex, i.uv); 66 | float3 normalDir = normalize(i.normal); 67 | float3 viewDir = normalize(_WorldSpaceCameraPos.xyz - i.wpos.xyz); 68 | float NNdotV = 1 - dot(normalDir, viewDir); 69 | float rim = pow(NNdotV, _RimPower) * _RimAmplitude; 70 | col.rgb = col.rgb * _RimTint.a + rim * _RimTint.rgb; 71 | // apply fog 72 | UNITY_APPLY_FOG(i.fogCoord, col); 73 | return col; 74 | } 75 | ENDCG 76 | 77 | } 78 | } 79 | Fallback "Diffuse" 80 | } 81 | -------------------------------------------------------------------------------- /RotateMesh.shader: -------------------------------------------------------------------------------- 1 | Shader "Custom/RotateMesh" 2 | { 3 | Properties 4 | { 5 | _MainTex ("Texture", 2D) = "white" { } 6 | _Color ("Main Color", Color) = (1.0, 1.0, 1.0, 1.0) 7 | _Speed ("Rotation Speed", Float) = 1.0 8 | _Cutoff ("Alpha Cutoff", Range(0.0, 1.0)) = 0.5 9 | [Toggle]_SwitchX ("Rotate around X axis", Float) = 0.0 10 | [Toggle]_SwitchY ("Rotate around Y axis", Float) = 0.0 11 | [Toggle]_SwitchZ ("Rotate around Z axis", Float) = 0.0 12 | [Toggle]_SwitchR ("Rotate randomly", Float) = 0.0 13 | //_EmissionTex ("Emission", 2D) = "white" {} 14 | //_EmissionColor("Emission Color", Color) = (1.0, 1.0, 1.0, 1.0) 15 | } 16 | SubShader 17 | { 18 | Pass 19 | { 20 | Tags { "Queue" = "Transparent" "IgnoreProjector" = "True" "RenderType" = "TransparentCutout" } 21 | LOD 100 22 | 23 | Cull Off 24 | ZWrite On 25 | 26 | CGPROGRAM 27 | 28 | #pragma vertex vert 29 | #pragma fragment frag 30 | // make fog work 31 | #pragma multi_compile_fog 32 | 33 | #include "UnityCG.cginc" 34 | 35 | struct appdata 36 | { 37 | float4 vertex: POSITION; 38 | float2 uv: TEXCOORD0; 39 | }; 40 | 41 | struct v2f 42 | { 43 | float2 uv: TEXCOORD0; 44 | UNITY_FOG_COORDS(1) 45 | float4 vertex: SV_POSITION; 46 | }; 47 | 48 | uniform sampler2D _MainTex; uniform float4 _MainTex_ST; 49 | uniform float _Speed; 50 | uniform float _SwitchX; 51 | uniform float _SwitchY; 52 | uniform float _SwitchZ; 53 | uniform float _SwitchR; 54 | uniform float _Cutoff; 55 | uniform fixed4 _Color; 56 | uniform half4 _EmissionColor; 57 | uniform sampler2D _EmissionTex; 58 | 59 | float4 RotateMeshX(float4 vertex, float degrees) 60 | { 61 | float alpha = degrees * UNITY_PI / 180.0; 62 | float sina, cosa; 63 | sincos(alpha, sina, cosa); 64 | float2x2 m = float2x2(cosa, -sina, sina, cosa); 65 | return float4(mul(m, vertex.xz), vertex.yw).xzyw; 66 | } 67 | 68 | float4 RotateMeshY(float4 vertex, float degrees) 69 | { 70 | float alpha = degrees * UNITY_PI / 180.0; 71 | float sina, cosa; 72 | sincos(alpha, sina, cosa); 73 | float2x2 m = float2x2(cosa, -sina, sina, cosa); 74 | return float4(vertex.x, mul(m, vertex.yz), vertex.w).xyzw; 75 | } 76 | 77 | float4 RotateMeshZ(float4 vertex, float degrees) 78 | { 79 | float alpha = degrees * UNITY_PI / 180.0; 80 | float sina, cosa; 81 | sincos(alpha, sina, cosa); 82 | float2x2 m = float2x2(cosa, -sina, sina, cosa); 83 | return float4(mul(m, vertex.xy), vertex.zw).xyzw; 84 | } 85 | 86 | float4 RotateMeshR(float4 vertex, float degrees) 87 | { 88 | float alpha = degrees * UNITY_PI / 180.0; 89 | float sina, cosa; 90 | sincos(alpha, sina, cosa); 91 | float2x2 m = float2x2(cosa, -sina, sina, cosa); 92 | float4 vertex2 = float4(mul(m, vertex.xz), vertex.yw).xzyw; 93 | float4 vertex3 = float4(vertex2.x, mul(m, vertex2.yz), vertex2.w).xyzw; 94 | return float4(mul(m, vertex3.xy), vertex3.zw).xyzw; 95 | } 96 | 97 | v2f vert(appdata v) 98 | { 99 | v2f o; 100 | float4 vertexRotate = 0; 101 | vertexRotate += lerp(0, RotateMeshX(v.vertex, _Time.z * _Speed * 10), _SwitchX); 102 | vertexRotate += lerp(0, RotateMeshY(v.vertex, _Time.z * _Speed * 10), _SwitchY); 103 | vertexRotate += lerp(0, RotateMeshZ(v.vertex, _Time.z * _Speed * 10), _SwitchZ); 104 | vertexRotate += lerp(0, RotateMeshR(v.vertex, _Time.z * _Speed * 10), _SwitchR); 105 | if (vertexRotate.x == 0 && vertexRotate.y == 0 && vertexRotate.z == 0) 106 | { 107 | vertexRotate = v.vertex; 108 | } 109 | o.vertex = UnityObjectToClipPos(vertexRotate); 110 | o.uv = TRANSFORM_TEX(v.uv, _MainTex); 111 | UNITY_TRANSFER_FOG(o, o.vertex); 112 | return o; 113 | } 114 | 115 | fixed4 frag(v2f i): SV_Target 116 | { 117 | fixed4 col = tex2D(_MainTex, i.uv) * _Color; 118 | float t = ((2 * _SinTime.w * _CosTime.w) + 1.0) * 0.5; 119 | float e = tex2D(_EmissionTex, i.uv).a * t; 120 | //col += _EmissionColor * e; 121 | clip(col.a - _Cutoff); 122 | // apply fog 123 | UNITY_APPLY_FOG(i.fogCoord, col); 124 | return col; 125 | } 126 | ENDCG 127 | 128 | } 129 | } 130 | Fallback "Diffuse" 131 | } 132 | -------------------------------------------------------------------------------- /RotateWireVoxel.shader: -------------------------------------------------------------------------------- 1 | Shader "Custom/RotateWireVoxel" 2 | { 3 | Properties 4 | { 5 | [Header(Voxel Setting)] 6 | _Scale ("Box Scale", float) = 0.005 7 | _Color ("Wire Color", Color) = (1., 1., 1., 1.) 8 | _WireframeVal ("Wireframe width", Range(0., 0.34)) = 0.05 9 | [Header(Rotate Settings)] 10 | _Speed ("Rotation Speed", Float) = 1.0 11 | [Toggle]_SwitchX ("Rotate around X axis", Float) = 0.0 12 | [Toggle]_SwitchY ("Rotate around Y axis", Float) = 0.0 13 | [Toggle]_SwitchZ ("Rotate around Z axis", Float) = 0.0 14 | [Toggle]_SwitchR ("Rotate randomly", Float) = 0.0 15 | } 16 | 17 | CGINCLUDE 18 | #include "UnityCG.cginc" 19 | 20 | uniform float _Speed; 21 | uniform float _SwitchX; 22 | uniform float _SwitchY; 23 | uniform float _SwitchZ; 24 | uniform float _SwitchR; 25 | 26 | float2x2 rotateFnc(float degrees) 27 | { 28 | float alpha = degrees * UNITY_PI / 180.0; 29 | float sina, cosa; 30 | sincos(alpha, sina, cosa); 31 | return float2x2(cosa, -sina, sina, cosa); 32 | } 33 | 34 | float4 RotateX(float4 a, float degrees) 35 | { 36 | float2x2 m = rotateFnc(degrees); 37 | return float4(mul(m, a.xz), a.yw).xzyw; 38 | } 39 | 40 | float4 RotateY(float4 a, float degrees) 41 | { 42 | float2x2 m = rotateFnc(degrees); 43 | return float4(a.x, mul(m, a.yz), a.w).xyzw; 44 | } 45 | 46 | float4 RotateZ(float4 a, float degrees) 47 | { 48 | float2x2 m = rotateFnc(degrees); 49 | return float4(mul(m, a.xy), a.zw).xyzw; 50 | } 51 | 52 | float4 RotateR(float4 a, float degrees) 53 | { 54 | float2x2 m = rotateFnc(degrees); 55 | float4 a2 = float4(mul(m, a.xz), a.yw).xzyw; 56 | float4 a3 = float4(a2.x, mul(m, a2.yz), a2.w).xyzw; 57 | return float4(mul(m, a3.xy), a3.zw).xyzw; 58 | } 59 | 60 | float4 allInOne(float4 a) 61 | { 62 | float4 aRotate = 0; 63 | aRotate += lerp(0, RotateX(a, _Time.z * _Speed * 10), _SwitchX); 64 | aRotate += lerp(0, RotateY(a, _Time.z * _Speed * 10), _SwitchY); 65 | aRotate += lerp(0, RotateZ(a, _Time.z * _Speed * 10), _SwitchZ); 66 | aRotate += lerp(0, RotateR(a, _Time.z * _Speed * 10), _SwitchR); 67 | return aRotate; 68 | } 69 | 70 | #define convertToClip1(v) o.vertex = UnityObjectToClipPos(v); o.bary = float3(1., 0., 0.); UNITY_TRANSFER_FOG(o, o.vertex); TriStream.Append(o); 71 | #define convertToClip2(v) o.vertex = UnityObjectToClipPos(v); o.bary = float3(0., 1., 0.); UNITY_TRANSFER_FOG(o, o.vertex); TriStream.Append(o); 72 | #define convertToClip3(v) o.vertex = UnityObjectToClipPos(v); o.bary = float3(0., 0., 1.); UNITY_TRANSFER_FOG(o, o.vertex); TriStream.Append(o); 73 | #define makeTri(v1, v2, v3) convertToClip1(v1) convertToClip2(v2) convertToClip3(v3) TriStream.RestartStrip(); 74 | ENDCG 75 | 76 | SubShader 77 | { 78 | Tags { "Queue" = "Transparent" } 79 | LOD 100 80 | 81 | pass 82 | { 83 | Cull Front 84 | CGPROGRAM 85 | 86 | #pragma vertex vert 87 | #pragma fragment frag 88 | #pragma geometry geo 89 | 90 | #include "UnityCG.cginc" 91 | 92 | struct appdata 93 | { 94 | float2 uv: TEXCOORD0; 95 | float4 vertex: POSITION; 96 | float4 color: COLOR; 97 | }; 98 | 99 | struct v2f 100 | { 101 | float2 uv: TEXCOORD0; 102 | float4 color: TEXCOORD2; 103 | float4 wpos: TEXCOORD3; 104 | float4 vertex: SV_POSITION; 105 | float3 bary: TEXCOORD5; 106 | }; 107 | 108 | uniform sampler2D _MainTex; uniform float4 _MainTex_ST; 109 | uniform float _Scale; 110 | uniform float _WireframeVal; 111 | uniform fixed4 _Color; 112 | 113 | v2f vert(appdata v) 114 | { 115 | v2f o; 116 | o.vertex = v.vertex; 117 | o.color = v.color; 118 | o.wpos = mul(unity_ObjectToWorld, v.vertex); 119 | o.bary = float3(0., 0., 0.); 120 | return o; 121 | } 122 | 123 | [maxvertexcount(36)] 124 | void geo(triangle v2f v[3], inout TriangleStream < v2f > TriStream) 125 | { 126 | float4 wpos = (v[0].wpos + v[1].wpos + v[2].wpos) / 3; 127 | float4 vertex = (v[0].vertex + v[1].vertex + v[2].vertex) / 3; 128 | 129 | v2f o = v[0]; 130 | o.wpos = wpos; 131 | 132 | float4 a[8]; 133 | a[0] = float4(1, 1, 1, 0); 134 | a[1] = float4(1, 1, -1, 0); 135 | a[2] = float4(1, -1, 1, 0); 136 | a[3] = float4(1, -1, -1, 0); 137 | a[4] = float4(-1, 1, 1, 0); 138 | a[5] = float4(-1, 1, -1, 0); 139 | a[6] = float4(-1, -1, 1, 0); 140 | a[7] = float4(-1, -1, -1, 0); 141 | float4 vertexR[8]; 142 | for (int i = 0; i < 8; i ++) 143 | { 144 | vertexR[i] = allInOne(a[i]); 145 | if (vertexR[i].x == 0 && vertexR[i].y == 0 && vertexR[i].z == 0) 146 | { 147 | vertexR[i] = a[i]; 148 | } 149 | } 150 | float4 v0 = (vertexR[0] + float4(0, 0, 0, 1)) * _Scale + float4(vertex.xyz, 0); 151 | float4 v1 = (vertexR[1] + float4(0, 0, 0, 1)) * _Scale + float4(vertex.xyz, 0); 152 | float4 v2 = (vertexR[2] + float4(0, 0, 0, 1)) * _Scale + float4(vertex.xyz, 0); 153 | float4 v3 = (vertexR[3] + float4(0, 0, 0, 1)) * _Scale + float4(vertex.xyz, 0); 154 | float4 v4 = (vertexR[4] + float4(0, 0, 0, 1)) * _Scale + float4(vertex.xyz, 0); 155 | float4 v5 = (vertexR[5] + float4(0, 0, 0, 1)) * _Scale + float4(vertex.xyz, 0); 156 | float4 v6 = (vertexR[6] + float4(0, 0, 0, 1)) * _Scale + float4(vertex.xyz, 0); 157 | float4 v7 = (vertexR[7] + float4(0, 0, 0, 1)) * _Scale + float4(vertex.xyz, 0); 158 | makeTri(v0, v2, v3); 159 | makeTri(v3, v1, v0); 160 | makeTri(v5, v7, v6); 161 | makeTri(v6, v4, v5); 162 | makeTri(v4, v0, v1); 163 | makeTri(v1, v5, v4); 164 | makeTri(v7, v3, v2); 165 | makeTri(v2, v6, v7); 166 | makeTri(v6, v2, v0); 167 | makeTri(v0, v4, v6); 168 | makeTri(v5, v1, v3); 169 | makeTri(v3, v7, v5); 170 | } 171 | 172 | fixed4 frag(v2f i): SV_Target 173 | { 174 | if(!any(bool3(i.bary.x < _WireframeVal, i.bary.y < _WireframeVal, i.bary.z < _WireframeVal))) discard; 175 | return _Color; 176 | } 177 | ENDCG 178 | 179 | } 180 | 181 | pass 182 | { 183 | Cull Back 184 | CGPROGRAM 185 | 186 | #pragma vertex vert 187 | #pragma fragment frag 188 | #pragma geometry geo 189 | 190 | #include "UnityCG.cginc" 191 | 192 | struct appdata 193 | { 194 | float2 uv: TEXCOORD0; 195 | float4 vertex: POSITION; 196 | float4 color: COLOR; 197 | }; 198 | 199 | struct v2f 200 | { 201 | float2 uv: TEXCOORD0; 202 | float4 color: TEXCOORD2; 203 | float4 wpos: TEXCOORD3; 204 | float4 vertex: SV_POSITION; 205 | float3 bary: TEXCOORD5; 206 | }; 207 | 208 | uniform sampler2D _MainTex; uniform float4 _MainTex_ST; 209 | uniform float _Scale; 210 | uniform float _WireframeVal; 211 | uniform fixed4 _Color; 212 | 213 | v2f vert(appdata v) 214 | { 215 | v2f o; 216 | o.vertex = v.vertex; 217 | o.color = v.color; 218 | o.wpos = mul(unity_ObjectToWorld, v.vertex); 219 | o.bary = float3(0., 0., 0.); 220 | return o; 221 | } 222 | 223 | [maxvertexcount(36)] 224 | void geo(triangle v2f v[3], inout TriangleStream < v2f > TriStream) 225 | { 226 | float4 wpos = (v[0].wpos + v[1].wpos + v[2].wpos) / 3; 227 | float4 vertex = (v[0].vertex + v[1].vertex + v[2].vertex) / 3; 228 | 229 | v2f o = v[0]; 230 | o.wpos = wpos; 231 | 232 | float4 a[8]; 233 | a[0] = float4(1, 1, 1, 0); 234 | a[1] = float4(1, 1, -1, 0); 235 | a[2] = float4(1, -1, 1, 0); 236 | a[3] = float4(1, -1, -1, 0); 237 | a[4] = float4(-1, 1, 1, 0); 238 | a[5] = float4(-1, 1, -1, 0); 239 | a[6] = float4(-1, -1, 1, 0); 240 | a[7] = float4(-1, -1, -1, 0); 241 | float4 vertexR[8]; 242 | for (int i = 0; i < 8; i ++) 243 | { 244 | vertexR[i] = allInOne(a[i]); 245 | if (vertexR[i].x == 0 && vertexR[i].y == 0 && vertexR[i].z == 0) 246 | { 247 | vertexR[i] = a[i]; 248 | } 249 | } 250 | float4 v0 = (vertexR[0] + float4(0, 0, 0, 1)) * _Scale + float4(vertex.xyz, 0); 251 | float4 v1 = (vertexR[1] + float4(0, 0, 0, 1)) * _Scale + float4(vertex.xyz, 0); 252 | float4 v2 = (vertexR[2] + float4(0, 0, 0, 1)) * _Scale + float4(vertex.xyz, 0); 253 | float4 v3 = (vertexR[3] + float4(0, 0, 0, 1)) * _Scale + float4(vertex.xyz, 0); 254 | float4 v4 = (vertexR[4] + float4(0, 0, 0, 1)) * _Scale + float4(vertex.xyz, 0); 255 | float4 v5 = (vertexR[5] + float4(0, 0, 0, 1)) * _Scale + float4(vertex.xyz, 0); 256 | float4 v6 = (vertexR[6] + float4(0, 0, 0, 1)) * _Scale + float4(vertex.xyz, 0); 257 | float4 v7 = (vertexR[7] + float4(0, 0, 0, 1)) * _Scale + float4(vertex.xyz, 0); 258 | makeTri(v0, v2, v3); 259 | makeTri(v3, v1, v0); 260 | makeTri(v5, v7, v6); 261 | makeTri(v6, v4, v5); 262 | makeTri(v4, v0, v1); 263 | makeTri(v1, v5, v4); 264 | makeTri(v7, v3, v2); 265 | makeTri(v2, v6, v7); 266 | makeTri(v6, v2, v0); 267 | makeTri(v0, v4, v6); 268 | makeTri(v5, v1, v3); 269 | makeTri(v3, v7, v5); 270 | } 271 | 272 | fixed4 frag(v2f i): SV_Target 273 | { 274 | if(!any(bool3(i.bary.x < _WireframeVal, i.bary.y < _WireframeVal, i.bary.z < _WireframeVal))) discard; 275 | return _Color; 276 | } 277 | ENDCG 278 | 279 | } 280 | } 281 | Fallback "Diffuse" 282 | } 283 | -------------------------------------------------------------------------------- /ToonShading.shader: -------------------------------------------------------------------------------- 1 | Shader "Custom/ToonShading" 2 | { 3 | Properties 4 | { 5 | _MainTex ("Texture", 2D) = "white" { } 6 | _FetchTex ("Fetching Texture", 2D) = "white" { } 7 | _Color ("Color", Color) = (0.0, 0.0, 0.0, 1.0) 8 | _Ambient ("Ambient Color", Color) = (0.1, 0.1, 0.4, 1) 9 | _Diffuse ("Diffuse", Color) = (0.3, 0.3, 1, 1) 10 | _DiffuseH ("Diffuse Half", Color) = (1.0, 1.0, 1.0, 1) 11 | _DiffuseHH ("Diffuse Half Half", Color) = (1.0, 1.0, 1.0, 1) 12 | _DiffuseBorder ("Diffuse Border", Range(0.01, 1)) = 0.2 13 | _DiffuseBorderBlur ("Diffuse Border Blur", Range(0.01, 0.2)) = 0.01 14 | _Shininess ("shininess", Range(0.01, 1)) = 0.7 15 | _Specular ("Specular Color", Color) = (1, 1, 1, 1) 16 | _SpecularBorder ("_SpecularBorder", Range(0.01, 1)) = 0.5 17 | _SpecularBorderBlur ("Specular Border Blur", Range(0.01, 0.2)) = 0.01 18 | } 19 | SubShader 20 | { 21 | Tags { "RenderType" = "Opaque" } 22 | //Blend DstColor Zero 23 | LOD 100 24 | 25 | Pass 26 | { 27 | CGPROGRAM 28 | 29 | #pragma vertex vert 30 | #pragma fragment frag 31 | // make fog work 32 | #pragma multi_compile_fog 33 | 34 | #include "UnityCG.cginc" 35 | 36 | struct appdata 37 | { 38 | float4 vertex: POSITION; 39 | float2 uv: TEXCOORD0; 40 | float3 normal: NORMAL; 41 | float2 fuv: TEXCOORD1; 42 | }; 43 | 44 | struct v2f 45 | { 46 | float2 uv: TEXCOORD0; 47 | UNITY_FOG_COORDS(1) 48 | float4 vertex: SV_POSITION; 49 | fixed4 color: COLOR; 50 | float3 normal: TEXCOORD2; 51 | float3 lightDir: TEXCOORD3; 52 | float3 reflectDir: TEXCOORD4; 53 | float4 wpos: TEXCOORD5; 54 | float2 fuv: TEXCOORD6; 55 | }; 56 | 57 | uniform sampler2D _MainTex; uniform float4 _MainTex_ST; 58 | uniform sampler2D _FetchTex; uniform float4 _FetchTex_ST; 59 | uniform fixed4 _Color; 60 | uniform fixed4 _Ambient; 61 | uniform fixed4 _Diffuse; 62 | uniform fixed4 _DiffuseH; 63 | uniform fixed4 _DiffuseHH; 64 | uniform float _DiffuseBorder; 65 | uniform float _DiffuseBorderBlur; 66 | uniform float _Shininess; 67 | uniform fixed4 _Specular; 68 | uniform float _SpecularBorder; 69 | uniform float _SpecularBorderBlur; 70 | 71 | v2f vert(appdata v) 72 | { 73 | v2f o; 74 | o.vertex = UnityObjectToClipPos(v.vertex); 75 | o.uv = TRANSFORM_TEX(v.uv, _MainTex); 76 | o.fuv = TRANSFORM_TEX(v.fuv, _FetchTex); 77 | UNITY_TRANSFER_FOG(o, o.vertex); 78 | o.color = _Color; 79 | o.normal = UnityObjectToWorldNormal(v.normal); 80 | o.lightDir = WorldSpaceLightDir(v.vertex); 81 | float3 viewDir = ObjSpaceViewDir(v.vertex); 82 | o.reflectDir = reflect(-viewDir, v.normal); 83 | o.wpos = mul(unity_ObjectToWorld, v.vertex); 84 | return o; 85 | } 86 | 87 | fixed4 frag(v2f i): SV_Target 88 | { 89 | float4 fetchTex = tex2D(_FetchTex, i.fuv); 90 | float scalar = max(fetchTex.r, max(fetchTex.g, fetchTex.b)); 91 | 92 | float3 L = normalize(i.lightDir); 93 | float3 N = normalize(i.normal); 94 | float3 R = normalize(i.reflectDir); 95 | 96 | //ノーマルとライトベクトルの内積 97 | float NdotL = clamp(dot(N, L), 0, 1); 98 | float I_d = NdotL; 99 | 100 | float hI_d = NdotL / 3.0; 101 | 102 | //float hhI_d = hI_d / 2.0; 103 | 104 | float3 viewDir = normalize(_WorldSpaceCameraPos - i.wpos.xyz); 105 | float NNdotV = 1 - dot(N, viewDir); 106 | 107 | float hhI_d = NNdotV / 3.0; 108 | 109 | //ノーマルと反射ベクトルの内積 110 | //float NdotR = clamp(dot(N, R), 0, 1); 111 | 112 | //ライトベクトルと反射ベクトルの内積 113 | float LdotR = clamp(dot(L, R), 0, 1); 114 | float shininess = pow(500.0, _Shininess); 115 | float I_s = pow(LdotR, shininess); 116 | 117 | float4 c_a = _Ambient; 118 | float t_d = smoothstep(_DiffuseBorder, _DiffuseBorder, I_d); 119 | float4 c_d = lerp(c_a, _Diffuse, t_d); 120 | 121 | float hc_a = _DiffuseH; 122 | float ht_d = smoothstep(_DiffuseBorder, _DiffuseBorder, hI_d); 123 | float4 hc_d = lerp(c_d, hc_a, ht_d); 124 | 125 | float hhc_a = _DiffuseHH; 126 | float hht_d = smoothstep(_DiffuseBorder, _DiffuseBorder, hhI_d); 127 | float4 hhc_d = lerp(hc_d, hhc_a, hht_d); 128 | 129 | float t_s = smoothstep(_SpecularBorder - _SpecularBorderBlur, _SpecularBorder + _SpecularBorderBlur, I_s); 130 | float4 c = lerp(hhc_d, _Specular, t_s); 131 | 132 | // sample the texture 133 | //fixed4 col = lerp(tex2D(_MainTex, i.uv), fetchTex, 0.5) * c; 134 | fixed4 col = tex2D(_MainTex, i.uv) * c; 135 | col.rgb = dot(col.rgb, float3(0.3, 0.59, 0.11)); 136 | // apply fog 137 | UNITY_APPLY_FOG(i.fogCoord, col); 138 | return col; 139 | } 140 | ENDCG 141 | 142 | } 143 | } 144 | Fallback "Diffuse" 145 | } 146 | -------------------------------------------------------------------------------- /UVScrollShader.shader: -------------------------------------------------------------------------------- 1 | Shader "Custom/UVScrollShader" 2 | { 3 | Properties 4 | { 5 | _EmissionColor ("Emission Color", Color) = (1.0, 1.0, 1.0, 1.0) 6 | _MainTex ("Base (RGB) Trans (A)", 2D) = "white" { } 7 | _Color ("Main Color", Color) = (1.0, 1.0, 1.0, 1.0) 8 | _Cutoff ("Alpha cutoff", Range(0.0, 1.0)) = 0.5 9 | _ScrollSpeeds ("Scroll Speeds", vector) = (-0.01, 0, 0, 0) 10 | _EmissionTex ("Emission", 2D) = "white" { } 11 | [Toggle(TURNING_LIGHT)] _Hoge ("Turning Light", Float) = 0 12 | } 13 | 14 | SubShader 15 | { 16 | Tags { "Queue" = "Transparent" "IgnoreProjector" = "True" "RenderType" = "TransparentCutout" } 17 | LOD 200 18 | 19 | Cull Off 20 | ZWrite on 21 | 22 | CGPROGRAM 23 | 24 | #pragma surface surf Lambert alphatest:_Cutoff 25 | #pragma shader_feature TURNING_LIGHT 26 | 27 | fixed4 _Color; 28 | float4 _ScrollSpeeds; 29 | half4 _EmissionColor; 30 | sampler2D _MainTex; 31 | sampler2D _EmissionTex; 32 | 33 | struct Input 34 | { 35 | float2 uv_MainTex; 36 | }; 37 | 38 | void surf(Input IN, inout SurfaceOutput o) 39 | { 40 | float4 d = _ScrollSpeeds * _Time.z; 41 | half4 c = tex2D(_MainTex, IN.uv_MainTex + d) * _Color; 42 | float t = ((2 * _SinTime.w * _CosTime.w) + 1.0) * 0.5; 43 | float e = tex2D(_EmissionTex, IN.uv_MainTex + d).a * t; 44 | o.Albedo = c.rgb; 45 | o.Alpha = c.a; 46 | #ifdef TURNING_LIGHT 47 | o.Emission = _EmissionColor * e; 48 | #endif 49 | } 50 | ENDCG 51 | 52 | } 53 | fallback "Diffuse" 54 | } 55 | -------------------------------------------------------------------------------- /UnlitWater.shader: -------------------------------------------------------------------------------- 1 | Shader "Custom/UnlitWater" 2 | { 3 | Properties 4 | { 5 | _NoiseTex ("Noise Texture", 2D) = "white" { } 6 | _DispTex ("Displacement Texture", 2D) = "white" { } 7 | _ColorTop ("Color Top", Color) = (1, 1, 1, 1) 8 | _ColorBottom ("Color Bottom", Color) = (0, 0, 0, 1) 9 | _Scale ("Scale", Float) = 1.0 10 | _Speed ("Speed", Float) = 1.0 11 | [Enum(OFF, 0, FRONT, 1, BACK, 2)] _CullMode ("Cull Mode", int) = 0 12 | } 13 | SubShader 14 | { 15 | Tags { "Queue" = "Transparent" } 16 | LOD 100 17 | Cull[_CullMode] 18 | 19 | Pass 20 | { 21 | CGPROGRAM 22 | 23 | #pragma vertex vert 24 | #pragma fragment frag 25 | #pragma multi_compile_fog 26 | 27 | #include "UnityCG.cginc" 28 | 29 | struct appdata 30 | { 31 | float4 vertex: POSITION; 32 | float2 uv: TEXCOORD0; 33 | }; 34 | 35 | struct v2f 36 | { 37 | float2 uv: TEXCOORD0; 38 | UNITY_FOG_COORDS(1) 39 | float4 vertex: SV_POSITION; 40 | }; 41 | 42 | uniform sampler2D _NoiseTex; uniform float4 _NoiseTex_ST; 43 | uniform sampler2D _DispTex; uniform float4 _DispTex_ST; 44 | uniform fixed4 _ColorTop; 45 | uniform fixed4 _ColorBottom; 46 | uniform float _Scale; 47 | uniform float _Speed; 48 | 49 | v2f vert(appdata v) 50 | { 51 | v2f o; 52 | o.vertex = UnityObjectToClipPos(v.vertex); 53 | o.uv = TRANSFORM_TEX(v.uv, _NoiseTex); 54 | UNITY_TRANSFER_FOG(o, o.vertex); 55 | return o; 56 | } 57 | 58 | fixed4 frag(v2f i): SV_Target 59 | { 60 | float4 dispTex = tex2D(_DispTex, float2(i.uv.x, i.uv.y + _Time.y / 5.0 * _Speed)); 61 | float4 noise = tex2D(_NoiseTex, float2(i.uv.x * 4, i.uv.y - dispTex.g)); 62 | float a = round(noise.r * 3.0) / 3.0; 63 | 64 | fixed4 col = pow(lerp(lerp(_ColorBottom, _ColorTop, i.uv.y), fixed4(1, 1, 1, 1), a), max(0, _Scale)); 65 | UNITY_APPLY_FOG(i.fogCoord, col); 66 | return col; 67 | } 68 | ENDCG 69 | 70 | } 71 | } 72 | Fallback "Diffuse" 73 | } 74 | -------------------------------------------------------------------------------- /UnlitWaterFallShader.Shader: -------------------------------------------------------------------------------- 1 | Shader "Custom/UnlitWaterFallShader" 2 | { 3 | Properties 4 | { 5 | _NoiseTex ("Noise Texture", 2D) = "white" { } 6 | _DispTex ("Displacement Texture", 2D) = "white" { } 7 | _ColorTop ("Color Top", Color) = (1, 1, 1, 1) 8 | _ColorBottom ("Color Bottom", Color) = (0, 0, 0, 1) 9 | _Speed ("Speed", Float) = 1.0 10 | _Scale ("Scale", Float) = 1.0 11 | _DispAmount ("Disp Amount", Float) = 1.0 12 | _HeightThreshold ("Height Threshold", Float) = 0.0 13 | _SpeedFoam ("Foam Speed", Float) = 1.0 14 | _DispAmountFoam ("Foam Disp Amount", Float) = 1.0 15 | _Cutoff ("Cutoff", Range(0.0, 1.0)) = 0.0 16 | [Enum(OFF, 0, FRONT, 1, BACK, 2)] _CullMode ("Cull Mode", int) = 0 17 | } 18 | SubShader 19 | { 20 | Tags { "Queue" = "Transparent" } 21 | LOD 100 22 | Blend SrcAlpha OneMinusSrcAlpha 23 | Cull[_CullMode] 24 | 25 | Pass 26 | { 27 | CGPROGRAM 28 | 29 | #pragma vertex vert 30 | #pragma fragment frag 31 | #pragma multi_compile_fog 32 | 33 | #include "UnityCG.cginc" 34 | 35 | struct appdata 36 | { 37 | float4 vertex: POSITION; 38 | float2 uv: TEXCOORD0; 39 | }; 40 | 41 | struct v2f 42 | { 43 | float2 uv: TEXCOORD0; 44 | UNITY_FOG_COORDS(1) 45 | float4 vertex: SV_POSITION; 46 | }; 47 | 48 | uniform sampler2D _NoiseTex; uniform float4 _NoiseTex_ST; 49 | uniform sampler2D _DispTex; uniform float4 _DispTex_ST; 50 | uniform float _Speed; 51 | uniform fixed4 _ColorTop; 52 | uniform fixed4 _ColorBottom; 53 | uniform float _Scale; 54 | uniform float _HeightThreshold; 55 | uniform float _Cutoff; 56 | uniform float _DispAmount; 57 | uniform float _SpeedFoam; 58 | uniform float _DispAmountFoam; 59 | 60 | v2f vert(appdata v) 61 | { 62 | v2f o; 63 | o.vertex = UnityObjectToClipPos(v.vertex); 64 | o.uv = TRANSFORM_TEX(v.uv, _NoiseTex); 65 | UNITY_TRANSFER_FOG(o, o.vertex); 66 | return o; 67 | } 68 | 69 | fixed4 frag(v2f i): SV_Target 70 | { 71 | float2 dispTex = tex2D(_DispTex, float2(i.uv.x, i.uv.y * 0.1 + _Time.x * _Speed)).xy; 72 | dispTex = ((dispTex * 2) - 1) * _DispAmount; 73 | float2 dispFoam = tex2D(_DispTex, float2(i.uv.x, i.uv.y + _Time.x * _SpeedFoam)).xy; 74 | dispFoam = ((dispFoam * 2) - 1) * _DispAmountFoam; 75 | float4 noise = tex2D(_NoiseTex, float2(i.uv.x * 1.5, i.uv.y * 0.3 + _Time.y / 3.0) - dispTex); 76 | float a = round(noise.r * 3.0) / 3.0; 77 | 78 | fixed4 col = lerp(fixed4(1, 1, 1, 1), pow(lerp(lerp(_ColorBottom, _ColorTop, i.uv.y), fixed4(1, 1, 1, 1), a), max(0, _Scale)), step(_HeightThreshold * 0.1, pow(dispFoam.r + i.uv.y, 2))); 79 | col.a = 1 - _Cutoff; 80 | UNITY_APPLY_FOG(i.fogCoord, col); 81 | return col; 82 | } 83 | ENDCG 84 | 85 | } 86 | } 87 | Fallback "Diffuse" 88 | } 89 | -------------------------------------------------------------------------------- /images/ApplicationFrameHost_2018-09-04_18-05-22.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/nkihrk/everyday-one-shader/ca86ddcd4bdc4753ceffa70a7d6d620f2fb9daf9/images/ApplicationFrameHost_2018-09-04_18-05-22.jpg -------------------------------------------------------------------------------- /images/ApplicationFrameHost_2018-09-04_18-06-24.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/nkihrk/everyday-one-shader/ca86ddcd4bdc4753ceffa70a7d6d620f2fb9daf9/images/ApplicationFrameHost_2018-09-04_18-06-24.jpg -------------------------------------------------------------------------------- /images/ApplicationFrameHost_2018-09-04_18-07-26.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/nkihrk/everyday-one-shader/ca86ddcd4bdc4753ceffa70a7d6d620f2fb9daf9/images/ApplicationFrameHost_2018-09-04_18-07-26.png -------------------------------------------------------------------------------- /images/ApplicationFrameHost_2018-09-04_18-31-54.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/nkihrk/everyday-one-shader/ca86ddcd4bdc4753ceffa70a7d6d620f2fb9daf9/images/ApplicationFrameHost_2018-09-04_18-31-54.jpg -------------------------------------------------------------------------------- /images/ApplicationFrameHost_2018-09-04_19-19-38.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/nkihrk/everyday-one-shader/ca86ddcd4bdc4753ceffa70a7d6d620f2fb9daf9/images/ApplicationFrameHost_2018-09-04_19-19-38.jpg -------------------------------------------------------------------------------- /images/ApplicationFrameHost_2018-09-04_19-21-57.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/nkihrk/everyday-one-shader/ca86ddcd4bdc4753ceffa70a7d6d620f2fb9daf9/images/ApplicationFrameHost_2018-09-04_19-21-57.png -------------------------------------------------------------------------------- /images/ApplicationFrameHost_2018-09-04_20-06-33.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/nkihrk/everyday-one-shader/ca86ddcd4bdc4753ceffa70a7d6d620f2fb9daf9/images/ApplicationFrameHost_2018-09-04_20-06-33.jpg -------------------------------------------------------------------------------- /images/ApplicationFrameHost_2018-09-07_13-21-09.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/nkihrk/everyday-one-shader/ca86ddcd4bdc4753ceffa70a7d6d620f2fb9daf9/images/ApplicationFrameHost_2018-09-07_13-21-09.jpg -------------------------------------------------------------------------------- /images/BRDFTranslucentSSS.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/nkihrk/everyday-one-shader/ca86ddcd4bdc4753ceffa70a7d6d620f2fb9daf9/images/BRDFTranslucentSSS.gif -------------------------------------------------------------------------------- /images/BRDFTranslucentSSS_2.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/nkihrk/everyday-one-shader/ca86ddcd4bdc4753ceffa70a7d6d620f2fb9daf9/images/BRDFTranslucentSSS_2.gif -------------------------------------------------------------------------------- /images/PlasticShader.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/nkihrk/everyday-one-shader/ca86ddcd4bdc4753ceffa70a7d6d620f2fb9daf9/images/PlasticShader.gif -------------------------------------------------------------------------------- /images/UnlitWaterFall.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/nkihrk/everyday-one-shader/ca86ddcd4bdc4753ceffa70a7d6d620f2fb9daf9/images/UnlitWaterFall.gif -------------------------------------------------------------------------------- /images/bandicam_2018-08-23_19-07-47-604.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/nkihrk/everyday-one-shader/ca86ddcd4bdc4753ceffa70a7d6d620f2fb9daf9/images/bandicam_2018-08-23_19-07-47-604.gif -------------------------------------------------------------------------------- /images/bandicam_2018-09-01_08-50-44-304.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/nkihrk/everyday-one-shader/ca86ddcd4bdc4753ceffa70a7d6d620f2fb9daf9/images/bandicam_2018-09-01_08-50-44-304.gif -------------------------------------------------------------------------------- /images/bandicam_2018-09-01_08-56-24-256.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/nkihrk/everyday-one-shader/ca86ddcd4bdc4753ceffa70a7d6d620f2fb9daf9/images/bandicam_2018-09-01_08-56-24-256.gif -------------------------------------------------------------------------------- /images/bandicam_2018-09-01_09-03-54-539.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/nkihrk/everyday-one-shader/ca86ddcd4bdc4753ceffa70a7d6d620f2fb9daf9/images/bandicam_2018-09-01_09-03-54-539.gif -------------------------------------------------------------------------------- /images/bandicam_2018-09-03_22-59-01-611.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/nkihrk/everyday-one-shader/ca86ddcd4bdc4753ceffa70a7d6d620f2fb9daf9/images/bandicam_2018-09-03_22-59-01-611.gif -------------------------------------------------------------------------------- /images/bandicam_2018-09-06_23-28-09-416.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/nkihrk/everyday-one-shader/ca86ddcd4bdc4753ceffa70a7d6d620f2fb9daf9/images/bandicam_2018-09-06_23-28-09-416.gif -------------------------------------------------------------------------------- /images/bandicam_2018-09-07_13-06-44-810.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/nkihrk/everyday-one-shader/ca86ddcd4bdc4753ceffa70a7d6d620f2fb9daf9/images/bandicam_2018-09-07_13-06-44-810.gif -------------------------------------------------------------------------------- /images/bandicam_2018-09-07_13-19-37-498.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/nkihrk/everyday-one-shader/ca86ddcd4bdc4753ceffa70a7d6d620f2fb9daf9/images/bandicam_2018-09-07_13-19-37-498.gif -------------------------------------------------------------------------------- /images/bandicam_2018-09-10_07-27-13-144.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/nkihrk/everyday-one-shader/ca86ddcd4bdc4753ceffa70a7d6d620f2fb9daf9/images/bandicam_2018-09-10_07-27-13-144.gif -------------------------------------------------------------------------------- /images/bandicam_2018-09-10_12-56-15-356.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/nkihrk/everyday-one-shader/ca86ddcd4bdc4753ceffa70a7d6d620f2fb9daf9/images/bandicam_2018-09-10_12-56-15-356.gif -------------------------------------------------------------------------------- /images/bandicam_2018-09-12_01-08-48-646.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/nkihrk/everyday-one-shader/ca86ddcd4bdc4753ceffa70a7d6d620f2fb9daf9/images/bandicam_2018-09-12_01-08-48-646.gif -------------------------------------------------------------------------------- /images/bandicam_2018-09-12_03-46-10-580.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/nkihrk/everyday-one-shader/ca86ddcd4bdc4753ceffa70a7d6d620f2fb9daf9/images/bandicam_2018-09-12_03-46-10-580.gif -------------------------------------------------------------------------------- /images/bandicam_2018-09-15_17-39-52-972.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/nkihrk/everyday-one-shader/ca86ddcd4bdc4753ceffa70a7d6d620f2fb9daf9/images/bandicam_2018-09-15_17-39-52-972.gif -------------------------------------------------------------------------------- /marimo.shader: -------------------------------------------------------------------------------- 1 | Shader "Custom/MARIMO" 2 | { 3 | 4 | Properties 5 | { 6 | _MainTex ("Base (RGB)", 2D) = "white" { } 7 | _NormalMap ("Normalmap", 2D) = "bump" { } 8 | _Color ("Color", color) = (1, 1, 1, 0) 9 | _SpecColor ("Specular color", color) = (0.5, 0.5, 0.5, 0.5) 10 | _MinDist ("Min Distance", Range(0.1, 50)) = 10 11 | _MaxDist ("Max Distance", Range(0.1, 50)) = 25 12 | _TessFactor ("Tessellation", Range(1, 50)) = 10 13 | _NoiseTex ("Noise Texture", 2D) = "black" {} 14 | _NoiseSpeed ("Noise Speed", Range(0.0, 10)) = 1.0 15 | _NoisePower ("Noise Power", Range(0.0, 3.0)) = 1.0 16 | _NoiseFactor ("Noise Factor", Range(0.0, 10)) = 1.0 17 | } 18 | 19 | CGINCLUDE 20 | float C2F(float3 Color) 21 | { 22 | int c1 = 255; 23 | int c2 = 255 * 255; 24 | int c3 = 255 * 255 * 255; 25 | return(Color.x * 255 + Color.y * 255 * c1 + Color.z * 255 * c2) / c3; 26 | } 27 | 28 | fixed2 rand(fixed2 st) 29 | { 30 | st = fixed2(dot(st, fixed2(127.1, 311.7)), dot(st, fixed2(269.5, 183.3))); 31 | return - 1.0 + 2.0 * frac(sin(st) * 43758.5453123); 32 | } 33 | 34 | float perlinNoise(fixed2 st) 35 | { 36 | fixed2 p = floor(st); 37 | fixed2 f = frac(st); 38 | fixed2 u = f * f * (3.0 - 2.0 * f); 39 | float v00 = rand(p + fixed2(0, 0)); 40 | float v10 = rand(p + fixed2(1, 0)); 41 | float v01 = rand(p + fixed2(0, 1)); 42 | float v11 = rand(p + fixed2(1, 1)); 43 | return lerp(lerp(dot(v00, f - fixed2(0, 0)), dot(v10, f - fixed2(1, 0)), u.x), lerp(dot(v01, f - fixed2(0, 1)), dot(v11, f - fixed2(1, 1)), u.x), u.y) + 0.5f; 44 | } 45 | 46 | float fBm(fixed2 st) 47 | { 48 | float f = 0; 49 | fixed2 q = st; 50 | f += 0.5000 * perlinNoise(q); q = q * 2.01; 51 | f += 0.2500 * perlinNoise(q); q = q * 2.02; 52 | f += 0.1250 * perlinNoise(q); q = q * 2.03; 53 | f += 0.0625 * perlinNoise(q); q = q * 2.01; 54 | return f; 55 | } 56 | ENDCG 57 | 58 | SubShader 59 | { 60 | Tags { "RenderType" = "Opaque" } 61 | Cull Off 62 | 63 | CGPROGRAM 64 | 65 | #pragma surface surf BlinnPhong addshadow fullforwardshadows vertex:disp tessellate:tessDistance nolightmap 66 | #pragma target 5.0 67 | #include "Tessellation.cginc" 68 | 69 | uniform sampler2D _MainTex; 70 | uniform sampler2D _NormalMap; 71 | uniform sampler2D _NoiseTex; 72 | uniform fixed4 _Color; 73 | uniform float _TessFactor; 74 | uniform float _MinDist; 75 | uniform float _MaxDist; 76 | uniform float _NoiseSpeed; 77 | uniform float _NoisePower; 78 | uniform float _NoiseFactor; 79 | 80 | struct appdata 81 | { 82 | float4 vertex: POSITION; 83 | float4 tangent: TANGENT; 84 | float3 normal: NORMAL; 85 | float2 texcoord: TEXCOORD0; 86 | }; 87 | 88 | struct Input 89 | { 90 | float2 uv_MainTex; 91 | }; 92 | 93 | float4 tessDistance(appdata v0, appdata v1, appdata v2) 94 | { 95 | return UnityDistanceBasedTess(v0.vertex, v1.vertex, v2.vertex, _MinDist, _MaxDist, _TessFactor); 96 | } 97 | 98 | void disp(inout appdata v) 99 | { 100 | float2 uv = v.texcoord; 101 | float angle = 180 * UNITY_PI * (_Time.x / 100 * _NoiseSpeed); 102 | float pivot = 0.5; 103 | float x = (uv.x - pivot) * cos(angle) - (uv.y - pivot) * sin(angle) + pivot; 104 | float y = (uv.x - pivot) * sin(angle) + (uv.y - pivot) * cos(angle) + pivot; 105 | uv = float2(x, y); 106 | fixed4 noiseTex = tex2Dlod(_NoiseTex, float4(uv, 0, 0)); 107 | float c2f = pow(pow(_NoisePower, _NoisePower), C2F(noiseTex.rgb)); 108 | float c = fBm(v.texcoord.xy * _Time.x * _NoiseSpeed); 109 | fixed4 prlNoise = lerp(fixed4(c, c, c, 1), fixed4(c2f, c2f, c2f, 1), saturate(noiseTex * 100)); 110 | 111 | v.vertex.xyz += v.normal * prlNoise.xyz * _NoiseFactor; 112 | } 113 | 114 | void surf(Input IN, inout SurfaceOutput o) 115 | { 116 | half4 c = tex2D(_MainTex, IN.uv_MainTex) * _Color; 117 | o.Albedo = c.rgb; 118 | o.Specular = 0.2; 119 | o.Gloss = 1.0; 120 | o.Normal = UnpackNormal(tex2D(_NormalMap, IN.uv_MainTex)); 121 | } 122 | 123 | ENDCG 124 | 125 | } 126 | 127 | FallBack "Diffuse" 128 | } --------------------------------------------------------------------------------