unityzgy/Assets/ThirdPackages/DCG Shaders/_Common/Standard Assets/ImageEffects/Scripts/MotionBlur.cs
ayuan9957 bf12e02276 feat: 多语言本地化系统 - 支持中/英/法/俄实时切换
- LocalizationManager: 新增翻译表(SetFormatted/SetDuration/LocalizeOperateMsg)
- LoginPanel: InputField placeholder本地化、字体颜色保持
- HistoryPanel: 用时数据本地化、placeholder本地化
- RecordDetailPanel: 操作详情消息本地化(LanguageChanged重建)
- AppraiseWindowBase: 评价等级本地化、操作消息重建
- EditorAppraiser: 所有评估消息改用InjectOperateMsgLocalized
- StudentOperateRecorder: 新增InjectOperateMsgLocalized方法
- LocalizationLanguageTestBar: 单例模式、ScreenSpaceOverlay筛选
- 字体切换时保留颜色和verticalOverflow
2026-07-16 10:05:59 +08:00

76 lines
2.8 KiB
C#

using System;
using UnityEngine;
// This class implements simple ghosting type Motion Blur.
// If Extra Blur is selected, the scene will allways be a little blurred,
// as it is scaled to a smaller resolution.
// The effect works by accumulating the previous frames in an accumulation
// texture.
namespace UnityStandardAssets.ImageEffects
{
[ExecuteInEditMode]
[AddComponentMenu("Image Effects/Blur/Motion Blur (Color Accumulation)")]
[RequireComponent(typeof(Camera))]
public class MotionBlur : ImageEffectBase
{
public float blurAmount = 0.8f;
public bool extraBlur = false;
private RenderTexture accumTexture;
override protected void Start()
{
if (!SystemInfo.supportsRenderTextures)
{
enabled = false;
return;
}
base.Start();
}
override protected void OnDisable()
{
base.OnDisable();
DestroyImmediate(accumTexture);
}
// Called by camera to apply image effect
void OnRenderImage (RenderTexture source, RenderTexture destination)
{
// Create the accumulation texture
if (accumTexture == null || accumTexture.width != source.width || accumTexture.height != source.height)
{
DestroyImmediate(accumTexture);
accumTexture = new RenderTexture(source.width, source.height, 0);
accumTexture.hideFlags = HideFlags.HideAndDontSave;
Graphics.Blit( source, accumTexture );
}
// If Extra Blur is selected, downscale the texture to 4x4 smaller resolution.
if (extraBlur)
{
RenderTexture blurbuffer = RenderTexture.GetTemporary(source.width/4, source.height/4, 0);
accumTexture.MarkRestoreExpected();
Graphics.Blit(accumTexture, blurbuffer);
Graphics.Blit(blurbuffer,accumTexture);
RenderTexture.ReleaseTemporary(blurbuffer);
}
// Clamp the motion blur variable, so it can never leave permanent trails in the image
blurAmount = Mathf.Clamp( blurAmount, 0.0f, 0.92f );
// Setup the texture and floating point values in the shader
material.SetTexture("_MainTex", accumTexture);
material.SetFloat("_AccumOrig", 1.0F-blurAmount);
// We are accumulating motion over frames without clear/discard
// by design, so silence any performance warnings from Unity
accumTexture.MarkRestoreExpected();
// Render the image using the motion blur shader
Graphics.Blit (source, accumTexture, material);
Graphics.Blit (accumTexture, destination);
}
}
}