Bake out Texture – RSL NODE SHADER DOWNLOAD

**rendermancode utility coding**

+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++

**shading parameters**

string bake_file = “”

color i_color

output color o_color

**shading code**

extern point P;

extern normal N;

normal Nf = normalize(N);

bake ( bake_file, s, t, i_color);

o_color=i_color;

+++++++++++++++++++++++++++++++++++++++++++++++++++++++

put in “texturename.bake” in shader parameter

+++++++++++++++++++++++++++++++++++++++++++++++++++++++

set up geometry –

1. set attribute on geometry in 3delight- cull hidden surfaces, cull backfacing surfaces, raster orientated dicing to off

2. set up camera view to encompass the geometry

+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++

Bake out bake map on command line

tdlmake -bakeres 1200(or whatever texture size you want) C:\texture.bake C:\texture.tdl

++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++

////////////////////////////////////////////////////////////////////////////////////////////////////////////

Bake out AO TEXTURE – DOWNLOAD

////////////////////////////////////////////////////////////////////////////////////////////////////////////

constantTexture.sl – DOWNLOAD

////////////////////////////////////////////////////////////////////////////////////////////////////////////

AOVanisotropic.sl – DOWNLOAD

bake_occlusion_Pref.sl – DOWNLOAD

POINT CLOUD BAKING FOR GEOMETRY THAT IS GOING TO DEFORM

1) Select Geometry – Maya Menu – Rendering – Texturing – Create Texture ref object.

2) Add attribute Reference Geometry in 3delight, output Pref, output Nref

//////////////////////////////////////////////////////////////////////////////////////////////////////////

**ONE LINE CODE**

**Ci is a global variable in surface shaders and is the output color. The parameters are hard-coded into the shader, because there are no parameter variables set up in between the ().**

**surface whateverthenameis()
{
// put one line code in here
}
**

**COLOR**

**S & T**

**MOD FUNCTION**

**STEP WITH MOD FUNCTION**

**NOISE FUNCTION**

**SMOOTHSTEP FUNCTION**

**SPLINE FUNCTION**

**STEP FUNCTION**

**SIN FUNCTION**

Ci = 0.5+0.5*sin(s*2*PI*4);

**CELL NOISE**

**COS FUNCTION**

**ATAN FUNCTION**

**ASIN FUNCTION**

Ci = asin(-1*s*2*t);

**SHADERS 101**

**Shader Structure**

**ShaderType ShaderName (ShaderParameters)
{RSL code that gets executed………..
}**

**Global Variables of Surface Shaders**

**
**

**CONSTANT SHADER**

surface constant()

{Oi = Os;

Ci = Oi * Cs;

}

**CONSTANT COLOR SHADER**

surface constant_surfaceColor(

color surfaceColor = (1,0,0);

color surfaceOpac = (1,1,1);

)

{Oi = surfaceOpac;

Ci = Oi * surfaceColor;

}

**DIFFUSE SHADER**

surface lambert(

uniform float Ka = 0.5;

uniform float Kd = 0.85;

color surfaceColor = color (1,1,1);

color surfaceOpac = color (1,1,1);

)

{

/* Variables */

normal Nf = faceforward( normalize(N), I );

Oi = surfaceOpac;

Ci = Oi * surfaceColor * (Ka * ambient() + Kd * diffuse(Nf));

}

**PLASTIC SHADER**

surface plastic( float Ka = 1.0,

Kd = 1.0,

Ks = 0.5,

roughness = 0.1;

color specularColor = 1,

surfaceColor = color (1, 0, 0);)

{

normal Nf = faceforward(normalize(N), I);

vector V = -normalize(I);

Ci = surfaceColor * (Ka*ambient() + Kd*diffuse(Nf)) + Ks*specularColor*specular(Nf, V, roughness);

Oi = Os; Ci *= Oi;

}

**Operators in Shading Language**

Symbol | Name | Returns 1 (True) if |
---|---|---|

== | equal | left is equal to right |

!= | not equal | left is not equal to right |

< | less than | left is less than right |

<= | less or equal to | left is less than or equal to right |

> | greater than | left is greater than right |

>= | greater or equal to | left is greater than or equal to right |

wow!

I love your blog and this introduction to RSL.

I would love if you can extend this section by more math and more advanced math functions!!

thank you so much for the effort you put into this.

Thanks for the kind words bastiant. I’m not a natural with Maths so I don’t know how advanced I can get 🙂

As always if anybody out there would like to submit some useful notes / tutorials – that would indeed be a beautiful thing.

Thank you so much for this!

very helpful.