/* renderman/fromscratch/beginning.go * mae 012018 */ package main import ( "flag" "fmt" "os" ) const Version string = "renderman/fromscratch/beginning program 1" func main() { scale := flag.Float64("scale", 1.0, "`scale of output image") filename := flag.String("filename", "beginning.exr", "output filename") intensity := flag.Float64("intensity", 5.0, "fill_light intensity") maxsamples := flag.Int("maxsamples", 512, "maxsamples for raytrace hider") minsamples := flag.Int("minsamples", 16, "minsamples for raytrace hider") red := flag.Float64("red", 1.0, "red colour channel") green := flag.Float64("green", 0.0, "green colour channel") blue := flag.Float64("blue", 0.0, "blue colour channel") help := flag.Bool("help",false,"print the help") flag.Parse() if *help { fmt.Printf("%s\n\nhelp -\n",Version) flag.PrintDefaults() os.Exit(0) } within := func(d float64) float64 { if d < 0.000000 { return 0.0 } if d > 1.000000 { return 1.0 } return d } r := within(*red) g := within(*green) b := within(*blue) s := *scale if s < 0.1 { s = 0.1 } if s > 5.0 { s = 5.0 } width := int(640.0 * s) height := int(480.0 * s) d := fmt.Printf d("##RenderMan\n") d("##Machine Generated By %q\n", "beginning.go") d("##Cmd go run beginning.go -scale %.3f -intensity %.2f -maxsamples %d -minsamples %d -red %.3f -green %.3f -blue %.3f -filename %q\n", *scale,*intensity,*maxsamples,*minsamples,*red,*green,*blue,*filename) d("##Scene beginning.rib\n") d("version 3.04\n") d("Display %q %q %q\n", *filename, "openexr", "rgba") d("Format %d %d 1\n", width, height) d("Projection %q %q [60]\n", "perspective", "float fov") d("Hider %q %q [%d] %q [%d] %q [%d]\n", "raytrace", "int maxsamples", *maxsamples, "int minsamples", *minsamples, "int incremental", 100) d("Integrator %q %q\n", "PxrPathTracer", "example") d("WorldBegin\n") d("\tTranslate 0 0 10\n") d("\tAttributeBegin\n") d("\t\tTranslate 0 10 -5\n") d("\t\tScale 3 3 3\n") d("\t\tLight %q %q %q [%.2f]\n", "PxrSphereLight", "fill_light", "float intensity", *intensity) d("\tAttributeEnd\n") d("\tAttributeBegin\n") d("\t\tTranslate 0 0 -10\n") d("\t\tRotate 180 0 1 0\n") d("\t\tScale 2 2 2\n") d("\t\tLight %q %q\n", "PxrSphereLight", "key_light") d("\tAttributeEnd\n") d("\tAttributeBegin\n") d("\t\tBxdf %q %q %q [%.2f %.2f %.2f]\n", "PxrDiffuse", "surface", "color diffuseColor", r, g, b) d("\t\tScale 2 4 2\n") d("\t\tSphere 1 -1 1 360\n") d("\tAttributeEnd\n") d("WorldEnd\n") }