From: <ma...@us...> - 2003-06-25 17:14:08
|
Update of /cvsroot/jrman/drafts/src/org/jrman/render In directory sc8-pr-cvs1:/tmp/cvs-serv6208/src/org/jrman/render Modified Files: SimpleMicropolygon.java RendererHidden.java Sampler.java ImageStore.java Log Message: Implemented pixel filter support. Index: SimpleMicropolygon.java =================================================================== RCS file: /cvsroot/jrman/drafts/src/org/jrman/render/SimpleMicropolygon.java,v retrieving revision 1.3 retrieving revision 1.4 diff -C2 -d -r1.3 -r1.4 *** SimpleMicropolygon.java 7 Jun 2003 13:25:32 -0000 1.3 --- SimpleMicropolygon.java 25 Jun 2003 17:14:04 -0000 1.4 *************** *** 152,156 **** sampler.getHeight() - 1); for (int row = minRow; row <= maxRow; row++) { - boolean found = false; for (int col = minColumn; col <= maxColumn; col++) { sampleCount++; --- 152,155 ---- *************** *** 163,169 **** if (touched) sampledSampleCount++; - if (found && !touched) - break; - found = touched; } } --- 162,165 ---- Index: RendererHidden.java =================================================================== RCS file: /cvsroot/jrman/drafts/src/org/jrman/render/RendererHidden.java,v retrieving revision 1.33 retrieving revision 1.34 diff -C2 -d -r1.33 -r1.34 *** RendererHidden.java 12 Jun 2003 18:36:08 -0000 1.33 --- RendererHidden.java 25 Jun 2003 17:14:04 -0000 1.34 *************** *** 41,45 **** import org.jrman.geom.Plane; import org.jrman.geom.Transform; - import org.jrman.maps.MipMap; import org.jrman.options.Display; import org.jrman.options.Filter; --- 41,44 ---- *************** *** 54,57 **** --- 53,58 ---- import org.jrman.util.Calc; import org.jrman.util.Format; + import org.jrman.util.GaussianSamplesFilter; + import org.jrman.util.SamplesFilter; public class RendererHidden extends Renderer { *************** *** 97,100 **** --- 98,111 ---- private long worldParseEnd; + private int hFilterExtra; + + private int vFilterExtra; + + private int hPixelLess; + + private int vPixelLess; + + private SamplesFilter samplesFilter; + public void init(Frame frame, World world) { super.init(frame, world); *************** *** 109,112 **** --- 120,124 ---- createClippingVolume(); createBuckets(); + samplesFilter = new GaussianSamplesFilter(); worldParseStart = System.currentTimeMillis(); } *************** *** 276,283 **** frame.getHorizontalSamplingRate(), frame.getVerticalSamplingRate()); int[] pixels = new int[bucketWidth * bucketHeight]; long start = System.currentTimeMillis(); Point2f rmin = rasterWindow.getMin(); ! for (int row = 0; row < bucketRows; row++) for (int column = 0; column < bucketColumns; column++) { Bucket bucket = getBucket(column, row); --- 288,307 ---- frame.getHorizontalSamplingRate(), frame.getVerticalSamplingRate()); + Filter filter = frame.getFilter(); + samplesFilter.init( + (int) Math.ceil(filter.getHorizontalWidth() * sampler.getPixelWidth()), + (int) Math.ceil(filter.getVerticalWidth() * sampler.getPixelHeight()), + filter.getHorizontalWidth(), + filter.getVerticalWidth()); + float[] samples = + new float[sampler.getWidth() + * bucketColumns + * (sampler.getHeight() + vFilterExtra + vPixelLess * sampler.getPixelHeight()) + * 3]; + float[] filteredSamples = new float[bucketWidth * bucketHeight * 3]; int[] pixels = new int[bucketWidth * bucketHeight]; long start = System.currentTimeMillis(); Point2f rmin = rasterWindow.getMin(); ! for (int row = 0; row < bucketRows; row++) { for (int column = 0; column < bucketColumns; column++) { Bucket bucket = getBucket(column, row); *************** *** 329,348 **** sampler.sampleBucket(bucket); bucket.flush(); ! Color3f[] colors = sampler.getColors(); ! colorsToPixels(colors, pixels); ! Point2f min = rasterWindow.getMin(); imageStore.setPixels( pixels, ! column * bucketWidth + (int) min.x, ! row * bucketHeight + (int) min.y, ! bucketWidth, ! bucketHeight); if (rc != null) rc.repaint( ! column * bucketWidth + (int) min.x, ! row * bucketHeight + (int) min.y, ! bucketWidth, ! bucketHeight); } if (frame.getDisplay().getType() == Display.Type.FILE) try { --- 353,413 ---- sampler.sampleBucket(bucket); bucket.flush(); ! sampler.getColors( ! samples, ! (column * sampler.getWidth() ! + (row == 0 ? 0 : 1) ! * (vFilterExtra + vPixelLess * sampler.getPixelHeight()) ! * bucketColumns ! * sampler.getWidth()) ! * 3, ! bucketColumns * sampler.getWidth(), ! 3, ! 0); ! samplesFilter.doFilter( ! samples, ! (column * sampler.getWidth() ! - (column == 0 ! ? 0 ! : (hFilterExtra + hPixelLess * sampler.getPixelWidth()))) ! * 3, ! bucketColumns * sampler.getWidth(), ! filteredSamples, ! 0, ! bucketWidth, ! bucketWidth - (column == 0 ? hPixelLess : 0), ! bucketHeight - (row == 0 ? vPixelLess : 0), ! sampler.getPixelWidth(), ! sampler.getPixelHeight(), ! 3); ! colorsToPixels(filteredSamples, pixels); imageStore.setPixels( pixels, ! column * bucketWidth - (column == 0 ? 0 : hPixelLess) + (int) rmin.x, ! row * bucketHeight - (row == 0 ? 0 : vPixelLess) + (int) rmin.y, ! bucketWidth - (column == 0 ? hPixelLess : 0), ! bucketHeight - (row == 0 ? vPixelLess : 0), ! bucketWidth); if (rc != null) rc.repaint( ! column * bucketWidth - (column == 0 ? 0 : hPixelLess) + (int) rmin.x, ! row * bucketHeight - (row == 0 ? 0 : vPixelLess) + (int) rmin.y, ! bucketWidth - (column == 0 ? hPixelLess : 0), ! bucketHeight - (row == 0 ? vPixelLess : 0)); } + System + .arraycopy( + samples, + (bucketHeight * sampler.getPixelHeight() + - (row == 0 ? (vFilterExtra + vPixelLess * sampler.getPixelHeight()) : 0)) + * bucketColumns + * sampler.getWidth() + * 3, + samples, + 0, + (vFilterExtra + vPixelLess * sampler.getPixelHeight()) + * bucketColumns + * sampler.getWidth() + * 3); + } if (frame.getDisplay().getType() == Display.Type.FILE) try { *************** *** 404,420 **** } ! private void colorsToPixels(Color3f[] colors, int[] result) { ! int pw = (int) frame.getHorizontalSamplingRate(); ! int ph = (int) frame.getVerticalSamplingRate(); Color3f tmp = new Color3f(); for (int row = 0; row < bucketHeight; row++) for (int col = 0; col < bucketWidth; col++) { ! tmp.set(0f, 0f, 0f); ! for (int r = 0; r < ph; r++) ! for (int c = 0; c < pw; c++) { ! int offset = (row * ph + r) * (bucketWidth * pw) + col * pw + c; ! tmp.add(colors[offset]); ! } ! tmp.scale(1f / (ph * pw)); frame.getExposure().expose(tmp, tmp); Quantizer qt = frame.getColorQuantizer(); --- 469,480 ---- } ! private void colorsToPixels(float[] colors, int[] result) { Color3f tmp = new Color3f(); for (int row = 0; row < bucketHeight; row++) for (int col = 0; col < bucketWidth; col++) { ! int offset = (row * bucketWidth + col) * 3; ! tmp.x = colors[offset++]; ! tmp.y = colors[offset++]; ! tmp.z = colors[offset]; frame.getExposure().expose(tmp, tmp); Quantizer qt = frame.getColorQuantizer(); *************** *** 422,426 **** int green = qt.quantize(tmp.y); int blue = qt.quantize(tmp.z); ! int offset = row * bucketWidth + col; result[offset] = ((255 << 24) | (red << 16) | (green << 8) | blue); } --- 482,486 ---- int green = qt.quantize(tmp.y); int blue = qt.quantize(tmp.z); ! offset = row * bucketWidth + col; result[offset] = ((255 << 24) | (red << 16) | (green << 8) | blue); } *************** *** 470,474 **** --- 530,538 ---- Filter filter = frame.getFilter(); float xw = (filter.getHorizontalWidth() - 1) / 2f; + hFilterExtra = (int) Math.ceil(xw * frame.getHorizontalSamplingRate()); + hPixelLess = (int) Math.ceil((float) hFilterExtra / frame.getHorizontalSamplingRate()); float yw = (filter.getVerticalWidth() - 1) / 2f; + vFilterExtra = (int) Math.ceil(yw * frame.getVerticalSamplingRate()); + vPixelLess = (int) Math.ceil((float) vFilterExtra / frame.getVerticalSamplingRate()); rxmin = (float) Math.floor(rxmin - xw); rxmax = (float) Math.ceil(rxmax + xw); Index: Sampler.java =================================================================== RCS file: /cvsroot/jrman/drafts/src/org/jrman/render/Sampler.java,v retrieving revision 1.6 retrieving revision 1.7 diff -C2 -d -r1.6 -r1.7 *** Sampler.java 12 May 2003 16:46:16 -0000 1.6 --- Sampler.java 25 Jun 2003 17:14:04 -0000 1.7 *************** *** 30,33 **** --- 30,35 ---- private Point2f min = new Point2f(); + + private Color3f tmpColor = new Color3f(); private int width; *************** *** 49,54 **** private SamplePoint[] samplePoints; - private Color3f[] colors; - private MaskElement rootVisibility = new MaskElement(); --- 51,54 ---- *************** *** 89,93 **** pixelHeight = height / bucketHeight; sampleWidth = 1f / hSamples; ! sampleHeight = 1f / hSamples; samplePoints = new SamplePoint[width * height]; for (int row = 0; row < height; row++) --- 89,93 ---- pixelHeight = height / bucketHeight; sampleWidth = 1f / hSamples; ! sampleHeight = 1f / vSamples; samplePoints = new SamplePoint[width * height]; for (int row = 0; row < height; row++) *************** *** 95,101 **** samplePoints[row * width + column] = new SamplePoint(this, column / pixelWidth, row / pixelHeight); - colors = new Color3f[width * height]; - for (int i = 0; i < colors.length; i++) - colors[i] = new Color3f(); pixelsVisibility = new MaskElement[bucketWidth * bucketHeight]; for (int i = 0; i < pixelsVisibility.length; i++) --- 95,98 ---- *************** *** 109,113 **** float x = min.x + sampleWidth * .5f; for (int column = 0; column < width; column++) { ! samplePoints[row * width + column].init(x, y); x += sampleWidth; } --- 106,112 ---- float x = min.x + sampleWidth * .5f; for (int column = 0; column < width; column++) { ! float jx = x + ((float) Math.random() - .5f) * sampleWidth; ! float jy = y + ((float) Math.random() - .5f) * sampleHeight; ! samplePoints[row * width + column].init(jx, jy); x += sampleWidth; } *************** *** 132,139 **** } ! public Color3f[] getColors() { ! for (int i = 0; i < samplePoints.length; i++) ! samplePoints[i].getColor(colors[i]); ! return colors; } --- 131,143 ---- } ! public void getColors(float[] dst, int dstOffset, int rowLength, int bands, int bandOffset) { ! for (int row = 0; row < height; row++) ! for (int col = 0; col < width; col++){ ! samplePoints[row * width + col].getColor(tmpColor); ! int offset = dstOffset + (row * rowLength + col) * bands + bandOffset; ! dst[offset++] = tmpColor.x; ! dst[offset++] = tmpColor.y; ! dst[offset] = tmpColor.z; ! } } Index: ImageStore.java =================================================================== RCS file: /cvsroot/jrman/drafts/src/org/jrman/render/ImageStore.java,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -d -r1.1 -r1.2 *** ImageStore.java 1 Jun 2003 03:12:57 -0000 1.1 --- ImageStore.java 25 Jun 2003 17:14:04 -0000 1.2 *************** *** 36,40 **** } ! public void setPixels(int[] pixels, int x, int y, int w, int h) { for (int row = 0; row < h; row++) { if (y + row < 0 || y + row >= vSize) --- 36,40 ---- } ! public void setPixels(int[] pixels, int x, int y, int w, int h, int rowLength) { for (int row = 0; row < h; row++) { if (y + row < 0 || y + row >= vSize) *************** *** 43,47 **** if (x + col < 0 || x + col >= hSize) continue; ! int pixel = pixels[row * w + col]; image.setRGB(x + col, y + row, pixel); } --- 43,47 ---- if (x + col < 0 || x + col >= hSize) continue; ! int pixel = pixels[row * rowLength + col]; image.setRGB(x + col, y + row, pixel); } |