Lights, Material, Textures
- Karla G
- 28 mar 2015
- 2 Min. de lectura
In order to make a graphic look more realistic, you should add lights, texture and materials.
LIGHTS: (Information gotten from processing.org)
Directional:
//The direction of light
size(100, 100, P3D);
background(0);
noStroke();
directionalLight(51, 102, 126, -1, 0, 0);
translate(20, 50, 0);
sphere(30);
(Processing)
Ambient:
(As the natural light)
size(100, 100, P3D);
background(0);
noStroke();
directionalLight(153, 153, 153, .5, 0, -1);
ambientLight(153, 102, 0);
ambient(51, 26, 0);
translate(70, 50, 0);
sphere(30);
Point:
(Add light at a point of the object)
size(100, 100, P3D);
background(0);
noStroke();
pointLight(51, 102, 126, 35, 40, 36);
translate(80, 50, 0);
sphere(30);
MATERIAL:
You can change the material of te objects in the graphic system. This will change the way that light reflects on the object since each material transfers or receives different the light.
There are different types of materials.
These are some of them:
specular();
size(100, 100, P3D);
background(0);
noStroke();
background(0);
fill(0, 51, 102);
lightSpecular(255, 255, 255);
directionalLight(204, 204, 204, 0, 0, -1);
translate(20, 50, 0);
specular(255, 255, 255);
sphere(30);
translate(60, 0, 0);
specular(204, 102, 0);
sphere(30);
Description: Sets the specular color of the materials used for shapes drawn to the screen, which sets the color of highlights. Specular refers to light which bounces off a surface in a preferred direction (rather than bouncing in all directions like a diffuse light). Used in combination with emissive(), ambient(), andshininess() in setting the material properties of shapes.
shininess();
size(100, 100, P3D);
background(0);
noStroke();
background(0);
fill(0, 51, 102);
ambientLight(102, 102, 102);
lightSpecular(204, 204, 204);
directionalLight(102, 102, 102, 0, 0, -1);
specular(255, 255, 255);
translate(30, 50, 0);
shininess(1.0);
sphere(20);
// Left sphere translate(40, 0, 0);
shininess(5.0); sphere(20);
// Right sphere
DescriptionSets the amount of gloss in the surface of shapes. Used in combination with ambient(), specular(), and emissive() in setting the material properties of shapes.
ambient();
size(100, 100, P3D);
background(0);
noStroke();
directionalLight(153, 153, 153, .5, 0, -1);
ambientLight(153, 102, 0);
ambient(51, 26, 0);
translate(70, 50, 0);
sphere(30);
Description: Sets the ambient reflectance for shapes drawn to the screen. This is combined with the ambient light component of environment. The color components set through the parameters define the reflectance. For example in the default color mode, setting v1=255, v2=127, v3=0, would cause all the red light to reflect and half of the green light to reflect. Used in combination with emissive(), specular(), andshininess() in setting the material properties of shapes.
TEXTURES:
size(100, 100, P3D);
noStroke();
PImage img = loadImage("laDefense.jpg");
beginShape();
texture(img);
vertex(10, 20, 0, 0);
vertex(80, 5, 100, 0);
vertex(95, 90, 100, 100);
vertex(40, 95, 0, 100);
endShape();
DescriptionSets a texture to be applied to vertex points. The texture() function must be called betweenbeginShape() and endShape() and before any calls to vertex(). This function only works with the P2D and P3D renderers. When textures are in use, the fill color is ignored. Instead, use tint() to specify the color of the texture as it is applied to the shape.
References:
Processing. (2001). Processing. 24 Marzo 2015, de Processing.org Sitio web: https://processing.org/
Commentaires