1 / 9

Lab 2 Organization

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 &

keene
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. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. Lab 2 Organization CSE 681

  2. 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

  3. Material Class - fields SoMFColor ambientColor SoMFColor diffuseColor SoMFColor specularColor SoMFColor emissiveColor SoMFFloat shininess SoMFFloat transparency CSE 681

  4. Material Properties for basic illumination material-> ambientColor[0][0-2] material-> diffuseColor[0][0-2] material->specularColor[0][0-2] CSE 681

  5. 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

  6. 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

  7. Combine shading If not transparent c += shininess*reflective_color If transparent c = (1-transparency)*(c + shininess*reflective_color) + transparency*refractive_color; CSE 681

  8. 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

  9. 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

More Related