BasicsOfRenderman

From K-3D

Jump to: navigation, search

If you decide to use some form of compliant RenderMan system as an external renderer, (aqsis is recommended), then you should also stick to RenderMan materials and lights throughout. A virgin document should be equipped with a couple of fundamental RenderMan objects (as it is actually the recommended rendersystem for k3d).

It will soon become very clear that most things in RenderMan is about the RenderMan shading language. A shader is simply a small program that produces whatever it is supposed to produce. A surface shader produces color values for the surface. A light shader produces light intensities. So instead of specifying a constant color value or a texturefile, you can calculate the desired values. Used cleverly, the effects achievable are very many.

Accompanying K3D is a library of shaders that are programmed and ready for use already. If you are not keened on learning the RenderMan shading language (I don't know a bit about it myself), there is no need to. When you need to choose a shader for some purpose - bricks, wood, bitmapped textures or whatever - just choose one of the many shaders in the library that begins with 'k3d_'. In this tutorial, only the default shaders will be treated.

Here is how to do things the RenderMan way:


L i g h t s

You simply add a RenderManLight and connect it to a RenderManLightShader. The RenderManEngine takes care of searching the scene for all RenderManLights when needed.

RenderManLight

Basically fulfills the same role as a MeshInstance does to a mesh. It handles position, rotation, scale, input and output matrix. Must be connected to a RenderManLightShader through the 'shader' property.

RenderManLightShader

This object encapsules all aspects of the lightsource, namely the type and properties pertaining to the particular shader script from the library, that it uses.

name. The name of the object

shader_name. The name of a shaderprogram that expresses this light. Depending on what is chosen here, a set of associated properties shows up in the dialog beneath the shader_name:

shader_name=k3d_pointlight. A simple point-like lightsource gleaming in all directions.

intensity and lightcolor. An intensity of 3000 is not a bad start if light is to be placed 40m away.

shader_name=k3d_distant_shadow. This is the setting you should go for if you want this light to cast shadows.

shadowname. Here you should connect the RenderManLightShader to a RenderManShadowMap.



S h a d o w s

Light and shadows behaves a little bit funny in the RenderMan world. Image that you had a flashlight emitting a special kind of lightrays that went through everything. Things would be lighted up for sure, but obstacles would not cast shadows as they didn't block the light. That is the situation with RenderMan lights.

What we need is to attach a kind of light-mask on the flashlight itself, but it has to be a very special kind that takes depth into consideration so that the first object visible in the line of lightray gets illuminated, but all subsequent objects are not. The mask should kick in at the exact point in space where the first object is intersected by a particular lightray. Sort of like a three-d mask.

That mask is in RenderMask terminology called a RenderManShadowMap. A special kind of lightsource is also necessary, as only the light shader named 'k3d_distant_shadow' can have a lightmask clipped on. It is also necessary that the shadow map is oriented just like the lightsource. A mental picture will help: In a way we have a setup like a film in a camera. The mask is the exposed film, and the cameralens must "see" what the lightsource "sees" for the mask to be correctly computed. To aid in seing what a RenderManShadowMap sees, K3D also creates a Viewport whose position and orientation is locked to the shadow map. You will manually have to clip the shadow map to on the lightsource yourself though.

Follow these steps:

  1. create a RenderManLight
  2. create a RenderManLightShader
  3. set the 'shader' property of the RenderManLight to the RenderManLightShader (click on the drop-down menu and select the object)
  4. set the 'shader_name' property of the above shader to 'k3d_distant_shadow' [Question: Why is it called distant?]
  5. create a RenderManShadowMap (this operation will also create a RenderManShadowMapViewport)
  6. set the 'shadowname' property of the RenderManLightShader to the shadow map created above
  7. make the shadow map follow the light source: Connect the 'input_matrix' of the shadow map with the output_matrix of the light source.
  8. Place some objects and render. There should be shadows now.

RenderManShadowMap

This is the object that rhymes well with the RenderManLightShader of type k3d_distant_shadow.

input_matrix. You will have to connect the output_matrix of your light to this property of the shadowmap to make sure that the shadowmap precisely track the lightsource that it is supposed to mask. Otherwise funny things happen, notably shadows being casted without reason. Connecting this property should happen automatically when a RenderManShadowMap is created via the 'Plugins' menu

pixel_width, pixel_height. With these properties the resolution of the shadowmap can be controlled.

T e x t u r e s

(not written yet)

RenderManMaterial

RenderManSurfaceShader

shader_name. You can select the name of a predefined shader with this. Start with something simple like k3d_matte and then work your way around.

If you want a textured object, select k3d_paintedplastic in shader_name of the shader. After that create a new RenderManTextureMap object

RenderManTextureMap

The 'input' property of this object should be set to something producing a 'bitmap' value such as a new BitmapReader object.

Personal tools