1 of 16

Computer Graphics

Environment mapping

Practice session 10

2 of 16

Reflection

http://www.jholko.com/data/photos/641_1polar_bear_reflection_svalbard.jpg

3 of 16

In game screens

http://media1.gameinformer.com/imagefeed/screenshots/DeusExHumanRevolution/DeusExHumanRevolutionMedia/dx_hr_screenshot_hacking2.jpg

4 of 16

Other kind of in game screens

http://oyster.ignimgs.com/wordpress/stg.ign.com/2014/03/portal.jpg

5 of 16

User interfaces

6 of 16

Game engines

7 of 16

How-to

  1. Render the scene to texture.
  2. Render the scene again and blend the rendered material colors from lighting calculation together with colors sampled from texture.

8 of 16

Javascript exercise

9 of 16

A slight variation (c++ exercise)

  1. Render the scene into framebuffer
  2. Render the scene into framebuffer again and use glBlendFunc to blend with colors already in the framebuffer.

10 of 16

A slight variation - slightly less abstract

  1. Create a stencil in stencil buffer for the reflective object.

11 of 16

Stencil buffer

In the simplest case, the stencil buffer is used to limit the area of rendering(stencling).

12 of 16

A slight variation - slightly less abstract

Except since we are only writing to stencil buffer.

13 of 16

A slight variation - slightly less abstract

2. Draw reflected area

14 of 16

Mirroring

xz plane as plane of reflection

glm::scale(model, glm::vec3(1.0, -1.0, 1.0));

http://image.tutorvista.com/cms/images/38/horizontal-and-vertical-reflection.jpg

15 of 16

A slight variation - slightly less abstract

3. Together with the stencil we created

16 of 16

A slight variation - slightly less abstract

Blend together with semi transparent floor and add rest of the scene without blending.