#include "Defs.fxh" #include "AOlib.fxh" PS3PRAGMA(texformat default RGBA8) PS3PRAGMA(regcount 8) float4 NearFarZRange; half4 ScreenSize; sampler2D TexIn; sampler2D TexDepth; struct VSInput { float4 vPos : POSITION; }; struct VSOutput { float4 vHPos : POSITION; }; VSOutput VShader(in VSInput IN) { VSOutput OUT; IN.vPos.z=0; OUT.vHPos = IN.vPos; return OUT; } // bilateral blur (uwzglednia bufor z) void BlurSample(float2 tc, float ref_depth, half3 ref_normal, inout half weight, inout half4 col, in half dist_scale) { float d; half3 norm; SamplePackedZN(TexDepth, tc, NearFarZRange, d, norm); // pt: !!! liczymy na podstawie wartosci w buf z - na pc dx9 i konsolach to beda rozne wartosci - potestowac (na xbox wyglada bardzo ladnie i pc tez) half diff = (d - ref_depth)*4;// * 0.25; half dist = saturate(1 - diff*diff) * dist_scale; //ładniej ?, MT: tak dużo ładniej dist *= saturate(dot(norm, ref_normal)); col += tex2D(TexIn, tc) * dist; weight += dist; } half4 PShader(in VSOutput IN, half2 vPos: VPOS) : COLOR0 { // te .5 żeby zrobić taki malutki filtr bilinear od razu half2 tc = get_screen_texcoord(vPos, ScreenSize); float ref_depth; half3 ref_normal; SamplePackedZN(TexDepth, tc, NearFarZRange, ref_depth, ref_normal); half dist_scale = 1; half4 sum = tex2D(TexIn, tc); half sum_weight = 1; #if defined(_PS3) || defined(_XBOX) //MT; dziwne myko "blurowania po skosie": half s = 2.5; // ułożenie na połówce tekseli żeby się bilinear zrobił half sx = 3.5; // ułożenie na połówce tekseli żeby się bilinear zrobił BlurSample(tc + half2(s, 0)*ScreenSize.zw, ref_depth, ref_normal, sum_weight, sum, dist_scale); BlurSample(tc + half2(-s, 0)*ScreenSize.zw, ref_depth, ref_normal, sum_weight, sum, dist_scale); BlurSample(tc + half2(0, -s)*ScreenSize.zw, ref_depth, ref_normal, sum_weight, sum, dist_scale); BlurSample(tc + half2(sx, sx)*ScreenSize.zw, ref_depth, ref_normal, sum_weight, sum, dist_scale); #else half s = 2.5; // ułożenie na połówce tekseli żeby się bilinear zrobił half sx = 3.5; // ułożenie na połówce tekseli żeby się bilinear zrobił BlurSample(tc + half2(s, 0)*ScreenSize.zw, ref_depth, ref_normal, sum_weight, sum, dist_scale); BlurSample(tc + half2(-s, 0)*ScreenSize.zw, ref_depth, ref_normal, sum_weight, sum, dist_scale); BlurSample(tc + half2(0, s)*ScreenSize.zw, ref_depth, ref_normal, sum_weight, sum, dist_scale); BlurSample(tc + half2(0, -s)*ScreenSize.zw, ref_depth, ref_normal, sum_weight, sum, dist_scale); BlurSample(tc + half2(sx, -sx)*ScreenSize.zw, ref_depth, ref_normal, sum_weight, sum, dist_scale); BlurSample(tc + half2(-sx, sx)*ScreenSize.zw, ref_depth, ref_normal, sum_weight, sum, dist_scale); BlurSample(tc + half2(sx, sx)*ScreenSize.zw, ref_depth, ref_normal, sum_weight, sum, dist_scale); BlurSample(tc + half2(-sx, -sx)*ScreenSize.zw, ref_depth, ref_normal, sum_weight, sum, dist_scale); #endif sum /= sum_weight; #ifdef _XBOX // bufor ambient jest w przestrzeni gamma 2.0 sum = sqrt(sum); #endif return sum; } DEVTEST_TECH(__t2, VShader, PShader)