Name

normal()

Description

Sets the current normal vector. Used for drawing three-dimensional shapes and surfaces, normal() specifies a vector perpendicular to a shape's surface which, in turn, determines how lighting affects it. Processing attempts to automatically assign normals to shapes, but since that's imperfect, this is a better option when you want more control. This function is identical to glNormal3f() in OpenGL.

Examples

  • size(400, 400, P3D);
    noStroke();
    background(0);
    pointLight(150, 250, 150, 40, 120, 200);
    beginShape();
    normal(0, 0, 4);
    vertex(80, 80, -40);
    vertex(320, 80, 40);
    vertex(320, 320, -40);
    vertex(80, 320, 40);
    endShape(CLOSE);
    Image output for example 1

Syntax

  • normal(nx, ny, nz)

Parameters

  • nx(float)x direction
  • ny(float)y direction
  • nz(float)z direction

Return

  • void