Skip to content

ChickenFunctions

Michael edited this page Dec 10, 2023 · 3 revisions

The following are the list of functions used with Luminous Chickens.

cluck_apply(shader)

Returns: N/A

Parameter Type Description
shader shader The Luminous Chicken shader you wish to enable (shd_chluck_vertex, shd_cluck_fragment, or shd_cluck_unlit)

Use this function to set one of the Luminous Chickens shaders.

Rather than setting the shader(s) directly using GameMaker's shader_set function, it is generally easier to use this function to both set the shader and automatically apply all of the relevant shader uniforms in a single function call. Setting the shaders directly will do nothing and will result in everything drawing black, since the uniforms will not have been set.

cluck_set_fog(enabled?, color, strength, start, end)

Returns: N/A

Parameter Type Description
enabled? boolean True if distance fog is to be enabled, false otherwise
color color The color of the fog
strength number The strength of the fog at the end distance (from 0 to 1)
start number The distance from the camera at which the fog will start to take effect
end number The distance from the camera where the fog will be at its maximum strength

Use this function to enable or disable distance fog.

The color is the color of the fog. This may be a GameMaker color code such as c_white or c_black, or a color that you create yourself using one of the other color functions.

The strength is the intensity of the fog at the maximum distance. Most of the time this should be 1 so that distant objects are blended with the fog color completely, but you may set this to any number between 0 and 1 if you ever want distant objects to only partially be blended with the fog color. Setting this to 0 will make fog invisible.

The start value is the distance from the camera at which fog will begin to take effect; anything closer than this will not have a fog effect applied.

The end value is the distance from the camera at which the fog will be at maximum strength. This should be larger than the start value.

cluck_set_ambient(color)

Returns: N/A

Parameter Type Description
color color The color of unlit regions

Use this function to set the ambient light color.

The ambient light color is the color of regions where no light is applied. Most of the time this will be either black (regions outside of direct light will be completely black) or a shade of dark gray (regions outside of direct light will be very dark). Setting this to white will cause all lights to be ignored. Setting this to some other value may have some interesting atmospheric effects; feel free to experiment.

cluck_set_light_direction(index, color, dx, dy, dz)

Returns: N/A

Parameter Type Description
index number (integer) The index of the light source (0 through 16)
color color The color of light source
dx number The x component of the vector representing the light's direction
dy number The y component of the vector representing the light's direction
dz number The z component of the vector representing the light's direction

Define a directional light. Directional lights are used to simulate a light source that is very bright and very far away; in almost all cases, this means the sun or some other omnipresent source of light.

The color is the color of the light source. The dx, dy, and dz parameters are a vector representing the direction of the light. Directional lights have effectively infinite range, and do not originate at any point in the world.

cluck_set_light_point(index, color, x, y, z, radius, *inner_radius)

Returns: N/A

Parameter Type Description
index number (integer) The index of the light source (0 through 16)
color color The color of light source
x number The x component of the vector representing the light's position in the world
y number The y component of the vector representing the light's position in the world
z number The z component of the vector representing the light's position in the world
radius number The maximum range of the light source
*inner_radius number Optional; the distance from the light source where light will start to attenuate

Define a point light. Point lights are defined by a point in space, and a radius which they affect. They are often used to represent light sources which originate from a single point and radiate out in all directions, such as a torch flame or an unshaded lamp.

The color is the color of the light source. The x, y, and z parameters are a vector representing the light's position in space. The radius is the maximum distance from the light which the light will have any influence; beyond this, the light will have no affect.

Ordinarily, a point light will be a full strength at its position in space (zero distance from the light source) and linearly attenuate between there and the outer radius, but it's quite possible to exert a little more control over the way the light fades out. The inner radius is an optional parameter which may be used to define the distance from the light at which the light will start to fade; any nearer and the light will be applied at full strength. If not provided, this value will default to 0. Setting it equal to the outer radius will cause the entire area within to be fully lit, and to abruptly end afterwards. You may wish to use this if you want a sharper, more cartoony look.

cluck_set_light_spot(index, color, x, y, z, dx, dy, dz, radius, angle, *inner_angle)

Returns: N/A

Parameter Type Description
index number (integer) The index of the light source (0 through 16)
color color The color of light source
x number The x component of the vector representing the light's position in the world
y number The y component of the vector representing the light's position in the world
z number The z component of the vector representing the light's position in the world
dx number The x component of the vector representing the light's direction
dy number The y component of the vector representing the light's direction
dz number The z component of the vector representing the light's direction
radius number The maximum range of the light source
angle number The angle of the light cone (in degrees)
*inner_angle number Optional; the angle from the center of the cone where light will start to attenuate

Define a spot light. Spot lights can be though of as a combination of point and directional lights: they are defined at a point in space and have a maximum radius after which they will have no effect, but they are also oriented in a specific direction and only affect things within a certain angle of their direction. They are often used to represent lights which can be pointed in a specific direction, such as a flashlight or head lamp.

The color is the color of the light source. The x, y, and z parameters are a vector representing the light's position in space.The dx, dy, and dz parameters are a vector representing the direction in which the light is pointing.

The radius is the maximum distance from the light which the light will have any influence; beyond this, the light will have no effect. The angle is the angle of the cone of light between the center of the beam and the edge (i.e., half of the total angle of the beam), in degrees. Much like the inner radius of a point light (see above), spot lights can optionally have an inner angle to their cone inside which everything will be fully illuminated. Set this equal to the outer angle for a hard cutoff between light and darkness.

cluck_set_light_disable(index)

Returns: N/A

Parameter Type Description
index number (integer) The index of the light source to disable (0 through 16)

Disable a light at a specific index.

Specular Lights

At some point I decided it'd be fun to add a bit of code for specular reflections too.

cluck_set_spec_camera_position(x, y, z)

Returns: N/A

Parameter Type Description
x number X
y number Y
z number Z

Defines the camera position used for specular reflections. Ought to be set whenever you move the camera and before cluck_apply.

cluck_set_spec_strength(strength)

Returns: N/A

Parameter Type Description
strength number Should be a value between 0 and 1

Sets the strength of the specular reflections. You can think of this as the opacity of the highlight.

cluck_set_spec_exponent(exponent)

Returns: N/A

Parameter Type Description
exponent number Generally a value around 32 or so is good

Sets the exponent used in the specular reflections; a lower value means the specular reflections will be more spread out over the surface, while a higher value will cause the reflections to be more focused.

Clone this wiki locally