Search in sources :

Example 1 with RenderColor

use of org.jwildfire.create.tina.palette.RenderColor in project JWildfire by thargor6.

the class PostBlurRenderIterationState method plotPoint.

@Override
protected void plotPoint(int screenX, int screenY, double rawX, double rawY, double intensity, XYZPoint origin) {
    if (p.rgbColor) {
        plotRed = p.redColor;
        plotGreen = p.greenColor;
        plotBlue = p.blueColor;
    } else {
        RenderColor color = colorProvider.getColor(p, q);
        plotRed = color.red;
        plotGreen = color.green;
        plotBlue = color.blue;
    }
    transformPlotColor(p);
    if (ctx.random() > blurFade) {
        for (int k = screenY - blurRadius, yk = 0; k <= screenY + blurRadius; k++, yk++) {
            if (k >= 0 && k < rasterHeight) {
                for (int l = screenX - blurRadius, xk = 0; l <= screenX + blurRadius; l++, xk++) {
                    if (l >= 0 && l < rasterWidth) {
                        // y, x
                        double scl = blurKernel[yk][xk];
                        double finalRed = plotRed * scl * prj.intensity;
                        double finalGreen = plotGreen * scl * prj.intensity;
                        double finalBlue = plotBlue * scl * prj.intensity;
                        plotBuffer[plotBufferIdx++].set(l, k, finalRed, finalGreen, finalBlue, rawX, rawY, prj.z * view.bws, p.material, prj.dofDist, origin.x, origin.y, origin.z, p.receiveOnlyShadows);
                        if (plotBufferIdx >= plotBuffer.length) {
                            applySamplesToRaster();
                        }
                        if (observers != null && observers.size() > 0) {
                            for (IterationObserver observer : observers) {
                                observer.notifyIterationFinished(renderThread, l, k, prj, q.x, q.y, q.z, finalRed, finalGreen, finalBlue);
                            }
                        }
                    }
                }
            }
        }
    } else {
        double finalRed = plotRed * prj.intensity;
        double finalGreen = plotGreen * prj.intensity;
        double finalBlue = plotBlue * prj.intensity;
        plotBuffer[plotBufferIdx++].set(screenX, screenY, finalRed, finalGreen, finalBlue, rawX, rawY, prj.z * view.bws, p.material, prj.dofDist, origin.x, origin.y, origin.z, p.receiveOnlyShadows);
        if (plotBufferIdx >= plotBuffer.length) {
            applySamplesToRaster();
        }
        if (observers != null && observers.size() > 0) {
            for (IterationObserver observer : observers) {
                observer.notifyIterationFinished(renderThread, screenX, screenY, prj, q.x, q.y, q.z, finalRed, finalGreen, finalBlue);
            }
        }
    }
}
Also used : RenderColor(org.jwildfire.create.tina.palette.RenderColor) XYZPoint(org.jwildfire.create.tina.base.XYZPoint)

Example 2 with RenderColor

use of org.jwildfire.create.tina.palette.RenderColor in project JWildfire by thargor6.

the class SVGWFFunc method getColorIdx.

private double getColorIdx(double pR, double pG, double pB) {
    if (pR == lastR && pG == lastG && pB == lastB) {
        return lastColorIdx;
    }
    int nearestIdx = 0;
    RenderColor color = renderColors[0];
    double dr, dg, db;
    dr = (color.red - pR);
    dg = (color.green - pG);
    db = (color.blue - pB);
    double nearestDist = sqrt(dr * dr + dg * dg + db * db);
    for (int i = 1; i < renderColors.length; i++) {
        color = renderColors[i];
        dr = (color.red - pR);
        dg = (color.green - pG);
        db = (color.blue - pB);
        double dist = sqrt(dr * dr + dg * dg + db * db);
        if (dist < nearestDist) {
            nearestDist = dist;
            nearestIdx = i;
        }
    }
    lastColorIdx = (double) nearestIdx / (double) (renderColors.length - 1);
    lastR = pR;
    lastG = pG;
    lastB = pB;
    return lastColorIdx;
}
Also used : RenderColor(org.jwildfire.create.tina.palette.RenderColor) XYZPoint(org.jwildfire.create.tina.base.XYZPoint)

Example 3 with RenderColor

use of org.jwildfire.create.tina.palette.RenderColor in project JWildfire by thargor6.

the class YPlot2DWFFunc method getUVColorIdx.

private double getUVColorIdx(int pR, int pG, int pB) {
    RenderColor pColor = new RenderColor(pR, pG, pB);
    Double res = uvIdxMap.get(pColor);
    if (res == null) {
        int nearestIdx = 0;
        RenderColor color = uvColors[0];
        double dr, dg, db;
        dr = (color.red - pR);
        dg = (color.green - pG);
        db = (color.blue - pB);
        double nearestDist = sqrt(dr * dr + dg * dg + db * db);
        for (int i = 1; i < uvColors.length; i++) {
            color = uvColors[i];
            dr = (color.red - pR);
            dg = (color.green - pG);
            db = (color.blue - pB);
            double dist = sqrt(dr * dr + dg * dg + db * db);
            if (dist < nearestDist) {
                nearestDist = dist;
                nearestIdx = i;
            }
        }
        res = (double) nearestIdx / (double) (uvColors.length - 1);
        uvIdxMap.put(pColor, res);
    }
    return res;
}
Also used : RenderColor(org.jwildfire.create.tina.palette.RenderColor) XYZPoint(org.jwildfire.create.tina.base.XYZPoint)

Example 4 with RenderColor

use of org.jwildfire.create.tina.palette.RenderColor in project JWildfire by thargor6.

the class YPlot3DWFFunc method getUVColorIdx.

private double getUVColorIdx(int pR, int pG, int pB) {
    RenderColor pColor = new RenderColor(pR, pG, pB);
    Double res = uvIdxMap.get(pColor);
    if (res == null) {
        int nearestIdx = 0;
        RenderColor color = uvColors[0];
        double dr, dg, db;
        dr = (color.red - pR);
        dg = (color.green - pG);
        db = (color.blue - pB);
        double nearestDist = sqrt(dr * dr + dg * dg + db * db);
        for (int i = 1; i < uvColors.length; i++) {
            color = uvColors[i];
            dr = (color.red - pR);
            dg = (color.green - pG);
            db = (color.blue - pB);
            double dist = sqrt(dr * dr + dg * dg + db * db);
            if (dist < nearestDist) {
                nearestDist = dist;
                nearestIdx = i;
            }
        }
        res = (double) nearestIdx / (double) (uvColors.length - 1);
        uvIdxMap.put(pColor, res);
    }
    return res;
}
Also used : RenderColor(org.jwildfire.create.tina.palette.RenderColor) XYZPoint(org.jwildfire.create.tina.base.XYZPoint)

Example 5 with RenderColor

use of org.jwildfire.create.tina.palette.RenderColor in project JWildfire by thargor6.

the class AbstractColorMapWFFunc method getColorIdx.

private double getColorIdx(int pR, int pG, int pB) {
    RenderColor pColor = new RenderColor(pR, pG, pB);
    Double res = colorIdxMap.get(pColor);
    if (res == null) {
        int nearestIdx = 0;
        RenderColor color = renderColors[0];
        double dr, dg, db;
        dr = (color.red - pR);
        dg = (color.green - pG);
        db = (color.blue - pB);
        double nearestDist = sqrt(dr * dr + dg * dg + db * db);
        for (int i = 1; i < renderColors.length; i++) {
            color = renderColors[i];
            dr = (color.red - pR);
            dg = (color.green - pG);
            db = (color.blue - pB);
            double dist = sqrt(dr * dr + dg * dg + db * db);
            if (dist < nearestDist) {
                nearestDist = dist;
                nearestIdx = i;
            }
        }
        res = (double) nearestIdx / (double) (renderColors.length - 1);
        colorIdxMap.put(pColor, res);
    }
    return res;
}
Also used : RenderColor(org.jwildfire.create.tina.palette.RenderColor) XYZPoint(org.jwildfire.create.tina.base.XYZPoint)

Aggregations

RenderColor (org.jwildfire.create.tina.palette.RenderColor)10 XYZPoint (org.jwildfire.create.tina.base.XYZPoint)9