Skip to content

Commit 8a82dca

Browse files
committed
Adds first fog test
1 parent 9d82837 commit 8a82dca

File tree

13 files changed

+208
-2
lines changed

13 files changed

+208
-2
lines changed

Assets/_Project/Prefabs/Monster.prefab

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,7 @@ SpriteRenderer:
5252
m_RenderingLayerMask: 1
5353
m_RendererPriority: 0
5454
m_Materials:
55-
- {fileID: 10754, guid: 0000000000000000f000000000000000, type: 0}
55+
- {fileID: 2100000, guid: a4286a2a0b440473fa49e6953572262a, type: 2}
5656
m_StaticBatchInfo:
5757
firstSubMesh: 0
5858
subMeshCount: 0

Assets/_Project/Prefabs/Player.prefab

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -185,6 +185,10 @@ PrefabInstance:
185185
propertyPath: m_Controller
186186
value:
187187
objectReference: {fileID: 0}
188+
- target: {fileID: 2736477805894834975, guid: 1edc95efb8d7a4866b149a313687cc5e, type: 3}
189+
propertyPath: m_Materials.Array.data[0]
190+
value:
191+
objectReference: {fileID: 2100000, guid: a4286a2a0b440473fa49e6953572262a, type: 2}
188192
- target: {fileID: 3905223414317444978, guid: 1edc95efb8d7a4866b149a313687cc5e, type: 3}
189193
propertyPath: mid
190194
value: 15

Assets/_Project/Scenes/VizTest1.unity

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ RenderSettings:
1717
m_Fog: 1
1818
m_FogColor: {r: 0.16862746, g: 0.07450981, b: 0.40392157, a: 1}
1919
m_FogMode: 3
20-
m_FogDensity: 0.01
20+
m_FogDensity: 0.015
2121
m_LinearFogStart: 0
2222
m_LinearFogEnd: 300
2323
m_AmbientSkyColor: {r: 0.212, g: 0.227, b: 0.259, a: 1}

Assets/_Project/Shader.meta

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

Assets/_Project/Shader/NewSurfaceShader.shader.meta

Lines changed: 9 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.
Lines changed: 86 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,86 @@
1+
%YAML 1.1
2+
%TAG !u! tag:unity3d.com,2011:
3+
--- !u!21 &2100000
4+
Material:
5+
serializedVersion: 6
6+
m_ObjectHideFlags: 0
7+
m_CorrespondingSourceObject: {fileID: 0}
8+
m_PrefabInstance: {fileID: 0}
9+
m_PrefabAsset: {fileID: 0}
10+
m_Name: SpriteWithFog
11+
m_Shader: {fileID: 4800000, guid: dc975798651f44108baa6f968f2a20f7, type: 3}
12+
m_ShaderKeywords: ETC1_EXTERNAL_ALPHA
13+
m_LightmapFlags: 4
14+
m_EnableInstancingVariants: 0
15+
m_DoubleSidedGI: 0
16+
m_CustomRenderQueue: -1
17+
stringTagMap: {}
18+
disabledShaderPasses: []
19+
m_SavedProperties:
20+
serializedVersion: 3
21+
m_TexEnvs:
22+
- _AlphaTex:
23+
m_Texture: {fileID: 0}
24+
m_Scale: {x: 1, y: 1}
25+
m_Offset: {x: 0, y: 0}
26+
- _BumpMap:
27+
m_Texture: {fileID: 0}
28+
m_Scale: {x: 1, y: 1}
29+
m_Offset: {x: 0, y: 0}
30+
- _DetailAlbedoMap:
31+
m_Texture: {fileID: 0}
32+
m_Scale: {x: 1, y: 1}
33+
m_Offset: {x: 0, y: 0}
34+
- _DetailMask:
35+
m_Texture: {fileID: 0}
36+
m_Scale: {x: 1, y: 1}
37+
m_Offset: {x: 0, y: 0}
38+
- _DetailNormalMap:
39+
m_Texture: {fileID: 0}
40+
m_Scale: {x: 1, y: 1}
41+
m_Offset: {x: 0, y: 0}
42+
- _EmissionMap:
43+
m_Texture: {fileID: 0}
44+
m_Scale: {x: 1, y: 1}
45+
m_Offset: {x: 0, y: 0}
46+
- _MainTex:
47+
m_Texture: {fileID: 0}
48+
m_Scale: {x: 1, y: 1}
49+
m_Offset: {x: 0, y: 0}
50+
- _MetallicGlossMap:
51+
m_Texture: {fileID: 0}
52+
m_Scale: {x: 1, y: 1}
53+
m_Offset: {x: 0, y: 0}
54+
- _OcclusionMap:
55+
m_Texture: {fileID: 0}
56+
m_Scale: {x: 1, y: 1}
57+
m_Offset: {x: 0, y: 0}
58+
- _ParallaxMap:
59+
m_Texture: {fileID: 0}
60+
m_Scale: {x: 1, y: 1}
61+
m_Offset: {x: 0, y: 0}
62+
m_Floats:
63+
- PixelSnap: 0
64+
- _BumpScale: 1
65+
- _Cutoff: 0.5
66+
- _DetailNormalMapScale: 1
67+
- _DstBlend: 0
68+
- _EnableExternalAlpha: 0
69+
- _GlossMapScale: 1
70+
- _Glossiness: 0.5
71+
- _GlossyReflections: 1
72+
- _Metallic: 0
73+
- _Mode: 0
74+
- _OcclusionStrength: 1
75+
- _Parallax: 0.02
76+
- _SmoothnessTextureChannel: 0
77+
- _SpecularHighlights: 1
78+
- _SrcBlend: 1
79+
- _UVSec: 0
80+
- _ZWrite: 1
81+
m_Colors:
82+
- _Color: {r: 1, g: 1, b: 1, a: 1}
83+
- _EmissionColor: {r: 0, g: 0, b: 0, a: 1}
84+
- _Flip: {r: 1, g: 1, b: 1, a: 1}
85+
- _RendererColor: {r: 1, g: 1, b: 1, a: 1}
86+
m_BuildTextureStacks: []

Assets/_Project/Shader/SpriteWithFog.mat.meta

Lines changed: 8 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Library/ArtifactDB

0 Bytes
Binary file not shown.

Library/SceneVisibilityState.asset

-1.55 KB
Binary file not shown.

0 commit comments

Comments
 (0)