We simply supply six images into our program, and then load the textures once before rendering. We can get the other sides of the face by incrementing GL_TEXTURE_CUBE_MAP_POSITIVE_X.įor a static cubemap, this is very easy to implement. We assign the images to each side of the cubemap using the GL_TEXTURE_CUBE_MAP_POSITIVE_X enum, where positive x is the image on the "right" face of the cube, as shown in the following picture. When binded to a newly generated texture, this informs OpenGL that we're going to create a cubemap. In OpenGL, there is an enum called GL_TEXTURE_CUBE_MAP. The image below illustrates this concept. A cubemap made out of provided textures are called static cubemaps, whereas textures provided during run-time are called dynamic cubemaps.Īfter providing a cubemap to the program, the fragment shader computes a normalized direction vector from the origin of the object, and the first fragment color it finds is used to color the object's fragment. What are cubemaps?Ī cubemap is essentially a box made out of six 2D textures, which can be provided to the program or generated at run-time. In the case of a 3D world, this can be done using a type of texture called a cubemap. The after images that appear on the sphere below do not show up in the actual program.Įnvironment mapping is an image-based lighting technique where we can approximate the appearance of a reflective or refractive surface using a texture image. The GIF quality is a bit poor, so please keep that in mind. The finished program looked something like this.
0 Comments
Leave a Reply. |
Details
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |