Is it easier to use rect and ellipse to make complex shapes or to use PShapes?
It depends! In 2D, you can get a surprising amount of mileage out of just the basic shapes. In 3D, it can be tricky to make complex things out of boxes, but it's totally possible.
However, shape containers (SVG and OBJ) are inherently very complex formats. This means they're harder to handle, harder to animate, and have more bugs.
Generally, technology without any advantages doesn't get used.
Is there a way to track 3D coordinates so that you don't have to try-and-see with 3D rendering?
Can we rotate the camera around objects in 3D?
Unfortunately, no. This is part of what makes 3D tricky to work with.
You can use beginCamera() and endCamera() to rotate the camera in 3D space. However, be warned that there are several known bugs with these functions.
The more complete way to do this is to implement something known as an orbital camera, which forces the eye to travel on the surface of a sphere while looking at the object.
Is there a way to change the intensity of point lights?
How would you make a laser pointer using lighting models?
Is it possible to make a shape glow?
You can use the emissive material property (discussed in today's class).
However, since we are working with direct illumination only, the light will not "splash" to other surfaces.
Option 1: Point light at the surface of the object wherever the laser intersects.
Option 2: Very focused spotlight.
Yes, we can use the color of the light.
Are 3D shapes rendered the same way as 2D shapes? How does raytracing fit into all of this?
Ask for the student topic classes!
Toy Story (1995)
Big Hero 6 (2014)
Lights only capture one half of shading.
Shining the same light at a mirror, a piece of paper, and a glow-in-the-dark toy will have very different effects.
Step 1: Light comes in
Step 2: ????
Step 3: Colors!
If only physics were this simple.
Why are we seeing red as opposed to blue or white?
Why can we see the little dents/divots in the surface of the cover? (The material is the same everywhere).
Why does the color change as we get close to the top of the cover?
Cover of a Clairefontaine Notebook
Stainless Steel Watch Band
Why are the top halves of the links bright, but not the bottom half?
Why is the plastic surface bright in some parts and not others?
How does the plastic interact with the light in the non-bright parts?
We want some way to capture the interaction of light with matter.
Need to balance different goals!
Non-physically-based material model that roughly captures material properties.
By Brad Smith - Own work, CC BY-SA 3.0, https://commons.wikimedia.org/w/index.php?curid=1030364
Add some small component to the shading.
Is this physically realistic? Of course not!
But can be used to approximate e.g. light that bounces off of other surfaces, or other light that comes from outside the scene.
Can also be used artistically.
Light position and camera position are irrelevant, always add color.
In fancy speak, "Lambertian Reflectance." Captures the light that is scattered off of the surface due to micro-irregularities in the surface.
1
2
Is based on the cosine of angle between the light and the surface.
Responsible for object "shininess". Based on many things: material parameters, angle between light and surface, and angle between surface and camera.
Typically has a narrow angular region where it is very intense, but falls off quickly.
Depending on the exact parameters, Phong shading tends to create a plasticky, shiny look which is somewhat unrealistic.
But it's very fast (implemented in the early 1970s!) and simple to understand.
All material properties function like attributes: they set the material properties for any subsequent objects generated.
Ambient: ambient(r, g, b)
Diffuse: is built into the Processing lighting models, cannot be changed (is affected by shape color)
Specular:
specular(r,g,b)
shininess(s)
lightSpecular(r,g,b)
The Phong shading model can't capture everything!
Many interesting materials require us to think about light bouncing around within the material, not just at the surface.
But this is a lot harder to replicate. Requires much more advanced mathematics and a lot more compute.
Fun fact: SSS on marble is one reason why so many statues are made of it.
Think back to the notebook cover shown earlier in class.
How can we start to replicate the patterned look on the surface of this notebook?
Provides details on surface of geometry, deforming with the geometry.
Challenge: we need to map between the surface of the geometry and the coordinates of the texture.
How do we make this display on that?
Assign each part of the geometry some coordinate in the texture, then move between them smoothly.
Zoom
How would the following code change the texture?
vertex(0, 0, 0, 0, 0);
vertex(350, 0, 0, .5, 0);
vertex(350, 200, 0, .5, 1);
vertex(0, 200, 0, 0, 1);
Sometimes you don't know how large the image is, so specifying coordinates in pixels is annoying. textureMode(NORMAL)
sets coordinates to be in normalized image coordinate (0.0-1.0)
The default behavior is given by textureMode(IMAGE)
.
Sometimes you want to wrap the texture by repeating it over the shape (e.g. if you have a texture of bricks and are texturing a brick wall). You can achieve this with textureWrap(REPEAT)
.
The default behavior is given by textureWrap(CLAMP)
We can manually apply textures to meshes with processing.