纳金网
标题:
shader实现夜视效果代码
[打印本页]
作者:
会飞的鱼
时间:
2012-3-9 13:47
标题:
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);
}
}
作者:
浩劫
时间:
2012-3-9 20:06
欢迎光临 纳金网 (http://wwww.narkii.com/club/)
Powered by Discuz! X2.5