Search in sources :

Example 1 with XYZColor

use of org.sunflow.image.XYZColor in project joons-renderer by joonhyublee.

the class IGIBitmapWriter method writeTile.

public void writeTile(int x, int y, int w, int h, Color[] color, float[] alpha) throws IOException {
    for (int j = 0, index = 0, pixel = 3 * (x + y * width); j < h; j++, pixel += 3 * (width - w)) {
        for (int i = 0; i < w; i++, index++, pixel += 3) {
            XYZColor c = Color.NATIVE_SPACE.convertRGBtoXYZ(color[index]);
            xyz[pixel + 0] = c.getX();
            xyz[pixel + 1] = c.getY();
            xyz[pixel + 2] = c.getZ();
        }
    }
}
Also used : XYZColor(org.sunflow.image.XYZColor)

Example 2 with XYZColor

use of org.sunflow.image.XYZColor in project joons-renderer by joonhyublee.

the class SunSkyLight method getSkyRGB.

private Color getSkyRGB(Vector3 dir) {
    if (dir.z < 0 && !groundExtendSky) {
        return groundColor;
    }
    if (dir.z < 0.001f) {
        dir.z = 0.001f;
    }
    dir.normalize();
    double theta = Math.acos(MathUtils.clamp(dir.z, -1, 1));
    double gamma = Math.acos(MathUtils.clamp(Vector3.dot(dir, sunDir), -1, 1));
    double x = perezFunction(perezx, theta, gamma, zenithx);
    double y = perezFunction(perezy, theta, gamma, zenithy);
    double Y = perezFunction(perezY, theta, gamma, zenithY) * 1e-4;
    XYZColor c = ChromaticitySpectrum.get((float) x, (float) y);
    // XYZColor c = new ChromaticitySpectrum((float) x, (float) y).toXYZ();
    float X = (float) (c.getX() * Y / c.getY());
    float Z = (float) (c.getZ() * Y / c.getY());
    return RGBSpace.SRGB.convertXYZtoRGB(X, (float) Y, Z);
}
Also used : XYZColor(org.sunflow.image.XYZColor)

Aggregations

XYZColor (org.sunflow.image.XYZColor)2