formZ SDK | 5.0 API Reference | Project | Modeling | Rendering | Shaders

# fz_shdr_smooth_step

Description

This is a simple utility function to create a smooth transition of a value from and to a min and a max limit. If the val parameter is less than min will return 0.0. If the val parameter is greater than max will return 1.0. If the val parameter is between min and max, will return a value between 0.0 and 1.0. However, the value is not a linear interpolation, When plotted as a function graph, the curve resembles a leaning S, connecting y = 0.0 and y = 1.0 in a smooth fashion.
This function can be used to create fuzz along edges of sharp contrast in a pattern.

Plugin Prototype

double fz_shdr_smooth_step(

double | min,
double | max,
double | val )

Parameters

min [Input]

The minimum value below which returns 0.0

max [Input]

The maximum value above which returns 1.0

val [Input]

The input value

Returns

none

Availability

5.0.0.0

Plugin Example

For example consider a simple pattern of horizontal stripes :
fz_shdr_get_tspace_st(&st); st.y = fz_shdr_saw_tooth(st.y,1.0); if ( st.y < 0.5 ) col = black; else col = white;
This will create a crips border between the black and white color. To create a fuzzy border, fz_shdr_smooth_step can be used :
fz_shdr_get_tspace_st(&st); st.y = fz_shdr_saw_tooth(st.y,1.0); val = fz_shdr_smooth_step(0.4,0.6,st.y); col = val * white + (1.0 - val) * black;
If st.y is less than 0.4 fz_shdr_smooth_step returns 0.0 and the color computation yields :
col = 0.0 * white + (1.0 - 0.0) * black;
which is all black. If st.y is greater than 0.6 fz_shdr_smooth_step returns 1.0 and the color computation yields :
col = 1.0 * white + (1.0 - 1.0) * black;
which is all white. In the zone where st.y is between 0.4 and 0.6 black and white are mixed. More black is used as st.y approaches 0.4 and more white is used as it approaches 0.6. This creates a smooth color transition from black to white.

Function Set

fz_shdr_fset

Defined in

fz_rzne_shdr_api.h