Cube Maps Slide Set 7 01 What is

Cube Maps Slide Set 7. 01

What is a Cube Map? • Six square textures arranged in a cube with sides parallel to the axis planes • Sides are named X+, X-, Y+, Y-, Z+, Z • For the axis which goes through the center of that square 2

Cube Map Faces 3

Sampling a Cube Map • Sampled using a vector giving a direction • The vector length does not matter • gvec 4 texture(gsampler. Cube sampler, vec 3 P); 4

Examples Using Cube Maps • Applying a cube map texture to a shape • Sky box: providing a background to a scene • Reflective objects: reflecting the environment • We will discuss dynamic reflection but do not have an Open. GL example working 5

Example 06 -cube-map • Textures loaded from files in two ways • From. dds file, provided by the text • From six separate files • There is one approach to loading from six separate files that does not work at this point • The position of a fragment in object coordinates is used to pick the texture sample 6

Texture Loaded from. dds File • Function init_cube_texture_from_dds • The vgl. Load. Texture function provided by the authors detects the type of texture being loaded • The function is given a texture unit to use • The function returns a texture name, but we don’t use that • “Direct. Draw Surface” was developed by Microsoft 7

Texture Loaded from Six Files • Function init_cube_texture_from_file • We use an older method of creating and configuring textures • Uses a binding point, similar to the approach for buffers • For each image • Read in image • Store date for associated face • Dispose of the memory used to store the image • Configure the texture 8

Failed Version of Loading • Function init_texture_from_file 2 • This uses newer functions but fails for some reason • We are using the newer functions for plain textures • Have looked online but see nothing that helps • The book writes about this approach • However, the examples provided in source with the text do not use this approach 9

Texture Vector • The object coordinates are what are passed to the vertex shader using the position buffer • The value is passed to the fragment shader which gets interpolated values for each fragment • These should be mathematically accurate • The vector direction is from the middle of the cube through the fragment position 10

Performance • Loading the fjaderholmarna files is quite slow, each image is 2048 by 2048 • The images that show the name and orientation of each face are 512 by 512 and load much faster 11
- Slides: 11