噩梦5 BloomOptimized 物体人物发光
来源:互联网 发布:空中客车a380数据 编辑:程序博客网 时间:2024/06/05 09:09
using System;
using UnityEngine;
namespace UnitySampleAssets.ImageEffects
{
[ExecuteInEditMode]
[RequireComponent (typeof(Camera))]
[AddComponentMenu ("Image Effects/Bloom and Glow/Bloom (Optimized)")]
class BloomOptimized : PostEffectsBase
{
public enum Resolution {
Low = 0,
High = 1,
}
public enum BlurType {
Standard = 0,
Sgx = 1,
}
[Range(0.0f, 1.5f)]
public float threshhold = 0.25f;
[Range(0.0f, 2.5f)]
public float intensity = 0.75f;
[Range(0.25f, 5.5f)]
public float blurSize = 1.0f;
Resolution resolution = Resolution.Low;
[Range(1, 4)]
public int blurIterations = 1;
public BlurType blurType= BlurType.Standard;
public Shader fastBloomShader = null;
private Material fastBloomMaterial = null;
public override bool CheckResources () {
CheckSupport (false);
fastBloomMaterial = CheckShaderAndCreateMaterial (fastBloomShader, fastBloomMaterial);
if (!isSupported)
ReportAutoDisable ();
return isSupported;
}
void OnDisable () {
if (fastBloomMaterial)
DestroyImmediate (fastBloomMaterial);
}
void OnRenderImage (RenderTexture source, RenderTexture destination) {
if (CheckResources() == false) {
Graphics.Blit (source, destination);
return;
}
int divider = resolution == Resolution.Low ? 4 : 2;
float widthMod = resolution == Resolution.Low ? 0.5f : 1.0f;
fastBloomMaterial.SetVector ("_Parameter", new Vector4 (blurSize * widthMod, 0.0f, threshhold, intensity));
source.filterMode = FilterMode.Bilinear;
var rtW= source.width/divider;
var rtH= source.height/divider;
// downsample
RenderTexture rt = RenderTexture.GetTemporary (rtW, rtH, 0, source.format);
rt.filterMode = FilterMode.Bilinear;
Graphics.Blit (source, rt, fastBloomMaterial, 1);
var passOffs= blurType == BlurType.Standard ? 0 : 2;
for(int i = 0; i < blurIterations; i++) {
fastBloomMaterial.SetVector ("_Parameter", new Vector4 (blurSize * widthMod + (i*1.0f), 0.0f, threshhold, intensity));
// vertical blur
RenderTexture rt2 = RenderTexture.GetTemporary (rtW, rtH, 0, source.format);
rt2.filterMode = FilterMode.Bilinear;
Graphics.Blit (rt, rt2, fastBloomMaterial, 2 + passOffs);
RenderTexture.ReleaseTemporary (rt);
rt = rt2;
// horizontal blur
rt2 = RenderTexture.GetTemporary (rtW, rtH, 0, source.format);
rt2.filterMode = FilterMode.Bilinear;
Graphics.Blit (rt, rt2, fastBloomMaterial, 3 + passOffs);
RenderTexture.ReleaseTemporary (rt);
rt = rt2;
}
fastBloomMaterial.SetTexture ("_Bloom", rt);
Graphics.Blit (source, destination, fastBloomMaterial, 0);
RenderTexture.ReleaseTemporary (rt);
}
}
}
using UnityEngine;
namespace UnitySampleAssets.ImageEffects
{
[ExecuteInEditMode]
[RequireComponent (typeof(Camera))]
[AddComponentMenu ("Image Effects/Bloom and Glow/Bloom (Optimized)")]
class BloomOptimized : PostEffectsBase
{
public enum Resolution {
Low = 0,
High = 1,
}
public enum BlurType {
Standard = 0,
Sgx = 1,
}
[Range(0.0f, 1.5f)]
public float threshhold = 0.25f;
[Range(0.0f, 2.5f)]
public float intensity = 0.75f;
[Range(0.25f, 5.5f)]
public float blurSize = 1.0f;
Resolution resolution = Resolution.Low;
[Range(1, 4)]
public int blurIterations = 1;
public BlurType blurType= BlurType.Standard;
public Shader fastBloomShader = null;
private Material fastBloomMaterial = null;
public override bool CheckResources () {
CheckSupport (false);
fastBloomMaterial = CheckShaderAndCreateMaterial (fastBloomShader, fastBloomMaterial);
if (!isSupported)
ReportAutoDisable ();
return isSupported;
}
void OnDisable () {
if (fastBloomMaterial)
DestroyImmediate (fastBloomMaterial);
}
void OnRenderImage (RenderTexture source, RenderTexture destination) {
if (CheckResources() == false) {
Graphics.Blit (source, destination);
return;
}
int divider = resolution == Resolution.Low ? 4 : 2;
float widthMod = resolution == Resolution.Low ? 0.5f : 1.0f;
fastBloomMaterial.SetVector ("_Parameter", new Vector4 (blurSize * widthMod, 0.0f, threshhold, intensity));
source.filterMode = FilterMode.Bilinear;
var rtW= source.width/divider;
var rtH= source.height/divider;
// downsample
RenderTexture rt = RenderTexture.GetTemporary (rtW, rtH, 0, source.format);
rt.filterMode = FilterMode.Bilinear;
Graphics.Blit (source, rt, fastBloomMaterial, 1);
var passOffs= blurType == BlurType.Standard ? 0 : 2;
for(int i = 0; i < blurIterations; i++) {
fastBloomMaterial.SetVector ("_Parameter", new Vector4 (blurSize * widthMod + (i*1.0f), 0.0f, threshhold, intensity));
// vertical blur
RenderTexture rt2 = RenderTexture.GetTemporary (rtW, rtH, 0, source.format);
rt2.filterMode = FilterMode.Bilinear;
Graphics.Blit (rt, rt2, fastBloomMaterial, 2 + passOffs);
RenderTexture.ReleaseTemporary (rt);
rt = rt2;
// horizontal blur
rt2 = RenderTexture.GetTemporary (rtW, rtH, 0, source.format);
rt2.filterMode = FilterMode.Bilinear;
Graphics.Blit (rt, rt2, fastBloomMaterial, 3 + passOffs);
RenderTexture.ReleaseTemporary (rt);
rt = rt2;
}
fastBloomMaterial.SetTexture ("_Bloom", rt);
Graphics.Blit (source, destination, fastBloomMaterial, 0);
RenderTexture.ReleaseTemporary (rt);
}
}
}
0 0
- 噩梦5 BloomOptimized 物体人物发光
- shader forge扭曲、粒子发光、物体交互
- 噩梦射手5 移动 转向 这个没有加速的过程 不适合rpg人物 把移动检测去掉
- 噩梦5 敌人血量
- 噩梦5 camera跟随
- 噩梦
- 噩梦
- 噩梦
- 噩梦
- 噩梦
- 噩梦
- 噩梦
- 显示被遮挡的人物或者物体
- 视频中发光物体的颜色显示问题
- 发光
- 现代游戏设计师的5大噩梦
- 人物
- unity 用点乘和叉乘来判断 物体与人物的相对位置
- 企业移动应用平台:走进SAP SUP的世界
- C/C++中作用域详解
- Cached VS Buffers
- jiffies 时间转换
- MySQL-终端基本操作
- 噩梦5 BloomOptimized 物体人物发光
- Silver Cow Party
- web前端开发必备压缩工具整理
- 黑马程序员----基础题----我的基础题
- Collection接口和Collections类的简单区别和讲解
- 九度oj 1113
- 【BFS搜索】poj1945 Power Hungry Cows
- Android图片的拉取与缓存
- jQuery()里面提供的4种构建jQuery对象的方式