public bool Update(ParameterList pl, SunflowAPI api) { function = pl.getInt("function", function); size = pl.getFloat("size", size); scale = pl.getFloat("scale", scale); return true; }
public override bool Update(ParameterList pl, SunflowAPI api) { string filename = pl.getstring("texture", null); if (filename != null) tex = TextureCache.getTexture(api.resolveTextureFilename(filename), false); return tex != null && base.Update(pl, api); }
public bool update(ParameterList pl, SunflowAPI api) { // get parameters fov = pl.getFloat("fov", fov); aspect = pl.getFloat("aspect", aspect); update(); return true; }
public bool update(ParameterList pl, SunflowAPI api) { string filename = pl.getstring("texture", null); if (filename != null) bumpTexture = TextureCache.getTexture(api.resolveTextureFilename(filename), true); scale = pl.getFloat("scale", scale); return bumpTexture != null; }
public bool update(ParameterList pl, SunflowAPI api) { lineColor = pl.getColor("line", lineColor); fillColor = pl.getColor("fill", fillColor); width = pl.getFloat("width", width); cosWidth = (float)Math.Cos(width); return true; }
public bool update(ParameterList pl, SunflowAPI api) { // take all attributes, and update them into the current set foreach (KeyValuePair<string, Parameter> e in pl.list) { list[e.Key] = e.Value; e.Value.check(); } return true; }
public virtual bool Update(ParameterList pl, SunflowAPI api) { bright = pl.getColor("bright", bright); dark = pl.getColor("dark", dark); samples = pl.getInt("samples", samples); maxDist = pl.getFloat("maxdist", maxDist); if (maxDist <= 0) maxDist = float.PositiveInfinity; return true; }
public bool Update(ParameterList pl, SunflowAPI api) { // get parameters fov = pl.getFloat("fov", fov); aspect = pl.getFloat("aspect", aspect); shiftX = pl.getFloat("shift.x", shiftX); shiftY = pl.getFloat("shift.y", shiftY); Update(); return true; }
public bool Update(ParameterList pl, SunflowAPI api) { shutterOpen = pl.getFloat("shutter.open", shutterOpen); shutterClose = pl.getFloat("shutter.close", shutterClose); c2w = pl.getMovingMatrix("transform", c2w); w2c = c2w.inverse(); if (w2c == null) { UI.printWarning(UI.Module.CAM, "Unable to compute camera's inverse transform"); return false; } return lens.Update(pl, api); }
public bool update(ParameterList pl, SunflowAPI api) { return obj.update(pl, api); }
public bool update(string name, ParameterList pl, SunflowAPI api) { RenderObjectHandle obj = renderObjects[name]; bool success; if (obj == null) { UI.printError(UI.Module.API, "Unable to update \"{0}\" - object was not defined yet", name); success = false; } else { UI.printDetailed(UI.Module.API, "Updating {0} object \"{1}\"", obj.typeName(), name); success = obj.update(pl, api); if (!success) { UI.printError(UI.Module.API, "Unable to update \"{0}\" - removing", name); remove(name); } else { switch (obj.type) { case RenderObjectType.GEOMETRY: case RenderObjectType.INSTANCE: rebuildInstanceList = true; break; case RenderObjectType.LIGHT: rebuildLightList = true; break; default: break; } } } return success; }
public bool Update(ParameterList pl, SunflowAPI api) { nx = pl.getInt("resolutionX", nx); ny = pl.getInt("resolutionY", ny); nz = pl.getInt("resolutionZ", nz); voxelwx = 2.0f / nx; voxelwy = 2.0f / ny; voxelwz = 2.0f / nz; invVoxelwx = 1 / voxelwx; invVoxelwy = 1 / voxelwy; invVoxelwz = 1 / voxelwz; return true; }
public bool update(ParameterList pl, SunflowAPI api) { radiance = pl.getColor("radiance", radiance); numSamples = pl.getInt("samples", numSamples); radius = pl.getFloat("radius", radius); r2 = radius * radius; center = pl.getPoint("center", center); return true; }
private bool updateCameraMatrix(int index, ParameterList pl) { string offset = index < 0 ? "" : string.Format("[{0}]", index); if (index < 0) index = 0; Matrix4 transform = pl.getMatrix(string.Format("transform{0}", offset), null); if (transform == null) { // no transform was specified, check eye/target/up Point3 eye = pl.getPoint(string.Format("eye{0}", offset), null); Point3 target = pl.getPoint(string.Format("target{0}", offset), null); Vector3 up = pl.getVector(string.Format("up{0}", offset), null); if (eye != null && target != null && up != null) { c2w[index] = Matrix4.fromBasis(OrthoNormalBasis.makeFromWV(Point3.sub(eye, target, new Vector3()), up)); c2w[index] = Matrix4.translation(eye.x, eye.y, eye.z).multiply(c2w[index]); } else { // the matrix for this index was not specified // return an error, unless this is a regular update return offset.Length == 0; } } else c2w[index] = transform; return true; }
public bool update(ParameterList pl, SunflowAPI api) { updateBasis(pl.getVector("center", null), pl.getVector("up", null)); numSamples = pl.getInt("samples", numSamples); string filename = pl.getstring("texture", null); if (filename != null) texture = TextureCache.getTexture(api.resolveTextureFilename(filename), true); // no texture provided if (texture == null) return false; Bitmap b = texture.getBitmap(); if (b == null) return false; // rebuild histograms if this is a new texture if (filename != null) { imageHistogram = new float[b.Width][]; for(int i = 0;i < imageHistogram.Length;i++) imageHistogram[i] = new float[b.Height]; colHistogram = new float[b.Width]; float du = 1.0f / b.Width; float dv = 1.0f / b.Height; for (int x = 0; x < b.Width; x++) { for (int y = 0; y < b.Height; y++) { float u = (x + 0.5f) * du; float v = (y + 0.5f) * dv; Color c = texture.getPixel(u, v); // box filter the image // c.add(texture.getPixel(u + du, v)); // c.add(texture.getPixel(u + du, v+ dv)); // c.add(texture.getPixel(u, v + dv)); // c.mul(0.25f); imageHistogram[x][y] = c.getLuminance() * (float) Math.Sin(Math.PI * v); if (y > 0) imageHistogram[x][y] += imageHistogram[x][y - 1]; } colHistogram[x] = imageHistogram[x][b.Height - 1]; if (x > 0) colHistogram[x] += colHistogram[x - 1]; for (int y = 0; y < b.Height; y++) imageHistogram[x][y] /= imageHistogram[x][b.Height - 1]; } for (int x = 0; x < b.Width; x++) colHistogram[x] /= colHistogram[b.Width - 1]; jacobian = (float) (2 * Math.PI * Math.PI) / (b.Width * b.Height); } // take fixed samples if (pl.getbool("fixed", samples != null)) { // Bitmap loc = new Bitmap(filename); samples = new Vector3[numSamples]; colors = new Color[numSamples]; for (int i = 0; i < numSamples; i++) { double randX = (double) i / (double) numSamples; double randY = QMC.halton(0, i); int x = 0; while (randX >= colHistogram[x] && x < colHistogram.Length - 1) x++; float[] rowHistogram = imageHistogram[x]; int y = 0; while (randY >= rowHistogram[y] && y < rowHistogram.Length - 1) y++; // sample from (x, y) float u = (float) ((x == 0) ? (randX / colHistogram[0]) : ((randX - colHistogram[x - 1]) / (colHistogram[x] - colHistogram[x - 1]))); float v = (float) ((y == 0) ? (randY / rowHistogram[0]) : ((randY - rowHistogram[y - 1]) / (rowHistogram[y] - rowHistogram[y - 1]))); float px = ((x == 0) ? colHistogram[0] : (colHistogram[x] - colHistogram[x - 1])); float py = ((y == 0) ? rowHistogram[0] : (rowHistogram[y] - rowHistogram[y - 1])); float su = (x + u) / colHistogram.Length; float sv = (y + v) / rowHistogram.Length; float invP = (float) Math.Sin(sv * Math.PI) * jacobian / (numSamples * px * py); samples[i] = getDirection(su, sv); basis.transform(samples[i]); colors[i] = texture.getPixel(su, sv).mul(invP); // loc.setPixel(x, y, Color.YELLOW.copy().mul(1e6f)); } // loc.save("samples.hdr"); } else { // turn off samples = null; colors = null; } return true; }
public bool Update(ParameterList pl, SunflowAPI api) { // get parameters fov = pl.getFloat("fov", fov); aspect = pl.getFloat("aspect", aspect); shiftX = pl.getFloat("shift.x", shiftX); shiftY = pl.getFloat("shift.y", shiftY); focusDistance = pl.getFloat("focus.distance", focusDistance); lensRadius = pl.getFloat("lens.radius", lensRadius); lensSides = pl.getInt("lens.sides", lensSides); lensRotation = pl.getFloat("lens.rotation", lensRotation); Update(); return true; }
public virtual bool update(ParameterList pl, SunflowAPI api) { rhoD = pl.getColor("diffuse", rhoD); rhoS = pl.getColor("specular", rhoS); alphaX = pl.getFloat("roughnessX", alphaX); alphaY = pl.getFloat("roughnessY", alphaY); numRays = pl.getInt("samples", numRays); return true; }
/** * Reset the state of the API completely. The object table is cleared, and * all search paths areset back to their default values. */ public void reset() { scene = new Scene(); includeSearchPath = new SearchPath("include"); textureSearchPath = new SearchPath("texture"); parameterList = new ParameterList(); renderObjects = new RenderObjectMap(); currentFrame = 1; }
public bool Update(ParameterList pl, SunflowAPI api) { color = pl.getColor("color", color); return true; }
public override bool update(ParameterList pl, SunflowAPI api) { radiance = pl.getColor("radiance", radiance); numSamples = pl.getInt("samples", numSamples); return base.update(pl, api); }
public bool update(ParameterList pl, SunflowAPI api) { src = pl.getPoint("source", src); dir = pl.getVector("dir", dir); dir.normalize(); r = pl.getFloat("radius", r); basis = OrthoNormalBasis.makeFromW(dir); r2 = r * r; radiance = pl.getColor("radiance", radiance); return true; }
public bool update(ParameterList pl, SunflowAPI api) { int n = pl.getInt("transform.steps", 0); if (n <= 0) { // no motion blur, get regular arguments or leave unchanged updateCameraMatrix(-1, pl); } else { // new motion blur settings - get transform for each step c2w = new Matrix4[n]; for (int i = 0; i < n; i++) { if (!updateCameraMatrix(i, pl)) { UI.printError(UI.Module.CAM, "Camera matrix for step {0} was not specified!", i + 1); return false; } } } w2c = new Matrix4[c2w.Length]; for (int i = 0; i < c2w.Length; i++) { if (c2w[i] != null) { w2c[i] = c2w[i].inverse(); if (w2c[i] == null) { UI.printError(UI.Module.CAM, "Camera matrix is not invertible"); return false; } } else w2c[i] = null; } return lens.update(pl, api); }
public bool update(ParameterList pl, SunflowAPI api) { string file = pl.getstring("filename", null); if (file != null) filename = api.resolveIncludeFilename(file); smoothNormals = pl.getbool("smooth_normals", smoothNormals); return filename != null; }
public bool update(ParameterList pl, SunflowAPI api) { ParameterList.FloatParameter pts = pl.getPointArray("points"); if (pts != null) { BoundingBox bounds = new BoundingBox(); for (int i = 0; i < pts.data.Length; i += 3) bounds.include(pts.data[i], pts.data[i + 1], pts.data[i + 2]); // cube extents minX = bounds.getMinimum().x; minY = bounds.getMinimum().y; minZ = bounds.getMinimum().z; maxX = bounds.getMaximum().x; maxY = bounds.getMaximum().y; maxZ = bounds.getMaximum().z; } return true; }
public bool Update(ParameterList pl, SunflowAPI api) { string geometryName = pl.getstring("geometry", null); if (geometry == null || geometryName != null) { if (geometryName == null) { UI.printError(UI.Module.GEOM, "geometry parameter missing - unable to create instance"); return false; } geometry = api.lookupGeometry(geometryName); if (geometry == null) { UI.printError(UI.Module.GEOM, "Geometry \"{0}\" was not declared yet - instance is invalid", geometryName); return false; } } string[] shaderNames = pl.getstringArray("shaders", null); if (shaderNames != null) { // new shader names have been provided shaders = new IShader[shaderNames.Length]; for (int i = 0; i < shaders.Length; i++) { shaders[i] = api.lookupShader(shaderNames[i]); if (shaders[i] == null) UI.printWarning(UI.Module.GEOM, "Shader \"{0}\" was not declared yet - ignoring", shaderNames[i]); } } else { // re-use existing shader array } string[] modifierNames = pl.getstringArray("modifiers", null); if (modifierNames != null) { // new modifier names have been provided modifiers = new Modifier[modifierNames.Length]; for (int i = 0; i < modifiers.Length; i++) { modifiers[i] = api.lookupModifier(modifierNames[i]); if (modifiers[i] == null) UI.printWarning(UI.Module.GEOM, "Modifier \"{0}\" was not declared yet - ignoring", modifierNames[i]); } } o2w = pl.getMovingMatrix("transform", o2w); w2o = o2w.inverse(); if (w2o == null) { UI.printError(UI.Module.GEOM, "Unable to compute transform inverse"); return false; } return true; }
public bool Update(ParameterList pl, SunflowAPI api) { return true; }
public bool update(ParameterList pl, SunflowAPI api) { Vector3 up = pl.getVector("up", null); Vector3 east = pl.getVector("east", null); if (up != null && east != null) basis = OrthoNormalBasis.makeFromWV(up, east); else if (up != null) basis = OrthoNormalBasis.makeFromW(up); numSkySamples = pl.getInt("samples", numSkySamples); sunDirWorld = pl.getVector("sundir", sunDirWorld); turbidity = pl.getFloat("turbidity", turbidity); // recompute model initSunSky(); return true; }
public bool Update(ParameterList pl, SunflowAPI api) { diff = pl.getColor("diffuse", diff); spec = pl.getColor("specular", spec); string filename; filename = pl.getstring("diffuse.texture", null); if (filename != null) diffmap = TextureCache.getTexture(api.resolveTextureFilename(filename), false); filename = pl.getstring("specular.texture", null); if (filename != null) specmap = TextureCache.getTexture(api.resolveTextureFilename(filename), false); diffBlend = MathUtils.clamp(pl.getFloat("diffuse.blend", diffBlend), 0, 1); specBlend = MathUtils.clamp(pl.getFloat("specular.blend", diffBlend), 0, 1); glossyness = MathUtils.clamp(pl.getFloat("glossyness", glossyness), 0, 1); numSamples = pl.getInt("samples", numSamples); return true; }
public bool update(ParameterList pl, SunflowAPI api) { acceltype = pl.getstring("accel", acceltype); // clear up old tesselation if it exists if (tesselatable != null) { primitives = null; builtTess = 0; } // clear acceleration structure so it will be rebuilt accel = null; builtAccel = 0; if (tesselatable != null) return tesselatable.update(pl, api); // update primitives return primitives.update(pl, api); }
private TriangleMesh generate(int[] tris, float[] verts, bool smoothNormals) { ParameterList pl = new ParameterList(); pl.addIntegerArray("triangles", tris); pl.addPoints("points", ParameterList.InterpolationType.VERTEX, verts); if (smoothNormals) { float[] normals = new float[verts.Length]; // filled with 0's Point3 p0 = new Point3(); Point3 p1 = new Point3(); Point3 p2 = new Point3(); Vector3 n = new Vector3(); for (int i3 = 0; i3 < tris.Length; i3 += 3) { int v0 = tris[i3 + 0]; int v1 = tris[i3 + 1]; int v2 = tris[i3 + 2]; p0.set(verts[3 * v0 + 0], verts[3 * v0 + 1], verts[3 * v0 + 2]); p1.set(verts[3 * v1 + 0], verts[3 * v1 + 1], verts[3 * v1 + 2]); p2.set(verts[3 * v2 + 0], verts[3 * v2 + 1], verts[3 * v2 + 2]); Point3.normal(p0, p1, p2, n); // compute normal // add face normal to each vertex // note that these are not normalized so this in fact weights // each normal by the area of the triangle normals[3 * v0 + 0] += n.x; normals[3 * v0 + 1] += n.y; normals[3 * v0 + 2] += n.z; normals[3 * v1 + 0] += n.x; normals[3 * v1 + 1] += n.y; normals[3 * v1 + 2] += n.z; normals[3 * v2 + 0] += n.x; normals[3 * v2 + 1] += n.y; normals[3 * v2 + 2] += n.z; } // normalize all the vectors for (int i3 = 0; i3 < normals.Length; i3 += 3) { n.set(normals[i3 + 0], normals[i3 + 1], normals[i3 + 2]); n.normalize(); normals[i3 + 0] = n.x; normals[i3 + 1] = n.y; normals[i3 + 2] = n.z; } pl.addVectors("normals", ParameterList.InterpolationType.VERTEX, normals); } TriangleMesh m = new TriangleMesh(); if (m.update(pl, null)) return m; // something failed in creating the mesh, the error message will be // printed by the mesh itself - no need to repeat it here return null; }
public bool update(ParameterList pl, SunflowAPI api) { // TODO: build accelstructure into this (?) return(true); }