查看: 1843|回复: 1
打印 上一主题 下一主题

shader实现夜视效果代码

[复制链接]

5552

主题

2

听众

8万

积分

首席设计师

Rank: 8Rank: 8

纳金币
-1
精华
11

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

跳转到指定楼层
楼主
发表于 2012-3-9 13:47:51 |只看该作者 |倒序浏览
////shaer:
Shader "Hidden/NightVision" {
Properties {
_MainTex ("Base (RGB)", 2D) = "white" {}
}
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"
uniform sampler2D _MainTex;
float4 frag (v2f_img i) : COLOR {
float4 c = tex2D(_MainTex, i.uv);
c.b = c.r*2;
c.g = c.b*2;
return c;
}
ENDCG
}
}
Fallback off
}
/////c# code for camera;
using UnityEngine;



[ExecuteInEditMode]
[AddComponentMenu("Image Effects/NightVision")]
public class NightVision : ImageEffectBase {



// Called by camera to apply image effect
void OnRenderImage (RenderTexture source, RenderTexture destination) {
Graphics.Blit (source, destination, material);
}
}

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

使用道具 举报

103

主题

1

听众

7956

积分

高级设计师

Rank: 6Rank: 6

纳金币
7953
精华
0

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

沙发
发表于 2012-3-9 20:06:30 |只看该作者
回复

使用道具 举报

您需要登录后才可以回帖 登录 | 立即注册

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

GMT+8, 2024-9-20 19:40 , Processed in 0.126191 second(s), 32 queries .

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

© 2008-2019 Narkii Inc.

回顶部