Professional Documents
Culture Documents
Unit-4 CG Ans
Unit-4 CG Ans
Their shape cannot be defined so in this case, we use fractals. So these are
nothing but natural objects that can be drawn with the help of fractals. Below is
an example of a fractal diagram.
Basically, Fractals are used in many areas for its importance such as –
• Astronomy: for the analysis purpose of Saturn’s rings, galaxies, etc.
• Biology/Chemistry: For the purpose of illustrating chemical reactions, human
anatomy, molecules, plants, and bacterial cultures.
• Others: For the purpose of representing the required clouds, borders, the
coast, data compression, diffusion, economy, fractal music, fractal art,
landscapes, special effects, and so forth.
Types of Fractal
• Self Affine: It has parts formed with different scaling parameters in different
coordinate directions. For example in the direction, the scaling may be
different from that t of y-direction. So the fractal will not be exactly similar in
all directions.
Fractal Dimension
Koch Curve
In the Koch curve, initially, you have to take a triangle, and in that triangle, each
straight line is replaced with four equal-sized lines of scaling factor 1/3.
Step 2: After n iterations, we will get a Koch curve that will look like this.
In the Koch curve, the fractal dimension is 1.2619. This value is calculated using
the following procedure:
At each iteration, the scaling factor S is 1/3 because each line segment is divided
into 1/3 of its original length, and N is 4 because each line segment is replaced by
four smaller line segments.
Therefore, we can calculate the fractal dimension of the Koch curve as follows:
D = log(4) / log(1 / 3)
D ≈ 1.2619
Peano Curves
In computer graphics, the Peano curve, also known as the Hilbert-Peano curve, is
a type of space-filling curve named after Italian mathematician Giuseppe Peano.
It is constructed by recursively dividing a square into smaller squares and then
connecting the corners of those squares in a specific order.
The Peano curve has several interesting properties that make it useful in computer
graphics:
1. Space-filling: The curve passes through every point in the square, effectively
filling the entire space. This property is useful for generating fractals and for
tasks such as texture mapping and data compression.
2. Local coherence: Points that are close to each other in the curve are also close
to each other in the square. This property is beneficial for tasks like ray tracing
and spatial indexing.
3. Self-similarity: The curve exhibits self-similarity at different scales, meaning
that smaller portions of the curve resemble the whole curve. This property can be
exploited for generating complex patterns and for achieving level-of-detail
effects.
4. Easy to generate: The Peano curve can be generated using simple recursive
algorithms, making it computationally efficient to construct and manipulate.
Applications:
i). In computer graphics, the Peano curve is often used in techniques such as
space-filling curves for
data indexing,
texture mapping.
An initial image is transformed to produce new image and that image is again
transformed to another image. This can be shown by the following diagram:
1. Initialization: Start with a set of initial points in the space, often a simple shape
like a point, line, or square.
4. Coloring and Rendering: Once the fractal is generated, it can be colored and
rendered to create visually appealing images. Different coloring techniques, such
as assigning colors based on the point's position or density, can be used to
enhance the visual appearance of the fractal.
- Texture Synthesis: IFS can be used to synthesize textures with complex patterns
that exhibit self-similarity, such as wood grain or marble.
One approach to visualize Mandelbrot set is Escape Time Rendering and the
algorithm is as follows:
Algorithm:
Step 5: If |Zn| > R( where R-> predetermined threshold) then point C is not part
of mandelbrot set.
Step 6: Repeat the steps 1 to 5 for each and every point in the plane to generate
the Mandelbrot sets.
Julia Sets:
Julia sets are another fascinating aspect of fractal geometry, closely related to
Mandelbrot sets. They are named after the French mathematician Gaston Julia,
who studied them in the early 20th century. Julia sets are generated by iterating a
complex function on complex numbers.
To visualize Julia sets, here's a step-by-step process:
1. Choose a Complex Function: Unlike the Mandelbrot set, which uses the
function \( f(z) = z^2 + c \), Julia sets use a fixed complex function \( f(z) \).
Common choices include quadratic polynomials, such as \( f(z) = z^2 + c \),
where \( c \) is a complex constant.
2. Initialize Parameters:
- Define the range of complex numbers to explore in the complex plane (xmin,
xmax, ymin, ymax).
- For each pixel (x, y), map its coordinates to a complex number \( z \) in the
specified range in the complex plane.
7. Assign Colors:
8. Visualization:
- Render the image using the computed colors for each pixel.
```python
# Define parameters
max_iter = 100
z = complex(cx, cy)
n=0
z = z**2 + c
n += 1
if abs(z) <= 2:
color = compute_color(n)
set_pixel_color(x, y, color)
else:
set_pixel_color(x, y, background_color)
display_or_save_image("julia_set.png")
```
In this example, we visualize the Julia set for the function \( f(z) = z^2 + c \),
where \( c = -0.8 + 0.156i \). You can experiment with different complex
constants \( c \) and functions to explore different Julia sets.
Random fractals:
• Ray tracing
The rendering time is very slow since the ray is simulated and calculated
for each pixel on the screen. That’s why producing VFX films cost more
and require high computation power requiring GPU specially made to
render films(render farms).
3. if it is a reflective material
• recursively shoot out rays from the reflected point based on the reflectivity
and the light bounce limit.
4. calculate the light intensity of each pixel.
Intersecting rays with other primitives: Adding Surface texture
In computer graphics, intersecting rays with other primitives is a
fundamental operation used in rendering to determine what objects are visible
in a scene, and where they intersect with a ray representing a camera's view.
This process is essential for ray tracing, a technique used to simulate the way
light interacts with objects in a scene.
1. Ray Definition:
- A ray in computer graphics is represented by its origin point and a direction
vector. The origin point is typically the position of the camera or the point
where the ray starts, and the direction vector indicates the direction in which
the ray extends.
2. Primitive Representation:
- Primitives are basic geometric shapes such as spheres, triangles, planes,
cubes, etc., that make up the objects in a scene. Primitives can be represented
in various ways, including mathematical equations (like the equation of a
sphere or plane) or sets of vertices and indices (for triangles).
3. Intersection Test:
- To determine whether a ray intersects with a primitive, specific
intersection tests are performed based on the type of primitive:
- For spheres, the ray-sphere intersection equation (quadratic equation) is
solved.
- For triangles, ray-triangle intersection tests like Möller–Trumbore
intersection algorithm can be used.
- For other primitives, custom intersection algorithms may be implemented
depending on their mathematical representation.
4. Closest Intersection:
- During the intersection tests, the closest intersection point to the ray's
origin (if any) is recorded. This is essential for determining which primitive is
visible at a given point along the ray's path. The distance between the ray's
origin and the intersection point is typically used to determine the closest
intersection.
5. Shading:
- Once the closest intersection point is found, various shading attributes at
that point are computed. These attributes may include the surface normal
(direction perpendicular to the surface), material properties (e.g., color,
reflectivity, transparency), texture coordinates (if textures are used), etc.
By following these steps, ray tracing algorithms can generate highly realistic
images with accurate lighting, shading, and reflections, making them valuable
tools in various applications such as rendering for movies, video games, and
architectural visualization.
Types of Reflection:
1. Reflection about x-axis: The object can be reflected about x-axis with the help
of the following matrix
In this transformation value of x will remain same whereas the value of y will
become negative. Following figures shows the reflection of the object axis. The
object will lie another side of the x-axis.
2. Reflection about y-axis: The object can be reflected about y-axis with the help
of following transformation matrix:
3. Reflection about an axis perpendicular to xy plane and passing through
origin:
In the matrix of this transformation is given below
In this value of x and y both will be reversed. This is also called as half revolution
about the origin.
4. Reflection about line y=x: The object may be reflected about line y = x with
the help of following transformation matrix
First of all, the object is rotated at 45°. The direction of rotation is clockwise. After
it reflection is done concerning x-axis. The last step is the rotation of y=x back to
its original position that is counterclockwise at 45°.
What is transparency?
Depth peeling can avoid sorting and depth testing issues, but is expensive and
memory-intensive. Stochastic transparency can create a natural and smooth effect,
but can also introduce noise and variance that require more samples to reduce
them.
Boolean operations are a powerful tool for creating complex shapes and
forms in 3D modeling. They allow you to combine, subtract, or intersect two or
more objects using different modes. However, choosing the right Boolean
operation for your modeling goal can be tricky, as each mode has its own
advantages and disadvantages. In this article, we will explain the basics of Boolean
operations, the common modes and their effects, and some tips and best practices
for using them effectively.
What are Boolean operations?
For example, if you want to create a hole in a cube, you can use a Boolean
operation to subtract a cylinder from the cube, leaving only the parts of the cube
that are not occupied by the cylinder.
Each mode has a different effect on the resulting object, based on the order
and orientation of the operands.
Union combines the operands into one object, keeping all parts from either
one or both.
Difference subtracts the second operand from the first, keeping only those
parts from the first one.
Intersection keeps only those parts belonging to both operands, discarding
the rest.
Inverse reverses the effect of the other modes, discarding what would be
kept and keeping what would be discarded.
For instance, unioning two spheres will create a shape resembling a peanut;
differencing a sphere from a cube will leave a cube with a spherical hole;
intersecting two spheres will give a shape resembling a lens; and inverting a union
of two spheres will create a crescent-like shape.
How do you choose the right mode for your modeling goal?
Choosing the correct mode for your modeling goal depends on several factors,
such as the size and shape of the operands, the desired outcome, and the level of
detail and complexity.
Generally, Union mode is used when you want to create a new shape by
combining two or more objects, or when you need to simplify your geometry by
merging overlapping objects. Difference mode is employed when you wish to
create a hole, a cut, or a notch in an object by removing another object from it, or
to create a negative space or silhouette. Intersection mode is used when you want
to create a shape defined by the overlap of two or more objects, or to isolate a
common area or cross-section.
Lastly, Inverse mode is selected when you need to create a shape defined by
the opposite of the overlap of two or more objects, or when you want to generate a
hollow or gap.
An intersection operation can keep the overlap of two tori, creating a ring
effect, such as a toroidal shape with a smaller hole in it. An inverse
operation can reverse the effect of a difference operation, creating a cheese
effect, such as a cubic shape with spherical holes in it.
General Computer Animation
2. Procedural:
3. Behavioral:
4. Key Framing:
6. Dynamics:
Example:
Story Board Layout
1. In our animation an apple falls from the tree and bounces on the ground.
2. Then a bird flies and swirls around the air to see if any danger is there.
3. Then it sits on the apple picks it up and flies away.
Object Definition:
a. Tree
b. Apple
c. Mud
d. Bird
Animation Functions:
Example:
In the first step, one initial image and other final image are added to morphing
application as shown in fig: Ist & 4th object consider as key frames.
The second step involves the selection of key points on both the images for a
smooth transition between two images as shown in 2nd object.
3. In the third step, the key point of the first image transforms to a corresponding
key point of the second image as shown in 3rd object of the figure.
2. Wrapping: Wrapping function is similar to morphing function. It distorts only
the initial images so that it matches with final images and no fade occurs in this
function.
5. Zooming: In zooming, the window is fixed an object and change its size, the
object also appear to change in size. When the window is made smaller about a
fixed center, the object comes inside the window appear more enlarged. This
feature is known as Zooming In.
When we increase the size of the window about the fixed center, the object comes
inside the window appear small. This feature is known as Zooming Out.
Computer Images are made up of a bitmap or grid called the “raster graphics”
Raster graphics make up the majority of images on the web and on our computer.
They are one of the two main picture types used in vector graphics on computers.
A raster graphic’s file size relies on a number of factors. The first is the raster
graphic’s resolution or the size of the image in terms of pixels.
Computer images are generally stored in raster graphics formats, such as GIF,
JPEG, and PNG, which are commonly used on the Web. Tessellation of a two-
dimensional plane into cells, each containing a single value is the basis of a raster
data format. Before the data can be saved in a file, the two-dimensional array
must be serialized. A row-major format lists the cells from left to right starting
with the ones along the first (often top) row, then the cells along the second row,
and so on.
Looks Real: Raster graphics are useful for producing photographs-like images.
Used on the Internet: This is the process used to make many of the images you
see on the Internet.
Lots of Colors: A large range of smooth colors are possible for raster graphics.
Useful for Web Images: The images you see on websites, social media, and other
online platforms are often created using raster graphics. They load quickly and
look good on screens.
Three-Dimensional Raster’s
2. Interpolation:
3. Attributes:
- Keyframe systems allow animators to set and manipulate various attributes for
each keyframe, such as:
5. Ease Curves:
- Animators can control the timing and easing of animations by adjusting ease
curves or interpolation curves between keyframes. These curves determine how
attribute values change over time, affecting the speed and acceleration of motion
transitions.
Keyframe systems are powerful tools that enable animators to create complex and
expressive animations by defining key poses and transitions in an intuitive and
efficient manner. They form the backbone of animation production pipelines,
facilitating the creation of dynamic and visually appealing motion sequences in
computer graphics.
Motion Specification – Morphing and Tweening
1. Morphing:
- In morphing, key shapes or keyframes are defined at the beginning and end of
the transformation. These key shapes represent the starting and ending states of
the morphing process.
- Morphing is often used for transforming one object or character into another,
such as transforming a human face into an animal face or changing the shape of a
logo.
2. Tweening (Interpolation):
Morphing and tweening are both techniques used for motion specification
in computer animation. Morphing is used to smoothly transform one object or
shape into another, while tweening is used to generate smooth motion transitions
between keyframes. Both techniques are essential tools for creating dynamic and
visually appealing animations in computer graphics.