Goldsmiths: Advanced Graphics and Animation

109 flashcards · Computer Science · by lakesare

  1. What does CAD stand for?

    Computer-Aided Design

  2. What does CGI stand for?

    Computer-Generated Imagery

  3. What's graphics pipeline?

    Sequence of steps used to create a 2D representation of a 3D scene. Once a 3D model has been created, for instance in a video game, the graphics pipeline is the process of turning that 3D model into what the computer displays.

  4. Write down how the identity transform affects (x, y, z) vector.

    The simplest transform is the one that leaves a vector unchanged, called the identity matrix.

  5. Write down the transform that scales (x, y, z) by a.

    This will scale the vector by a, it will become larger if a is greater than 1 and smaller if a is less than 1.

  6. Uniform VS non-uniform scale transformation?

    Uniform - use same scale factor for each axis direction. Non-uniform - use separate scale factor for each axis direction. Uniform: Non-uniform:

  7. When we rotate (x, 0) vector by angle A - what are the resulting (x', y')?

    The transformed point is (x cos(θ), −x sin(θ)). The minus sign is there because we are using a coordinate system in which y points down, but y 0 points up.

  8. When we rotate (x, 0) vector by angle A - what are the resulting (x', y')?

    The transformed point is (y sin(θ), y cos(θ))

  9. If we rotate (x, 0) by θ, resulting point is (x cos(θ), −x sin(θ)). If we rotate (0, y) by θ, resulting point is (y sin(θ), y cos(θ)). What is the result of rotating (x, y) by θ?

    The above equations give us the relationship between the untransformed values position vector (x, y) and the transformed vector (x' , y'). This is a general linear transform that can be used to rotate any 2D vector. As (x', y') is just a linear combination of the untransformed coordinates x and y we can write it as a matrix:

  10. This is the rotation of (x, y) line: What's the matrix for rotation around the z axis in 3d?

    Moving to 3D we can define a rotation about the z axis that has the same effect on the x and y coordinates as a 2D rotation and we can use a similar matrix Any 3D rotation can be created out of a combination of rotations about the three axes. As the combination of rotations can be quite complex (particularly given that matrix multiplication is non-commutative) most graphics engines restrict rotations to three rotations about each of the axes x, y, z. Or rotations around z & y axes.

  11. Translation of a point p is equivalent to adding tx, ty, tz to p. What's the transform matrix for translation?

    A 3D translation cannot be performed by a 3x3 transform matrix acting on a 3D vector. However, we can do a translation by using a trick. We add a fourth component to our vector: v = (x, y, z, 1). 4x4 identity matrix with components (tx, ty, tz, 1) as the 4th column:

  12. What do these transform matrices do for (x, y, z)?

    scale by a rotation around z-axis translation by tx, ty, tz The transform nearest the vector is applied first: that is, the rightmost one. In this case it is the scale. Transforms can therefore be read right to left, in the opposite order we would expect from reading English.

  13. Evaluate:

    The transpose of a matrix was introduced in 1858 by the British mathematician Arthur Cayley

  14. 3D computer graphics rely on a number of coordinate systems. Describe: World Coordinate System Object Coordinate System Local Coordinate System Viewpoint Coordinate System Screen Coordinate System

    World Coordinate System - base reference system for the overall model, to which all other model coordinates relate. Also known as the "universe" or sometimes "model" coordinate system.Object Coordinate System - when modelling a desk, the modeller might choose a point in the center of the desk for the origin. When this object is moved to a point in the world coordinate system, it is really the origin of the object ( in object coordinate system ) that is moved to the new world coordinates, and al…

  15. What's the difference between perspective projection and parallel projection?

    Perspective projection - similar to the human visual system: it has perspective foreshortening, in that the size of an object varies inversely with distance. Even wireframe objects look ‘real’ if perspective is used – that is, distant objects look smaller. A feature of perspective drawings is that sets of parallel lines appear to meet at a vanishing point – like train tracks running into the distance. Parallel projection: Parallel projection is a less realistic view as there is no foreshortenin…

  16. Name 2 algorithms for line drawing. Points do not equate to pixels. To give the impression of a continuous line on a screen, the pixels that most closely approximate the mathematical line should be set to the colour of that line

    These differ slightly in their methods but produce the same lines: Midpoint algorithm Bresenham's algorithm Bresenham's algorithm can be considered an efficient form of the midpoint algorithm. Both of these algorithms extend and simplify the Digital Differential Analyzer (DDA) algorithm (which uses floating points and is slower, less efficient and less accurate). The algorithm works incrementally from a starting point (x0, y0) and the first step is to identify in which one of eight octants the…

  17. Vector monitor VS raster monitor?

    Vector (calligraphic) displays lines drawn directly, no predefined grid commands tell the electron gun where to move and when to turn on/off + lines are smooth + close to the 'pure mathematics' of the model - slower with more elements to be drawn, can start to flicker - only lines possible, no filled polygons, or bitmaps - monocrome for each electron gun Raster displays image represented by a rectangular grid of pixels (picture elements) image stored in a frame buffer electron gun(s) continuall…

  18. What do these stand for: CRT LCD

    CRT - Cathode-Ray Tube On a CRT monitor, the screen is coated in millions of phosphor dots, with one red, green, and blue dot for every individual pixel. To light up each pixel, an electron beam scans across the screen, focusing electrons on individual phosphor dots and causing them to emit photons. Applying more voltage to the system generates more electrons, in turn causing each dot to emit more light.LCD - Liquid-Crystal Display By contrast, an LCD requires physical movement on the part of e…

  19. Describe the DDA algorithm (digital differential analyzer) for drawing a line. Digital differenti after the digital differential analyzer, an early electromechanical device for digital simulation of differential equations.

    Because a line satisfies the differential equation dy/dx = m, where m is the slope, generating a line segment is equivalent to solving a simple differential equation numerically.

  20. What's a frame buffer?

    A framebuffer is a portion of RAM representing a frame that holds the properties such as the colours of that frame and sends it to an output device, most typically a screen.

  21. How many colors does the frame buffer allow: if it has 1 bit depth? if it has 8 bit depth?

    1 bit depth: just 2 colors. 8 bit depth: 28 = 256 colors. True Color system24 bits almost always use 8 bits each of R, G, and B. As of 2018, 24-bit color depth is used by virtually every computer and phone display and the vast majority of image storage formats.224 gives 16,777,216 color variations. The human eye can discriminate up to ten million colors and since the gamut of a display is smaller than the range of human vision, this means this should cover that range with more detail than can b…

  22. What's that expandable part?

    It's bellows. In photography, a bellows is the accordion-like, pleated expandable part of a camera, usually a large or medium format camera, to allow the lens to be moved with respect to the focal plane for focusing.

  23. What are Euclidean Spaces? What are Affine Spaces?

    Euclidean space - vector space extended with definition of a length. Affine space - vector space extended with points.

  24. What's rigging?

    Rigging is a technique used in skeletal animation for representing a 3D character model using a series of interconnected digital bones. Computer animation (both 2D and 3D) is quite a lot like Stop Motion Animation. You put a lot of effort into creating a (virtual) model of a character and then when animating it you move it frame by frame. You will spend a lot of time making easy-to-use controls for a character, a process called rigging.

  25. Page 100 (& before) has a pretty awesome explanation for how for Catmull splines & etc.

    Mb will write a blog post.

  26. Character animation is normally divided into Body animation and Facial animation each of which uses different techniques. Within each there are a number of important topics: Body animation • skeletal animation • skinning • motion capture Facial animation • morph targets • facial bones • facial motion capture.

  27. The black circle is the root, the position and rotation offset from the origin. The root is (normally) the only element of the skeleton that has a translation. The character is animated by rotating joints and translating and rotating the root

  28. What do Taylor series claim?

    Taylor series state that a small change (δt) in a function can be represented as an infinite series like this:

  29. What's deltaTime here? Basic function of a physics engine is to evaluate all of the forces on an object, sum them to calculate the acceleration and then use the acceleration to update the velocity and position.The code assumes you have defined a class to represent a force.

    Time since last frame.

  30. We know the exact acceleration at any given time. However, this acceleration changes over time as forces change! How do we know calculation of v and x work? v = v0 + a * deltaTime x = x0 + v * deltaTime Basic function of a physics engine is to evaluate all of the forces on an object, sum them to calculate the acceleration and then use the acceleration to update the velocity and position.The code assumes you have defined a class to represent a force.

    Taylor series state that a small change (δt) in a function can be represented as an infinite series like this: For small values of δt the later terms become smaller and smaller so the function can be approximated with the first few terms. Our code implements the following equation for position (and the equivalent for velocity):

  31. Particles VS rigid bodies VS compound bodies VS soft bodies/cloth?

    Particles - have position, velocy, mass, but NO shape. Particles are the simplest type of object. They have a position, velocity and mass but zero size and no shape (at least from the point of view of the simulation). They can move, but they do not have a rotation. They are typically used for very small objects.Rigid bodies - have position, velocity, mass, shape, but CANNOT change their shape. Rigid bodies are slightly more complex. They have a size and shape. They can move around and rotate bu…

  32. Name 3 shape representations an object can have for physics model (as opposed to graphics). An object typically has a different shape representation for physics than it has for graphics - physics shapes need to be fairly simple so that the collision calculations can be done efficiently.

    Primitives shaped (box, sphere, plane) Compound primitive shapes (primitives joined together) Meshes (usual mesh but with fewer polygons) Simulating meshes is much more expensive than simulating primitives, so the meshes must be simple. They are usually a different, and much lower resolution, mesh from the one used to render the graphics. They are typically created by starting with the graphics mesh and greatly reducing the number of polygons.

  33. How many degrees of freedom does a rigid body have?

    3 positional DOFs (x, y, z) 3 rotational DOFs (rotation about the x, y, z axes) 6 degrees of freedom, e.g. motion of a ship at sea. Moving up and down (elevating/heaving); Moving left and right (strafing/swaying); Moving forward and backward (walking/surging); Swivels left and right (yawing); Tilts forward and backward (pitching); Pivots side to side (rolling).

  34. Upon hitting the surface, light can get: a... r... t...

    absorbed reflected transmitted

  35. What's meant by local illumination VS global illumination models?

    When deciding how to color an object, we rely on Local illumination – take into account only direct light. Global illumination – take into account how light reflects off all the other objects. Such algorithms take into account not only the light that comes directly from a light source (direct illumination), but also subsequent cases in which light rays from the same source are reflected by other surfaces in the scene, whether reflective or not (indirect illumination). Theoretically, reflections…

  36. How many different colors can the 24-bit color depth offer? As of 2018, 24-bit color depth is used by virtually every computer.Almost all cases of 32-bit color depths assigns 24 bits to the color, and the remaining 8 are the alpha channel.

    Number of different colors: 224 gives 16,777,216. Each color is represented by 1 byte integer, so each of the three RGB components is an integer between 0 and 255.The three integers together take up three bytes, which is 24 bits: thus a system with 24 bit colour has 256 possible levels for each of the three primary colours.This is defined as ‘true colour’ or ‘millions of colours’ – a total of at least 16,777 216 colour variations, allowing for perceptually smooth transitions

  37. Name 4 different light source models in a 3d computer model of a scene.

    directional/parallel source shines in a particular direction, but doesn't emanate from any particular location. All of the rays from a directional light source have a common direction and no point of origin (Figure 5.2). It is as if the light source was infinitely far away from the surface that it is illuminating. For outdoor scenes, the sun is so far away that its illumination is simulated as a directional light source with all rays arriving at the scene in a parallel direction.point source -…

  38. What's a specular highlight?

    A specular highlight is the bright spot of light that appears on shiny objects when illuminated (for example, see image on right). Specular highlights are important in 3D computer graphics, as they provide a strong visual cue for the shape of an object and its location with respect to light sources in the scene. The term specular means that light is perfectly reflected in a mirror-like way from the light source to the viewer.

  39. Broadly - what's a Phong reflection model?

    It's an empirical model of local illumination, - approximates reflection at point p of the material. The Phong reflection model is widely used for real-time computer graphics to approximate specular reflection. Phong Bui-Tuong observed that for very shiny surfaces the specular highlight was small and the intensity fell off rapidly, while for duller surfaces it was larger and fell off more slowly.The model consists of three reflection components: the diffuse component, the specular component and…

  40. In the Phong reflection model - what's meant by specular reflection diffuse reflection ambient reflection?

    specular reflection - mirror-like reflection of shiny surfaces. Simulates the bright spot of a light that appears on shiny objects. Specular highlights are more inclined to the color of the light than the color of the object.diffuse reflection - scattered reflection of rough surfaces. Most visually significant component of the lighting model. The more a part of an object faces the light source, the brighter it becomes.ambient reflection - term to account for the small amount of ambient light th…

  41. What's Lambert's Cosine Law?

    One way to understand this law is to consider a small parallel light source striking a plane, as shown in Figure 6.16. As the source is lowered in the (artificial) sky, the same amount of light is spread over a larger area, and the surface appears dimmer.

  42. What's the informal observation behind the Phong reflection model? Phong reflection model is an empirical model, which is not based on physics, but on physical observation; - that is, it fits empirical observations but with no particular theoretical justification.

    Shiny surfaces have small intense specular highlights, dull surfaces have large highlights that fall off more gradually.

  43. Given this sphere - what would be flat shading and interpolation shading?

    flat shading - lighting is evaluated only once for each polygon, based on the polygon's surface normal and on the assumption that all polygons are flat. The computed color is used for the whole polygon, making the corners look sharp. This is usually used when more advanced shading techniques are too computationally expensive. Specular highlights are rendered poorly with flat shading: If there happens to be a large specular component at the representative vertex, that brightness is drawn uniform…

  44. Name 2 types of interpolation shading. Shading flat shading interpolation shading _____________ _____________

    Gouraud shading Phong shading

  45. What's the difference between Gouraud and Phong shading? Shading flat shading interpolation shading Gouraud Phong

    Gouraud shading - interpolate light intensities Phong shading - interpolate normals Phong shading is similar to Gouraud shading, except that instead of interpolating the light intensities the normals are interpolated between the vertices and the lighting is evaluated per-pixel. Thus, the specular highlights are computed much more precisely than in the Gouraud shading model. Gouraud shading Determine the normal at each vertex of the polygon. Apply an illumination model to each vertex to calculat…

  46. [x to the right is positive, y down is positive] What are the new coordinates if we rotate the vector (x, 0) by θ with a positive x axis?

    (x cos(θ), y sin(θ))

  47. [x to the right is positive, y down is positive] What are the new coordinates if we rotate the vector (0, y) by θ with a positive y axis?

    (y sin(θ), y cos(θ))

  48. [x to the right is positive, y down is positive] To rotate vector (x, 0) by θ: (x cos(θ), y sin(θ)) To rotate vector (0, y) by θ: (y sin(θ), y cos(θ)) How to rotate (x, y) by θ?

    To rotate a vector with components about both axes (x, y), we can combine these equations:

  49. Write this as a matrix:

  50. What's a quadrilateral?

    In Euclidean plane geometry, a quadrilateral is a polygon with 4 edges and 4 vertices. Other names for quadrilateral include quadrangle, tetragon, and 4-gon.

  51. What's rasterisation?

    Takes an image described in vectors graphic format => a raster image (a series of pixels) Rasterisation is the task of taking an image described in a vector graphics format (shapes) and converting it into a raster image (a series of pixels, dots or lines, which, when displayed together, create the image which was represented via shapes). Rasterisation may refer to the technique of drawing 3D models, or the conversion of 2D rendering primitives such as polygons, line segments into a rasterized f…

  52. What's a flood fill (or seed fill) algorithm?

    Seed fill algorithm determines the area connected to a given node in a multi-dimensional array. Scanline fill It is used in the "bucket" fill tool of paint programs to fill connected, similarly-colored areas with a different color

  53. Name 3 coordinate systems.

    World, object, local Viewport (or camera) Coordinate System - based upon the viewport of the observer. Moving an object forward moves the object along the direction that the viewer is looking at. Screen Coordinate System - 2D CS, refers to physical coordinates of the pixels on the computer screen based on current screen resolution, e.g. 1024x768.

  54. [Textures] What's texture mapping VS procedural texturing?

    Texture mapping - places images on top of the polygons and thus can make simple models look incredibly realistic and is the easiest way to add fine detail. Texture mapping places images on top of the polygons and thus can make simple models look incredibly realistic and is the easiest way to add fine detail.Procedural textures - calculated mathematically to provide realism at any resolution . Procedural textures are calculated mathematically to provide realism at any resolution.

  55. [Textures] What's bump mapping VS displacement mapping?

    Bump mapping - adjusts the shading of surfaces. During the bump mapping, unlike displacement mapping, the surface geometry is not modified.Displacement mapping - adjusts the position of surfaces. Effect where the actual geometric position of points over the textured surface are displaced, often along the local surface normal, according to the value the texture function evaluates to at each point on the surface.

  56. [Textures] What's reflection mapping?

    Efficient image-based lighting technique for approximating the appearance of a reflective surface by means of a precomputed texture. First, the environment itself has to be created or captured – either computer generated or captured using a probe, such as a chrome sphere, which captures real world reflections. The object is then surrounded by a closed three dimensional surface onto which the environment is projected. An example of reflection mapping.

  57. [OpenGL] What does GLSL stand for?

    OpenGL Shading Language OpenGL Shading Language (GLSL) is a high-level shading language with a syntax based on the C programming language.There are several languages that can be used to write shaders, such as Cg, HLSL and GLSL. The latter is the shader language included in OpenGL, the standard rendering library and API used across a wide variety of computing devices, ranging from high-end desktop computers to smartphones. GLSL simply stands for OpenGL Shading Language.

  58. [OpenGL] What does OpenGL stand for?

    Open Graphics Library OpenGL (Open Graphics Library) is a cross-language, cross-platform application programming interface (API) for rendering 2D and 3D vector graphics.

  59. What are shaders responsible for?

    Everything, all the rendering stages, starting with camera transformations that are applied on the raw geometry, and ending at the evaluation of the final color of each visible pixel in the screen. A shader is basically a program that runs on the Graphics Processing Unit (GPU) of the computer, and generates the visual output we see on the screen given the information that defines a 2D or 3D scene: vertices, colors, textures, lights, etc. The term "shader" itself might be slightly misleading, si…

  60. What language do we have to use to write custom shaders in Processing?

    GLSL. Since Processing uses OpenGL as the basis for its P2D and P3D renderers, GLSL is the shader language that one has to use to write custom shaders to include in Processing sketches.There are several languages that can be used to write shaders, such as Cg, HLSL and GLSL. The latter is the shader language included in OpenGL.

  61. [OpenGL] Uniform VS attribute variables? In this case we don't call it uniform because it will be different from thread to thread, instead gl_FragCoord is called a varying. The camera, light, transformation and vertex data defined in the sketch result in two types of input for the pipeline: uniform and attribute variables.

    Uniform variables - remain constant for each vertex in the scene. The projection and modelview matrices computed from the camera and transformation setup fall in this category, since each vertex in the scene is affected by the same projection/modelview matrices.The lighting parameters (source position, color, etc) are also passed to the pipeline as uniform variables for the same reason. Attribute variables - change from vertex to vertex are called attributes Three different type of attributes p…

  62. Vertex shader - computes position and color for each vertex. It uses the vertex attributes (in this case positions, colors and normals), projection and modelview matrices, and light parameters in order to compute, for each vertex, what its position and color on the screen turns out to be. We can think of the vertex shader operating on one vertex at the time, and carrying out all the mathematical operations to project the vertex on the screen plane and to determine its color given the particular…

    \

  63. What are 2 programmable stages of the graphics pipeline in Processing?

    Vertex shader Fragment shader In the previous section we saw that the two programmable stages in the GPU pipeline are the vertex and fragment shaders.

  64. [OpenGL] Uniform VS attribute VS varying variables?

    uniform - set by the CPU program per shader. These are variables that have a single value passed per object or render. They are set by the CPU program and do not change until the CPU program starts a new shader. They can be read in any shader but not written to. Examples include light positions and transform matrices.attribute - per-vertex variables (typically : positions, normals, colors, UVs, ...) ; These variables have a different value for each vertex. These are sent from the CPU to the sha…

  65. [Processing] What are 2 issues with immediate mode objects drawn like this? The process described above is called Immediate Mode graphics and is a low level approach to graphics that closely corresponds to how the graphics card works. Transforms and styles are maintained in a state machine. Shapes are drawn by specifying vertices, which are immediately sent for drawing on the graphics card.

    It's not how we think of our objects Firstly, it does not correspond well to how we normally think about graphics. We do not normally think in terms of graphics states and vertices. We think in terms of objects. Vertices are not ephemeral things that are re-created in each frame; they form stable objects that exist from frame to frame (for example, a teapot, or a table). Colours and positions are not graphics states, they are properties of objects. In the real world there is no abstract ‘red’ s…

  66. What are shaders? The graphics pipeline: the stages involved in going from geometric models to images.1. Model. Objects in the world are modelled out of vertices by the CPU program. These vertices are sent to the GPU.2. Transform. All vertices are transformed into view coordinates by the ModelView matrix. This stage can also include other operations such as lighting vertices.3. Projection. The vertices are projected into screen space using the Projection matrix (perspective or orthographic).4.…

    Shaders are short programs that can be run directly on the GPU. Early GPUs simply implemented a fixed set of graphics functionality in hardware, but modern GPUs are programmable: you can run short programs to be run directly on the GPU hardware that will change the way your objects are drawn. These programs are traditionally called Shaders. Shaders allow you to create a vast range of effects that are not possible with the fixed functionality:complex materials: rough stone, translucent skin, shi…

  67. [OpenGL] What's billboarding?

    When we use the 2D element always facing the camera in the 3d world. Billboards are 2D elements injected in a 3D world. Not a 2D menu on top of everything else; not a 3D plane around which you can turn; but something in-between, like health bars in many games.What’s different with billboards is that they are positioned at a specific location, but their orientation is automatically computed so that it always faces the camera.

  68. [Processing] How to use immediate mode objects VS 'retained mode' objects in Processing? Drawing the memorized geometry (called a "Vertex Buffer Object" in lower-level OpenGL syntax) is called "retained" mode and is a great deal faster. Try to draw around 500 stars and your sketch may run rather slowly, about 10 FPS. This is because this style of drawing, often referred to as "immediate" mode, requires the renderer to compute the geometry each time through draw for each and every star. But is t…

    Immediate mode: beginShape(); vertex(-47, -15); vertex(-14, -20); endShape(CLOSE); Retained mode: s = createShape(); s.beginShape(); // You can set fill and stroke s.fill(102); s.stroke(255); s.strokeWeight(2); s.vertex(0, -50); s.vertex(14, -20); s.endShape(CLOSE);

  69. What's the difference between Phong shading and Phong reflection model?

    Phong shading - interpolation technique where we interpolate normals Phong reflection model - empirical model of illumination (ambient, diffuse and specular lights) Interpolation techniques: Phong shading - interpolates normals Gouraud shading - interpolates light intensities Phong shading is similar to Gouraud shading, except that instead of interpolating the light intensities the normals are interpolated between the vertices and the lighting is evaluated per-pixel.

  70. [Shaders] How do in/out variable qualifiers relate to the attribute/varying variable qualifiers?

    Vertex shader: in (previously attribute) out (previously varying) Fragment shader: in (previously varying)

  71. [Shaders] What's the function of vertex shaders? Vertex shaders act on individual vertices. They act on the basic vertex data to produce values that are interpolated by the rasteriser and then sent to the fragment shader.

    Vertex shaders perform a number of functions: vertex and normal transformations texture coordinate calculation lighting material application.

  72. [Textures] What's a texel?

    Pixel in a texture. Typically, a texture is an image, which is applied to a polygon or a mesh. The pixels in the texture are called texels, each texel storing color values, such as 24-bit RGB or 32-bit RGBA, just as their counterpart pixels in the frame buffer.

  73. [Shaders] Why does the shader() need the 2nd argument (POINTS, LINES, TRIANGLES [default])?

    POINTS, LINES - points and lines in 3D always need to be facing the screen, and require a special transformation maths in the vertex shader. The point and line shaders are relevant only when using the P3D renderer.TRIANGLES - used to render anything else, which means that they will handle (lit/unlit, textured/non-textured) shapes. Because all shapes in Processing are ultimately made out of triangles, they are can be called TRIANGLE shaders.

  74. [Shaders] Name 4 types of the shader(polyShader, TRIANGLES). Together with the POINT and LINE shaders mentioned earlier, we end up having 6 different types of shaders in Processing.

    COLOR Render geometry with no lights and no texturesLIGHT - lights Render geometry with lights but no texturesTEXTURE - texture Render geometry with textures but no lightsTEXLIGHT - texture, lights Render geometry with textures and lights #define PROCESSING_POINT_SHADER #define PROCESSING_LINE_SHADER #define PROCESSING_COLOR_SHADER #define PROCESSING_LIGHT_SHADER #define PROCESSING_TEXTURE_SHADER #define PROCESSING_TEXLIGHT_SHADER The shader type can be set explicitly in the source code of the…

  75. [Phong shading] Why are distant lights often called directional lights? The geometry for Lambert’s law. Both n and l are unit vectors.

    Because the position of such light is only specified by its direction. Note that the vector l is typically assumed not to depend on the location of the object. That assumption is equivalent to assuming the light is “distant” relative to object size. Such a “distant” light is often called a directional light, because its position is specified only by a direction.

  76. [GLSL] What's the meaning of * operator: scalar * vector or matrix

    Scalar multiplication. If m is a scalar and n is a vector or matrix, then m*n is a vector or matrix of the same size as n whose entries are the original vector or matrix entries, each multiplied by m

  77. [GLSL] What's the meaning of * operator: vector * vector Of the same size

    Component by component product, the result of which is a vector! If m and n are both vectors of the same size, then m*n is the scalar product (component-by-component product) of the vectors, not their dot product.

  78. [GLSL] What's the meaning of * operator: matrix * vector Of the same size

    Usual matrix multiplication. If m is a matrix and n is a vector of compatible size, then m*n is a vector of the appropriate size that is the usual matrix*vector product.If m and n are both matrices of compatible sizes, then m*n is a matrix of the appropriate size that is the usual matrix*matrix product.

  79. [GLSL] What does aVertex.xyz give you?

    First 3 components of a vector. You can also use any subset of the symbolic names to access parts of a vector. For example, aVertex.xyz gets you the first three components of a vertex. Another new kind of vector access involves rearranging their components, or “swizzling” them. Components can be swizzled by giving the symbolic names of the components in changed order (e.g., c1.rgba = c2.abgr) to rearrange their order.

  80. [Shaders] What do these uniform variables mean: mat4 uModelViewMatrix - ??? mat4 uProjectionMatrix - the matrix of the projection transformation that is active for the particular vertex. mat4 uModelViewProjectionMatrix - the product of the ModelView matrix and the Projection matrix. mat3 uNormalMatrix - the normal matrix that is active for the particular vertex (as we will see, this is the inverse transpose of the ModelView matrix). There are also some uniform variables that you will use a lot.…

    mat4 uModelViewMatrix - product of viewing and modeling transformation matrices. The ModelView matrix, the product of the viewing and modeling transformation matrices, that is active for the particular vertex.

  81. [Shaders] What do these uniform variables mean: mat4 uModelViewMatrix - the ModelView matrix, the product of the viewing and modeling transformation matrices, that is active for the particular vertex. mat4 uProjectionMatrix - the matrix of the projection transformation that is active for the particular vertex. mat4 uModelViewProjectionMatrix - ??? mat3 uNormalMatrix - the normal matrix that is active for the particular vertex (as we will see, this is the inverse transpose of the ModelView matri…

    mat4 uModelViewProjectionMatrix - product of uModelViewMatrix and uProjectionMatrix. The product of the ModelView matrix and the Projection matrix.

  82. [GLSL] What data type is v4.rgb?

    vec3 made from the first three components of v4.

  83. [GLSL] What data type is v4.b?

    Float whose value is the third component of v4; Just like v4.z or v4.p.

  84. [GLSL - vector constructors] What does vec2(float) initialise?

    vec2 with the float value in each position.

  85. [GLSL - vector constructors] What does bvec4(int, int, float, float) initialise?

    bvec4 with 4 booleans (converted).

  86. [GLSL - vector constructors] What does vec2(vec3) initialise?

    Drops the 3rd component of vec3.

  87. [GLSL - vector constructors] What does vec3(vec2, float) initialise?

    [vec2.x, vec2.y, float]

  88. [GLSL - vector constructors] What's the logic behind these constructors?

    The construction acts as though the matrix begins as an identity matrix (or a subset of an identity matrix), and the new elements that are specified replace the originals.

  89. [GLSL] Where are these taken from? Attribute variables are only accessible in a vertex shader and are read-only for that shader.

    Originally, GLSL had built-in variable names for all the standard OpenGL vertex attributes to give you easy access to data defined by OpenGL vertex functions.

  90. [GLSL] Name 1 of the 4 primary matrices available to shaders as a uniform variable. GLSL has a large set of built-in uniform variables that let you access the graphics states set by the OpenGL API in your application.

    uniform mat4 gl_ModelViewMatrix; uniform mat4 gl_ProjectionMatrix; uniform mat4 gl_ModelViewProjectionMatrix; uniform mat4 gl_TextureMatrix[gl_MaxTextureCoords]; Primary matrices. OpenGL maintains four primary matrices that are available to your shaders. And derived matrixes:uniform mat3 gl_NormalMatrix; // transpose of inverse of the upper leftmost 3x3 of gl_ModelViewMatrixuniform mat4 gl_ModelViewMatrixInverse;uniform mat4 gl_ProjectionMatrixInverse;uniform mat4 gl_ModelViewProjectionMatrixIn…

  91. [Phong reflection model] What are L, N, R and E vectors?

    L - from point to the light source N - normal to the surface at the point R - reflected light from the surface at the point E - from point to the eye A point on a surface with normalized (unit) vectors from the point to the eye, Eˆ.

  92. [Phong reflection model] This is the ambient light component - what's L and M?

    Lambient - vec3 of light's ambient color Mambient - vec3 of material's ambient color

  93. [Phong reflection model] This is the diffuse light component - what's L, M and N?

    Ldiffuse - vec3 of light's diffuse color Mdiffuse - vec3 of material's diffuse color L - vec3 of normalized vector to the light source N - vec3 of normalized normal vector Diffuse light contributes to the lighting as a product of the diffuse light itself LD , the diffuse light color of the material being lighted MD , and the cosine of the angle Θ between the light and the normal, (Lˆ • Nˆ).

  94. [Phong reflection model] This is the specular light component - what's L M R E SH?

    Lspecular - vec3 of light's specular color Mspecular - vec3 of material's specular color R - vec3 of normalized light source reflection E - vec3 of normalized eye vector SH - shininess coefficient Specular light contributes to the lighting as a product of the specular light itself LS , the specular light color of the material being lighted MS , and a power (the “shininess” coefficient SH) of the cosine of the angle Φ between the eye vector and the light reflection vector, (Rˆ •Eˆ )SH.

  95. [Phong reflection model] Where's which lightning component here?

    Ambient Diffuse Specular

  96. [GLSL] What does ecPosition stand for?

    Eye coordinate position

  97. [Processing] Think of a scene with 3 types of light: directional point source spotlight

    directional: sun point source: just 4 point sources scattered throughout the scene spotlight: flashlight We are going to simulate a sun-like light as a directional light source, 4 point lights scattered throughout the scene and we'll be adding a flashlight as well.

  98. [GLSL] How would the shader accounting for sun, 4 point sources, and flashlight look?

    The actual code will likely differ per implementation, but the general structure remains the same. We define several functions that calculate the impact per light source and add its resulting color to an output color vector. If for example two light sources are close to the fragment, their combined contribution would result in a more brightly lit fragment compared to the fragment being lit by a single light source.

  99. [Processing] What's the resulting color?

    The overlap of ambientLight() lighting and ambient() material. If the color in your ambientLight() overlaps with the ambient() material, the object will be illuminated with the color of the overlap.

  100. All in variables in the fragment shader (varying variables) are interpolated!

    All outputs of the vertex shader are per vertex. When you set v_Color in the vertex shader, it sets it on the current vertex. When the fragment shader runs, it reads the v_Color value for each vertex in the primitive and interpolates between them based on the fragment's location. When you set v_Color in the vertex shader, it sets it on the vertex. When the fragment shader runs, it reads all of the vertices' v_Color values and interpolates between them based on the fragment's location.