Panda3D
|
Classes | |
class | CommonFilters |
class | FilterConfig |
Variables | |
string | CARTOON_BODY |
Class CommonFilters implements certain common image postprocessing filters. It is not ideal that these filters are all included in a single monolithic module. Unfortunately, when you want to apply two filters at the same time, you have to compose them into a single shader, and the composition process isn't simply a question of concatenating them: you have to somehow make them work together. I suspect that there exists some fairly simple framework that would make this automatable. However, until I write some more filters myself, I won't know what that framework is. Until then, I'll settle for this clunky approach. - Josh
string CARTOON_BODY |
00001 """ 00002 float4 cartoondelta = k_cartoonseparation * texpix_txaux.xwyw; 00003 float4 cartoon_p0 = l_texcoordN + cartoondelta.xyzw; 00004 float4 cartoon_c0 = tex2D(k_txaux, cartoon_p0.xy); 00005 float4 cartoon_p1 = l_texcoordN - cartoondelta.xyzw; 00006 float4 cartoon_c1 = tex2D(k_txaux, cartoon_p1.xy); 00007 float4 cartoon_p2 = l_texcoordN + cartoondelta.wzyx; 00008 float4 cartoon_c2 = tex2D(k_txaux, cartoon_p2.xy); 00009 float4 cartoon_p3 = l_texcoordN - cartoondelta.wzyx; 00010 float4 cartoon_c3 = tex2D(k_txaux, cartoon_p3.xy); 00011 float4 cartoon_mx = max(cartoon_c0,max(cartoon_c1,max(cartoon_c2,cartoon_c3))); 00012 float4 cartoon_mn = min(cartoon_c0,min(cartoon_c1,min(cartoon_c2,cartoon_c3))); 00013 float cartoon_thresh = saturate(dot(cartoon_mx - cartoon_mn, float4(3,3,0,0)) - 0.5); 00014 o_color = lerp(o_color, float4(0,0,0,1), cartoon_thresh); 00015 """