1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58
| Shader "Yemi/OilpaintShader" { Properties { _MainTex ("Albedo (RGB)", 2D) = "white" {}
} SubShader { Pass { Name "Pass1" CGPROGRAM #pragma vertex vert_img #pragma fragment frag #pragma fragmentoption ARB_precision_hint_fastest #include "UnityCG.cginc" uniform sampler2D _MainTex;
half4 frag(v2f_img i) : COLOR { int a[20] = { 0,0,0,0,0, 0,0,0,0,0, 0,0,0,0,0, 0,0,0,0,0 }; half4 c[20] = { half4(0,0,0,0),half4(0,0,0,0),half4(0,0,0,0),half4(0,0,0,0),half4(0,0,0,0), half4(0,0,0,0),half4(0,0,0,0),half4(0,0,0,0),half4(0,0,0,0),half4(0,0,0,0), half4(0,0,0,0),half4(0,0,0,0),half4(0,0,0,0),half4(0,0,0,0),half4(0,0,0,0), half4(0,0,0,0),half4(0,0,0,0),half4(0,0,0,0),half4(0,0,0,0),half4(0,0,0,0),
}; for (int x = -5; x <= 5; x++) {
for (int y = -5; y <= 5; y++) {
half4 p1 = tex2D(_MainTex, i.uv + 0.001*half2(x,y)); int pi1 = int((p1.r + p1.g + p1.b)/3.0 * 19); a[pi1] ++; c[pi1] += p1; } } int index = 0; int max = a[0]; for (int n = 0; n < 20; n++) { if (a[n] >= max) { max = a[n]; index = n; } } half4 oc = c[index] / max; oc.a = 1; return oc; } ENDCG } } FallBack "Diffuse" }
|