12 第1页 | 共2 页下一页
返回列表 发新帖
查看: 6283|回复: 15
打印 上一主题 下一主题

[Shaders] simple bloom effect,一个shader

[复制链接]

1023

主题

3

听众

359

积分

设计实习生

Rank: 2

纳金币
335582
精华
0

最佳新人

跳转到指定楼层
楼主
发表于 2011-9-8 08:02:43 |只看该作者 |倒序浏览
Here is a simple bloom effect, sort of faking it as cheap as possible. I would appreciate if anyone with ios or android capabilities to test it and tell me if it works on mobile platforms.

This is the effect file itself, save it as PP_BloomSimple.cs file

using UnityEngine;



[ExecuteInEditMode]
[AddComponentMenu("Image Effects/Aubergine/BloomSimple")]
public class PP_BloomSimple : MonoBehaviour {
//Color
public float strength = 0.5f;

public Shader shader;
private Material m_Material;
//Properties
protected Material material {
get {
if (m_Material == null) {
m_Material = new Material(shader);
m_Material.hideFlags = HideFlags.HideAndDontSave;
}
return m_Material;
}
}
//Methods
protected void Start () {
// Disable if we don't support image effects
if (!SystemInfo.supportsImageEffects) {
enabled = false;
return;
}
// Disable the image effect if the shader can't***n on the users graphics card
if (!shader || !shader.isSupported) enabled = false;
}
protected void OnDisable () {
if( m_Material ) {
DestroyImmediate(m_Material);
}
}



void Awake () {
material.SetFloat("_Strength", strength);
}
void OnEnable () {
shader = Shader.Find("Hidden/Aubergine/BloomSimple");
}
// Called by camera to apply image effect
void OnRenderImage (RenderTexture source, RenderTexture destination) {
material.SetFloat("_Strength", strength);
Graphics.Blit (source, destination, material);
}
}
This is the shader file.


Shader "Hidden/Aubergine/BloomSimple" {
Properties {
_MainTex ("Base (RGB)", 2D) = "white" {}
_Strength ("Bloom Strength", Float) = 0.5
}
SubShader {
Pass {
ZTest Always Cull Off ZWrite Off Lighting Off Fog { Mode off }
CGPROGRAM
#pragma vertex vert_img
#pragma fragment frag
#pragma fragmentoption ARB_precision_hint_fastest
#include "UnityCG.cginc"



sampler2D _MainTex;
float _Strength;



float4 frag (v2f_img i) : COLOR {
float4 col = tex2D(_MainTex, i.uv);
float4 bloom = col;
col.rgb = pow(bloom.rgb, _Strength);
col.rgb *= bloom;
col.rgb += bloom;
return col;
}
ENDCG
}
}
Fallback off
}

分享到: QQ好友和群QQ好友和群 腾讯微博腾讯微博 腾讯朋友腾讯朋友 微信微信
转播转播0 分享淘帖0 收藏收藏0 支持支持0 反对反对0
回复

使用道具 举报

Asen    

867

主题

0

听众

1万

积分

外协人员

Rank: 7Rank: 7Rank: 7

纳金币
17488
精华
1
沙发
发表于 2011-9-8 09:30:05 |只看该作者
回复

使用道具 举报

   

671

主题

1

听众

3247

积分

中级设计师

Rank: 5Rank: 5

纳金币
324742
精华
0

最佳新人 活跃会员 热心会员 灌水之王 突出贡献

板凳
发表于 2012-3-4 23:21:34 |只看该作者
其实楼主所说的这些,俺支很少用!
回复

使用道具 举报

   

671

主题

1

听众

3247

积分

中级设计师

Rank: 5Rank: 5

纳金币
324742
精华
0

最佳新人 活跃会员 热心会员 灌水之王 突出贡献

地板
发表于 2012-3-5 23:31:37 |只看该作者
好`我顶``顶顶
回复

使用道具 举报

5969

主题

1

听众

39万

积分

首席设计师

Rank: 8Rank: 8

纳金币
-1
精华
0

最佳新人 活跃会员 热心会员 灌水之王 突出贡献

5#
发表于 2012-3-13 23:31:55 |只看该作者
先顶上去,偶要高亮加精鸟!
回复

使用道具 举报

797

主题

1

听众

1万

积分

资深设计师

Rank: 7Rank: 7Rank: 7

纳金币
5568
精华
0

最佳新人 活跃会员 热心会员 灌水之王 突出贡献

6#
发表于 2012-3-16 19:40:55 |只看该作者

   
回复

使用道具 举报

1023

主题

3

听众

359

积分

设计实习生

Rank: 2

纳金币
335582
精华
0

最佳新人

7#
发表于 2012-5-3 23:18:19 |只看该作者
已阵亡的 蝶 随 风 舞 说过  偶尔按一下 CTRL A 会发现 世界还有另一面
回复

使用道具 举报

markq    

511

主题

1

听众

1万

积分

资深设计师

Rank: 7Rank: 7Rank: 7

纳金币
15839
精华
0

最佳新人 活跃会员 热心会员 灌水之王 突出贡献

8#
发表于 2012-5-4 23:22:39 |只看该作者
谢谢分享



爱生活 爱3D 爱纳金网



www.narkii.com
回复

使用道具 举报

   

671

主题

1

听众

3247

积分

中级设计师

Rank: 5Rank: 5

纳金币
324742
精华
0

最佳新人 活跃会员 热心会员 灌水之王 突出贡献

9#
发表于 2012-5-8 23:22:10 |只看该作者
你们都躲开,我来顶
回复

使用道具 举报

462

主题

1

听众

31万

积分

首席设计师

Rank: 8Rank: 8

纳金币
2
精华
0

最佳新人 活跃会员 热心会员 灌水之王 突出贡献

10#
发表于 2012-5-15 23:23:06 |只看该作者
不错哦,顶一下......
回复

使用道具 举报

12 第1页 | 共2 页下一页
返回列表 发新帖
您需要登录后才可以回帖 登录 | 立即注册

手机版|纳金网 ( 闽ICP备2021016425号-2/3

GMT+8, 2025-8-14 00:18 , Processed in 0.192929 second(s), 28 queries .

Powered by Discuz!-创意设计 X2.5

© 2008-2019 Narkii Inc.

回顶部