This commit is contained in:
2025-11-14 18:44:06 +08:00
parent 10156da245
commit 22e867d077
7013 changed files with 2572882 additions and 1804 deletions

View File

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

View File

@@ -0,0 +1,41 @@
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEditor;
using UnityEditor.UI;
public class BF_TerrainEdit : Editor
{
[CustomEditor(typeof(BF_SnowTerrain))]
class DecalMeshHelperEditor : Editor
{
private GUIStyle style;
public override void OnInspectorGUI()
{
BF_SnowTerrain myTarget = (BF_SnowTerrain)target;
myTarget.terrainToCopy = EditorGUILayout.ObjectField("Terrain To Copy (Data Override)", myTarget.terrainToCopy, typeof(Terrain), true) as Terrain;
myTarget.avoidCulling = EditorGUILayout.Toggle("Avoid Terrain Culling", myTarget.avoidCulling);
if (style == null)
{
style = new GUIStyle(GUI.skin.button);
}
if (myTarget.terrainToCopy != null)
{
if (GUILayout.Button("Sync Terrain Data (Data Override)", style))
{
myTarget.CopyTerrainData();
myTarget.MoveTerrainSync();
style.normal.background = Texture2D.linearGrayTexture;
}
if (GUILayout.Button("Revert Terrain Data"))
{
myTarget.RevertTerrainData();
style.normal.background = Texture2D.whiteTexture;
}
}
serializedObject.ApplyModifiedProperties();
}
}
}

View File

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

View File

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

View File

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

View File

@@ -0,0 +1,251 @@
//
// Kino/Bloom v2 - Bloom filter for Unity
//
// Copyright (C) 2015, 2016 Keijiro Takahashi
//
// Permission is hereby granted, free of charge, to any person obtaining a copy
// of this software and associated documentation files (the "Software"), to deal
// in the Software without restriction, including without limitation the rights
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
// copies of the Software, and to permit persons to whom the Software is
// furnished to do so, subject to the following conditions:
//
// The above copyright notice and this permission notice shall be included in
// all copies or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
// THE SOFTWARE.
//
#include "UnityCG.cginc"
// Mobile: use RGBM instead of float/half RGB
#define USE_RGBM defined(SHADER_API_MOBILE)
sampler2D _MainTex;
sampler2D _BaseTex;
float2 _MainTex_TexelSize;
float2 _BaseTex_TexelSize;
half4 _MainTex_ST;
half4 _BaseTex_ST;
float _PrefilterOffs;
half _Threshold;
half3 _Curve;
float _SampleScale;
half _Intensity;
// Brightness function
half Brightness(half3 c)
{
return max(max(c.r, c.g), c.b);
}
// 3-tap median filter
half3 Median(half3 a, half3 b, half3 c)
{
return a + b + c - min(min(a, b), c) - max(max(a, b), c);
}
// Clamp HDR value within a safe range
half3 SafeHDR(half3 c) { return min(c, 65000); }
half4 SafeHDR(half4 c) { return min(c, 65000); }
// RGBM encoding/decoding
half4 EncodeHDR(float3 rgb)
{
#if USE_RGBM
rgb *= 1.0 / 8;
float m = max(max(rgb.r, rgb.g), max(rgb.b, 1e-6));
m = ceil(m * 255) / 255;
return half4(rgb / m, m);
#else
return half4(rgb, 0);
#endif
}
float3 DecodeHDR(half4 rgba)
{
#if USE_RGBM
return rgba.rgb * rgba.a * 8;
#else
return rgba.rgb;
#endif
}
// Downsample with a 4x4 box filter
half3 DownsampleFilter(float2 uv)
{
float4 d = _MainTex_TexelSize.xyxy * float4(-1, -1, +1, +1);
half3 s;
s = DecodeHDR(tex2D(_MainTex, uv + d.xy));
s += DecodeHDR(tex2D(_MainTex, uv + d.zy));
s += DecodeHDR(tex2D(_MainTex, uv + d.xw));
s += DecodeHDR(tex2D(_MainTex, uv + d.zw));
return s * (1.0 / 4);
}
// Downsample with a 4x4 box filter + anti-flicker filter
half3 DownsampleAntiFlickerFilter(float2 uv)
{
float4 d = _MainTex_TexelSize.xyxy * float4(-1, -1, +1, +1);
half3 s1 = DecodeHDR(tex2D(_MainTex, uv + d.xy));
half3 s2 = DecodeHDR(tex2D(_MainTex, uv + d.zy));
half3 s3 = DecodeHDR(tex2D(_MainTex, uv + d.xw));
half3 s4 = DecodeHDR(tex2D(_MainTex, uv + d.zw));
// Karis's luma weighted average (using brightness instead of luma)
half s1w = 1 / (Brightness(s1) + 1);
half s2w = 1 / (Brightness(s2) + 1);
half s3w = 1 / (Brightness(s3) + 1);
half s4w = 1 / (Brightness(s4) + 1);
half one_div_wsum = 1 / (s1w + s2w + s3w + s4w);
return (s1 * s1w + s2 * s2w + s3 * s3w + s4 * s4w) * one_div_wsum;
}
half3 UpsampleFilter(float2 uv)
{
#if HIGH_QUALITY
// 9-tap bilinear upsampler (tent filter)
float4 d = _MainTex_TexelSize.xyxy * float4(1, 1, -1, 0) * _SampleScale;
half3 s;
s = DecodeHDR(tex2D(_MainTex, uv - d.xy));
s += DecodeHDR(tex2D(_MainTex, uv - d.wy)) * 2;
s += DecodeHDR(tex2D(_MainTex, uv - d.zy));
s += DecodeHDR(tex2D(_MainTex, uv + d.zw)) * 2;
s += DecodeHDR(tex2D(_MainTex, uv )) * 4;
s += DecodeHDR(tex2D(_MainTex, uv + d.xw)) * 2;
s += DecodeHDR(tex2D(_MainTex, uv + d.zy));
s += DecodeHDR(tex2D(_MainTex, uv + d.wy)) * 2;
s += DecodeHDR(tex2D(_MainTex, uv + d.xy));
return s * (1.0 / 16);
#else
// 4-tap bilinear upsampler
float4 d = _MainTex_TexelSize.xyxy * float4(-1, -1, +1, +1) * (_SampleScale * 0.5);
half3 s;
s = DecodeHDR(tex2D(_MainTex, uv + d.xy));
s += DecodeHDR(tex2D(_MainTex, uv + d.zy));
s += DecodeHDR(tex2D(_MainTex, uv + d.xw));
s += DecodeHDR(tex2D(_MainTex, uv + d.zw));
return s * (1.0 / 4);
#endif
}
//
// Vertex shader
//
v2f_img vert(appdata_img v)
{
v2f_img o;
o.pos = UnityObjectToClipPos(v.vertex);
o.uv = UnityStereoScreenSpaceUVAdjust(v.texcoord, _MainTex_ST);
return o;
}
struct v2f_multitex
{
float4 pos : SV_POSITION;
float2 uvMain : TEXCOORD0;
float2 uvBase : TEXCOORD1;
};
v2f_multitex vert_multitex(appdata_img v)
{
v2f_multitex o;
o.pos = UnityObjectToClipPos(v.vertex);
o.uvMain = UnityStereoScreenSpaceUVAdjust(v.texcoord, _MainTex_ST);
o.uvBase = UnityStereoScreenSpaceUVAdjust(v.texcoord, _BaseTex_ST);
#if UNITY_UV_STARTS_AT_TOP
if (_BaseTex_TexelSize.y < 0.0)
o.uvBase.y = 1.0 - v.texcoord.y;
#endif
return o;
}
//
// fragment shader
//
half4 frag_prefilter(v2f_img i) : SV_Target
{
float2 uv = i.uv + _MainTex_TexelSize.xy * _PrefilterOffs;
#if ANTI_FLICKER
float3 d = _MainTex_TexelSize.xyx * float3(1, 1, 0);
half4 s0 = SafeHDR(tex2D(_MainTex, uv));
half3 s1 = SafeHDR(tex2D(_MainTex, uv - d.xz).rgb);
half3 s2 = SafeHDR(tex2D(_MainTex, uv + d.xz).rgb);
half3 s3 = SafeHDR(tex2D(_MainTex, uv - d.zy).rgb);
half3 s4 = SafeHDR(tex2D(_MainTex, uv + d.zy).rgb);
half3 m = Median(Median(s0.rgb, s1, s2), s3, s4);
#else
half4 s0 = SafeHDR(tex2D(_MainTex, uv));
half3 m = s0.rgb;
#endif
#if UNITY_COLORSPACE_GAMMA
m = GammaToLinearSpace(m);
#endif
// Pixel brightness
half br = Brightness(m);
// Under-threshold part: quadratic curve
half rq = clamp(br - _Curve.x, 0, _Curve.y);
rq = _Curve.z * rq * rq;
// Combine and apply the brightness response curve.
m *= max(rq, br - _Threshold) / max(br, 1e-5);
return EncodeHDR(m);
}
half4 frag_downsample1(v2f_img i) : SV_Target
{
#if ANTI_FLICKER
return EncodeHDR(DownsampleAntiFlickerFilter(i.uv));
#else
return EncodeHDR(DownsampleFilter(i.uv));
#endif
}
half4 frag_downsample2(v2f_img i) : SV_Target
{
return EncodeHDR(DownsampleFilter(i.uv));
}
half4 frag_upsample(v2f_multitex i) : SV_Target
{
half3 base = DecodeHDR(tex2D(_BaseTex, i.uvBase));
half3 blur = UpsampleFilter(i.uvMain);
return EncodeHDR(base + blur);
}
half4 frag_upsample_final(v2f_multitex i) : SV_Target
{
half4 base = tex2D(_BaseTex, i.uvBase);
half3 blur = UpsampleFilter(i.uvMain);
#if UNITY_COLORSPACE_GAMMA
base.rgb = GammaToLinearSpace(base.rgb);
#endif
half3 cout = base.rgb + blur * _Intensity;
#if UNITY_COLORSPACE_GAMMA
cout = LinearToGammaSpace(cout);
#endif
return half4(cout, base.a);
}

View File

@@ -0,0 +1,9 @@
fileFormatVersion: 2
guid: 1b8325918052c4c5492831d116e3ed27
timeCreated: 1463470294
licenseType: Store
ShaderImporter:
defaultTextures: []
userData:
assetBundleName:
assetBundleVariant:

View File

@@ -0,0 +1,268 @@
//
// Kino/Bloom v2 - Bloom filter for Unity
//
// Copyright (C) 2015, 2016 Keijiro Takahashi
//
// Permission is hereby granted, free of charge, to any person obtaining a copy
// of this software and associated documentation files (the "Software"), to deal
// in the Software without restriction, including without limitation the rights
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
// copies of the Software, and to permit persons to whom the Software is
// furnished to do so, subject to the following conditions:
//
// The above copyright notice and this permission notice shall be included in
// all copies or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
// THE SOFTWARE.
//
using UnityEngine;
namespace Kino
{
[ExecuteInEditMode]
[RequireComponent(typeof(Camera))]
[AddComponentMenu("Kino Image Effects/BloomKino")]
public class BloomKino : MonoBehaviour
{
#if !UNITY_ANDROID && !UNITY_IOS && !UNITY_WEBGL
#region Public Properties
/// Prefilter threshold (gamma-encoded)
/// Filters out pixels under this level of brightness.
public float thresholdGamma {
get { return Mathf.Max(_threshold, 0); }
set { _threshold = value; }
}
/// Prefilter threshold (linearly-encoded)
/// Filters out pixels under this level of brightness.
public float thresholdLinear {
get { return GammaToLinear(thresholdGamma); }
set { _threshold = LinearToGamma(value); }
}
[SerializeField]
[Tooltip("Filters out pixels under this level of brightness.")]
float _threshold = 0.8f;
/// Soft-knee coefficient
/// Makes transition between under/over-threshold gradual.
public float softKnee {
get { return _softKnee; }
set { _softKnee = value; }
}
[SerializeField, Range(0, 1)]
[Tooltip("Makes transition between under/over-threshold gradual.")]
float _softKnee = 0.5f;
/// Bloom radius
/// Changes extent of veiling effects in a screen
/// resolution-independent fashion.
public float radius {
get { return _radius; }
set { _radius = value; }
}
[SerializeField, Range(1, 7)]
[Tooltip("Changes extent of veiling effects\n" +
"in a screen resolution-independent fashion.")]
float _radius = 2.5f;
/// Bloom intensity
/// Blend factor of the result image.
public float intensity {
get { return Mathf.Max(_intensity, 0); }
set { _intensity = value; }
}
[SerializeField]
[Tooltip("Blend factor of the result image.")]
float _intensity = 0.8f;
/// High quality mode
/// Controls filter quality and buffer resolution.
public bool highQuality {
get { return _highQuality; }
set { _highQuality = value; }
}
[SerializeField]
[Tooltip("Controls filter quality and buffer resolution.")]
bool _highQuality = true;
/// Anti-flicker filter
/// Reduces flashing noise with an additional filter.
[SerializeField]
[Tooltip("Reduces flashing noise with an additional filter.")]
bool _antiFlicker = true;
public bool antiFlicker {
get { return _antiFlicker; }
set { _antiFlicker = value; }
}
#endregion
#region Private Members
[SerializeField, HideInInspector]
Shader _shader;
Material _material;
const int kMaxIterations = 16;
RenderTexture[] _blurBuffer1 = new RenderTexture[kMaxIterations];
RenderTexture[] _blurBuffer2 = new RenderTexture[kMaxIterations];
float LinearToGamma(float x)
{
#if UNITY_5_3_OR_NEWER
return Mathf.LinearToGammaSpace(x);
#else
if (x <= 0.0031308f)
return 12.92f * x;
else
return 1.055f * Mathf.Pow(x, 1 / 2.4f) - 0.055f;
#endif
}
float GammaToLinear(float x)
{
#if UNITY_5_3_OR_NEWER
return Mathf.GammaToLinearSpace(x);
#else
if (x <= 0.04045f)
return x / 12.92f;
else
return Mathf.Pow((x + 0.055f) / 1.055f, 2.4f);
#endif
}
#endregion
#region MonoBehaviour Functions
void OnEnable()
{
var shader = _shader ? _shader : Shader.Find("Hidden/Kino/BloomKino");
_material = new Material(shader);
_material.hideFlags = HideFlags.DontSave;
}
void OnDisable()
{
DestroyImmediate(_material);
}
void OnRenderImage(RenderTexture source, RenderTexture destination)
{
var useRGBM = Application.isMobilePlatform;
// source texture size
var tw = source.width;
var th = source.height;
// halve the texture size for the low quality mode
if (!_highQuality)
{
tw /= 2;
th /= 2;
}
// blur buffer format
var rtFormat = useRGBM ?
RenderTextureFormat.Default : RenderTextureFormat.DefaultHDR;
// determine the iteration count
var logh = Mathf.Log(th, 2) + _radius - 8;
var logh_i = (int)logh;
var iterations = Mathf.Clamp(logh_i, 1, kMaxIterations);
// update the shader properties
var lthresh = thresholdLinear;
_material.SetFloat("_Threshold", lthresh);
var knee = lthresh * _softKnee + 1e-5f;
var curve = new Vector3(lthresh - knee, knee * 2, 0.25f / knee);
_material.SetVector("_Curve", curve);
var pfo = !_highQuality && _antiFlicker;
_material.SetFloat("_PrefilterOffs", pfo ? -0.5f : 0.0f);
_material.SetFloat("_SampleScale", 0.5f + logh - logh_i);
_material.SetFloat("_Intensity", intensity);
// prefilter pass
var prefiltered = RenderTexture.GetTemporary(tw, th, 0, rtFormat);
var pass = _antiFlicker ? 1 : 0;
Graphics.Blit(source, prefiltered, _material, pass);
// construct a mip pyramid
var last = prefiltered;
for (var level = 0; level < iterations; level++)
{
_blurBuffer1[level] = RenderTexture.GetTemporary(
last.width / 2, last.height / 2, 0, rtFormat
);
pass = (level == 0) ? (_antiFlicker ? 3 : 2) : 4;
Graphics.Blit(last, _blurBuffer1[level], _material, pass);
last = _blurBuffer1[level];
}
// upsample and combine loop
for (var level = iterations - 2; level >= 0; level--)
{
var basetex = _blurBuffer1[level];
_material.SetTexture("_BaseTex", basetex);
_blurBuffer2[level] = RenderTexture.GetTemporary(
basetex.width, basetex.height, 0, rtFormat
);
pass = _highQuality ? 6 : 5;
Graphics.Blit(last, _blurBuffer2[level], _material, pass);
last = _blurBuffer2[level];
}
// finish process
if (_material.GetTexture("_BaseTex") != null)
{
if (source.dimension != _material.GetTexture("_BaseTex").dimension)
{
this.enabled = false;
return;
}
}
_material.SetTexture("_BaseTex", source);
pass = _highQuality ? 8 : 7;
Graphics.Blit(last, destination, _material, pass);
// release the temporary buffers
for (var i = 0; i < kMaxIterations; i++)
{
if (_blurBuffer1[i] != null)
RenderTexture.ReleaseTemporary(_blurBuffer1[i]);
if (_blurBuffer2[i] != null)
RenderTexture.ReleaseTemporary(_blurBuffer2[i]);
_blurBuffer1[i] = null;
_blurBuffer2[i] = null;
}
RenderTexture.ReleaseTemporary(prefiltered);
}
#endregion
#endif
}
}

View File

@@ -0,0 +1,13 @@
fileFormatVersion: 2
guid: 6363bba448bf64e60a763433f9ddf81b
timeCreated: 1445671165
licenseType: Store
MonoImporter:
serializedVersion: 2
defaultReferences:
- _shader: {fileID: 4800000, guid: 5a711a01011934ebcb58ef5ad52159d6, type: 3}
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

View File

@@ -0,0 +1,141 @@
//
// Kino/Bloom v2 - Bloom filter for Unity
//
// Copyright (C) 2015, 2016 Keijiro Takahashi
//
// Permission is hereby granted, free of charge, to any person obtaining a copy
// of this software and associated documentation files (the "Software"), to deal
// in the Software without restriction, including without limitation the rights
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
// copies of the Software, and to permit persons to whom the Software is
// furnished to do so, subject to the following conditions:
//
// The above copyright notice and this permission notice shall be included in
// all copies or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
// THE SOFTWARE.
//
Shader "Hidden/Kino/BloomKino"
{
Properties
{
_MainTex("", 2D) = "" {}
_BaseTex("", 2D) = "" {}
}
SubShader
{
// 0: Prefilter
Pass
{
ZTest Always Cull Off ZWrite Off
CGPROGRAM
#pragma multi_compile _ UNITY_COLORSPACE_GAMMA
#include "BloomKino.cginc"
#pragma vertex vert
#pragma fragment frag_prefilter
#pragma target 3.0
ENDCG
}
// 1: Prefilter with anti-flicker
Pass
{
ZTest Always Cull Off ZWrite Off
CGPROGRAM
#define ANTI_FLICKER 1
#pragma multi_compile _ UNITY_COLORSPACE_GAMMA
#include "BloomKino.cginc"
#pragma vertex vert
#pragma fragment frag_prefilter
#pragma target 3.0
ENDCG
}
// 2: First level downsampler
Pass
{
ZTest Always Cull Off ZWrite Off
CGPROGRAM
#include "BloomKino.cginc"
#pragma vertex vert
#pragma fragment frag_downsample1
#pragma target 3.0
ENDCG
}
// 3: First level downsampler with anti-flicker
Pass
{
ZTest Always Cull Off ZWrite Off
CGPROGRAM
#define ANTI_FLICKER 1
#include "BloomKino.cginc"
#pragma vertex vert
#pragma fragment frag_downsample1
#pragma target 3.0
ENDCG
}
// 4: Second level downsampler
Pass
{
ZTest Always Cull Off ZWrite Off
CGPROGRAM
#include "BloomKino.cginc"
#pragma vertex vert
#pragma fragment frag_downsample2
#pragma target 3.0
ENDCG
}
// 5: Upsampler
Pass
{
ZTest Always Cull Off ZWrite Off
CGPROGRAM
#include "BloomKino.cginc"
#pragma vertex vert_multitex
#pragma fragment frag_upsample
#pragma target 3.0
ENDCG
}
// 6: High quality upsampler
Pass
{
ZTest Always Cull Off ZWrite Off
CGPROGRAM
#define HIGH_QUALITY 1
#include "BloomKino.cginc"
#pragma vertex vert_multitex
#pragma fragment frag_upsample
#pragma target 3.0
ENDCG
}
// 7: Combiner
Pass
{
ZTest Always Cull Off ZWrite Off
CGPROGRAM
#pragma multi_compile _ UNITY_COLORSPACE_GAMMA
#include "BloomKino.cginc"
#pragma vertex vert_multitex
#pragma fragment frag_upsample_final
#pragma target 3.0
ENDCG
}
// 8: High quality combiner
Pass
{
ZTest Always Cull Off ZWrite Off
CGPROGRAM
#define HIGH_QUALITY 1
#pragma multi_compile _ UNITY_COLORSPACE_GAMMA
#include "BloomKino.cginc"
#pragma vertex vert_multitex
#pragma fragment frag_upsample_final
#pragma target 3.0
ENDCG
}
}
}

View File

@@ -0,0 +1,9 @@
fileFormatVersion: 2
guid: 5a711a01011934ebcb58ef5ad52159d6
timeCreated: 1435809878
licenseType: Store
ShaderImporter:
defaultTextures: []
userData:
assetBundleName:
assetBundleVariant:

View File

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

View File

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

View File

@@ -0,0 +1,79 @@
//
// Kino/Bloom v2 - Bloom filter for Unity
//
// Copyright (C) 2015, 2016 Keijiro Takahashi
//
// Permission is hereby granted, free of charge, to any person obtaining a copy
// of this software and associated documentation files (the "Software"), to deal
// in the Software without restriction, including without limitation the rights
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
// copies of the Software, and to permit persons to whom the Software is
// furnished to do so, subject to the following conditions:
//
// The above copyright notice and this permission notice shall be included in
// all copies or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
// THE SOFTWARE.
//
using UnityEngine;
using UnityEditor;
namespace Kino
{
#if !UNITY_ANDROID && !UNITY_IOS && !UNITY_WEBGL
[CanEditMultipleObjects]
[CustomEditor(typeof(BloomKino))]
public class BloomKinoEditor : Editor
{
BloomKinoGraphDrawer _graph;
SerializedProperty _threshold;
SerializedProperty _softKnee;
SerializedProperty _radius;
SerializedProperty _intensity;
SerializedProperty _highQuality;
SerializedProperty _antiFlicker;
static GUIContent _textThreshold = new GUIContent("Threshold (gamma)");
void OnEnable()
{
_graph = new BloomKinoGraphDrawer();
_threshold = serializedObject.FindProperty("_threshold");
_softKnee = serializedObject.FindProperty("_softKnee");
_radius = serializedObject.FindProperty("_radius");
_intensity = serializedObject.FindProperty("_intensity");
_highQuality = serializedObject.FindProperty("_highQuality");
_antiFlicker = serializedObject.FindProperty("_antiFlicker");
}
public override void OnInspectorGUI()
{
serializedObject.Update();
if (!serializedObject.isEditingMultipleObjects) {
EditorGUILayout.Space();
_graph.Prepare((BloomKino)target);
_graph.DrawGraph();
EditorGUILayout.Space();
}
EditorGUILayout.PropertyField(_threshold, _textThreshold);
EditorGUILayout.PropertyField(_softKnee);
EditorGUILayout.PropertyField(_intensity);
EditorGUILayout.PropertyField(_radius);
EditorGUILayout.PropertyField(_highQuality);
EditorGUILayout.PropertyField(_antiFlicker);
serializedObject.ApplyModifiedProperties();
}
}
#endif
}

View File

@@ -0,0 +1,12 @@
fileFormatVersion: 2
guid: 036bc30d96c3349ce86bfc8d95667da7
timeCreated: 1435816745
licenseType: Store
MonoImporter:
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

View File

@@ -0,0 +1,187 @@
//
// Kino/Bloom v2 - Bloom filter for Unity
//
// Copyright (C) 2015, 2016 Keijiro Takahashi
//
// Permission is hereby granted, free of charge, to any person obtaining a copy
// of this software and associated documentation files (the "Software"), to deal
// in the Software without restriction, including without limitation the rights
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
// copies of the Software, and to permit persons to whom the Software is
// furnished to do so, subject to the following conditions:
//
// The above copyright notice and this permission notice shall be included in
// all copies or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
// THE SOFTWARE.
//
using UnityEngine;
using UnityEditor;
namespace Kino
{
// Class used for drawing the brightness response curve
#if !UNITY_ANDROID && !UNITY_IOS && !UNITY_WEBGL
public class BloomKinoGraphDrawer
{
#region Public Methods
// Update internal state with a given bloom instance.
public void Prepare(BloomKino bloom)
{
#if UNITY_5_6_OR_NEWER
if (bloom.GetComponent<Camera>().allowHDR)
#else
if (bloom.GetComponent<Camera>().hdr)
#endif
{
_rangeX = 6;
_rangeY = 1.5f;
}
else
{
_rangeX = 1;
_rangeY = 1;
}
_threshold = bloom.thresholdLinear;
_knee = bloom.softKnee * _threshold + 1e-5f;
// Intensity is capped to prevent sampling errors.
_intensity = Mathf.Min(bloom.intensity, 10);
}
// Draw the graph at the current position.
public void DrawGraph()
{
_rectGraph = GUILayoutUtility.GetRect(128, 80);
// Background
DrawRect(0, 0, _rangeX, _rangeY, 0.1f, 0.4f);
// Soft-knee range
DrawRect(_threshold - _knee, 0, _threshold + _knee, _rangeY, 0.25f, -1);
// Horizontal lines
for (var i = 1; i < _rangeY; i++)
DrawLine(0, i, _rangeX, i, 0.4f);
// Vertical lines
for (var i = 1; i < _rangeX; i++)
DrawLine(i, 0, i, _rangeY, 0.4f);
// Label
Handles.Label(
PointInRect(0, _rangeY) + Vector3.right,
"Brightness Response (linear)", EditorStyles.miniLabel
);
// Threshold line
DrawLine(_threshold, 0, _threshold, _rangeY, 0.6f);
// Response curve
var vcount = 0;
while (vcount < _curveResolution)
{
var x = _rangeX * vcount / (_curveResolution - 1);
var y = ResponseFunction(x);
if (y < _rangeY)
{
_curveVertices[vcount++] = PointInRect(x, y);
}
else
{
if (vcount > 1)
{
// Extend the last segment to the top edge of the rect.
var v1 = _curveVertices[vcount - 2];
var v2 = _curveVertices[vcount - 1];
var clip = (_rectGraph.y - v1.y) / (v2.y - v1.y);
_curveVertices[vcount - 1] = v1 + (v2 - v1) * clip;
}
break;
}
}
if (vcount > 1)
{
Handles.color = Color.white * 0.9f;
Handles.DrawAAPolyLine(2.0f, vcount, _curveVertices);
}
}
#endregion
#region Response Function
float _threshold;
float _knee;
float _intensity;
float ResponseFunction(float x)
{
var rq = Mathf.Clamp(x - _threshold + _knee, 0, _knee * 2);
rq = rq * rq * 0.25f / _knee;
return Mathf.Max(rq, x - _threshold) * _intensity;
}
#endregion
#region Graph Functions
// Number of vertices in curve
const int _curveResolution = 96;
// Vertex buffers
Vector3[] _rectVertices = new Vector3[4];
Vector3[] _lineVertices = new Vector3[2];
Vector3[] _curveVertices = new Vector3[_curveResolution];
Rect _rectGraph;
float _rangeX;
float _rangeY;
// Transform a point into the graph rect.
Vector3 PointInRect(float x, float y)
{
x = Mathf.Lerp(_rectGraph.x, _rectGraph.xMax, x / _rangeX);
y = Mathf.Lerp(_rectGraph.yMax, _rectGraph.y, y / _rangeY);
return new Vector3(x, y, 0);
}
// Draw a line in the graph rect.
void DrawLine(float x1, float y1, float x2, float y2, float grayscale)
{
_lineVertices[0] = PointInRect(x1, y1);
_lineVertices[1] = PointInRect(x2, y2);
Handles.color = Color.white * grayscale;
Handles.DrawAAPolyLine(2.0f, _lineVertices);
}
// Draw a rect in the graph rect.
void DrawRect(float x1, float y1, float x2, float y2, float fill, float line)
{
_rectVertices[0] = PointInRect(x1, y1);
_rectVertices[1] = PointInRect(x2, y1);
_rectVertices[2] = PointInRect(x2, y2);
_rectVertices[3] = PointInRect(x1, y2);
Handles.DrawSolidRectangleWithOutline(
_rectVertices,
fill < 0 ? Color.clear : Color.white * fill,
line < 0 ? Color.clear : Color.white * line
);
}
#endregion
}
#endif
}

View File

@@ -0,0 +1,12 @@
fileFormatVersion: 2
guid: 4afcb2949e7fb42679b587b8848b7e02
timeCreated: 1457674915
licenseType: Store
MonoImporter:
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

View File

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

View File

@@ -0,0 +1,338 @@
using UnityEngine;
using System.Collections;
using System.Collections.Generic;
using System.Linq;
public class BF_AddSnow : MonoBehaviour
{
public Material snowMaterial;
public float angle = 80f;
public bool isAuto = false;
public float intersectionOffset = 0.25f;
public bool useIntersection = false;
public bool useUpdatedRotation = false;
private Mesh originalMesh;
private MeshFilter meshFilter;
private Mesh newMesh;
private GameObject newGO;
private float yIntersection = 0f;
private Quaternion ySlope = Quaternion.identity;
private float zNormal = 0;
private Vector3 normalHit = Vector3.zero;
private float oldyIntersection = -1f;
private int[] oldTri;
private Vector3[] oldVert;
private Vector3[] oldNorm;
private Vector3[] oldNormWorld;
private Vector2[] oldUV;
private Color[] oldCol;
private List<int> triangles = new List<int>();
private List<Vector3> vertexs = new List<Vector3>();
private List<Vector2> uvs = new List<Vector2>();
private List<Color> cols = new List<Color>();
void Start()
{
CheckValues();
BuildInitialGeometry();
}
private void Update()
{
if (useIntersection)
{
CheckIntersection();
}
if (useUpdatedRotation)
{
UpdateVertexColor();
}
}
private void CheckValues()
{
meshFilter = gameObject.GetComponent<MeshFilter>();
originalMesh = meshFilter.mesh;
oldTri = originalMesh.triangles;
oldVert = originalMesh.vertices;
oldNorm = originalMesh.normals;
oldNormWorld = oldNorm;
if (isAuto)
{
int k = 0;
foreach (Vector3 norm in oldNorm)
{
oldNormWorld[k] = this.transform.localToWorldMatrix.MultiplyVector(norm).normalized;
k++;
}
oldCol = new Color[oldVert.Length];
}
else
{
oldCol = originalMesh.colors;
}
oldUV = originalMesh.uv;
}
private void CheckIntersection()
{
int layerMask = 1 << 0 | 1 << 4;
RaycastHit hit;
RaycastHit hitIfHit;
if (Physics.Raycast(transform.position + Vector3.up*5f, Vector3.down, out hit, 200, layerMask))
{
if (hit.transform != this.transform)
{
yIntersection = hit.point.y + intersectionOffset;
//Vector3 tangent = Vector3.ProjectOnPlane(Vector3.down, hit.normal).normalized;
ySlope = Quaternion.LookRotation(hit.normal, Vector3.forward);
zNormal = ((hit.normal.normalized.z) + 1f) / 2f;
normalHit = hit.normal.normalized;
if (yIntersection != oldyIntersection)
{
UpdateSlopeColor();
}
oldyIntersection = yIntersection;
}
else
{
if (Physics.Raycast(hit.point + Vector3.up * -0.05f, Vector3.down, out hitIfHit, 200, layerMask))
{
if (hitIfHit.transform != this.transform)
{
yIntersection = hitIfHit.point.y + intersectionOffset;
//Vector3 tangent = Vector3.ProjectOnPlane(Vector3.down, hitIfHit.normal).normalized;
ySlope = Quaternion.LookRotation(hitIfHit.normal, Vector3.forward);
zNormal = ((hitIfHit.normal.normalized.z) + 1f) / 2f;
normalHit = hitIfHit.normal.normalized;
if (yIntersection != oldyIntersection)
{
UpdateSlopeColor();
}
oldyIntersection = yIntersection;
}
}
}
}
}
private void ClearGeometry()
{
triangles.Clear();
triangles.TrimExcess();
vertexs.Clear();
vertexs.TrimExcess();
uvs.Clear();
uvs.TrimExcess();
cols.Clear();
cols.TrimExcess();
}
private void BuildInitialGeometry()
{
if (meshFilter == null)
{
meshFilter = gameObject.GetComponent<MeshFilter>();
}
newMesh = new Mesh();
newGO = new GameObject();
MeshFilter mF = newGO.AddComponent<MeshFilter>();
MeshRenderer mR = newGO.AddComponent<MeshRenderer>();
mF.mesh = newMesh;
mR.material = snowMaterial;
snowMaterial.SetFloat("_ISADD", 1);
snowMaterial.EnableKeyword("IS_ADD");
if (useIntersection)
{
if (snowMaterial.GetFloat("_USEINTER") == 0)
{
snowMaterial.SetFloat("_USEINTER", 1);
snowMaterial.EnableKeyword("USE_INTER");
}
}
else
{
if (snowMaterial.GetFloat("_USEINTER") == 1)
{
snowMaterial.SetFloat("_USEINTER", 0);
snowMaterial.DisableKeyword("USE_INTER");
}
}
newGO.transform.parent = this.transform;
newGO.transform.localPosition = Vector3.zero;
newGO.transform.localScale = Vector3.one;
newGO.transform.localRotation = Quaternion.identity;
int indexNewV = 0;
foreach (Vector3 v in oldVert)
{
vertexs.Add(v + new Vector3(0,0,0));
uvs.Add(oldUV[indexNewV]);
indexNewV++;
}
indexNewV = 0;
foreach (int innt in oldTri)
{
triangles.Add(oldTri[indexNewV]);
indexNewV++;
}
if (isAuto)
{
int j = 0;
foreach (Vector3 norm in oldNormWorld)
{
if(j>= oldCol.Length)
{
break;
}
oldCol[j] = Color.red;
float theAngle = Vector3.Angle(Vector3.up, norm);
if (theAngle < (angle+10f))
{
Color lerpedColor = Color.Lerp(Color.white, Color.red, Mathf.Max(0f,theAngle- angle/2f) / (angle / 2f));
oldCol[j] = lerpedColor;
}
j++;
}
}
cols = oldCol.ToList();
newMesh.vertices = vertexs.ToArray();
newMesh.triangles = triangles.ToArray();
newMesh.uv = uvs.ToArray();
newMesh.colors = cols.ToArray();
newMesh.normals = originalMesh.normals;
RecalculateNormalsSeamless(newMesh);
newMesh.RecalculateBounds();
newMesh.Optimize();
}
private void UpdateVertexColor()
{
Color[] updatedColors = newMesh.colors;
Vector3[] newNormWorld = newMesh.normals;
if (isAuto)
{
int k = 0;
foreach (Vector3 norm in newMesh.normals)
{
newNormWorld[k] = this.transform.localToWorldMatrix.MultiplyVector(norm).normalized;
k++;
}
}
if (isAuto)
{
int j = 0;
foreach (Vector3 norm in newNormWorld)
{
if (j >= updatedColors.Length)
{
break;
}
float theAngle = Vector3.Angle(Vector3.up, norm);
if (theAngle < (angle + 10f))
{
Color lerpedColor = Color.Lerp(new Color(1,1,1, updatedColors[j].a), new Color(1, 0, 0, updatedColors[j].a), Mathf.Max(0f, theAngle - angle / 2f) / (angle / 2f));
updatedColors[j].r = lerpedColor.r;
updatedColors[j].g = lerpedColor.g;
updatedColors[j].b = lerpedColor.b;
updatedColors[j].a = lerpedColor.a;
}
j++;
}
}
newMesh.colors = updatedColors;
}
private void UpdateSlopeColor()
{
// This is not perfect for now but gets the job done... //
int j = 0;
Color[] updatedColors = newMesh.colors;
Vector2[] updatedUV4 = new Vector2[updatedColors.Count()];
Vector2[] updatedUV5 = new Vector2[updatedColors.Count()];
Vector2[] updatedUV6 = new Vector2[updatedColors.Count()];
Vector2[] updatedUV7 = new Vector2[updatedColors.Count()];
foreach (Color norm in newMesh.colors)
{
updatedColors[j].a = yIntersection;
updatedUV4[j] = new Vector2(normalHit.x, normalHit.y);
updatedUV5[j] = new Vector2(zNormal, normalHit.z);
updatedUV6[j] = new Vector2(ySlope.x, ySlope.y);
updatedUV7[j] = new Vector2(ySlope.z, ySlope.w);
j++;
}
newMesh.colors = updatedColors;
newMesh.uv4 = updatedUV4;
newMesh.uv5 = updatedUV5;
newMesh.uv6 = updatedUV6;
newMesh.uv7 = updatedUV7;
}
private void RecalculateNormalsSeamless(Mesh mesh)
{
var trianglesOriginal = mesh.triangles;
var triangles = trianglesOriginal.ToArray();
var vertices = mesh.vertices;
var mergeIndices = new Dictionary<int, int>();
for (int i = 0; i < vertices.Length; i++)
{
var vertexHash = vertices[i].GetHashCode();
if (mergeIndices.TryGetValue(vertexHash, out var index))
{
for (int j = 0; j < triangles.Length; j++)
if (triangles[j] == i)
triangles[j] = index;
}
else
mergeIndices.Add(vertexHash, i);
}
mesh.triangles = triangles;
var normals = new Vector3[vertices.Length];
mesh.RecalculateNormals();
var newNormals = mesh.normals;
for (int i = 0; i < vertices.Length; i++)
if (mergeIndices.TryGetValue(vertices[i].GetHashCode(), out var index))
normals[i] = newNormals[index];
mesh.triangles = trianglesOriginal;
mesh.normals = normals;
}
}

View File

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

View File

@@ -0,0 +1,46 @@
using UnityEngine;
using System.Collections;
public class BF_FPS : MonoBehaviour
{
float deltaTime = 0.0f;
private GUIStyle style = null;
private bool ShowFps = false;
private void Start()
{
ShowFps = true;
style = new GUIStyle();
style.alignment = TextAnchor.UpperLeft;
style.normal.textColor = new Color(1.0f, 0.0f, 0.0f, 1.0f);
}
void Update()
{
if(Input.GetKeyDown(KeyCode.Alpha2))
{
ShowFps = !ShowFps;
}
if(ShowFps)
deltaTime += (Time.unscaledDeltaTime - deltaTime) * 0.1f;
}
void OnGUI()
{
if (ShowFps)
{
int w = Screen.width, h = Screen.height;
style.fontSize = h * 4 / 100;
Rect rect = new Rect(0, 0, w, h * 2 / 100);
float msec = deltaTime * 1000.0f;
float fps = 1.0f / deltaTime;
GUI.Label(rect, string.Format("{0:0.0} ms ({1:0.} fps)", msec, fps), style);
}
}
}

View File

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

View File

@@ -0,0 +1,133 @@
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
#if ENABLE_INPUT_SYSTEM
using UnityEngine.InputSystem;
#endif
public class BF_FxMouse : MonoBehaviour
{
private Camera mainCam;
public ParticleSystem ps;
public ParticleSystem psRightClick;
public ParticleSystem psMiddleClick;
private float raycastSize = 200f;
// Start is called before the first frame update
void Start()
{
mainCam = this.GetComponent<Camera>();
}
void OnEnable()
{
mainCam = this.GetComponent<Camera>();
}
// Update is called once per frame
void Update()
{
#if ENABLE_LEGACY_INPUT_MANAGER
if (Input.GetMouseButton(0))
{
RaycastHit hit;
Ray ray = mainCam.ScreenPointToRay(Input.mousePosition);
Debug.DrawRay(this.transform.position, ray.direction);
if (Physics.Raycast(ray, out hit, raycastSize))
{
if (!ps.isEmitting)
{
ps.Play();
}
ps.transform.position = hit.point;
}
}
else
{
ps.Stop();
}
if (Input.GetMouseButton(1))
{
RaycastHit hit;
Ray ray = mainCam.ScreenPointToRay(Input.mousePosition);
Debug.DrawRay(this.transform.position, ray.direction);
if (Physics.Raycast(ray, out hit, raycastSize))
{
if (!psRightClick.isEmitting)
{
psRightClick.Play();
}
psRightClick.transform.position = hit.point;
}
}
else
{
psRightClick.Stop();
}
if (Input.GetMouseButton(2))
{
RaycastHit hit;
Ray ray = mainCam.ScreenPointToRay(Input.mousePosition);
Debug.DrawRay(this.transform.position, ray.direction);
if (Physics.Raycast(ray, out hit, raycastSize))
{
if (!psMiddleClick.isEmitting)
{
psMiddleClick.Play();
}
psMiddleClick.transform.position = hit.point;
}
}
else
{
psMiddleClick.Stop();
}
#else
if (Mouse.current.leftButton.isPressed)
{
RaycastHit hit;
Ray ray = mainCam.ScreenPointToRay(Mouse.current.position.ReadValue());
Debug.DrawRay(this.transform.position, ray.direction);
if (Physics.Raycast(ray, out hit, raycastSize))
{
if (!ps.isEmitting)
{
ps.Play();
}
ps.transform.position = hit.point;
}
else
{
// ps.Stop();
}
}
else
{
ps.Stop();
}
if (Mouse.current.rightButton.isPressed)
{
RaycastHit hit;
Ray ray = mainCam.ScreenPointToRay(Mouse.current.position.ReadValue());
Debug.DrawRay(this.transform.position, ray.direction);
if (Physics.Raycast(ray, out hit, raycastSize))
{
if (!psRightClick.isEmitting)
{
psRightClick.Play();
}
psRightClick.transform.position = hit.point;
}
else
{
// ps.Stop();
}
}
else
{
psRightClick.Stop();
}
#endif
}
}

View File

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

View File

@@ -0,0 +1,31 @@
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.EventSystems;
#if ENABLE_INPUT_SYSTEM
using UnityEngine.InputSystem;
using UnityEngine.InputSystem.UI;
#endif
public class BF_InputSystemSwitcher : MonoBehaviour
{
public GameObject eventS;
// Start is called before the first frame update
void Awake()
{
#if ENABLE_INPUT_SYSTEM
if (eventS.GetComponent<InputSystemUIInputModule>() == null)
{
if(eventS.GetComponent<StandaloneInputModule>() != null)
{
Destroy(eventS.GetComponent<StandaloneInputModule>());
}
InputSystemUIInputModule inputSystem = eventS.AddComponent<InputSystemUIInputModule>();
inputSystem.enabled = false;
inputSystem.enabled = true;
inputSystem.UpdateModule();
}
#endif
}
}

View File

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

View File

@@ -0,0 +1,74 @@
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
[ExecuteInEditMode]
public class BF_InteractiveEffects : MonoBehaviour
{
public Transform transformToFollow;
public RenderTexture rt;
public string GlobalTexName = "_GlobalEffectRT";
public string GlobalOrthoName = "_OrthographicCamSize";
public bool isPaced = false;
private float orthoMem = 0;
private Coroutine waitPace;
private bool paceRunning = false;
private void Awake()
{
orthoMem = GetComponent<Camera>().orthographicSize;
Shader.SetGlobalFloat(GlobalOrthoName, orthoMem);
Shader.SetGlobalTexture(GlobalTexName, rt);
Shader.SetGlobalFloat("_HasRT", 1);
}
private void OnEnable()
{
orthoMem = GetComponent<Camera>().orthographicSize;
Shader.SetGlobalFloat(GlobalOrthoName, orthoMem);
Shader.SetGlobalTexture(GlobalTexName, rt);
Shader.SetGlobalFloat("_HasRT", 1);
}
private void MoveCamera()
{
if (transformToFollow != null)
{
transform.position = new Vector3(transformToFollow.position.x, transformToFollow.position.y + 20, transformToFollow.position.z);
}
Shader.SetGlobalVector("_Position", transform.position);
transform.rotation = Quaternion.Euler(new Vector3(90, 0, 0));
}
private void Update()
{
if(isPaced)
{
if(!paceRunning)
{
waitPace = StartCoroutine(WaitPace());
}
}
else
{
if (paceRunning)
{
paceRunning = false;
StopCoroutine(WaitPace());
}
MoveCamera();
}
}
private IEnumerator WaitPace()
{
for(; ;)
{
paceRunning = true;
MoveCamera();
yield return new WaitForSeconds(1f);
}
}
}

View File

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

View File

@@ -0,0 +1,79 @@
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
[ExecuteInEditMode]
public class BF_InteractiveEffectsAdditional : MonoBehaviour
{
public Transform mainCamera;
public RenderTexture rt;
public string GlobalTexName = "_GlobalEffectRTAdditional";
public string GlobalOrthoName = "_OrthographicCamSizeAdditional";
public bool isPaced = false;
private float orthoMem = 0;
private Vector3 camDir;
private Coroutine waitPace;
private bool paceRunning = false;
private void Awake()
{
orthoMem = GetComponent<Camera>().orthographicSize;
Shader.SetGlobalFloat(GlobalOrthoName, orthoMem);
Shader.SetGlobalTexture(GlobalTexName, rt);
}
private void OnEnable()
{
orthoMem = GetComponent<Camera>().orthographicSize;
Shader.SetGlobalFloat(GlobalOrthoName, orthoMem);
Shader.SetGlobalTexture(GlobalTexName, rt);
}
private void MoveCamera()
{
if (mainCamera != null)
{
camDir = Vector3.ProjectOnPlane(mainCamera.forward, Vector3.up).normalized;
camDir.y = 0f;
if (mainCamera != null)
{
float YView = Vector3.Angle(Vector3.down, mainCamera.forward);
transform.position = new Vector3(mainCamera.position.x, mainCamera.position.y + 20, mainCamera.position.z) + camDir.normalized * Mathf.Max(0f, orthoMem - 20f) * Mathf.Clamp01(((YView - 35) * 3) / 35);
}
}
Shader.SetGlobalVector("_PositionAdd", transform.position);
transform.rotation = Quaternion.Euler(new Vector3(90, 0, 0));
}
private void Update()
{
if (isPaced)
{
if (!paceRunning)
{
waitPace = StartCoroutine(WaitPace());
}
}
else
{
if (paceRunning)
{
paceRunning = false;
StopCoroutine(WaitPace());
}
MoveCamera();
}
}
private IEnumerator WaitPace()
{
for (; ; )
{
paceRunning = true;
MoveCamera();
yield return new WaitForSeconds(1f);
}
}
}

View File

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

View File

@@ -0,0 +1,30 @@
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class BF_LightSwitch : MonoBehaviour
{
public GameObject lightScene;
public Material skyboxScene;
void OnEnable()
{
if(lightScene != null)
{
lightScene.SetActive(true);
}
if(skyboxScene != null)
{
RenderSettings.skybox = skyboxScene;
}
}
void OnDisable()
{
if (lightScene != null)
{
lightScene.SetActive(false);
}
}
}

View File

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

View File

@@ -0,0 +1,84 @@
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
#if ENABLE_INPUT_SYSTEM
using UnityEngine.InputSystem;
#endif
public class BF_PlayerMovement : MonoBehaviour
{
public Camera cam;
private Rigidbody rb;
private Quaternion camRot;
private Vector3 moveDirection;
private Vector3 inputDirection;
// Start is called before the first frame update
void Start()
{
rb = this.GetComponent<Rigidbody>();
if(cam == null)
{
cam = Camera.main;
}
} // Start is called before the first frame update
void OnEnable()
{
rb = this.GetComponent<Rigidbody>();
if(cam == null)
{
cam = Camera.main;
}
}
// Update is called once per frame
void FixedUpdate()
{
inputDirection = Vector3.zero;
#if ENABLE_INPUT_SYSTEM
if (Keyboard.current.qKey.isPressed || Keyboard.current.aKey.isPressed)
{
inputDirection += new Vector3(0, 0, 1);
}
if (Keyboard.current.dKey.isPressed)
{
inputDirection += new Vector3(0, 0, -1);
}
if (Keyboard.current.wKey.isPressed || Keyboard.current.zKey.isPressed)
{
inputDirection += new Vector3(1, 0, 0);
}
if (Keyboard.current.sKey.isPressed)
{
inputDirection += new Vector3(-1, 0, 0);
}
#else
if (Input.GetKey(KeyCode.Q)|| Input.GetKey(KeyCode.A))
{
inputDirection += new Vector3(0, 0, 1);
}
if (Input.GetKey(KeyCode.D))
{
inputDirection += new Vector3(0, 0, -1);
}
if (Input.GetKey(KeyCode.Z) || Input.GetKey(KeyCode.W))
{
inputDirection += new Vector3(1, 0, 0);
}
if (Input.GetKey(KeyCode.S))
{
inputDirection += new Vector3(-1, 0, 0);
}
#endif
MoveBall();
}
private void MoveBall()
{
camRot = Quaternion.LookRotation(cam.transform.forward, Vector3.up);
moveDirection = camRot * new Vector3(Mathf.Clamp(inputDirection.x * 2, -1, 1), 0, Mathf.Clamp(inputDirection.z * 2, -1, 1));
rb.AddTorque(moveDirection*22.5f);
rb.AddForce(moveDirection*15f,ForceMode.Force);
}
}

View File

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

View File

@@ -0,0 +1,19 @@
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class BF_PlayerReset : MonoBehaviour
{
public GameObject player;
public Transform playerPos;
void OnEnable()
{
player.transform.position = playerPos.position;
}
void Start()
{
player.transform.position = playerPos.position;
}
}

View File

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

View File

@@ -0,0 +1,156 @@
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class BF_PlayerSnow : MonoBehaviour
{
public Collider playerCollider;
public ParticleSystem particleSys;
public PhysicsMaterial playerMatDefault;
public PhysicsMaterial playerMatSnow;
public PhysicsMaterial playerMatIce;
private Rigidbody rB;
private float speedMult = 1;
private float lerpIce = 0;
private MeshCollider oldMC = null;
private Mesh mesh = null;
private ParticleSystem.MainModule pSMain;
// Start is called before the first frame update
void Start()
{
oldMC = null;
mesh = null;
rB = this.GetComponent<Rigidbody>();
pSMain = particleSys.main;
}
private void CheckIceCols(float snowCol)
{
lerpIce = snowCol / 255f;
if (snowCol == -1)
{
if (playerCollider.material != playerMatDefault)
{
playerCollider.material = playerMatDefault;
}
return;
}
if (lerpIce <= 0.925f && playerCollider.material != playerMatIce)
{
playerCollider.material = playerMatIce;
rB.angularDamping = 0.25f;
}
else if(lerpIce >= 0.925f && playerCollider.material != playerMatSnow)
{
playerCollider.material = playerMatSnow;
rB.angularDamping = 5f;
}
}
private void OnCollisionStay(Collision collision)
{
if (lerpIce >= 0.925f && collision.collider.gameObject.layer == 4)
{
AddSnow(1.5f);
}
else
{
RemoveSnow(0.05f);
}
}
private void OnCollisionEnter(Collision collision)
{
if(collision.impulse.magnitude>10)
{
// RemoveSnow(20);
}
}
private void AddSnow(float multiplier)
{
if (playerCollider.transform.localScale.x < 7f)
{
speedMult = Mathf.Clamp(rB.linearVelocity.magnitude * 0.02f,0,1);
playerCollider.transform.localScale += Vector3.zero + Vector3.one * 0.0035f * 2 * multiplier* speedMult;
playerCollider.transform.localScale += Vector3.zero + Vector3.one * 0.005f * 2 * multiplier * speedMult;
}
}
private void RemoveSnow(float multiplier)
{
if (playerCollider.transform.localScale.x >= 1.1f)
{
if (!playerCollider.transform.gameObject.activeInHierarchy)
{
// SnowPlayer.gameObject.SetActive(true);
}
playerCollider.transform.localScale -= Vector3.zero + Vector3.one * 0.0035f * 4 * multiplier;
playerCollider.transform.localScale -= Vector3.zero + Vector3.one * 0.005f * 4 * multiplier;
}
if (playerCollider.transform.localScale.x < 1.1f)
{
if (playerCollider.transform.gameObject.activeInHierarchy)
{
// SnowPlayer.gameObject.SetActive(false);
}
playerCollider.transform.localScale = Vector3.one * 1.1f;
playerCollider.transform.localScale = Vector3.one * 1.1f;
}
}
private void FixedUpdate()
{
ChangePlayerMass();
CheckSnowUnderneath();
}
private void CheckSnowUnderneath()
{
RaycastHit hit;
int layerMask = 1 << 4;
if (Physics.Raycast(transform.position+(Vector3.down*(playerCollider.transform.localScale.x/2)+Vector3.up*0.5f), Vector3.down, out hit, 5, layerMask,QueryTriggerInteraction.Ignore))
{
MeshCollider meshCollider = hit.collider as MeshCollider;
if (oldMC != meshCollider || mesh == null)
{
mesh = meshCollider.GetComponent<MeshFilter>().sharedMesh;
}
oldMC = meshCollider;
if (meshCollider == null || meshCollider.sharedMesh == null)
{
CheckIceCols(255f);
return;
}
//Mesh mesh = meshCollider.sharedMesh;
int[] triangles = mesh.triangles;
Color32[] colorArray;
colorArray = mesh.colors32;
var vertIndex1 = triangles[hit.triangleIndex * 3 + 0];
CheckIceCols(((float)colorArray[vertIndex1].g) / 1);
}
else
{
if (playerCollider.material != playerMatDefault)
{
playerCollider.material = playerMatDefault;
}
}
}
private void ChangePlayerMass()
{
rB.mass = Mathf.Lerp(1.95f, 2.5f, (playerCollider.transform.localScale.x-1.2f) / 7);
pSMain.startSize = playerCollider.transform.localScale.x+0.5f;
}
}

View File

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

View File

@@ -0,0 +1,12 @@
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class BF_Rotator : MonoBehaviour
{
public float RotSpeed = 1;
void Update()
{
this.transform.Rotate(new Vector3(0, RotSpeed*Time.deltaTime, 0), Space.World);
}
}

View File

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

View File

@@ -0,0 +1,122 @@
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.Events;
#if ENABLE_INPUT_SYSTEM
using UnityEngine.InputSystem;
#endif
public class BF_SnowAssetManager : MonoBehaviour
{
public GameObject UIText;
public int showcaseIndex = 0;
[HideInInspector] public int subShowcaseIndex = 0;
public List<GameObject> showcasesGO;
public List<GameObject> cameras;
public List<GameObject> lights;
public List<Material> skyboxes;
[Space]
public GameObject specialCamera;
public GameObject specialButton;
public GameObject specialInfo;
private int maxIndex = 4;
[HideInInspector] public int maxSubIndex = 3;
[HideInInspector] public UnityEvent m_ShowcaseChange = new UnityEvent();
// Start is called before the first frame update
void Start()
{
maxIndex = showcasesGO.Count - 1;
SwitchShowcase(0);
SwitchSubShowcase(0);
RenderSettings.fog = true;
RenderSettings.fogDensity = 0.00f;
UIText.SetActive(false);
specialCamera.SetActive(false);
specialButton.SetActive(true);
specialInfo.SetActive(true);
}
public void SwitchShowcase(int addIndex)
{
for (int i = 0; i <= maxIndex; i++)
{
showcasesGO[i].SetActive(false);
cameras[i].SetActive(false);
lights[i].SetActive(false);
}
showcaseIndex += addIndex;
if (showcaseIndex <= -1)
{
showcaseIndex = maxIndex;
}
else if (showcaseIndex == maxIndex + 1)
{
showcaseIndex = 0;
}
showcasesGO[showcaseIndex].SetActive(true);
cameras[showcaseIndex].SetActive(true);
lights[showcaseIndex].SetActive(true);
RenderSettings.skybox = skyboxes[showcaseIndex];
subShowcaseIndex = 0;
m_ShowcaseChange.Invoke();
if(showcaseIndex != 0)
{
RenderSettings.fogDensity = 0.001f;
specialCamera.SetActive(false);
specialButton.SetActive(false);
specialInfo.SetActive(false);
}
else
{
specialCamera.SetActive(false);
RenderSettings.fogDensity = 0.00f;
specialButton.SetActive(true);
specialInfo.SetActive(true);
}
}
public void SwitchSubShowcase(int addIndex)
{
subShowcaseIndex += addIndex;
if (subShowcaseIndex <= -1)
{
subShowcaseIndex = maxSubIndex;
}
else if (subShowcaseIndex == maxSubIndex + 1)
{
subShowcaseIndex = 0;
}
m_ShowcaseChange.Invoke();
}
public void ActivateSpecialCamera()
{
specialCamera.SetActive(!specialCamera.activeInHierarchy);
cameras[0].SetActive(!cameras[0].activeInHierarchy);
}
private void Update()
{
#if ENABLE_LEGACY_INPUT_MANAGER
if (Input.GetKeyDown(KeyCode.Alpha1))
{
SwitchSubShowcase(-1);
}
if (Input.GetKeyDown(KeyCode.Alpha2))
{
SwitchSubShowcase(1);
}
#else
if (Keyboard.current.digit1Key.wasPressedThisFrame)
{
SwitchSubShowcase(-1);
}
if (Keyboard.current.digit2Key.wasPressedThisFrame)
{
SwitchSubShowcase(1);
}
#endif
}
}

View File

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

View File

@@ -0,0 +1,55 @@
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.UI;
using UnityEngine.Events;
public class BF_SnowSubShowcase : MonoBehaviour
{
public BF_SnowAssetManager aM;
public Text uiText;
public List<GameObject> subShowcases;
public List<string> nameSubs;
private int oldIndex = -1;
private UnityAction showcaseChange;
// Start is called before the first frame update
private void OnEnable()
{
aM.maxSubIndex = subShowcases.Count-1;
aM.m_ShowcaseChange.AddListener(ChangeIndex);
}
private void OnDisable()
{
aM.m_ShowcaseChange.RemoveListener(ChangeIndex);
}
void Update()
{
/*
if(aM.subShowcaseIndex != oldIndex)
{
oldIndex = aM.subShowcaseIndex;
foreach(GameObject GO in subShowcases)
{
GO.SetActive(false);
}
subShowcases[oldIndex].SetActive(true);
uiText.text = nameSubs[oldIndex];
}
*/
}
private void ChangeIndex()
{
oldIndex = aM.subShowcaseIndex;
foreach (GameObject GO in subShowcases)
{
GO.SetActive(false);
}
subShowcases[oldIndex].SetActive(true);
uiText.text = nameSubs[oldIndex];
}
}

View File

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

View File

@@ -0,0 +1,204 @@
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEditor;
[ExecuteInEditMode]
public class BF_SnowTerrain : MonoBehaviour
{
public Terrain terrainToCopy;
public bool avoidCulling = false;
private Terrain terrainAsset;
private TerrainData terrainData;
private TerrainData terrainDataOld = null;
private Vector3 sizeOld = Vector3.one * 100f;
private float[,] terrainHeightOld = null;
private int heightRezOld = 0;
private Vector3 posOld = Vector3.zero;
private Material terrainMaterial;
private GameObject selectGO;
private bool isSynced = false;
void Start()
{
UpdateTerrainData();
}
void OnEnable()
{
UpdateTerrainData();
}
private void StoreTerrainData()
{
if (terrainDataOld == null)
{
terrainDataOld = terrainAsset.terrainData;
terrainHeightOld = terrainAsset.terrainData.GetHeights(0, 0, terrainAsset.terrainData.heightmapResolution, terrainAsset.terrainData.heightmapResolution);
sizeOld = terrainAsset.terrainData.size;
heightRezOld = terrainAsset.terrainData.heightmapResolution;
posOld = terrainAsset.transform.position;
}
}
private void ClearTerrainData()
{
terrainDataOld = null;
terrainHeightOld = null;
isSynced = false;
sizeOld = Vector3.one*100f;
}
private void UpdateTerrainData()
{
terrainAsset = this.GetComponent<Terrain>();
if (avoidCulling)
{
terrainAsset.patchBoundsMultiplier = Vector3.one * 2f;
}
else
{
terrainAsset.patchBoundsMultiplier = Vector3.one;
}
terrainData = terrainAsset.terrainData;
terrainMaterial = terrainAsset.materialTemplate;
terrainMaterial.SetTexture("_Control0", terrainData.GetAlphamapTexture(0));
terrainMaterial.SetTexture("_Control1", terrainData.GetAlphamapTexture(1));
terrainMaterial.SetVector("_TerrainScale", terrainData.size);
terrainMaterial.SetFloat("_IST", 1);
terrainMaterial.EnableKeyword("IS_T");
if (terrainData.terrainLayers.Length <= 4)
{
terrainMaterial.DisableKeyword("USE_COMPLEX_T");
}
if (terrainData.terrainLayers.Length > 4)
{
terrainMaterial.EnableKeyword("USE_COMPLEX_T");
terrainMaterial.SetTexture("_Normal4", terrainData.terrainLayers[4].normalMapTexture);
terrainMaterial.SetFloat("_NormalScale4", terrainData.terrainLayers[4].normalScale);
terrainMaterial.SetTexture("_Splat4", terrainData.terrainLayers[4].diffuseTexture);
terrainMaterial.SetVector("_Splat4_STn", new Vector4(terrainData.terrainLayers[4].tileSize.x, terrainData.terrainLayers[4].tileSize.y, terrainData.terrainLayers[4].tileOffset.x, terrainData.terrainLayers[4].tileOffset.y));
terrainMaterial.SetColor("_Specular4", terrainData.terrainLayers[4].specular);
terrainMaterial.SetFloat("_Metallic4", terrainData.terrainLayers[4].metallic);
terrainMaterial.SetTexture("_Mask4", terrainData.terrainLayers[4].maskMapTexture);
}
if (terrainData.terrainLayers.Length > 5)
{
terrainMaterial.SetTexture("_Normal5", terrainData.terrainLayers[5].normalMapTexture);
terrainMaterial.SetFloat("_NormalScale5", terrainData.terrainLayers[5].normalScale);
terrainMaterial.SetTexture("_Splat5", terrainData.terrainLayers[5].diffuseTexture);
terrainMaterial.SetVector("_Splat5_STn", new Vector4(terrainData.terrainLayers[5].tileSize.x, terrainData.terrainLayers[5].tileSize.y, terrainData.terrainLayers[5].tileOffset.x, terrainData.terrainLayers[5].tileOffset.y));
terrainMaterial.SetColor("_Specular5", terrainData.terrainLayers[5].specular);
terrainMaterial.SetFloat("_Metallic5", terrainData.terrainLayers[5].metallic);
terrainMaterial.SetTexture("_Mask5", terrainData.terrainLayers[5].maskMapTexture);
}
if (terrainData.terrainLayers.Length > 6)
{
terrainMaterial.SetTexture("_Normal6", terrainData.terrainLayers[6].normalMapTexture);
terrainMaterial.SetFloat("_NormalScale6", terrainData.terrainLayers[6].normalScale);
terrainMaterial.SetTexture("_Splat6", terrainData.terrainLayers[6].diffuseTexture);
terrainMaterial.SetVector("_Splat6_STn", new Vector4(terrainData.terrainLayers[6].tileSize.x, terrainData.terrainLayers[6].tileSize.y, terrainData.terrainLayers[6].tileOffset.x, terrainData.terrainLayers[6].tileOffset.y));
terrainMaterial.SetColor("_Specular6", terrainData.terrainLayers[6].specular);
terrainMaterial.SetFloat("_Metallic6", terrainData.terrainLayers[6].metallic);
terrainMaterial.SetTexture("_Mask6", terrainData.terrainLayers[6].maskMapTexture);
}
if (terrainData.terrainLayers.Length > 7)
{
terrainMaterial.SetTexture("_Normal7", terrainData.terrainLayers[7].normalMapTexture);
terrainMaterial.SetFloat("_NormalScale7", terrainData.terrainLayers[7].normalScale);
terrainMaterial.SetTexture("_Splat7", terrainData.terrainLayers[7].diffuseTexture);
terrainMaterial.SetVector("_Splat7_STn", new Vector4(terrainData.terrainLayers[7].tileSize.x, terrainData.terrainLayers[7].tileSize.y, terrainData.terrainLayers[7].tileOffset.x, terrainData.terrainLayers[7].tileOffset.y));
terrainMaterial.SetColor("_Specular7", terrainData.terrainLayers[7].specular);
terrainMaterial.SetFloat("_Metallic7", terrainData.terrainLayers[7].metallic);
terrainMaterial.SetTexture("_Mask7", terrainData.terrainLayers[7].maskMapTexture);
}
}
public void CopyTerrainData()
{
if(terrainToCopy != null && terrainToCopy != terrainAsset)
{
StoreTerrainData();
terrainAsset.terrainData.heightmapResolution = terrainToCopy.terrainData.heightmapResolution;
terrainAsset.terrainData.SetHeights(0, 0, terrainToCopy.terrainData.GetHeights(0, 0, terrainToCopy.terrainData.heightmapResolution, terrainToCopy.terrainData.heightmapResolution));
terrainAsset.terrainData.size = terrainToCopy.terrainData.size;
}
}
public void MoveTerrainSync()
{
if (terrainToCopy != null && terrainToCopy != terrainAsset)
{
isSynced = true;
terrainAsset.transform.position = terrainToCopy.transform.position + Vector3.up * 0.01f;
//terrainMaterial.SetFloat("_GrassCut", 1);
terrainAsset.terrainData.heightmapResolution = terrainToCopy.terrainData.heightmapResolution;
terrainAsset.terrainData.baseMapResolution = terrainToCopy.terrainData.baseMapResolution;
terrainAsset.terrainData.alphamapResolution = terrainToCopy.terrainData.alphamapResolution;
terrainMaterial.SetFloat("_ISADD", 1);
terrainMaterial.EnableKeyword("IS_ADD");
}
else
{
//terrainMaterial.SetFloat("_GrassCut", 0);
terrainMaterial.SetFloat("_ISADD", 0);
terrainMaterial.DisableKeyword("IS_ADD");
}
}
public void RevertTerrainData()
{
if (terrainDataOld != null)
{
terrainToCopy = null;
terrainAsset.terrainData = terrainDataOld;
terrainAsset.terrainData.heightmapResolution = heightRezOld;
terrainAsset.terrainData.size = sizeOld;
terrainAsset.terrainData.SetHeights(0, 0, terrainHeightOld);
//terrainMaterial.SetFloat("_GrassCut", 0);
terrainMaterial.SetFloat("_ISADD", 0);
terrainMaterial.DisableKeyword("IS_ADD");
terrainAsset.transform.position = posOld;
ClearTerrainData();
}
}
void OnRenderObject()
{
#if UNITY_EDITOR
if ((Application.isEditor && !Application.isPlaying)&& terrainToCopy!=null && isSynced)
{
if (Selection.activeGameObject == this.gameObject && selectGO != this.gameObject)
{
selectGO = Selection.activeGameObject;
terrainAsset.transform.position = terrainToCopy.transform.position + Vector3.up * 0.01f;
}
else if (Selection.activeGameObject == terrainToCopy.gameObject && selectGO != terrainToCopy.gameObject)
{
selectGO = Selection.activeGameObject;
terrainAsset.transform.position = terrainToCopy.transform.position + Vector3.down * 0.01f;
}
}
#endif
}
private void Update()
{
#if UNITY_EDITOR
if (Application.isEditor && !Application.isPlaying)
{
UpdateTerrainData();
if (isSynced && terrainToCopy != null && terrainToCopy.terrainData.GetHeights(0, 0, terrainToCopy.terrainData.heightmapResolution, terrainToCopy.terrainData.heightmapResolution) != terrainAsset.terrainData.GetHeights(0, 0, terrainAsset.terrainData.heightmapResolution, terrainAsset.terrainData.heightmapResolution))
{
CopyTerrainData();
}
}
#endif
}
}

View File

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

View File

@@ -0,0 +1,15 @@
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
[ExecuteInEditMode]
[RequireComponent(typeof(Camera))]
public class BF_SquareBanding : MonoBehaviour
{
public Material cinematicBandsFX = null;
private void OnRenderImage(RenderTexture source, RenderTexture destination)
{
Graphics.Blit(source, destination, cinematicBandsFX);
}
}

View File

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

View File

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

View File

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

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.9 MiB

View File

@@ -0,0 +1,92 @@
fileFormatVersion: 2
guid: f42cea328e314cb44a1359ea9e70a7d6
TextureImporter:
internalIDToNameTable: []
externalObjects: {}
serializedVersion: 11
mipmaps:
mipMapMode: 0
enableMipMap: 1
sRGBTexture: 1
linearTexture: 0
fadeOut: 0
borderMipMap: 0
mipMapsPreserveCoverage: 0
alphaTestReferenceValue: 0.5
mipMapFadeDistanceStart: 1
mipMapFadeDistanceEnd: 3
bumpmap:
convertToNormalMap: 0
externalNormalMap: 0
heightScale: 0.25
normalMapFilter: 0
isReadable: 0
streamingMipmaps: 0
streamingMipmapsPriority: 0
grayScaleToAlpha: 0
generateCubemap: 6
cubemapConvolution: 0
seamlessCubemap: 0
textureFormat: 1
maxTextureSize: 2048
textureSettings:
serializedVersion: 2
filterMode: -1
aniso: -1
mipBias: -100
wrapU: -1
wrapV: -1
wrapW: -1
nPOTScale: 1
lightmap: 0
compressionQuality: 50
spriteMode: 0
spriteExtrude: 1
spriteMeshType: 1
alignment: 0
spritePivot: {x: 0.5, y: 0.5}
spritePixelsToUnits: 100
spriteBorder: {x: 0, y: 0, z: 0, w: 0}
spriteGenerateFallbackPhysicsShape: 1
alphaUsage: 1
alphaIsTransparency: 0
spriteTessellationDetail: -1
textureType: 0
textureShape: 1
singleChannelComponent: 0
maxTextureSizeSet: 0
compressionQualitySet: 0
textureFormatSet: 0
applyGammaDecoding: 0
platformSettings:
- serializedVersion: 3
buildTarget: DefaultTexturePlatform
maxTextureSize: 2048
resizeAlgorithm: 0
textureFormat: -1
textureCompression: 1
compressionQuality: 50
crunchedCompression: 0
allowsAlphaSplitting: 0
overridden: 0
androidETC2FallbackOverride: 0
forceMaximumCompressionQuality_BC6H_BC7: 0
spriteSheet:
serializedVersion: 2
sprites: []
outline: []
physicsShape: []
bones: []
spriteID:
internalID: 0
vertices: []
indices:
edges: []
weights: []
secondaryTextures: []
spritePackingTag:
pSDRemoveMatte: 0
pSDShowRemoveMatteOption: 0
userData:
assetBundleName:
assetBundleVariant: