CS 419/519 -- Winter Quarter 2013

Project #6

Image Manipulation and Displacement Textures

100 Points

Due: February 20


This page was last updated: February 11, 2013


Requirements:

  1. You are flying cross-country in a small aircraft and want to avoid high clouds and rainy weather as much as you can. So, the goal of this project is to manipulate three images to create an interesting way to view weather data.

    The three input images are:
    Enhanced Infrared (EIR) Visible Water Vapor
    sat_ir_enh_us.bmp sat_vis_us.bmp sat_wv_us.bmp

  2. The Enhanced Infrared shows cloud temperatures, which can be converted to cloud heights.
    The Visible shows what the Earth looked like in visible light.
    The Water Vapor shows the concentration of water vapor in the air.

  3. Read the three .bmp files into 2D textures using glman's Texture2D command.

  4. Draw a QuadXZ with a lot of sub-quads.

  5. Convert the Enhanced IR image into per-vertex heights.

  6. Have either of the three images overlay the 3D display, depending on a uBlend slider. The EIR and Visible images should be mapped just as is. The Water Vapor image should have its values turned into a rainbow color scale first, to make the differences in its data more obvious.
    (One way to handle the uBlend slider is to have it go from 0. to 3. and interpret its value as:
    0.-1.Blend EIR and Visible
    1.-2.Blend Visible and Water vapor
    2.-3.Blend Water vapor and EIR

  7. You can have as many other < > uniform variables as you wish.

So far, we have only used texture-sampling from fragment shaders. But, in fact, texture-sampling is enabled in all shader types. Textures are often used from vertex shaders to tell you how much to displace vertices. We will do that here with the EIR image to render the cloud tops. In addition, you will use all three textures to render the colors on the cloud tops.

GLIB file

Use a glib file that looks something like this:


##OpenGL GLIB
Perspective 70
LookAt 0 0 3  0 0 0  0 1 0

Texture2D 6 sat_ir_enh_us.bmp
Texture2D 7 sat_wv_us.bmp
Texture2D 8 sat_vis_us.bmp

Vertex   clouds.vert
Fragment clouds.frag
Program  Clouds                                         \
                uScale <0. ????? ?????>                 \
                uBlend <0. 0. 3.>                       \
                IRUnit  6                               \
                WVUnit  7                               \
                VisUnit 8

Translate 0 -.1 0
Scale 1.25 1. 1.		# because these images are 640x512
QuadXZ 0. 1. ???? ????		# you decide how to tessellate

Turning the Enhanced IR Colors into Cloud Temperatures

You will need to identify where the map is gray, where it is cyan, and where it is blue:



bool
IsGreen( vec3 color )
{
        ?????
}

bool
IsBlue( vec3 color )
{
        ?????
}

bool
IsCyan( vec3 color )
{
        ?????
}

bool
IsGray( vec3 color )
{
        ?????
}

Do not test against, for example, color.r == 0. The texture sampling process often blends colors from the texture. Instead, test against "SMALL" (and you get to decide what SMALL is).

Once you have identified what a general color is, you can turn it into a temparature by interpolating inside the above color scale:


        float temp = 15.;

        if( IsGray(htColor) )
        {
                temp = 51. - 137.5 * htColor.g;
        }
        else if( IsCyan(htColor) )
        {
                temp = -16. - 30. * htColor.g;
        }
        else if( IsBlue(htColor) )
        {
                temp = -79. + 30. * htColor.b;
        }
	else if( IsGreen(htColor) )
	{
		temp = -44.12 - 34.88 * htColor.g;
	}

Turning Temperatures into Cloud Heights

In the troposphere, temperature is linearly related to atmospheric height by the equation:


	float temp = 15. - 6.5*ht;
where temp is in degrees Celsius and ht is in kilometers.

Inverting this gives us height as a function of temperature:


        float ht = ( 15. - temp ) / 6.5;

When you use this, be sure that the height is restricted to being >= 0.

Hints

Extra Credit

+5 points

Make the cloud height surface look more 3D-ish by adding lighting. You will need to compute a normal at each vertex, compute a lighting intensity there, and then pass it through the rasterizer into the fragment shader to modify the color. Use the terrain.frag shader as a starting point for computing the normals.


vec3 color = ...

gl_FragColor = vec4( vLightIntensity*color, 1. );

Add a slider-controlled "fudge-factor" that scales the heights used for the normal calculations without scaling the heights used for geometry display.

The Turn-In Process:

  1. Your turnin will be done at http://engr.oregonstate.edu/teach and will consist of:
    1. All source files (.glib, .vert, .frag)
    2. Your PDF report.

  2. Your PDF report will consist of:
    1. A cover page (name, Project #6)
    2. Source listings (.glib, .vert, .frag)
    3. A prose explanation of what you did.
    4. One or more color images showing what your results were
    5. A link to your video
    6. If you did the Extra Credit, then also include at least one image exhibiting your lighting.

Be sure that your PDF file is turned-in separately (not part of a .zip file) and that it is named some unique variation of your name or login.

This Just In

The weather is constantly changing. Feel free to grab your own images from a different time. You can get the current images here. The small purple text at the top will take you to the different images.
Convert each image from an 8-bit GIF to a 24-bit (RGB) BMP.

Grading:

FeaturePoints
Cloud height displacement40
Able to scale cloud height displacement15
Map EIR image to the cloud tops15
Map Visible image to the cloud tops15
Map Water Vapor image to the cloud tops15
Extra Credit5
Potential Total105