Created
May 12, 2023 18:58
-
-
Save unitycoder/90032fb4e22919010f95dda8aaac0fb0 to your computer and use it in GitHub Desktop.
Noise Shader Testing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Shader "Unlit/NoiseFX" | |
| { | |
| Properties | |
| { | |
| _MainTex("Texture", 2D) = "white" {} | |
| _NoiseTex("Noise Texture", 2D) = "white" {} | |
| _Tint("Tint Color", Color) = (1,1,1,1) | |
| } | |
| SubShader | |
| { | |
| Tags { "RenderType" = "Opaque" } | |
| //Blend SrcAlpha OneMinusSrcAlpha // Traditional transparency | |
| //Blend One OneMinusSrcAlpha // Premultiplied transparency | |
| Blend One One // Additive | |
| //Blend OneMinusDstColor One // Soft additive | |
| //Blend DstColor Zero // Multiplicative | |
| //Blend DstColor SrcColor // 2x multiplicative | |
| LOD 100 | |
| Pass | |
| { | |
| CGPROGRAM | |
| #pragma vertex vert | |
| #pragma fragment frag | |
| #include "UnityCG.cginc" | |
| struct appdata | |
| { | |
| float4 vertex : POSITION; | |
| float2 uv : TEXCOORD0; | |
| }; | |
| struct v2f | |
| { | |
| float2 uv : TEXCOORD0; | |
| float4 vertex : SV_POSITION; | |
| }; | |
| sampler2D _MainTex; | |
| sampler2D _NoiseTex; | |
| float4 _MainTex_ST; | |
| float4 _Tint; | |
| v2f vert(appdata v) | |
| { | |
| v2f o; | |
| o.vertex = UnityObjectToClipPos(v.vertex); | |
| o.uv = TRANSFORM_TEX(v.uv, _MainTex); | |
| return o; | |
| } | |
| fixed4 frag(v2f i) : SV_Target | |
| { | |
| float2 scroll = float2(0,frac(_Time.x)); | |
| fixed2 noise = tex2D(_NoiseTex, i.uv - scroll).rg; | |
| //noise = smoothstep(noise.r, 0, 0.25); | |
| noise = smoothstep(0, 0.5, noise.r); | |
| //fixed4 col = tex2D(_MainTex, i.uv + noise * 0.1)*3; | |
| fixed4 col = tex2D(_MainTex, i.uv)*3; | |
| col.a *= noise.r+col.r; | |
| col.rgb = _Tint.rgb * col.a; | |
| col*=_Tint; | |
| return col; | |
| } | |
| ENDCG | |
| } | |
| } | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment