Add camp fog

This commit is contained in:
Sofia 2020-04-20 23:44:24 +03:00
parent a96bff5967
commit 07891ba69f
8 changed files with 301 additions and 2032 deletions

View File

@ -0,0 +1,80 @@
%YAML 1.1
%TAG !u! tag:unity3d.com,2011:
--- !u!21 &2100000
Material:
serializedVersion: 6
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_Name: CampFog
m_Shader: {fileID: 4800000, guid: 134ef850c5fcf3647bb68bbcf0882395, type: 3}
m_ShaderKeywords:
m_LightmapFlags: 4
m_EnableInstancingVariants: 0
m_DoubleSidedGI: 0
m_CustomRenderQueue: -1
stringTagMap: {}
disabledShaderPasses: []
m_SavedProperties:
serializedVersion: 3
m_TexEnvs:
- _BumpMap:
m_Texture: {fileID: 0}
m_Scale: {x: 1, y: 1}
m_Offset: {x: 0, y: 0}
- _DetailAlbedoMap:
m_Texture: {fileID: 0}
m_Scale: {x: 1, y: 1}
m_Offset: {x: 0, y: 0}
- _DetailMask:
m_Texture: {fileID: 0}
m_Scale: {x: 1, y: 1}
m_Offset: {x: 0, y: 0}
- _DetailNormalMap:
m_Texture: {fileID: 0}
m_Scale: {x: 1, y: 1}
m_Offset: {x: 0, y: 0}
- _EmissionMap:
m_Texture: {fileID: 0}
m_Scale: {x: 1, y: 1}
m_Offset: {x: 0, y: 0}
- _MainTex:
m_Texture: {fileID: 0}
m_Scale: {x: 1, y: 1}
m_Offset: {x: 0, y: 0}
- _MetallicGlossMap:
m_Texture: {fileID: 0}
m_Scale: {x: 1, y: 1}
m_Offset: {x: 0, y: 0}
- _OcclusionMap:
m_Texture: {fileID: 0}
m_Scale: {x: 1, y: 1}
m_Offset: {x: 0, y: 0}
- _ParallaxMap:
m_Texture: {fileID: 0}
m_Scale: {x: 1, y: 1}
m_Offset: {x: 0, y: 0}
m_Floats:
- _BumpScale: 1
- _Cutoff: 0.5
- _DetailNormalMapScale: 1
- _DstBlend: 0
- _GlossMapScale: 1
- _Glossiness: 0.5
- _GlossyReflections: 1
- _Intensity: 2.5
- _Metallic: 0
- _Mode: 0
- _OcclusionStrength: 1
- _Parallax: 0.02
- _SmoothnessTextureChannel: 0
- _SpecularHighlights: 1
- _SrcBlend: 1
- _Transparency: 0.04502965
- _UVSec: 0
- _ZWrite: 1
m_Colors:
- _Color: {r: 0.99841505, g: 1, b: 0.3254717, a: 1}
- _EmissionColor: {r: 0, g: 0, b: 0, a: 1}
- _FogColor: {r: 1, g: 1, b: 0.6084906, a: 1}

View File

@ -0,0 +1,8 @@
fileFormatVersion: 2
guid: cb39cf5f82f3b7d41aa60ecd72bc528d
NativeFormatImporter:
externalObjects: {}
mainObjectFileID: 0
userData:
assetBundleName:
assetBundleVariant:

File diff suppressed because it is too large Load Diff

View File

@ -0,0 +1,13 @@
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class CampfireFog : MonoBehaviour {
public GameObject Player;
public Material FogMaterial;
void Update() {
FogMaterial.SetFloat("_Transparency", Mathf.Min(Mathf.Sqrt(Mathf.Max((transform.position - Player.transform.position).magnitude - 15, 0)) / 100, 0.15f));
}
}

View File

@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: 7348cb47373d05242823512e3d48b7dc
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

8
Assets/Shaders.meta Normal file
View File

@ -0,0 +1,8 @@
fileFormatVersion: 2
guid: 28c10a905e8e88b41a972af006c17552
folderAsset: yes
DefaultImporter:
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant:

View File

@ -0,0 +1,72 @@
// Upgrade NOTE: replaced 'mul(UNITY_MATRIX_MVP,*)' with 'UnityObjectToClipPos(*)'
Shader "Unlit/CampFog"
{
Properties
{
_FogColor ("Color", Color) = (1, 0, 0, 1)
_Intensity ("Intensity", Float) = 2.5
_Transparency ("Transparency", Float) = 1
}
SubShader
{
Tags { "Queue"="Transparent" "RenderType"="Transparent" }
LOD 100
ZWrite Off
Blend SrcAlpha OneMinusSrcAlpha
Pass
{
CGPROGRAM
#pragma vertex vert
#pragma fragment frag
#include "UnityCG.cginc"
struct appdata
{
float4 vertex : POSITION;
};
struct v2f
{
float4 vertex : SV_POSITION;
float4 screenpos : TEXCOORD1;
float4 center : TEXCOORD2;
float4 orig : TEXCOORD3;
};
float4 _FogColor;
float _Intensity;
float _Transparency;
v2f vert (appdata v)
{
v2f o;
o.vertex = UnityObjectToClipPos (v.vertex);
o.orig = v.vertex;
o.screenpos = ComputeScreenPos(o.vertex);
o.center = ComputeScreenPos (UnityObjectToClipPos(fixed3(0, 0, 0)));
return o;
}
fixed4 frag (v2f i) : SV_Target
{
float2 pos = (i.screenpos.xy/i.screenpos.w);
float2 center = (i.center.xy/i.center.w);
float2 distance = center - pos;
if (_ScreenParams.y > _ScreenParams.x) {
distance.y /= (_ScreenParams.x / _ScreenParams.y);
} else {
distance.x /= (_ScreenParams.y / _ScreenParams.x);
}
float value = length(distance) / length(unity_ObjectToWorld[0].xyz);
value = 1 - value * i.center.w * _Intensity;
fixed4 col = fixed4(_FogColor.xyz * value, value * _Transparency);
return col;
}
ENDCG
}
}
}

View File

@ -0,0 +1,9 @@
fileFormatVersion: 2
guid: 134ef850c5fcf3647bb68bbcf0882395
ShaderImporter:
externalObjects: {}
defaultTextures: []
nonModifiableTextures: []
userData:
assetBundleName:
assetBundleVariant: