Task gpu006: Crystal ball

The task is to implement light refraction in a crystal (glass) sphere using only fragment shader programming. Crystal ball will move on a horizontal surface (table) covered by a color texture, so refraction effects should be visible.

Crystal ball

You can start with the sample09 project from the ogl repository (C++) or with the 086shader project from the grcis repository (C#).

Details

Use precise sphere implementation (a la ray-tracing), "ray-sphere" intersection will be computed in fragment shader together with all optics (refractions, reflections, shadows..). Scene could be reduced to one quad (two triangles), there is no need to draw anything outside of the quad's projection.

Horizontal surface (table) must be covered by appropriate texture in order to see the optical effects. Simple procedural texture (checkerboard) is sufficient.

Optical effects

You must implement at least the first effect, other ones are optional:

  • light refraction from the camera - use index of refraction to compute exact viewing-ray trajectory from the camera, through the crystal ball ("in" and "out" .. two refractions) and the ray hits the surface at last. Of course a ray frequently doesn't intersect the ball at all, it that case a surface point is rendered directly.
  • shadow from one light source - simple sharp shadow, without any caustics. Shadow computation affects only directly rendered surface points.
  • shadow visible through the sphere - shadow is computed on the surface and is visible through crystal ball as well.
  • multiple light sources - shadows from more than one point light sources.

Interactivity

You must add at least some interactivity using keyboard and/or mouse. Ball should be able to move (roll) on the table surface, there is no need to lift it. Momentum (slowing down) would be nice.
Camera movement is optional but recommended, as well as light source animation.
Be inspired by default mouse-handling and keyboard-handling functions present in pilot projects. You can adopt some techniques from your 004 solution. Don't forget to add your new functionality to the F1 key help.

Your solution

Send all your modifications (C#/C++ main and shader file) or complete Visual Studio project. Write a brief document about your ideas and operating manual.

Deadline

Hand in before: 10. 6. 2018

Points

Basis: 18 points for basic optics (two refractions) and necessary interactivity,
bonuses: up to 8 additional points for ball and camera movement,
4 to 8 points for shadows (visible through the sphere or not),
up to 6 more points for another effects (more light sources, interactive change of ball size, index of refraction, ..).

Project

Recommended starting point: Visual Studio project 086shader from the grcis repository or project sample09 from the ogl repository.


Copyright (C) 2013-2018 J. Pelikán, last change: 2019-05-09 17:52:59 +0200 (Thu, 09 May 2019)