Final Displacement

This displacement is using my "fullridges" shader placed on top of a sphere polygon. I keyframed various changes to the frequency of fractal and simple_remap OSL shader controls.

Basic Displacements

All shaders are programmed in OSL and rendered in Render Man for Maya.

Plus Displacement

shader

plus_displacement(

float s = 0

[[

int lockgeom = 0,

string widget = "null",

]],

float t = 0

[[

int lockgeom = 0,

string widget = "null",

]],

float smin = 0.4,

float smax = 0.6,

float tmin = 0.4,

float tmax = 0.6,

output float resultF = 0)

{

if ( (s >= smin && s <= smax)

|| (t >= tmin && t <= tmax) )

resultF = 1;

else

resultF = 0;

}

Round Displacement

shader

round(

float s = 0

[[ int lockgeom = 0,

string widget = "null", ]],

float t = 0

[[ int lockgeom = 0,

string widget = "null", ]],

float s_input = 0,

float t_input = 0,

float radius = 0.15,

float scenter = 0.5,

float tcenter = 0.5,

float blur = 0.03,

output float resultF = 0)

{

float ss = (isconnected(s_input)) ? s_input : s;

float tt = (isconnected(t_input)) ? t_input : t;

ss = mod(ss, 1);

tt = mod(tt, 1);

float dist = sqrt((tt - tcenter) * (tt - tcenter) + (ss - scenter) * (ss - scenter));

resultF = 1 - smoothstep(radius, radius + blur, dist);

}

Ridges Displacement

shader

ridges_displacement(

float s = 0

[[

int lockgeom = 0,

string widget = "null",

]],

float t = 0

[[

int lockgeom = 0,

string widget = "null",

]], ]

float phase = 0,

float freq = 0,

output float resultF = 0)

{

resultF = abs (sin ((s - phase) * M_2PI * freq ));

}

Full Ridges Displacement

shader

fullridges_displacement(

float s = 0

[[

int lockgeom = 0,

string widget = "null",

]],

float t = 0

[[

int lockgeom = 0,

string widget = "null",

]],

float tmin = 0,

float tmax = 0,

float smin = 0,

float smax = 0,

float freq = 0,

float phase = 0,

output float resultF = 0)

{

if

(s >= smin && t >= tmin && s <= smax && t <= tmax)

resultF = (sin ((s - phase) * M_2PI * freq));

else

resultF = (s <= smin && s >= smax && t <= tmin && t >= tmax);

}

Angled Corner Displacement

shader

egypt_displacement(

float s = 0

[[

int lockgeom = 0,

string widget = "null",

]],

float t = 0

[[

int lockgeom = 0,

string widget = "null",

]],

float tmin = 0.5,

float tmax = 1,

float smin = 0.5,

float smax = 1,

output float resultF = 0)

{

if ((t >= tmin && t <= tmax) || (s >= smin && s <= smax))

resultF = 1;

else

resultF = 0;

if ((t <= tmin ) && (s <= smin))

resultF = abs((s + 1) * 2) -2;

}

Conclusion

This was my first time coding shaders, so I dove in and tried to take away as much as possible from the experience. There were numerous hurdles (especially in debugging) but in the end I got past them.