diff --git a/gfx/FX/borders.fxh b/gfx/FX/borders.fxh old mode 100755 new mode 100644 index b3a05ba..4da5b23 --- a/gfx/FX/borders.fxh +++ b/gfx/FX/borders.fxh @@ -10,19 +10,16 @@ Code vArea3 = ( 1.f - vInternalPoint.x ) * ( 1.f - vInternalPoint.y ); } - void AddAreaToID( in float vID, in float vArea, inout float vTotals[9], inout float vIDs[9] ) - { - for( int i = 0; i < 9; ++i ) - { - vTotals[i] += vArea * ( 1 - saturate( abs( vIDs[i] - vID ) * 1000 ) ); - - //if( vIDs[i] == vID ) - //{ - // vTotals[i] += vArea; - // return; - //} - } - } + #define AddAreaToID(vID, vArea, vTotals, vIDs) \ + vTotals[0] += vArea * ( 1 - saturate( abs( vIDs[0] - vID ) * 1000 ) ); \ + vTotals[1] += vArea * ( 1 - saturate( abs( vIDs[1] - vID ) * 1000 ) ); \ + vTotals[2] += vArea * ( 1 - saturate( abs( vIDs[2] - vID ) * 1000 ) ); \ + vTotals[3] += vArea * ( 1 - saturate( abs( vIDs[3] - vID ) * 1000 ) ); \ + vTotals[4] += vArea * ( 1 - saturate( abs( vIDs[4] - vID ) * 1000 ) ); \ + vTotals[5] += vArea * ( 1 - saturate( abs( vIDs[5] - vID ) * 1000 ) ); \ + vTotals[6] += vArea * ( 1 - saturate( abs( vIDs[6] - vID ) * 1000 ) ); \ + vTotals[7] += vArea * ( 1 - saturate( abs( vIDs[7] - vID ) * 1000 ) ); \ + vTotals[8] += vArea * ( 1 - saturate( abs( vIDs[8] - vID ) * 1000 ) ); float GetBorderID( float2 vUV, out float vIntensity, in sampler2D BorderIDSampler, float vIDTextureSize ) { @@ -72,56 +69,28 @@ Code // of 1 and skip sampling/weighting for each "sub-area". //First quad - if ( ((vIDs[0] == vIDs[1]) && (vIDs[0] == vIDs[3]) && (vIDs[0] == vIDs[4])) ) - { - AddAreaToID( vIDs[0], 1.0, vTotals, vIDs ); - } - else - { - AddAreaToID( vIDs[0], vAreas[0], vTotals, vIDs ); - AddAreaToID( vIDs[1], vAreas[1], vTotals, vIDs ); - AddAreaToID( vIDs[3], vAreas[2], vTotals, vIDs ); - AddAreaToID( vIDs[4], vAreas[3], vTotals, vIDs ); - } + AddAreaToID( vIDs[0], vAreas[0], vTotals, vIDs ); + AddAreaToID( vIDs[1], vAreas[1], vTotals, vIDs ); + AddAreaToID( vIDs[3], vAreas[2], vTotals, vIDs ); + AddAreaToID( vIDs[4], vAreas[3], vTotals, vIDs ); //Second quad - if ( ((vIDs[1] == vIDs[2]) && (vIDs[1] == vIDs[4]) && (vIDs[1] == vIDs[5])) ) - { - AddAreaToID( vIDs[1], 1.0, vTotals, vIDs ); - } - else - { - AddAreaToID( vIDs[1], vAreas[0], vTotals, vIDs ); - AddAreaToID( vIDs[2], vAreas[1], vTotals, vIDs ); - AddAreaToID( vIDs[4], vAreas[2], vTotals, vIDs ); - AddAreaToID( vIDs[5], vAreas[3], vTotals, vIDs ); - } + AddAreaToID( vIDs[1], vAreas[0], vTotals, vIDs ); + AddAreaToID( vIDs[2], vAreas[1], vTotals, vIDs ); + AddAreaToID( vIDs[4], vAreas[2], vTotals, vIDs ); + AddAreaToID( vIDs[5], vAreas[3], vTotals, vIDs ); //Third quad - if ( ((vIDs[3] == vIDs[4]) && (vIDs[3] == vIDs[6]) && (vIDs[3] == vIDs[7])) ) - { - AddAreaToID( vIDs[3], 1.0, vTotals, vIDs ); - } - else - { - AddAreaToID( vIDs[3], vAreas[0], vTotals, vIDs ); - AddAreaToID( vIDs[4], vAreas[1], vTotals, vIDs ); - AddAreaToID( vIDs[6], vAreas[2], vTotals, vIDs ); - AddAreaToID( vIDs[7], vAreas[3], vTotals, vIDs ); - } + AddAreaToID( vIDs[3], vAreas[0], vTotals, vIDs ); + AddAreaToID( vIDs[4], vAreas[1], vTotals, vIDs ); + AddAreaToID( vIDs[6], vAreas[2], vTotals, vIDs ); + AddAreaToID( vIDs[7], vAreas[3], vTotals, vIDs ); //Fourth quad - if ( ((vIDs[4] == vIDs[5]) && (vIDs[4] == vIDs[7]) && (vIDs[4] == vIDs[8])) ) - { - AddAreaToID( vIDs[4], 1.0, vTotals, vIDs ); - } - else - { - AddAreaToID( vIDs[4], vAreas[0], vTotals, vIDs ); - AddAreaToID( vIDs[5], vAreas[1], vTotals, vIDs ); - AddAreaToID( vIDs[7], vAreas[2], vTotals, vIDs ); - AddAreaToID( vIDs[8], vAreas[3], vTotals, vIDs ); - } + AddAreaToID( vIDs[4], vAreas[0], vTotals, vIDs ); + AddAreaToID( vIDs[5], vAreas[1], vTotals, vIDs ); + AddAreaToID( vIDs[7], vAreas[2], vTotals, vIDs ); + AddAreaToID( vIDs[8], vAreas[3], vTotals, vIDs ); int nMax = 0; for( i = 1; i < 9; ++i )