Esempio n. 1
0
func TestTorus(t *testing.T) {

	compileShader(OCCLUSION_SHADER)
	compileShader(VIGNETTE_SHADER)

	launch := "launch:prman? -t -ctrl $ctrlin $ctrlout -capture debug.rib"
	ri.Begin(launch)
	ri.Format(512, 320, 1)
	ri.Display("grasshopper", "framebuffer", "rgba")
	ri.ShadingRate(4)
	ri.Option("limits", "int threads", 2)
	ri.Option("statistics",
		"xmlfilename", "stats.xml",
		"endofframe", true)
	ri.PixelSamples(4, 4)
	ri.Projection("perspective", "fov", 30.)
	ri.Translate(0, 0.25, 4)
	ri.Rotate(-20, 1, 0, 0)
	ri.Rotate(180, 1, 0, 0)
	ri.Imager("Vignette")
	ri.WorldBegin()
	ri.Declare("samples", "float")
	ri.Declare("em", "color")
	ri.Attribute("cull",
		"int backfacing", false,
		"int hidden", false)
	ri.Attribute("visibility",
		"int diffuse", true,
		"int specular", true)
	ri.Attribute("dice",
		"int rasterorient", false)

	// Floor
	ri.Attribute("identifier", "string name", "Floor")
	ri.Surface("Occlusion",
		"em", color(0, 0.65, 0.83),
		"samples", 64.)
	ri.TransformBegin()
	ri.Rotate(90, 1, 0, 0)
	ri.Disk(-0.7, 300, 360)
	ri.TransformEnd()

	// Sculpture
	ri.Attribute("identifier", "string name", "Sculpture")
	ri.Surface("Occlusion",
		"em", gray(1.1),
		"samples", 64.)
	ri.TransformBegin()
	ri.Translate(0, 0.75, 0)
	ri.Torus(1, 0.2, 0, 360, 360)
	ri.TransformEnd()
	ri.WorldEnd()

	ri.End()
}
Esempio n. 2
0
func main() {
	launch := "launch:prman? -t -ctrl $ctrlin $ctrlout"
	ri.Begin(launch)
	ri.Format(512, 320, 1)
	ri.Display("grasshopper", "framebuffer", "rgba")
	ri.ShadingRate(4)
	ri.Option("limits", "int threads", 2)
	ri.PixelSamples(4, 4)
	ri.Projection("perspective", "fov", 30.)
	ri.WorldBegin()
	ri.Color(0.2, 0.3, 0.9)
	ri.Translate(0, 0, 5)
	ri.Sphere(1.0, -1.0, 1.0, 360.0)
	ri.WorldEnd()
	ri.End()
}
Esempio n. 3
0
func main() {

	args := os.Args[1:]
	if len(args) != 3 {
		usage()
	}
	filename, threading, mode := args[0], args[1], args[2]

	var isThreading bool
	switch threading {
	case "single":
		isThreading = false
	case "multi":
		isThreading = true
	default:
		usage()
	}
	_ = isThreading // ignore for now

	var isSilent bool = false
	var isRendering bool
	switch mode {
	case "render":
		isRendering = true
	case "ribgen":
		isRendering = false
	case "lsys":
		isSilent = true
	}

	contents, _ := ioutil.ReadFile(filename)
	xml := strings.NewReader(string(contents))
	curve := Evaluate(xml)

	if isSilent {
		return
	}

	compileShader("Occlusion")
	compileShader("Vignette")

	var launch string
	if isRendering {
		launch = "launch:prman? -t -ctrl $ctrlin $ctrlout -capture debug.rib"
	} else {
		launch = ""
	}

	ri.Begin(launch)
	ri.Format(1920/2, 800/2, 1)
	ri.Display("grasshopper", "framebuffer", "rgba")
	ri.ShadingRate(1)
	ri.Option("limits", "int threads", 2)
	ri.Option("statistics",
		"xmlfilename", "stats.xml",
		"endofframe", true)
	ri.PixelSamples(4, 4)
	initCamera()
	drawWorld(&curve)
	ri.End()
}