Lab 2 organization
This presentation is the property of its rightful owner.
Sponsored Links
1 / 9

Lab 2 Organization PowerPoint PPT Presentation


  • 44 Views
  • Uploaded on
  • Presentation posted in: General

Lab 2 Organization. Illumination model. Object material properties Combine ambient, diffuse, specular. Lab 2 - requirements. Light sources & properties. Light sources. Loop through objects. shadows. Shininess / transparency material property Recursive call Blend colors. Reflection &

Download Presentation

Lab 2 Organization

An Image/Link below is provided (as is) to download presentation

Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author.While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server.


- - - - - - - - - - - - - - - - - - - - - - - - - - E N D - - - - - - - - - - - - - - - - - - - - - - - - - -

Presentation Transcript


Lab 2 organization

Lab 2 Organization

CSE 681


Lab 2 requirements

Illumination model

Object material properties

Combine ambient, diffuse, specular

Lab 2 - requirements

Light sources & properties

Light sources

Loop through objects

shadows

Shininess / transparency material property

Recursive call

Blend colors

Reflection &

refraction

CSE 681


Material class fields

Material Class - fields

SoMFColor ambientColor

SoMFColor diffuseColor

SoMFColor specularColor

SoMFColor emissiveColor

SoMFFloat shininess

SoMFFloat transparency

CSE 681


Material properties for basic illumination

Material Properties for basic illumination

material-> ambientColor[0][0-2]

material-> diffuseColor[0][0-2]

material->specularColor[0][0-2]

CSE 681


Light sources and basic illumination model

Light sources and Basic Illumination model

SbVec3f location = light->location.getValue();

float intensity = light->intensity.getValue();

SbVec3f color = light->color.getValue();

Ii = light_intensity

R = reflected incident ray

L = ray to light source

Illum(N,L,R, Ii,material)

c = Ii*(ambientColor + (N.L)*diffuseColor + pow((L.R),1000*ks2)*specularColor)

CSE 681


Somaterial

SoMaterial

Const float* s = material->shininess.getValues(0);

Float shininess = s[0];

OR

shininess = Material->shininess[0];

Const float* t material>transparency.getValues(0);

float transparency = t[0];

OR

transparency = Material-> transparency [0];

CSE 681


Combine shading

Combine shading

If not transparent

c += shininess*reflective_color

If transparent

c = (1-transparency)*(c + shininess*reflective_color) +

transparency*refractive_color;

CSE 681


Refraction

Refraction

Flip normal when inside the object: test N.d where d is incident ray

Only do transparency if > 0

keep track of exiting & entering indices of refraction

Test radical term; if negative, total internal refraction

CSE 681


Code organization

  • Color shade(ray,recursionDepth)

  • {

    • intersect objects…get material of intersected object

    • color c = (0,0,0); compute R …

    • For each light source, if not in shadow,

    • compute Ii; c += illum(N,L,R,Ii,material)

  • If (recursionDepth < maxRecursion) {

    • If (shininess > 0.0) c += shininess * shade(R, recursionDepth+1)

    • If (transparency > 0.0) {

  • Compute refractive ray, T, based on ray, normal, and Snell constants

  • c *= (1-transparency);

    • c += transparency * shade(T, recursionDepth+1)

    • }

  • }

  • clamp R,G,B to 1.0

  • Return c

  • }

  • Code organization

    CSE 681


  • Login