90 likes | 196 Views
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 &
E N D
Lab 2 Organization CSE 681
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 SoMFColor ambientColor SoMFColor diffuseColor SoMFColor specularColor SoMFColor emissiveColor SoMFFloat shininess SoMFFloat transparency CSE 681
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 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 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 If not transparent c += shininess*reflective_color If transparent c = (1-transparency)*(c + shininess*reflective_color) + transparency*refractive_color; CSE 681
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
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