Materials  -  G r i d

The Grid shader is just a sample of a shader script.  There are no controls for this shader, though you can hook up other nodes to its inputs to do some interesting things.  Here is the entire script for Grid.  When you create shader scripts, put them in your modules\scripts folder (just like any other kind of script).


//#messiahscript

#include <messiah_render.h>

#define SCRIPT_SHADER_STANDARD 0

int IN_W = 0;
int IN_H = 0;
int IN_D = 0;
int IN_T = 0;
int OUT_V = 0;

int ShaderObjectCreate(object obj)
{

IN_W = fxShaderCreateInput(obj, "Width", TYPE_FLOAT, 0);
IN_H = fxShaderCreateInput(obj, "Height", TYPE_FLOAT, 0);
IN_D = fxShaderCreateInput(obj, "Depth", TYPE_FLOAT, 0);
IN_T = fxShaderCreateInput(obj, "Thickness", TYPE_FLOAT, 0);

OUT_V = fxShaderCreateOutput(obj, "Value", TYPE_FLOAT, 0);

return (1);

}

int ShaderInitInputs(object obj, void shader_globals, void input)
{

SetInput(obj, input, IN_W, 0.1);
SetInput(obj, input, IN_H, 0.1);
SetInput(obj, input, IN_D, 0.1);
SetInput(obj, input, IN_T, 0.01);

return (1);

}

int ShaderEvaluate(object obj, void shader_globals, void input, void output)
{

double w, h, d, t, tl, th;
double x, y, z;

t = GetInputFloat(obj, input, IN_T);
th = t * 0.5;
tl = -th;

 

//Check x,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,
w = GetInputFloat(obj, input, IN_W);
x = _Px;
x = x%w;

if ((x>tl)&&(x<th))
{

SetOutput(obj, output, OUT_V, 1);
return (1);

}

 

//Check y,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,
h = GetInputFloat(obj, input, IN_H);
y = _Py;
y = y%h;

if ((y>tl)&&(y<th))
{

SetOutput(obj, output, OUT_V, 1);
return (1);

}

 

//Check z,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,
d = GetInputFloat(obj, input, IN_D);
z = _Pz;
z = z%d;

if ((z>tl)&&(z<th))
{

SetOutput(obj, output, OUT_V, 1);
return (1);

}

 

//Output 0 value,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,
SetOutput(obj, output, OUT_V, 0);

return (1);

}

Converted from CHM to HTML with chm2web Pro 2.82 (unicode)