资源简介
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+破解文件+教程
- 下一篇:屏幕特效之径向模糊
相关资源
- unity玻璃双面透明显示材质shader
- UGUI ScrollView 优化重复利用
- ConnectionLine.unitypackage
- Unity人物移动与视角跟随脚本
- vlc插件 for unity 5x以上版本
- unity3d通透材质shader
- Unity相机画面渲染序列帧插件
-
iap-subsc
ription_extension.unitypackage - Unity 沙土,雪效果
- UGUI 动态加载内容的 dropdown 控件
- 大富豪游戏源码 可编译运行,服务端
- unity网格地形地图框架源码.txt
- Unity DialogUI制作模板
- Unity3d脚本控制动画开关门代码
- Unity3D ArchVizPRO Interior Vol.01 - Vol.06 合集
- 基于TCP协议的客户端demo,内涵服务端
- Unity中国古风仙侠场景模型、人物模型
- 基于Unity3D的三维数字校园漫游系统
- unity 数据结构树的深度遍历
- Unity 5.6 -2017 新版NavMesh案例资源,支持
- Unity超好用的剪贴板插件-UniPasteBoard
- unity视觉范围视觉迷雾插件Fog Of War
- 麦克风音频可视化Demo
- unity游戏开发教程.txt
- unity路径跟随 曲线绘制
- Unity3d动态创建excel并写入数据
- mipai.unitypackage
- Unity3D模型-喷火龙
- MineSweeper
- 延迟消息机
评论
共有 条评论