Ejemplo n.º 1
0
def quadrics(ri):
    ri.RiTransformBegin()
    ri.RiTranslate(-3, 0, 0)
    ri.RiSphere(0.5, -0.5, 0.5, 360, "varying color Cs", [(1, 0, 0), (0, 1, 0),
                                                          (0, 0, 1),
                                                          (1, 1, 0)])
    ri.RiTranslate(1, 0, 0)
    ri.RiCone(1, 0.5, 360, "varying color Cs", [(1, 0, 0), (0, 1, 0),
                                                (0, 0, 1), (1, 1, 0)])
    ri.RiTranslate(1, 0, 0)
    ri.RiCylinder(0.5, -0.5, 0.5, 360, "varying color Cs",
                  [(1, 0, 0), (0, 1, 0), (0, 0, 1), (1, 1, 0)])
    ri.RiTranslate(1, 0, 0)
    ri.RiHyperboloid((0, 0.3, 0), (0.5, 0, 0), 360, "varying color Cs",
                     [(1, 0, 0), (0, 1, 0), (0, 0, 1), (1, 1, 0)])
    ri.RiTranslate(1, 0, 0)
    ri.RiParaboloid(0.5, 0.2, 0.7, 360, "varying color Cs", [(1, 0, 0),
                                                             (0, 1, 0),
                                                             (0, 0, 1),
                                                             (1, 1, 0)])
    ri.RiTranslate(1, 0, 0)
    if has_numpy:
        Cs = numpy.array([(1, 0, 0), (0, 1, 0), (0, 0, 1), (1, 1, 0)],
                         dtype=numpy.float32)
    else:
        Cs = [(1, 0, 0), (0, 1, 0), (0, 0, 1), (1, 1, 0)]
    ri.RiDisk(0, 0.5, 360, "varying color Cs", Cs)
    ri.RiTranslate(1, 0, 0)
    ri.RiTorus(0.45, 0.05, 0, 360, 360, "varying color Cs", [(1, 0, 0),
                                                             (0, 1, 0),
                                                             (0, 0, 1),
                                                             (1, 1, 0)])
    ri.RiTransformEnd()
Ejemplo n.º 2
0
def testContextSwitch(ri, archiveName):
    prevCtx = ri.RiGetContext()
    ri.RiBegin(archiveName)
    ri.RiAttributeBegin()
    ri.RiTranslate(4, -3, 0)
    ri.RiColor((1, 0.5, 0))
    ri.RiSphere(1, -1, 1, 360, "constant string info",
                "This sphere must be stored in include.rib")
    ri.RiAttributeEnd()
    ri.RiEnd()
    ri.RiContext(prevCtx)
    ri.RiReadArchive("include.rib")
Ejemplo n.º 3
0
def subdivFunc(data, detail):
    #    print "Subdiv",data,detail
    ri.RiSphere(0.5, -0.5, 0.5, 360, "uniform color Cs", [0, 0, 1],
                "constant string data", data, "constant string info",
                "This sphere was generated by a custom procedural")
Ejemplo n.º 4
0
def main(ri, name, archiveName="include.rib"):
    """Main function.
    
    ri: RenderMan API
    name: Argument for RiBegin()
    archiveName: Name of the test archive file
    """
    ri.RiBegin(name)

    ri.RiArchiveRecord(ri.RI_COMMENT, "Test RIB file %d", 1)
    ri.RiArchiveRecord(ri.RI_STRUCTURE, "Creator $CREATOR")
    ri.RiErrorHandler(customErrorFunc)
    ri.RiErrorHandler(ri.RiErrorAbort)
    ri.RiErrorHandler(ri.RiErrorPrint)
    ri.RiErrorHandler(ri.RiErrorIgnore)
    err = ri.RiLastError
    ri.RiOption("searchpath", "shader", "&:shaders")
    ri.RiOption("render", "string bucketorder", "horizontal")
    ri.RiFormat(800, 600, 1.0)
    ri.RiDisplay("out.tif", ri.RI_FRAMEBUFFER, ri.RI_RGBA, "integer[2] origin",
                 [10, 10])
    ri.RiCropWindow(0.25, 0.75, 0.1, 0.9)
    ri.RiCropWindow(0, 1, 0.0, 1.0)
    ri.RiPixelSamples(2, 2.5)
    ri.RiShadingRate(2.0)
    ri.RiExposure(1.0, 1.0)
    ri.RiFrameAspectRatio(4.0 / 3.0)
    ri.RiScreenWindow(-4.0 / 3, 4.0 / 3, -1, 1)
    ri.RiQuantize(ri.RI_RGBA, 255, 0, 255, 0.5)
    ri.RiPixelFilter(customPixelFilter, 1, 1)
    ri.RiPixelFilter(ri.RiBoxFilter, 1, 1)
    ri.RiPixelFilter(ri.RiTriangleFilter, 1, 1)
    ri.RiPixelFilter(ri.RiCatmullRomFilter, 1, 1)
    ri.RiPixelFilter(ri.RiSincFilter, 1, 1)
    ri.RiPixelFilter(ri.RiGaussianFilter, 2.0, 2.5)
    ri.RiClipping(1, 20)
    ri.RiSides(2)
    ri.RiDeclare("foo", "uniform float")
    ri.RiHider("hidden")
    ri.RiShadingInterpolation("constant")
    ri.RiPixelVariance(0.1)
    ri.RiGeometricApproximation("flatness", 1.0)
    ri.RiDepthOfField(22, 45, 1000)
    ri.RiDepthOfField(ri.RI_INFINITY, 45, 1000)
    ri.RiRelativeDetail(0.6)
    ri.RiColorSamples(mat3(1), mat3(1))

    ri.RiImager("foo", Ka=1.0)

    ri.RiIdentity()
    ri.RiProjection(ri.RI_PERSPECTIVE, fov=40)
    ri.RiTranslate(0, 0, 8)
    ri.RiTranslate((0, 0, 2))

    ri.RiShutter(0, 1)

    ri.RiClippingPlane(5, 0, 0, 1, 0, 0)

    ri.RiFrameBegin(1)
    ri.RiWorldBegin()
    ri.RiCoordinateSystem("myworld")
    ri.RiAttribute("identifier", "name", "object")

    ri.RiColor((1, 1, 1))
    ri.RiOpacity((1, 1, 1))

    lgt = ri.RiLightSource("distantlight", "from", (0, 0, -1), "to", (0, 0, 0))
    ri.RiIlluminate(lgt, ri.RI_TRUE)

    ri.RiSurface("plastic", Kd=1.0)

    ri.RiAttributeBegin()
    ri.RiTranslate(0, 3, 0)
    quadrics(ri)
    ri.RiAttributeEnd()

    ri.RiAttributeBegin()
    ri.RiTranslate(0, 1.5, 0)
    polys(ri)
    ri.RiAttributeEnd()

    ri.RiAttributeBegin()
    patches(ri)
    ri.RiAttributeEnd()

    ri.RiAttributeBegin()
    ri.RiTranslate(0, -1.5, 0)
    miscGeoms(ri)
    ri.RiAttributeEnd()

    testContextSwitch(ri, archiveName)

    ri.RiTransformBegin()

    ri.RiTranslate(0, -3, 0)
    # Motion blur
    ri.RiAttributeBegin()
    ri.RiMotionBegin(0.0, 1.0)
    ri.RiTranslate(-0.1, 0, 0)
    ri.RiTranslate(0.1, 0, 0)
    ri.RiMotionEnd()
    ri.RiMotionBegin([0.0, 1.0])
    ri.RiRotate(0, vec3(1, 0, 0))
    ri.RiRotate(90, vec3(1, 0, 0))
    ri.RiMotionEnd()
    ri.RiSphere(0.5, -0.5, 0.5, 360)
    ri.RiAttributeEnd()

    # Object instancing
    obj = ri.RiObjectBegin()
    ri.RiSphere(0.5, -0.5, 0.5, 360)
    ri.RiObjectEnd()
    ri.RiTranslate(1.33, 0, 0)
    ri.RiColor((0, 0.5, 0.5))
    ri.RiObjectInstance(obj)

    ri.RiTransformEnd()

    testTransformPoints(ri)

    # Misc
    ri.RiMatte(ri.RI_TRUE)
    ri.RiOrientation("lh")
    ri.RiReverseOrientation()
    ri.RiPerspective(45.0)
    ri.RiSkew(45, 0, 1, 0, 1, 0, 0)
    ri.RiSkew(45, vec3(0, 1, 0), vec3(1, 0, 0))
    ri.RiTransform(mat4(1))
    ri.RiConcatTransform(mat4(1))
    ri.RiTextureCoordinates(0, 0, 1, 0, 1, 1, 0, 1)
    ri.RiDisplacement("foo", {"Ka": 1.0, "constant string mapname": "foo.map"})
    ri.RiAtmosphere("foo", Ka=1.0, Ks=0.5)
    ri.RiInterior("foo", "Ka", 1.0, "Ks", 0.6, "constant string mapname",
                  "foo.map")
    ri.RiExterior("foo", Ka=1.0)
    algt = ri.RiAreaLightSource("foo", Ka=1.0)
    # Test string handles
    lgt2 = ri.RiLightSource("distantlight", ri.RI_HANDLEID, "mylight", "Ka",
                            0.7)
    ri.RiIlluminate(lgt2, ri.RI_FALSE)

    ri.RiBound([0, 1, 0, 1, 0, 1])
    ri.RiCoordSysTransform("myworld")
    ri.RiDetail([0, 1, 0, 1, 0, 1])
    ri.RiDetailRange(0, 0, 10, 20)
    ri.RiSolidBegin("primitive")
    ri.RiSolidEnd()

    ri.RiProcedural("mymodel.rib", [-1, 1, -1, 1, -1, 1],
                    ri.RiProcDelayedReadArchive, ri.RiProcFree)
    ri.RiProcedural(["python teapot.py", "foo"], [-1, 1, -1, 1, -1, 1],
                    ri.RiProcRunProgram, ri.RiProcFree)
    ri.RiProcedural(["teaspot.so", "bar"], [-1, 1, -1, 1, -1, 1],
                    ri.RiProcDynamicLoad, ri.RiProcFree)

    ri.RiWorldEnd()
    ri.RiMakeTexture("input.tif", "output.tex", ri.RI_PERIODIC, ri.RI_CLAMP,
                     ri.RiGaussianFilter, 2.0, 2.0)
    ri.RiMakeTexture("input.tif", "output.tex", ri.RI_PERIODIC, ri.RI_CLAMP,
                     customPixelFilter, 2.0, 2.0)
    ri.RiMakeShadow("input.tif", "output.tex")
    ri.RiMakeLatLongEnvironment("input.tif", "output.tex", ri.RiGaussianFilter,
                                2.0, 2.0)
    ri.RiMakeLatLongEnvironment("input.tif", "output.tex", customPixelFilter,
                                2.0, 2.0)
    ri.RiMakeCubeFaceEnvironment("px.tif", "nx.tif", "py.tif", "ny.tif",
                                 "pz.tif", "nz.tif", "output.tex", 95,
                                 ri.RiGaussianFilter, 2.0, 2.0)
    ri.RiMakeCubeFaceEnvironment("px.tif", "nx.tif", "py.tif", "ny.tif",
                                 "pz.tif", "nz.tif", "output.tex", 95,
                                 customPixelFilter, 2.0, 2.0)
    ri.RiFrameEnd()
    ri.RiEnd()