|
|
|
// This is a very basic shader. It just makes something red :-)
// Lines that start with "//" are comments and are ignored by CINEMA4D
// FillData is used to put default values for any user defined values
// It is called by CINEMA4D when the shader is first loaded.
// "data" is a structure that C4D maintains to allow the shader to
// remember its parameters.
FillData(data) {
return TRUE; // return TRUE to tell C4D that we successfully
// set up the defaults
}
// EditData is normally used to display a dialog for the user to
// change values that affect the shader. It is called by C4D when the
// user clicks on the edit button in the Edit Material dialog.
// "data" is a structure that C4D maintains to allow the shader to
// remember its parameters.
EditData(data) {
return TRUE; // In this case, just return TRUE to tell C4D
// that everything went OK.
}
// GetOuptut is called by C4D for each "pixel" that needs to be calculated
//
// "data" is a structure that C4D maintains to allow the shader to
// remember its parameters.
// "p" is the point being shaded. It is in "texture coordinates", usually
// in the range of 0.0 to 1.0, but if tiling is on it could be outside this
// range. p is given as a vector. Use p.x to access the x coordinate and
// p.y to access the y coordinate
// "n" is the normal to the surface at point p
// "time" is the current scene time in seconds
GetOutput(data,p,n,time) {
return vector(1.0,0.0,0.0); // C4D uses a "vector" to represent colors
// as well as coordinates. The vector is one
// of the built in data types in C4D.
// vector(r,g,b) defines a new vector representing
// the color with r,g,b values between 0.0 and 1.0
// So this function just generates a vector for red
// and returns it
}
// main is run when the shader is first loaded. All it does in this case is
// register the shader with C4D
main() {
RegisterChannelShader(10013666,0,"FillData","EditData","GetOutput");
// "RegisterChannelShader" registers our shader with C4D
// 1001366 is the ID number for this shader.
// 0 tells C4D that this shader has 0 elements
// in its data structure
// "FillData" tells C4D the name of your FillData function
// "EditData" tells C4D the name of your EditData function
// "GetOutput" tells C4D the name of your GetOuput function
// The names are case sensitive and must match exactly.
}
|
|