Presentation is loading. Please wait.

Presentation is loading. Please wait.

Reflections from Bumpy Surfaces

Similar presentations


Presentation on theme: "Reflections from Bumpy Surfaces"— Presentation transcript:

1 Reflections from Bumpy Surfaces
GPU Graphics

2 What are we trying to achieve?
Most surfaces are not flat like glass Some of these surfaces still give off reflections, we would like to model this effect

3 Methods for Reflection
Ray Tracing (expensive) Environment Mapping (cube maps) Is an option in the shader 4 model In shader model 3 we can not update the cube map in real time easily Spherical Environment Mapping (with cube map)

4 Cube Map Example Can not be updated in real-time easily
Cube Map pictures taken from Can not be updated in real-time easily Only currently works well for static scenes Shader 4 will allow arrays of textures, will make real-time cube maps easy to implement

5 Simple Cube Map Lookup Reflect incoming View vector around Normal T
Intersect Vr with environment map and perform texture lookup What is the issue here? T N Vr Two points with identical mirror directions will look up the same direction in the environment map V O Works well on the tea pot, works really badly on flat surfaces like floors 2D view of an environment map

6 Spherical Environment Mapping
EM V = view vector, reflected about the point normal at x r V V r P = point on sphere interior using regular cube map r EM V mod reflector O P = intersection between line x + V t and sphere using V = P – O to index cube map based at O x r mod Pg 212 of Advanced Renderman r < infinity V = modified view vector mod Assume the environment map exists on the interior of a sphere with a finite radius and center Define a ray using the position and mirror direction of the point, calculate the ray intersection with environment sphere Use intersection as the environment lookup direction

7 An even simpler case: The planar reflection
Two Pass algorithm Reflected image is rendered to a texture Reflected surface is shaded with reflected texture from first pass Only useful for something like floors

8 Rendering Reflection to Texture
Camera Pos: Er = reflecta(E) Front: Fr = reflecta(F) Right: Rr = reflecta(R) Up: Ur = - reflecta(U) E F R Reflector Plane (A) If we reflect the whole viewpoint reference frame it will cause culling issues If we flip the up vector we do not get the culling issue. Use a culling plane to make sure only objects on the same side as the viewpoint are reflected Essentially altering the view matrix, Model view and projection matrices stay the same Ur Rr Fr 1. Reflect the current viewpoint about the reflector plane. 2. Render the relevant parts of the scene from the new viewpoint. Er

9 Reflection Texture Lookup
For the Perfect Reflector: for_each fragment { Fpos = fragment world position Vr = reflected view matrix Epos = eye space position = Fpos * Vr Ppos = post projective space = Epos * P S = scale translate matrix texture_lookup = (S*P*Vr*Fpos).xy color = tex2d(texture_lookup) } Vr is same from the first pass Post projective space = homogenous clipping space P = projection matrix S moves all coordinates into [-1,1] to [0,1] range (Same techniques as is used with shadow maps) S, P, and Vr are computed on CPU and passed as constants

10 Reflection Texture Lookup
For the Bumpy Reflector N = normal E = viewpoint Er = reflected viewpoint N1 = fragment’s normal V = view vector VN1 = view vector reflected about N1 P = perfect reflector’s reflection P1 = non-perfect reflector’s reflection P1 P h N1 is taken from a texture lookup for the normal map fPos1 is what we want, that is the texture lookup for the reflection VN1 is V reflected around N1 Er is E reflected around the surface N1 N E viewpoint VN V 1 fPos fPos1 Solve for fPos1 Er reflected viewpoint


Download ppt "Reflections from Bumpy Surfaces"

Similar presentations


Ads by Google