RIS
Shading - Textures


return to main index



Introduction

This tutorial shows how to use the PxrTexture pattern plugin. It is assumed the reader has followed the instructions presented in the tutorial "RIS: Introduction to RIS Shading". The jack_scene.rib from that tutorial will be used in this demonstration.



Figure 1 - with and without a texture map


Step 1 - Create an Instance of PxrSurface

Create a new document and save it in the archives/materials directory.

    HOME_DIR
            |_/archives
                      |_/geo
                      |_/lights
                      |_/materials/
                                  |_ TimesSq.rib

Open the document and choose PxrSurface from the Plugins menu.



Figure 2


Cutter will insert a very long rib statement into the document. Most of the default values of the parameters of PxrSurface will not be altered and, therefore, can be deleted. For example,


Bxdf "PxrSurface" "PxrSurface1"
        "float diffuseGain" [1.0]
        "color diffuseColor" [0.18 0.18 0.18]
        # other inputs deleted


Step 2 - Assign a Texture Input to PxrSurface.diffuseColor

Move the text cursor to the beginning of the document and choose PxrTexture from the Plugins->PxrPatterns menu.



Figure 3


The archive will now have the following rib statements. Again, for brevity the parameters that will not be changed have been deleted.


# txmake -mode periodic ../tiffs/name.tif ../textures/name.tex
Pattern "PxrTexture" "PxrTexture1"
        "string filename" [""]
        "int linearize" [0]
        # Examples manifold connection
        #"reference struct manifold" ["PxrManifold2D1:result"]
        #"reference struct manifold" ["PxrManifold3D1:result"]
  
        # "PxrTexture1:resultRGB"    uses->|color|vector|normal|point| 
        # "PxrTexture1:resultR"    uses->|float| 
        # "PxrTexture1:resultG"    uses->|float| 
        # "PxrTexture1:resultB"    uses->|float| 
        # "PxrTexture1:resultA"    uses->|float| 
  
Bxdf "PxrSurface" "PxrSurface1"
        "float diffuseGain" [1.0]
        "color diffuseColor" [0.18 0.18 0.18]
        # other inputs deleted

Source images must be converted to a special texture file format before they can be used for texture mapping. Download times_sq.tif and copy it to the tiffs directory.

    HOME_DIR
            |_tiffs/times_sq.tif

Edit this comment so that it refers to the source image.

# txmake -mode periodic ../tiffs/times_sq.tif ../textures/times_sq.tex

Select the entire line of commented text and use the keyboard shortcut Alt + e, Control + e or Apple + e. Cutter will execute Pixars txmake command. After a brief delay the Process Monitor will report the texture conversion has been completed.



Figure 4


The PxrTexture plugin has several outputs. The one that will be connected to the diffuseColor input of the PxrSurface plugin is indicated by the comment.

# "PxrTexture1:resultRGB"     uses->|color|vector|normal|point| 

Change the code as shown below.


# txmake -mode periodic ../tiffs/times_sq.tif ../textures/times_sq.tex
Pattern "PxrTexture" "PxrTexture1"
        "string filename" ["times_sq.tex"] ## <-- note the use of the texture map
        "int linearize" [1]                ## <-- note change to 1
        # Examples manifold connection
        #"reference struct manifold" ["PxrManifold2D1:result"]
        # "PxrTexture1:resultRGB"    uses->|color|vector|normal|point| 
        
Bxdf "PxrSurface" "PxrSurface1"
        "float diffuseGain" [1.0]
        "reference color diffuseColor" ["PxrTexture1:resultRGB"]
        # other inputs deleted

In particular, notice the use of the keyword reference.


Step 3 - Assign a Manifold

The scale and offset of the texture map can be controlled with an instance of the PxrManifold2D plugin. Move the text cursor to the beginning of the document and choose PxrManifold2D from the Plugins->Patterns menu. The material rib archive will now contain the following script. Once again, for brevity, unused parameters has been deleted.


TimesSq.rib


Pattern "PxrManifold2D" "PxrManifold2D1"
        "float angle" [0]
        "float scaleS" [1]
        "float scaleT" [1]
        "float offsetS" [0]
        "float offsetT" [0]
        "int invertT" [1]
        
# txmake -mode periodic ../tiffs/times_sq.tif ../textures/times_sq.tex
Pattern "PxrTexture" "PxrTexture1"
        "string filename" ["times_sq.tex"] ## <-- note the use of the texture map
        "int linearize" [1]                ## <-- note change to 1
        "reference struct manifold" ["PxrManifold2D1:result"] ## <-- remove comment
        
Bxdf "PxrSurface" "PxrSurface1"
        "float diffuseGain" [1.0]
        "reference color diffuseColor" ["PxrTexture1:resultRGB"]


Step 4 - using ReadArchive

The following rib statement placed immediately before the geometry to be texture mapped.

    ReadArchive "materials/TimesSq.rib"






© 2002- Malcolm Kesson. All rights reserved.