Shading Variants
These three cylinders show the differences between Flat shading, Gouraud shading, and Phong shading. Surprisingly, the Gouraud and Phong shaded cylinders aren't all that different. | |
cyl = new vtkCylinderSource; cyl->SetResolution(8); cylMapper = new vtkPolyMapper; cylMapper->SetInput(cyl->GetOutput()); cyl1Actor = new vtkActor; cyl1Actor->SetMapper(cylMapper); cyl1Actor->GetProperty()->SetFlat(); cyl1Actor->GetProperty()->SetColor(1,1,1); cyl2Actor = new vtkActor; cyl2Actor->SetMapper(cylMapper); cyl2Actor->GetProperty()->SetGouraud(); cyl2Actor->GetProperty()->SetColor(1,1,1); cyl3Actor = new vtkActor; cyl3Actor->SetMapper(cylMapper); cyl3Actor->GetProperty()->SetPhong(); cyl3Actor->GetProperty()->SetColor(1,1,1); |
A greyscale comparison of Flat and Gouraud shading - removed to conserve space |
These images used to animate, but are now static to conserve space |
These cylinders are animating through differing lighting properties. The leftmost cylinder varies in its diffuse component, keeping specular and ambient properties constant. The middle cylinder varies in its specular component, and the rightmost cylinder varies in its ambient component. |
cyl = new vtkCylinderSource; cyl->SetResolution(8); cylMapper = new vtkPolyMapper; cylMapper->SetInput(cyl->GetOutput()); cyl1Actor = new vtkActor; cyl1Actor->SetMapper(cylMapper); cyl2Actor = new vtkActor; cyl2Actor->SetMapper(cylMapper); cyl3Actor = new vtkActor; cyl3Actor->SetMapper(cylMapper); for(i=1;i<10;i++) { cyl1Actor->GetProperty()->SetDiffuse(i/10); cyl2Actor->GetProperty()->SetSpecular(i/10); cyl3Actor->GetProperty()->SetAmbient(i/10); renWindow->Render(); } |
Varying specular power - link removed to conserve space |
This image used to animate, but is now static to conserve space |
Here we see how camera motion can influence the picture. The leftmost camera is cycling through 30-degree changes in azimuth; the middle camera is "dollying" towards the cone; and, the rightmost camera is rolling around the direction of projection. |
cone = new vtkConeSource; cone->SetResolution(8); coneMapper = new vtkPolyMapper; coneMapper->SetInput(cone->GetOutput()); cone1Actor = new vtkActor; cone1Actor->SetMapper(coneMapper); cone2Actor = new vtkActor; cone2Actor->SetMapper(coneMapper); cone3Actor = new vtkActor; cone3Actor->SetMapper(coneMapper); for(i=1;i<=12;i++) { ren1->GetActiveCamera()->Azimuth(30); ren2->GetActiveCamera()->Dolly(1.1); ren3->GetActiveCamera()->Roll(30); renWindow->Render(); } |
Camera movements around a focal point - dead link to conserve space Camera movements centered at camera position - dead link to conserve space |
This image used to animate, but is now static to conserve space. |
More advanced models can be built up from the building blocks. Here we see a rotating mace, generated by placing cones at the vertices of the underlying sphere and scaling them down. |
sphere = new vtkSphereSource(8); sphereMapper = new vtkPolyMapper; sphereMapper->SetInput(sphere->GetOutput()); sphereActor = new vtkActor; sphereActor->SetMapper(sphereMapper); cone = new vtkConeSource(6); glyph = new vtkGlyph3D; glyph->SetInput(sphere->GetOutput()); glyph->SetSource(cone->GetOutput()); glyph->UseNormal(); glyph->ScaleByVector(); glyph->SetScaleFactor(0.25); spikeMapper = new vtkPolyMapper; spikeMapper->SetInput(glyph->GetOutput()); spikeActor = new vtkActor; spikeActor->SetMapper(spikeMapper); renderer->AddActors(sphereActor); renderer->AddActors(spikeActor); renderer->SetBackground(1,1,1); renWin->SetSize(450,450); // interact with data for(i=1;i<12;i++) { renderer->GetActiveCamera()->Azimuth(15); renWin->Render(); sprintf(fname,"%d.ppm",i); renWin->SetFilename(fname); renWin->SaveImageAsPPM(); } |
A stereoscopic mace - dead link to conserve space Using Tk to control graphical aspects - dead link to conserve space Varying the focal point - dead link to conserve space Buffering rotations for motion blur - dead link to conserve space
|