1 of 13

PRIMITIVES

Advanced Computer Graphics

SEMINAR 2

2 of 13

Primitive Shading

  • Light source located at camera position
  • Lower light intensity of distant objects
  • Creates illusion of depth

2

Double intensity = MaxIntensity / ray.HitParam;

return ray.HitModel.Color * intensity;

3 of 13

zNear & zFar

  • Objects too close to camera would block all visible space
      • zNear clips objects too close
  • Objects too far from camera are negligibly small
      • zFar clips invisible objects
  • Why z?

3

4 of 13

Bias

 

4

ray

camera

sun

shadow

ray

P – intersection point

sphere

Unexpected intersections

Can be corrected with bias

5 of 13

AABB (Axis Aligned Bounding Box)

 

5

6 of 13

AABB – intersection parameters

6

 

 

 

 

2D case:

 

For x coordinate:

7 of 13

AABB checking for intersection

 

7

8 of 13

Ring (3D Circle)

 

8

9 of 13

Sphere

  • Defined by a center point C and radius R
  • Intersection point can be solved analytically or geometrically

9

 

10 of 13

Sphere – Geometric Solution

10

 

 

 

 

 

C

P

P’

O

 

d

R

 

 

tca

thc

 

 

L

t1

t0

r

11 of 13

Sphere – Analytical Solution

11

 

 

 

 

 

 

 

 

where:

12 of 13

Triangle

  • Defined by three points A, B, C
  • Intersection can be found using barycentric coordinates

12

 

where:

 

 

If ray intersects triangle they have a common point:

13 of 13

Template Assignment

  • Define primitive objects, similarly to Plane
      • Add class Sphere
      • Add class AABB
      • Add class Circle

  • Bonus
      • Add class Triangle
      • Add class Cylinder
      • Add class Cone

13