reflections and shadows on planar surfaces - ulisboa 05... · reflections and shadows on planar...

9
Reflections and Shadows on Planar Surfaces Reflections and Shadows on Planar Surfaces João Madeiras Pereira [email protected] Animation and 3D Visualisation Course 2010/2011 Reflections - Motivation Not easy to use ray-tracing techniques to simulate real-time reflections By using “tricks” and functionalities provided by the graphic hardware such effects can be achieved by the pipeline-based rendering

Upload: hathuy

Post on 09-Feb-2019

213 views

Category:

Documents


0 download

TRANSCRIPT

Reflections and Shadows on Planar Surfaces

Reflections and Shadows on Planar Surfaces

João Madeiras [email protected]

Animation and 3D Visualisation Course2010/2011

Reflections - Motivation

• Not easy to use ray-tracing techniques to simulate real-time reflections

• By using “tricks” and functionalities provided by the graphic hardware such effects can be achieved by the pipeline-based rendering

Planar reflections• Mirror: Ideal reflector planar surface• Color calculated by following the reflected ray• Alternative: to use reflected geometry through the mirror

plane• The reflected image of the object is simply the object itself,

physically reflected through the mirror plane.

Planar reflections

• Assume plane is y=0• Then apply a mirror scaling matrix: glScalef(1,-1,1);

• Effect:y

Planar reflections

Planar reflections

How should you render?

1) the ground plan polygon into the stencil buffer

2) the scaled (1,1,-1) model, but mask with stencil buffer

3) the ground plane (semi-transparent)4) the unscaled model

Another example

• Instead of the scale-trick, you can reflect the camera position and direction in the plane

• Then render reflection image from there

Imag

e co

urte

syof

Kas

per H

oey

Nie

lsen

Planar Reflections Operations

• plane y=0: use scale S(1,-1,1) to reflect the geometry andlight sources

• Arbitrary reflector plane: translate to origin and rotate inorder to align with y=0, scale; then invert the two initialtransforms

Reflections OpenGL considerations

• The reflector has to be partially transparent• Setting properly backface culling since mirror

scale matrix flips the sense • Avoid that reflected geometry can appear at

places where there is no reflector geometry. How?

• Objects that are on the far side (behind) the mirror should not be reflected. How? To set a user-defined clipping plane with the reflector plane equation oriented in the proper sense.

Reflexões em Superfícies Planas: Exercício

• O exercício consiste em implementar um pequeno programa que permita a navegação dentro de uma cena composta por um conjunto de objectos e um chão capaz de reflectir esses mesmos objectos. Ao observarmos o espaço debaixo do chão, não deve de ser possível ver nenhum objecto.

• Propõem-se as seguintes fases para a realização do algoritmo:

• Fase 1: Desenhar os objectos reflectidos; limitar o desenho dos objectos reflectidos à superfície de reflexão usando o stencil buffer.

• Fase 2: Desenhar a superfície de reflexão (o chão neste caso)

• Fase 3: Desenhar a geometria do Mundo

Planar Shadows

• Provides important visual cues about object placement in the world:- Distances and depth relationships between objects are used by our brain to generate the perception of 3D space

• Occluders cast shadows onto receivers• Study case: receiver is a planar surface

Real-Time Planar Shadows

• Pipeline de visualização tradicional apenas entra em conta com efeitos de reflexão local e não considera oclusões entre uma fonte de luz e objectos que estejam a ser iluminados.

• Algoritmos como ray-tracing ou radiosidade apresentam soluções elegantes para o cálculo de sombras, mas não podem ser executados em tempo real

• Técnicas para calcular sombras em tempo real , baseadas no pipeline de visualização tradicional, recorrendo ao hardware actual:• Sombras Planares • Shadow Volumes• Shadow Maps

Blinn Technique (1988)

• Jim Blinn, "Me and My (Fake) Shadow", IEEE Computer Graphics and Applications, January 1988,algorithm where arbitrary objects cast shadows of onto planar surfaces

• Esta técnica apenas calcula sombras sobre uma única superfície planar previamente escolhida, provenientes de objectos (quaisquer) que se encontrem entre a fonte de luz e a superfície

• Não considera sombras que os objectos possam projectar uns sobre os outros.

Blinn Technique (cont.)• Goal: for a point light source, derive the matrix that

projects the vertices of an arbitrary object (occluder) on to a ground plane (receiver). Light source is located at ‘l’, the vertex to be projected is at ‘v’ and the projected vertex is at ‘p’.

Linear Equation (cont.)• 2 equations system: parametric line and plane

equation

Planar Shadow Projection Matrix

• The linear equation can be converted into a projection matrix M:

• M should be concatenated with the ModelView matrix

Some OpenGL considerations

• Take measures to avoid allowing the projected objects to be rendered beneath the ground. Why?

• Safer method: draw the ground plane first, then draw the projected polygons with the z-buffer off, then render the original geometry. Why?

• Instead of render the shadows with dark color, we could “dark” the existing color in the color buffer by using blending. How?

• Use of stencil buffer:

1) to avoid that projected shadows can fall outside of our ground plane2) to ensure that each pixel is covered at most once (when, why and how?)

• By darking the existing color, shadows can exhibit specular color. WRONG: projected objets should have no illumination

• Possible solution: use the stencil buffer to mark all the shadowpoints on the ground plane, then re-draw the ground with light source turned off: only the ground fragments corresponding to the marked points in the stencill will be shown.