Skip to content

Commit

Permalink
Vertical Fog
Browse files Browse the repository at this point in the history
  • Loading branch information
marcozakaria committed May 27, 2020
1 parent b813eeb commit d230bd1
Show file tree
Hide file tree
Showing 4 changed files with 11 additions and 10 deletions.
Binary file removed Assets/Preview/VerticalFog Unlit.JPG
Binary file not shown.
Binary file added Assets/Preview/VerticalFogUnlit.JPG
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

19 changes: 10 additions & 9 deletions Assets/Shaders/Vertical Fog Unlit/VerticalFog.shader
Original file line number Diff line number Diff line change
Expand Up @@ -2,16 +2,17 @@
{
Properties
{
[Header(Object Colors)]
_TopColor ("Top Y Color", Color) = (.5,.5,.5,1.0)
_FrontColor ("Front Z Color", Color) = (.5,.5,.5,1.0)
_LeftColor ("Left X Color", Color) = (.5,.5,.5,1.0)

[Header(Fog Colors)]
_FogColor ("Fog Color Middle", Color) = (.5,.5,.5,1.0)
_MidleColorEnd ("Fog Color End", Color) = (.5,.5,.5,1.0)

_AlphaPoint("Siperate fog point", float) = 1.0
_Range("Fog Range", float) = 1.0
_FO("Fog Opacity Lerp", float) = 1.0
[Header(Fog Settings)]
_AlphaPoint("Siperate top-fog point", float) = 1.0
_Range("Fog Range Size", float) = 1.0
_FO("Fog Opacity Lerp", Range(0.0,3.0)) = 1.0
}
SubShader
{
Expand Down Expand Up @@ -50,15 +51,15 @@
VertexOutput o;
o.pos = UnityObjectToClipPos(i.vertex);
o.wp = mul(unity_ObjectToWorld, i.vertex);
// normal direction
half3 normalDir = normalize(mul(half4(i.normal, 0), unity_ObjectToWorld).xyz);

half3 normalDir = normalize(mul(half4(i.normal, 0), unity_ObjectToWorld).xyz);

if (dot(normalDir, half3(0, 1, 0)) > 0.99)
if (dot(normalDir, half3(0, 1, 0)) > 0.9) // if it is upper gorund to Y direction
{
o.color = _TopColor;
}
else
{
{ // set X-Direction colors
o.color = lerp(_FrontColor, _LeftColor, clamp(abs(dot(normalDir, half3(1, 0, 0))), 0, 1));
}

Expand Down

0 comments on commit d230bd1

Please sign in to comment.