Friday, March 22, 2013

Graphics Assignment 9

The first part of this assignment was Environment mapping. Creating a new effect which uses cubemap as a texture to produce a good environment map is what I have done in this part of assignment. Basically, I have two meshes, a sphere and a plane both of which use the same material.

Calculating Environment Map:

First, calculate the reflection direction. For that reflection direction which is a Vector3 get the rgb value of the cubemap. That rgb value will have the value of the cube map depending upon the view direction. For instance, looking in +z direction should show the reflection of the +z side of the cube map on the floor beneath.
Using Fresnel effect and Schlik's approximation: The fresnel effect is used to get the amount of reflection and refraction of light by surface. I am using fresnel effect to get more reflection as the angle of view gets more perpendicular to the normal of the surface of reflection. 
Then Lerping the value between the reflected rgb color and the diffuse color for some constant will interpolate the value between these values to give out diffuse color.
Using that diffuse color as a part of the o_color, like before, should show the effect.


Wobbling Effect:

Passing the projected position to the fragment shader will give the 2D image of the screen co-ordinates of the meshes.
Converting that 2D image from -1 and 1 co-ordinates to Directx' co-ordinate system of 0 and 1 and also inverse of the y-axis of the image.
Creating a distortion with a sin modification and adding it to the the above step will give out a distortion per pixel.
Sampling the opaque buffer texture for that distorted co-ordinate gives out the cool wobbly effect.

Pix showing the opaque buffer texture:

No comments:

Post a Comment