public override void writeTile(int x, int y, int w, int h, Color[] color, float[] alpha) { 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(); } } }
private Color getSkyRGB(Vector3 dir) { if (dir.z < 0) { return(Color.BLACK); } 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)); }