纳金网

标题: 使用Shader实现夜视效果 [打印本页]

作者: 王者再临    时间: 2013-8-14 23:38
标题: 使用Shader实现夜视效果
一个独特的效果实现,夜视效果,下面是代码:
////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);
}
}
作者: 毛毛虫    时间: 2013-8-17 10:33
好东西,改天试试!
作者: kekeshuai    时间: 2013-8-17 13:58
好啊
作者: 只爱脆夹心    时间: 2013-8-19 12:02
谢谢分享啊!!!
作者: dzspb    时间: 2013-8-19 17:21
不错,谢谢!
作者: ku    时间: 2013-8-19 18:41
我记得有一个插件合集有这类效果
作者: nts    时间: 2013-10-17 10:15
学习一下哦




欢迎光临 纳金网 (http://go.narkii.com/club/) Powered by Discuz! X2.5