Pixar
Pixar Home Feature Films Short Films The Theater How We Do It Artist's Corner Renderman Company Info

News Whats RenderMan Products Purchase Support


The RenderMan Interface Specification
Version 3.1

APPENDIX B - RENDERMAN SHADING LANGUAGE SYNTAX SUMMARY

This summary of the Shading Language syntax is intended more for aiding comprehension than as an exact description of the language.

 

Declarations

Shading Language source files consist of definitions:

	definitions:
		shader_definition
		function_definition

	shader_definition:
		shader_type identifier ([formals]) {[variables] statements }

	function_definition:
		[type] identifier ( [formals] ) { [variables] statements }

	shader_type:
		
		light
		surface
		volume
		displacement
		transformation
		imager

      	formals:
		variable_definitions
		formals ; variable_definitions

      	variables:
		variable_definitions ;
		variables variable_definitions ;

      	variable_definitions:
		typespec def_expressions

      	typespec:
		[detail] type

      	def_expressions:
		def_expression
		def_expressions , def_expression

      	def_expression:
		identifier [def_init]

      	def_init:
		= expression

      	detail:
		varying
		uniform

      	type:
		float
		string
		pspace
		cspace

      	pspace:
		point [spacetype]

      	cspace:
		color [spacetype]

      	spacetype:
		stringconstant

      	shadespace:
		pspace
		cspace
		pspace cspace
		cspace pspace

Statements

	statements:
		statements statement
	statement:
		assignexpression ;
		procedurecall ;
		return expression ;
		loop_modstmt ;
		if relation statement
		if relation statement else statement
		loop_control statement
		{ statements }
	loop_control:
		while relation
		for ( expression ; relation ; expression )
		solar ( )
		solar ( expression , expression )
		illuminate ( expression )
		illuminate ( expression , expression , expression )
		illuminance ( expression )
		illuminance ( expression , expression , expression )

	loop_modstmt:
		loop_mod [nteger]

	loop_mod:
		break
		continue

Expressions

The basic expressions are:

      	expression:
		primary
		expression binop expression
		- expression
		relation ? expression : expression
		type expression

      	primary:
		number
		texture
		identifier
		stringconstant
		procedurecall
		assignexpression
		( expression )
		( expression , expression , expression )

      	relation:
		( relation )
		expression relop expression
		relation logop relation
		! relation

      	assignexpression:
		identifier asgnop expression

      	procedurecall:
		identifier ( [proc_arguments] )

      	proc_arguments:
		expression
		proc_arguments , expression

      	texture:
		texture_type(texture_filename [channel] [texture_arguments] )

	texture_type:
		texture
		environment
		bump
		shadow

	texture_filename:
		identifier
		stringconstant

	channel:
		[ integer ]

	texture_arguments:
		, expression
		texture_arguments , expression

The primary-expression operators

	( )

have highest priority and group left-to-right. The unary operators

	-	!

have priority below the primary operators but higher than any binary or relational operator and group right-to-left. Binary, relational, and logical operators all group left-to-right and have priority decreasing as indicated:

	binop:
		.
		/	*
		^
		+	-

	relop:
		>	>=	<	<=
		==	!=

	logop:
		&&
		||

The conditional operator groups right-to-left

	?	:

Assignment operators all have the same priority and all group right-to-left.

	asgnop:
		=	+=	-=	*=	/=

Logical expressions have the value 1 for true, 0 for false. As in C, a non-zero logical expression is deemed to be true. In general, logical expressions are only defined for scalar types. The exception is == and != which are defined for every type.

Preprocessor

#define identifier token-string
#define identifier ( identifier , ... , identifier ) token_string
#undef identifier
#include "filename"
#include <filename>
#if constant-expression
#ifdef identifier
#ifndef identifier
#else
#endif
#line constant identifier


 


Terms of Use  |   Privacy Policy
TM & © 1986- Pixar. All Rights Reserved.