public static Light MakeLight(string name, Transform lightToWorld, ParamSet parameters) { switch (name) { case "distant": { var l = parameters.FindSpectrum("L", new Spectrum(1.0f)); var scale = parameters.FindSpectrum("scale", new Spectrum(1.0f)); var from = parameters.FindPoint("from", Point.Zero); var to = parameters.FindPoint("to", new Point(0, 0, 1)); var dir = from - to; return(new DistantLight(lightToWorld, l * scale, dir)); } case "point": { var i = parameters.FindSpectrum("I", new Spectrum(1.0f)); var scale = parameters.FindSpectrum("scale", new Spectrum(1.0f)); var from = parameters.FindPoint("from", Point.Zero); var l2w = Transform.Translate((Vector)from) * lightToWorld; return(new PointLight(l2w, i * scale)); } default: throw new ArgumentException("Unknown light: " + name); } }
public static AreaLight MakeAreaLight(string name, Transform lightToWorld, ParamSet parameters, Shape shape) { switch (name) { case "area": case "diffuse": { var l = parameters.FindSpectrum("L", new Spectrum(1.0f)); var scale = parameters.FindSpectrum("scale", new Spectrum(1.0f)); var numSamples = parameters.FindInt32("nsamples", 1); return new DiffuseAreaLight(lightToWorld, l * scale, numSamples, shape); } default: throw new ArgumentException("Unknown area light: " + name); } }
public static AreaLight MakeAreaLight(string name, Transform lightToWorld, ParamSet parameters, Shape shape) { switch (name) { case "area": case "diffuse": { var l = parameters.FindSpectrum("L", new Spectrum(1.0f)); var scale = parameters.FindSpectrum("scale", new Spectrum(1.0f)); var numSamples = parameters.FindInt32("nsamples", 1); return(new DiffuseAreaLight(lightToWorld, l * scale, numSamples, shape)); } default: throw new ArgumentException("Unknown area light: " + name); } }
public Texture <Spectrum> GetSpectrumTexture(string n, Spectrum defaultValue) { var name = _geomParams.FindTexture(n); if (string.IsNullOrEmpty(name)) { name = _materialParams.FindTexture(n); } if (!string.IsNullOrEmpty(name)) { if (_spectrumTextures.ContainsKey(name)) { return(_spectrumTextures[name]); } throw new InvalidOperationException(string.Format("Couldn't find spectrum texture named '{0}' for parameter '{1}'", name, n)); } var value = _geomParams.FindSpectrum(n, _materialParams.FindSpectrum(n, defaultValue)); return(new ConstantTexture <Spectrum>(value)); }
public static Light MakeLight(string name, Transform lightToWorld, ParamSet parameters) { switch (name) { case "distant" : { var l = parameters.FindSpectrum("L", new Spectrum(1.0f)); var scale = parameters.FindSpectrum("scale", new Spectrum(1.0f)); var from = parameters.FindPoint("from", Point.Zero); var to = parameters.FindPoint("to", new Point(0, 0, 1)); var dir = from - to; return new DistantLight(lightToWorld, l * scale, dir); } case "point": { var i = parameters.FindSpectrum("I", new Spectrum(1.0f)); var scale = parameters.FindSpectrum("scale", new Spectrum(1.0f)); var from = parameters.FindPoint("from", Point.Zero); var l2w = Transform.Translate((Vector) from) * lightToWorld; return new PointLight(l2w, i * scale); } default: throw new ArgumentException("Unknown light: " + name); } }
public Spectrum FindSpectrum(string name, Spectrum defaultValue) { return(_geomParams.FindSpectrum(name, defaultValue)); }