private Color3f antiAliasPixel( double ll_u, double ll_v, double u_incr, double v_incr, AntiAliasingPattern aap, Color3f ulColor, Color3f urColor, Color3f llColor, Color3f lrColor, HashMap<java.lang.Double, ColumnSubstitutorPair> csp_hm) { // first average pixel-corner colors Color3f finalColor; // adaptive supersampling float thresholdSqr = dcsd.antiAliasingThreshold * dcsd.antiAliasingThreshold; if (aap != AntiAliasingPattern.OG_2x2 && (colorDiffSqr(ulColor, urColor) >= thresholdSqr || colorDiffSqr(ulColor, llColor) >= thresholdSqr || colorDiffSqr(ulColor, lrColor) >= thresholdSqr || colorDiffSqr(urColor, llColor) >= thresholdSqr || colorDiffSqr(urColor, lrColor) >= thresholdSqr || colorDiffSqr(llColor, lrColor) >= thresholdSqr)) { // anti-alias pixel with advanced sampling pattern finalColor = new Color3f(); for (SamplingPoint sp : aap) { if (Thread.interrupted()) throw new RenderingInterruptedException(); Color3f ss_color; if (sp.getU() == 0.0 && sp.getV() == 0.0) ss_color = llColor; else if (sp.getU() == 0.0 && sp.getV() == 1.0) ss_color = ulColor; else if (sp.getU() == 1.0 && sp.getV() == 1.0) ss_color = urColor; else if (sp.getU() == 1.0 && sp.getV() == 0.0) ss_color = lrColor; else { // color of this sample point is not known -> calculate double v = ll_v + sp.getV() * v_incr; double u = ll_u + sp.getU() * u_incr; ColumnSubstitutorPair csp = csp_hm.get(v); if (csp == null) { csp = new ColumnSubstitutorPair( dcsd.surfaceRowSubstitutor.setV(v), dcsd.gradientRowSubstitutor.setV(v)); csp_hm.put(v, csp); } ss_color = tracePolynomial(csp.scs, csp.gcs, u, v); } finalColor.scaleAdd(sp.getWeight(), ss_color, finalColor); if (false) return new Color3f( 0, 0, 0); // paint pixels, that are supposed to be anti-aliased in black } } else { finalColor = new Color3f(ulColor); finalColor.add(urColor); finalColor.add(llColor); finalColor.add(lrColor); finalColor.scale(0.25f); } // clamp color, because floating point operations may yield values outside [0,1] finalColor.clamp(0f, 1f); return finalColor; }