add live select pannel

This commit is contained in:
CroakFang
2023-01-20 07:13:54 +08:00
parent 3b18268252
commit a4dc2516e3
1543 changed files with 107369 additions and 9227 deletions
@@ -0,0 +1,82 @@
using UnityEngine;
namespace UnityStandardAssets.ImageEffects
{
[ExecuteInEditMode]
[RequireComponent(typeof(Camera))]
[AddComponentMenu("Image Effects/Blur/Blur (Optimized)")]
public class BlurOptimized : PostEffectsBase
{
[Range(0f, 2f)]
public int downsample = 1;
[Range(0f, 10f)]
public float blurSize = 3f;
[Range(1f, 4f)]
public int blurIterations = 2;
public Shader blurShader;
private Material blurMaterial;
public override bool CheckResources()
{
CheckSupport(needDepth: false);
blurMaterial = CheckShaderAndCreateMaterial(blurShader, blurMaterial);
if (blurMaterial == null)
{
return false;
}
if (!isSupported)
{
ReportAutoDisable();
}
return isSupported;
}
public void OnDisable()
{
if ((bool)blurMaterial)
{
Object.DestroyImmediate(blurMaterial);
}
}
public void OnRenderImage(RenderTexture source, RenderTexture destination)
{
if (!CheckResources())
{
Graphics.Blit(source, destination);
return;
}
float num = 1f / (1f * (float)(1 << downsample));
blurMaterial.SetVector("_Parameter", new Vector4(blurSize * num, (0f - blurSize) * num, 0f, 0f));
source.filterMode = FilterMode.Bilinear;
int width = source.width >> downsample;
int height = source.height >> downsample;
RenderTexture renderTexture = RenderTexture.GetTemporary(width, height, 0, source.format);
renderTexture.filterMode = FilterMode.Bilinear;
Graphics.Blit(source, renderTexture, blurMaterial, 0);
int num2 = 0;
for (int i = 0; i < blurIterations; i++)
{
float num3 = (float)i * 1f;
blurMaterial.SetVector("_Parameter", new Vector4(blurSize * num + num3, (0f - blurSize) * num - num3, 0f, 0f));
RenderTexture temporary = RenderTexture.GetTemporary(width, height, 0, source.format);
temporary.filterMode = FilterMode.Bilinear;
Graphics.Blit(renderTexture, temporary, blurMaterial, 1 + num2);
RenderTexture.ReleaseTemporary(renderTexture);
renderTexture = temporary;
temporary = RenderTexture.GetTemporary(width, height, 0, source.format);
temporary.filterMode = FilterMode.Bilinear;
Graphics.Blit(renderTexture, temporary, blurMaterial, 2 + num2);
RenderTexture.ReleaseTemporary(renderTexture);
renderTexture = temporary;
}
Graphics.Blit(renderTexture, destination);
RenderTexture.ReleaseTemporary(renderTexture);
}
}
}
@@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: e4beaab526692ab42b7db5ec459df52e
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:
@@ -0,0 +1,99 @@
using UnityEngine;
/// <summary>
/// キャラクタ影を投影するオブジェクトに使用
/// </summary>
[ExecuteInEditMode]
[RequireComponent(typeof(Camera))]
[AddComponentMenu("Image Effects/CastShadow")]
public class CastShadowEffect : MonoBehaviour
{
private const int Resolution = 256;
private static readonly int ProjectedAmbientMatrixId = Shader.PropertyToID("_ProjectedAmbientMatrix");
private GameObject[] _rendererObj;
private int[] _backupLayer;
private int _cullingLayer;
private Camera _shadowCamera;
private Shader _shadowShader;
private RenderTexture _renderTexture;
private MeshRenderer _targetMesh;
public void Initialize(Shader shadowShader, Shader shadowReciveShader, CharacterObject characterObj, MeshRenderer revieveMesh, int cullingLayer)
{
_shadowShader = shadowShader;
_targetMesh = revieveMesh;
_targetMesh.material.shader = shadowReciveShader;
Renderer[] componentsInChildren = characterObj.GetComponentsInChildren<Renderer>();
_rendererObj = new GameObject[componentsInChildren.Length];
_backupLayer = new int[componentsInChildren.Length];
for (int i = 0; i < componentsInChildren.Length; i++)
{
_rendererObj[i] = componentsInChildren[i].gameObject;
}
_cullingLayer = cullingLayer;
}
private void Start()
{
_shadowCamera = GetComponent<Camera>();
_shadowCamera.SetReplacementShader(_shadowShader, "Chara");
if (Application.isPlaying)
{
_renderTexture = new RenderTexture(256, 256, 0);
_renderTexture.autoGenerateMips = false;
_renderTexture.useMipMap = false;
_renderTexture.filterMode = FilterMode.Bilinear;
_renderTexture.wrapMode = TextureWrapMode.Clamp;
_renderTexture.antiAliasing = 1;
_renderTexture.Create();
_targetMesh.material.SetTexture("_ProjectionTex", _renderTexture);
_shadowCamera.targetTexture = _renderTexture;
}
}
private void OnDestroy()
{
if (_renderTexture != null)
{
_renderTexture.Release();
_renderTexture = null;
}
}
private void OnPreCull()
{
int num = 0;
GameObject[] rendererObj = _rendererObj;
foreach (GameObject gameObject in rendererObj)
{
_backupLayer[num] = gameObject.layer;
gameObject.layer = _cullingLayer;
num++;
}
}
private void OnPostRender()
{
int num = 0;
GameObject[] rendererObj = _rendererObj;
for (int i = 0; i < rendererObj.Length; i++)
{
rendererObj[i].layer = _backupLayer[num];
num++;
}
}
private void Update()
{
Matrix4x4 value = _shadowCamera.projectionMatrix * _shadowCamera.worldToCameraMatrix;
_targetMesh.material.SetMatrix(ProjectedAmbientMatrixId, value);
}
}
@@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: 602f1a9b9659c414eaf227640efa73b9
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:
@@ -0,0 +1,235 @@
using UnityEngine;
namespace UnityStandardAssets.ImageEffects
{
[ExecuteInEditMode]
[RequireComponent(typeof(Camera))]
public class PostEffectsBase : MonoBehaviour
{
private static bool supportDX11 = false;
private static bool supportImageEffects = true;
private static bool supportHDRTextures = true;
private static bool supportDepthTexture = true;
protected Camera _camera;
protected bool isSupported = true;
private void Awake()
{
supportImageEffects = SystemInfo.supportsImageEffects;
supportDX11 = SystemInfo.graphicsShaderLevel >= 50 && SystemInfo.supportsComputeShaders;
supportHDRTextures = SystemInfo.SupportsRenderTextureFormat(RenderTextureFormat.ARGBHalf);
supportDepthTexture = SystemInfo.SupportsRenderTextureFormat(RenderTextureFormat.Depth);
}
protected Material CheckShaderAndCreateMaterial(Shader s, Material m2Create)
{
if (!s)
{
Debug.Log("Missing shader in " + ToString());
base.enabled = false;
return null;
}
if (s.isSupported && (bool)m2Create && m2Create.shader == s)
{
return m2Create;
}
if (!s.isSupported)
{
NotSupported();
Debug.Log("The shader " + s.ToString() + " on effect " + ToString() + " is not supported on this platform!");
return null;
}
m2Create = new Material(s);
m2Create.hideFlags = HideFlags.DontSave;
if ((bool)m2Create)
{
return m2Create;
}
return null;
}
protected Material CreateMaterial(Shader s, Material m2Create)
{
if (!s)
{
Debug.Log("Missing shader in " + ToString());
return null;
}
if ((bool)m2Create && m2Create.shader == s && s.isSupported)
{
return m2Create;
}
if (!s.isSupported)
{
return null;
}
m2Create = new Material(s);
m2Create.hideFlags = HideFlags.DontSave;
if ((bool)m2Create)
{
return m2Create;
}
return null;
}
private void OnEnable()
{
isSupported = true;
}
protected bool CheckSupport()
{
return CheckSupport(needDepth: false);
}
public virtual bool CheckResources()
{
Debug.LogWarning("CheckResources () for " + ToString() + " should be overwritten.");
return isSupported;
}
protected void Start()
{
CheckResources();
}
protected bool CheckSupport(bool needDepth)
{
isSupported = true;
if (!supportImageEffects)
{
NotSupported();
return false;
}
if (needDepth && !supportDepthTexture)
{
NotSupported();
return false;
}
if (needDepth && _camera == null)
{
_camera = GetComponent<Camera>();
}
return true;
}
protected bool CheckSupport(bool needDepth, bool needHdr)
{
if (!CheckSupport(needDepth))
{
return false;
}
if (needHdr && !supportHDRTextures)
{
NotSupported();
return false;
}
return true;
}
public bool Dx11Support()
{
return supportDX11;
}
protected void ReportAutoDisable()
{
Debug.LogWarning("The image effect " + ToString() + " has been disabled as it's not supported on the current platform.");
}
private bool CheckShader(Shader s)
{
Debug.Log("The shader " + s.ToString() + " on effect " + ToString() + " is not part of the Unity 3.2+ effects suite anymore. For best performance and quality, please ensure you are using the latest Standard Assets Image Effects (Pro only) package.");
if (!s.isSupported)
{
NotSupported();
return false;
}
return false;
}
protected void NotSupported()
{
base.enabled = false;
isSupported = false;
}
protected void DrawBorder(RenderTexture dest, Material material)
{
RenderTexture.active = dest;
bool flag = true;
GL.PushMatrix();
GL.LoadOrtho();
for (int i = 0; i < material.passCount; i++)
{
material.SetPass(i);
float y;
float y2;
if (flag)
{
y = 1f;
y2 = 0f;
}
else
{
y = 0f;
y2 = 1f;
}
float x = 0f + 1f / ((float)dest.width * 1f);
float y3 = 0f;
float y4 = 1f;
GL.Begin(7);
GL.TexCoord2(0f, y);
GL.Vertex3(0f, y3, 0.1f);
GL.TexCoord2(1f, y);
GL.Vertex3(x, y3, 0.1f);
GL.TexCoord2(1f, y2);
GL.Vertex3(x, y4, 0.1f);
GL.TexCoord2(0f, y2);
GL.Vertex3(0f, y4, 0.1f);
float x2 = 1f - 1f / ((float)dest.width * 1f);
x = 1f;
y3 = 0f;
y4 = 1f;
GL.TexCoord2(0f, y);
GL.Vertex3(x2, y3, 0.1f);
GL.TexCoord2(1f, y);
GL.Vertex3(x, y3, 0.1f);
GL.TexCoord2(1f, y2);
GL.Vertex3(x, y4, 0.1f);
GL.TexCoord2(0f, y2);
GL.Vertex3(x2, y4, 0.1f);
x = 1f;
y3 = 0f;
y4 = 0f + 1f / ((float)dest.height * 1f);
GL.TexCoord2(0f, y);
GL.Vertex3(0f, y3, 0.1f);
GL.TexCoord2(1f, y);
GL.Vertex3(x, y3, 0.1f);
GL.TexCoord2(1f, y2);
GL.Vertex3(x, y4, 0.1f);
GL.TexCoord2(0f, y2);
GL.Vertex3(0f, y4, 0.1f);
x = 1f;
y3 = 1f - 1f / ((float)dest.height * 1f);
y4 = 1f;
GL.TexCoord2(0f, y);
GL.Vertex3(0f, y3, 0.1f);
GL.TexCoord2(1f, y);
GL.Vertex3(x, y3, 0.1f);
GL.TexCoord2(1f, y2);
GL.Vertex3(x, y4, 0.1f);
GL.TexCoord2(0f, y2);
GL.Vertex3(0f, y4, 0.1f);
GL.End();
}
GL.PopMatrix();
}
}
}
@@ -0,0 +1,13 @@
fileFormatVersion: 2
guid: 4d8618bd67b541047918a64ed0a51fa3
timeCreated: 1537100826
licenseType: Free
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:
@@ -0,0 +1,55 @@
using UnityEngine;
namespace UnityStandardAssets.ImageEffects
{
[ExecuteInEditMode]
[RequireComponent(typeof(Camera))]
[AddComponentMenu("Image Effects/Other/Screen Overlay")]
public class ScreenOverlay : PostEffectsBase
{
public enum OverlayBlendMode
{
Additive,
ScreenBlend,
Multiply,
Overlay,
AlphaBlend
}
public OverlayBlendMode blendMode = OverlayBlendMode.Overlay;
public float intensity = 1f;
public Texture2D texture;
public Shader overlayShader;
private Material overlayMaterial;
public override bool CheckResources()
{
CheckSupport(needDepth: false);
overlayMaterial = CheckShaderAndCreateMaterial(overlayShader, overlayMaterial);
if (!isSupported)
{
ReportAutoDisable();
}
return isSupported;
}
private void OnRenderImage(RenderTexture source, RenderTexture destination)
{
if (!CheckResources())
{
Graphics.Blit(source, destination);
return;
}
Vector4 value = new Vector4(1f, 0f, 0f, 1f);
overlayMaterial.SetVector("_UV_Transform", value);
overlayMaterial.SetFloat("_Intensity", intensity);
overlayMaterial.SetTexture("_Overlay", texture);
Graphics.Blit(source, destination, overlayMaterial, (int)blendMode);
}
}
}
@@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: 0d43e60b74906a14cae98dbbf5c3bd5d
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:
@@ -0,0 +1,81 @@
using UnityEngine;
namespace UnityStandardAssets.ImageEffects
{
[RequireComponent(typeof(Camera))]
[AddComponentMenu("Image Effects/Camera/Tilt Shift (Lens Blur)")]
internal class TiltShift : PostEffectsBase
{
public enum TiltShiftMode
{
TiltShiftMode,
IrisMode
}
public enum TiltShiftQuality
{
Preview,
Normal,
High
}
public TiltShiftMode mode;
public TiltShiftQuality quality = TiltShiftQuality.Normal;
[Range(0f, 15f)]
public float blurArea = 1f;
[Range(0f, 25f)]
public float maxBlurSize = 5f;
[Range(0f, 1f)]
public int downsample;
public Shader tiltShiftShader;
private Material tiltShiftMaterial;
public override bool CheckResources()
{
CheckSupport(needDepth: true);
tiltShiftMaterial = CheckShaderAndCreateMaterial(tiltShiftShader, tiltShiftMaterial);
if (!isSupported)
{
ReportAutoDisable();
}
return isSupported;
}
private void OnRenderImage(RenderTexture source, RenderTexture destination)
{
if (!CheckResources())
{
Graphics.Blit(source, destination);
return;
}
tiltShiftMaterial.SetFloat("_BlurSize", (maxBlurSize < 0f) ? 0f : maxBlurSize);
tiltShiftMaterial.SetFloat("_BlurArea", blurArea);
source.filterMode = FilterMode.Bilinear;
RenderTexture renderTexture = destination;
if ((float)downsample > 0f)
{
renderTexture = RenderTexture.GetTemporary(source.width >> downsample, source.height >> downsample, 0, source.format);
renderTexture.filterMode = FilterMode.Bilinear;
}
int num = (int)quality;
num *= 2;
Graphics.Blit(source, renderTexture, tiltShiftMaterial, (mode == TiltShiftMode.TiltShiftMode) ? num : (num + 1));
if (downsample > 0)
{
tiltShiftMaterial.SetTexture("_Blurred", renderTexture);
Graphics.Blit(source, destination, tiltShiftMaterial, 6);
}
if (renderTexture != destination)
{
RenderTexture.ReleaseTemporary(renderTexture);
}
}
}
}
@@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: 202fac38dc6eae44e806cb36f5fa64bc
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant: