资源简介
UnityShader实例15,配套资源,,适用于移动平台的屏幕bloom特效,效率不错

代码片段和文件信息
using UnityEngine;
using System.Collections;
using System;
[ExecuteInEditMode]
[AddComponentMenu (“PengLu/ImageEffect/MobileBloom“)]
public class ImageEffect_MoblieBloom : MonoBehaviour {
#region Variables
public Shader BloomShader = null;
private Material BloomMaterial = null;
private RenderTextureFormat rtFormat = RenderTextureFormat.Default;
public Color colorMix = new Color(1.0f 1.0f 1.0f 1.0f);
[Range(0.0f 1.0f)]
public float threshold = 0.25f;
[Range(0.0f 2.5f)]
public float intensity = 0.75f;
[Range(0.2f 1.0f)]
public float BlurSize = 1.0f;
#endregion
// Use this for initialization
void Start () {
FindShaders ();
CheckSupport ();
CreateMaterials ();
}
void FindShaders () {
if (!BloomShader) {
BloomShader = Shader.Find(“PengLu/ImageEffect/Unlit/MobileBloom“);
}
}
void CreateMaterials() {
if(!BloomMaterial){
BloomMaterial = new Material(BloomShader);
BloomMaterial.hideFlags = HideFlags.HideAndDontSave;
}
}
bool Supported(){
return (SystemInfo.supportsImageEffects && SystemInfo.supportsRenderTextures && BloomShader.isSupported);
// return true;
}
bool CheckSupport() {
if(!Supported()) {
enabled = false;
return false;
}
rtFormat = SystemInfo.SupportsRenderTextureFormat (RenderTextureFormat.RGB565) ? RenderTextureFormat.RGB565 : RenderTextureFormat.Default;
return true;
}
void OnRenderImage (RenderTexture sourceTexture RenderTexture destTexture)
{
#if UNITY_EDITOR
FindShaders ();
CheckSupport ();
CreateMaterials ();
#endif
if(threshold != 0 && intensity != 0){
int rtW = sourceTexture.width/4;
int rtH = sourceTexture.height/4;
BloomMaterial.SetColor (“_ColorMix“ colorMix);
BloomMaterial.SetVector (“_Parameter“ new Vector4(BlurSize*1.5f 0.0f intensity0.8f - threshold));
// material.SetFloat(“_blurSize“BlurSize);
RenderTexture rtTempA = RenderTexture.GetTemporary (rtW rtH 0rtFormat);
rtTempA.filterMode = FilterMode.Bilinear;
RenderTexture rtTempB = RenderTexture.GetTemporary (rtW rtH 0rtFormat);
rtTempA.filterMode = FilterMode.Bilinear;
Graphics.Blit (sourceTexture rtTempABloomMaterial0);
Graphics.Blit (rtTempA rtTempB BloomMaterial1);
RenderTexture.ReleaseTemporary(rtTempA);
rtTempA = RenderTexture.GetTemporary (rtW rtH 0 rtFormat);
rtTempB.filterMode = FilterMode.Bilinear;
Graphics.Blit (rtTempB rtTempA BloomMaterial2);
BloomMaterial.SetTexture (“_Bloom“ rtTempA);
Graphics.Blit (sourceTexture destTexture BloomMaterial3);
RenderTexture.ReleaseTemporary(rtTempA);
RenderTexture.ReleaseTemporary(rtTempB);
}
else{
Graphics.Blit(sourceTexture destTexture);
}
}
// Update is called once per frame
// void Update () {
// #if UNITY_EDITOR
// if (Applicatio
属性 大小 日期 时间 名称
----------- --------- ---------- ----- ----
文件 4338 2015-09-17 14:50 ImageEffectUnlitMobileBloom.shader
文件 3278 2015-09-17 14:50 ImageEffect_MoblieBloom.cs
----------- --------- ---------- ----- ----
7616 2
- 上一篇:myeclipse2016+破解文件+教程
- 下一篇:屏幕特效之径向模糊
相关资源
- Unity3D登录界面工程
- unity3d反编译工具
-
UnityWebPla
yer及UnityWebPla yerFull -
UnityWebPla
yerFull - unity4.0官方正式版
- Behavior Designer 1.6.3(u2018.3.0).unitypa
- Unity纪念碑谷.rar
- A Pathfinding Project Pro v4.2.2.rar
- Unity 声音播放插件,支持将字符串转
- Gaia 1.7.2
- Unity3d实现扭动挤压浏览效果
- UnityShader卷轴效果
- 爱酱(绊爱Kizuna)模型
- The binding and unwinding properties of the Bl
- 遗传算法越野小车unity5.5
- unity 3D 百度语音合成 并播放
- unity案例入门坦克大战源码
- Graph And Chart 1.91.unitypackage
- Animated Steel Coaster 1.51.rar
- Unity3D游戏开发.pdf 宣雨松著完整高清
- Unity3D版水果忍者
- unity3d爆炸特效包
- unity3d_见缝插针源码及报告.zip
- Unity3d车库场景模型
- unity3d 警察动画模型
- unity20多种烟雾以及爆炸特效
- unity博物馆.zip
- burpsuite_community社区版x86系统
- unity3D 新手引导遮罩,支持圆形和矩形
- 兼容unity的System.Drawing.dll
评论
共有 条评论