public Bump() { Source = null; GradDisp = new Vector3D(0.1, 0.1, 0); BumpFactor = 5.0f; Samples = new Vector3D(2, 2, 0); }
// Lambertian! Replace with general BSDF. public virtual void radianceEstimatePrecomputed(RGBColor rad, Vector3D position, Vector3D normal, float initialDist, float maxDist) { NearestPhotons np; // locate the nearest photon float r = initialDist; do { np = new NearestPhotons(1, r, position); locatePhotonsPrecomputed(normal, np, 1); r = (float)(r * 2.0); }while (np.found == 0 && r < maxDist); if (np.found > 0) { Photon p = getPhoton(np.indices[1]); rad.set(p.accumPower); } else { rad.set(0.0f); } }
/** * Changes the extents of the box as needed to include the given {@link org.sunflow.math.Vector3D point} into this box. * Does nothing if the parameter is <code>null</code>. * * @param p point to be included */ public void include(Vector3D p) { if (p != null) { if (p.x() < minimum.x()) { minimum.X = p.x(); } if (p.x() > maximum.x()) { maximum.X = p.x(); } if (p.y() < minimum.y()) { minimum.Y = p.y(); } if (p.y() > maximum.y()) { maximum.Y = p.y(); } if (p.z() < minimum.z()) { minimum.Z = p.z(); } if (p.z() > maximum.z()) { maximum.Z = p.z(); } } }
/** * Creates an empty box. The minimum point will have all components set to positive infinity, and the maximum will * have all components set to negative infinity. */ public BoundingBox() { minimum = new Vector3D(Double.PositiveInfinity, Double.PositiveInfinity, Double.PositiveInfinity); maximum = new Vector3D(Double.NegativeInfinity, Double.NegativeInfinity, Double.NegativeInfinity); center = new Vector3D(); extents = new Vector3D(); }
public static OrthoNormalBasis makeFromW(Vector3D w) { OrthoNormalBasis onb = new OrthoNormalBasis(); onb.w.set(w); onb.w.normalize(); //w.normalize(onb.w); if ((Math.Abs(onb.w.x()) < Math.Abs(onb.w.y())) && (Math.Abs(onb.w.x()) < Math.Abs(onb.w.z()))) { onb.v.X = 0; onb.v.Y = onb.w.z(); onb.v.Z = -onb.w.y(); } else if (Math.Abs(onb.w.y()) < Math.Abs(onb.w.z())) { onb.v.X = onb.w.z(); onb.v.Y = 0; onb.v.Z = -onb.w.x(); } else { onb.v.X = onb.w.y(); onb.v.Y = -onb.w.x(); onb.v.Z = 0; } onb.v.normalize(); onb.u = onb.v.cross(onb.w); //Vector3.cross(onb.v.normalize(), onb.w, onb.u); return(onb); }
public Bump(Material source, Vector3D gradDisp, float bumpFactor, Vector3D samples) { Source = source; GradDisp = new Vector3D(gradDisp); BumpFactor = bumpFactor; Samples = new Vector3D(samples); }
public Vector3D untransform(Vector3D a, Vector3D dest) { dest.X = a.dot(u); dest.Y = a.dot(v); dest.Z = a.dot(w); return(dest); }
public Bump(Bump other) { Source = other.source(); GradDisp = new Vector3D(other.gradDisp()); BumpFactor = other.bumpFactor(); Samples = new Vector3D(other.samples()); }
public Vector3D transform(Vector3D a, Vector3D dest) { dest.X = (a.x() * u.x()) + (a.y() * v.x()) + (a.z() * w.x()); dest.Y = (a.x() * u.y()) + (a.y() * v.y()) + (a.z() * w.y()); dest.Z = (a.x() * u.z()) + (a.y() * v.z()) + (a.z() * w.z()); return(dest); }
public Primitive(Vector3D position) { boundingbox = new BoundingBox(); Position = position; material_ = new Material(); }
public TextureMaterial() : base() { OtherDiffuseColor = new RGBColor(); Tiling = new Vector3D(1, 1, 0); Offset = new Vector3D(); Mirror = false; Tile = true; }
public override RGBColor diffuseColor(Vector3D localPoint) { int value; value = (int)System.Math.Round(localPoint.x() / spacing_) + (int)System.Math.Round(localPoint.y() / spacing_) + (int)System.Math.Round(localPoint.z() / spacing_); return(((value & 1) == 0)?diffuseColor():otherDiffuseColor()); }
public virtual Ray getRay(double u, double v) { Vector3D direction = new Vector3D(u, v, focalLength_); direction.normalize(); return(new Ray(new Vector3D(u, v, 0), direction)); }
public override RGBColor diffuseColor(Vector3D localPoint) { RGBColor color = material1_.diffuseColor(localPoint).scaleNew(amount1_); color.add(material2_.diffuseColor(localPoint).scaleNew(amount2_)); return(color); }
public Primitive() { boundingbox = new BoundingBox(); Position = new Vector3D(); material_ = new Material(); }
public override RGBColor diffuseColor(Vector3D localPoint) { Vector3D finalLocalPoint; finalLocalPoint = localPoint.scaleNew(tiling_); finalLocalPoint.add(offset_); return(lerpTexel(finalLocalPoint)); }
public TextureMaterial(Material material, RGBColor otherDiffuseColor, Vector3D tiling, Vector3D offset, bool mirror, bool tile, System.String filename) : base(material) { OtherDiffuseColor = new RGBColor(otherDiffuseColor); Tiling = tiling; Offset = offset; Mirror = mirror; Tile = tile; loadJPEG(filename); }
internal Sample(Vector3D p, Vector3D n, int depth) { pi = new Vector3D(p); ni = new Vector3D(n); ni.normalize(); irr = null; next = null; this.depth = depth; }
public IrradianceCache(double tolerance, double minSpacing, BoundingBox sceneBounds) { this.tolerance = tolerance; invTolerance = 1.0 / tolerance; this.minSpacing = minSpacing; maxSpacing = 100.0 * minSpacing; Vector3D ext = sceneBounds.getExtents(); root = new Node(sceneBounds.getCenter(), 1.0001 * Math.Max(ext.x(), Math.Max(ext.y(), ext.z()))); }
public Vector3D transform(Vector3D a) { double x = (a.x() * u.x()) + (a.y() * v.x()) + (a.z() * w.x()); double y = (a.x() * u.y()) + (a.y() * v.y()) + (a.z() * w.y()); double z = (a.x() * u.z()) + (a.y() * v.z()) + (a.z() * w.z()); a.set(x, y, z); return(new Vector3D(a)); }
public void recalcMinMax() { Vector3D halfExtents = extents.scaleNew(1.0 / 2.0); minimum.set(center); minimum.sub(halfExtents); maximum.set(minimum); maximum.add(extents); }
public TextureMaterial(RGBColor ambientColor, RGBColor diffuseColor, RGBColor specularColor, RGBColor transmissionColor, float phongExponent, float IOR, RGBColor otherDiffuseColor, Vector3D tiling, Vector3D offset, bool mirror, bool tile, System.String filename) : base(ambientColor, diffuseColor, specularColor, transmissionColor, phongExponent, IOR) { OtherDiffuseColor = otherDiffuseColor; Tiling = tiling; Offset = offset; Mirror = mirror; Tile = tile; loadJPEG(filename); }
public override Vector3D normal(Vector3D intersectionPoint, Vector3D viewPoint) { Vector3D normal = new Vector3D(ng); if (viewPoint.subNew(intersectionPoint).dot(normal) < 0.0) { normal.neg(); } return(normal); }
public virtual Vector3D perturbNormal(Vector3D normal, Vector3D localPoint, Primitive primitive) { if (bump_ != null) { return(bump_.perturbNormal(normal, localPoint, primitive)); } else { return(normal); } }
internal NearestPhotons(int nphots, double maxDist, Vector3D pos) { dist2 = new double[nphots + 1]; indices = new int[nphots + 1]; position = new Vector3D(pos); max = nphots; found = 0; gotHeap = false; dist2[0] = maxDist * maxDist; }
public override Vector3D mapTextureCoordinate(Vector3D localPoint) { double x = localPoint.x(); double y = localPoint.y(); double z = localPoint.z(); double elev = System.Math.Atan2(y, System.Math.Sqrt(x * x + z * z)) * invPI; double ang = System.Math.Atan2(z, x) * invPI; return(new Vector3D(ang, elev, 0)); }
public PhotonMap() { storedPhotons_ = 0; prevScale = 1; photons = new System.Collections.ArrayList(10); bboxMin = new Vector3D(RaytracerPhotonmapping.SceneConstants.HUGE_VALUE); bboxMax = new Vector3D(-RaytracerPhotonmapping.SceneConstants.HUGE_VALUE); photons.Add(new Photon()); }
internal Sample(Vector3D p, Vector3D n, double r0, RGBColor irr, RGBColor[] rotGradient, RGBColor[] transGradient, int depth) { pi = new Vector3D(p); ni = new Vector3D(n); ni.normalize(); invR0 = 1.0 / r0; this.irr = new RGBColor(irr); this.rotGradient = rotGradient; this.transGradient = transGradient; this.depth = depth; next = null; }
// Lambertian! Replace with general BSDF. public virtual void radianceEstimate(RGBColor rad, Vector3D position, Vector3D normal, float maxDist, int noPhotons) { //float ALPHA = 0.918f; float MBETA = -1.953f; float DENOMFACTOR = 1.0f / (1.0f - (float)System.Math.Exp(MBETA)); NearestPhotons np = new NearestPhotons(noPhotons, maxDist, position); rad.set(0.0f); // locate the nearest photons locatePhotons(np, 1); // if less than MINPHOTONS return if (np.found < RaytracerPhotonmapping.SceneConstants.MIN_PHOTONS) { return; } Vector3D direction = new Vector3D(); //float mittrs = MBETA / (2.0f * (float) np.dist2[0]); float kdenom = (float)(1.0 / (1.1 * Math.Sqrt(np.dist2[0]))); // sum irrandiance from all photons for (int i = 1; i <= np.found; i++) { float cosNL; Photon p = getPhoton(np.indices[i]); // the toCartesian call and following if can be omitted (for speed) // if the scene does not have any thin surfaces p.toCartesian(direction); cosNL = (float)direction.dot(normal); //cosNL = -1.0f; if (cosNL < 0.0) { //float gaussWeight = 1.0f - (1.0f - (float) System.Math.Exp((float) p.position.distanceSqr(position) * mittrs)) * DENOMFACTOR; float coneWeight = 1.0f - (float)(p.position.distance(position) * kdenom); //rad.add(p.power.scaleNew((- cosNL) * gaussWeight)); //rad.add(p.power.scaleNew((- cosNL))); rad.add(p.power.scaleNew(coneWeight)); } } // estimate of density rad.scale(1.0f / (float)((1.0f - 2.0f / (3.0f * 1.1f)) * System.Math.PI * np.dist2[0])); }
internal Node(Vector3D center, double sideLength) { children = new Node[8]; for (int i = 0; i < 8; i++) { children[i] = null; } this.center = new Vector3D(center); this.sideLength = sideLength; halfSideLength = 0.5 * sideLength; quadSideLength = 0.5 * halfSideLength; first = null; }