GameBanana shows no ads to members. Sign up now!
Ads keep us online. Without them, we wouldn't exist. We don't have paywalls or sell mods - we never will. But every month we have large bills and running ads is our only way to cover them. Please consider unblocking us. Thank you from GameBanana <3

Sprite Effected By Fog Shader

A Config Script for Unity 3D

91 3 kb Raw Code
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
Shader "Custom/SpritesDefaultModded"
 {
   Properties
      {
          [PerRendererData] _MainTex ("Sprite Texture", 2D) = "white" {}
          _Color ("Tint", Color) = (1,1,1,1)
          [MaterialToggle] PixelSnap ("Pixel snap", Float) = 0
          [HideInInspector] _RendererColor ("RendererColor", Color) = (1,1,1,1)
          [HideInInspector] _Flip ("Flip", Vector) = (1,1,1,1)
          [PerRendererData] _AlphaTex ("External Alpha", 2D) = "white" {}
          [PerRendererData] _EnableExternalAlpha ("Enable External Alpha", Float) = 0
      }
 
      SubShader
      {
          Tags
          {
              "Queue"="Transparent"
              "IgnoreProjector"="True"
              "RenderType"="Transparent"
              "PreviewType"="Plane"
              "CanUseSpriteAtlas"="True"
          }
 
          Cull Off
          Lighting Off
          ZWrite Off
          Blend One OneMinusSrcAlpha
 
          Pass
          {
          CGPROGRAM
              #pragma vertex SpriteVertFog
              #pragma fragment SpriteFragFog
              #pragma target 2.0
              #pragma multi_compile_instancing
              #pragma multi_compile _ PIXELSNAP_ON
              #pragma multi_compile _ ETC1_EXTERNAL_ALPHA
              #pragma multi_compile_fog
              #include "UnitySprites.cginc"
 
              struct v2f_fog
              {
                  float4 vertex   : SV_POSITION;
                  fixed4 color    : COLOR;
                  float2 texcoord : TEXCOORD0;
                  UNITY_FOG_COORDS(1)
                  UNITY_VERTEX_OUTPUT_STEREO
              };
 
              v2f_fog SpriteVertFog(appdata_t IN)
              {
                  v2f_fog OUT;
 
                  UNITY_SETUP_INSTANCE_ID (IN);
                  UNITY_INITIALIZE_VERTEX_OUTPUT_STEREO(OUT);
 
              #ifdef UNITY_INSTANCING_ENABLED
                  IN.vertex.xy *= _Flip.xy;
              #endif
 
                  OUT.vertex = UnityObjectToClipPos(IN.vertex);
                  OUT.texcoord = IN.texcoord;
                  OUT.color = IN.color * _Color * _RendererColor;
 
              #ifdef PIXELSNAP_ON
                  OUT.vertex = UnityPixelSnap (OUT.vertex);
              #endif
 
 
                  UNITY_TRANSFER_FOG(OUT, OUT.vertex);
 
                  return OUT;
              }
 
 
              fixed4 SpriteFragFog(v2f_fog IN) : SV_Target
              {
                  fixed4 c = SampleSpriteTexture (IN.texcoord) * IN.color;
 
                  // apply fog
                  UNITY_APPLY_FOG(IN.fogCoord, c);
                  c.rgb *= c.a;
 
                  return c;
              }
 
          ENDCG
          }
      }
 }
This Shader Will Help Your Sprite Be Affected By Fog!
Sign up to access this!

No comments yet

Embed

Share banner
Image URL
HTML embed code
BB embed code
Markdown embed code

Credits

Key Authors
Baldiisagoodperson avatar
Baldiisagoodperson username pic Joined 1y ago
Eating at KFC
1,309 points Ranked 22856th
21 medals 2 legendary 5 rare
  • Submitted 50 Gamefiles Medal icon
  • Returned 5000 times Medal icon
  • Submitted 20 Gamefiles Medal icon
  • Returned 1000 times Medal icon
  • Thanked 50 submitters Medal icon
  • Received thanks 50 times Medal icon
Uploaded Shader To GB
Original Authors
bricevdm
made the fog shader

Submitter

Baldiisagoodperson avatar
Baldiisagoodperson username pic Joined 1y ago
Eating at KFC
1,309 points Ranked 22856th
21 medals 2 legendary 5 rare
  • Submitted 50 Gamefiles Medal icon
  • Returned 5000 times Medal icon
  • Submitted 20 Gamefiles Medal icon
  • Returned 1000 times Medal icon
  • Thanked 50 submitters Medal icon
  • Received thanks 50 times Medal icon
Baldiisagoodperson avatar
Baldiisagoodperson

Redistributor
Are you the owner? Request Ownership
Sign up to access this!
Sign up to access this!
Sign up to access this!

Game

Sign up to access this!

Category

License

Share

  • Share on Reddit
  • Share on Twitter
  • Share on Facebook
  • 2
  • 241
  • 22d
  • 22d

WiPs by Submitter