纳金网

标题: 卡通渲染效果shard-1 [打印本页]

作者: 会飞的鱼    时间: 2012-3-9 11:13
标题: 卡通渲染效果shard-1
Shader "Hidden/Edge Detect Normals" {
Properties {

_MainTex ("Base (RGB)", RECT) = "white" {}

_NormalsTexture ("Normals", RECT) = "white" {}

}
SubShader {

Pass {

  ZTest Always Cull Off ZWrite Off

  Fog { Mode off }
CGPROGRAM

#pragma vertex vert

#pragma fragment frag

#pragma fragmentoption ARB_precision_hint_fastest

#include "UnityCG.cginc"
uniform samplerRECT _MainTex;

uniform samplerRECT _NormalsTexture;

uniform float4 _MainTex_***lSize;
s***ct v2f {

float4 pos : POSITION;

float2 uv[3] : TEXCOORD0;

};
v2f vert( appdata_img v )

{

v2f o;

o.pos = mul (glstate.matrix.mvp, v.vertex);

float2 uv = MultiplyUV( glstate.matrix.texture[0], v.texcoord );

o.uv[0] = uv;

o.uv[1] = uv + float2(-_MainTex_***lSize.x, -_MainTex_***lSize.y);

o.uv[2] = uv + float2(+_MainTex_***lSize.x, -_MainTex_***lSize.y);

return o;

}
half4 frag (v2f i) : COLOR

{

half4 original = texRECT(_MainTex, i.uv[0]);



// three samples from normals+depth buffer  

half4 normalD1 = texRECT(_NormalsTexture, i.uv[0]);

half4 normalD2 = texRECT(_NormalsTexture, i.uv[1]);

half4 normalD3 = texRECT(_NormalsTexture, i.uv[2]);



// normals filter

half3 n1 = normalD1.rgb*2-1;

half3 n2 = normalD2.rgb*2-1;

half3 n3 = normalD3.rgb*2-1;

half2 ndiff;

ndiff.x = dot( n1, n2 );

ndiff.y = dot( n1, n3 );

ndiff -= 0.9;

ndiff = ndiff > half2(0,0) ? half2(1,1) : half2(0,0);

half ndiff1 = ndiff.x * ndiff.y;

original.rgb *= ndiff1;



// depth filter

float2 zdiff;

zdiff.x = normalD1.a - normalD2.a;

zdiff.y = normalD1.a - normalD3.a;

zdiff = abs( zdiff ) - 0.05;

zdiff = zdiff > half2(0,0) ? half2(0,0) : half2(1,1);

original *= zdiff.x*zdiff.y;



return original;

}

ENDCG

}

}
Fallback off
}
作者: 铁锹    时间: 2012-3-9 16:30
图片呢?
作者: BU Secret    时间: 2012-3-9 17:39
什么东东
作者: BU Secret    时间: 2012-3-9 17:43
这是什么啊
作者: 浩劫    时间: 2012-3-9 20:04





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