OpenGL Demos
OpenGL Misc
MSG Board
Megabyte Softworks
C++, OpenGL, Algorithms

Current series: OpenGL 3.3
(Return to list of OpenGL 3.3 tutorials)

Download (27.17 MB)
5311 downloads. 18 comments
21.) Multilayered Terrain

Hello guys! This is the 21-th tutorial from my series, and it will teach you how to render terrains using heightmaps loaded from regular grayscale images. Our terrain will have multiple (three) layers of textures on it, which transition smoothly between selves. Not only that, we will also use a special "path" texture for describing path, pavement (or call it how you want ) on that terrain. This is the longest article I have ever written, as this topic is pretty wide and there are lots of things asking for explanations . But if you go through it, you will receive like 1,000,000 Exp in OpenGL . So let's go.


Heightmap is in most common sense a 2D grid of values, each value meaning height in that point. Our ultimate goal is to read these heights from somewhere, create some rendering data from them, and then render the heightmap in 3D. I briefly explained heightmaps in Tutorial 5 - Indexed Drawing, so you can also have a look there.

The question now is - where and how to store these values? And you probably already know the answer - the easiest way to store heights is to create a heightmap image, where intensity (shade of grey) will represent height, with white intensity (255) being the maximum possible height and black (0) being the minimum possible height. This way, we can easily store 255 different heights, which is (for now) more than enough. The heightmap I'm using in this tutorial looks like this:

(The heightmap was created by me, in my own world editor, where you can raise hills with a circle, so that's why you can see so many circles in that heightmap)

But the point is, that these white circles are highest places in the map, and black spots are the lowest. If we stretch this small image over a 3D plane and then raise the vertices according to their corresponding heights, we will get our result - 3D heightmap.

Loading The Heightmap

As always, I will create a wrapper class, that will contain heightmap loading, rendering, releasing etc. This class is called CMultilayeredHeightmap. Here it is:

class CMultiLayeredHeightmap
   static bool LoadTerrainShaderProgram();
   static void ReleaseTerrainShaderProgram();

   bool LoadHeightMapFromImage(string sImagePath);
   void ReleaseHeightmap();

   void RenderHeightmap();

   void SetRenderSize(float fQuadSize, float fHeight);
   void SetRenderSize(float fRenderX, float fHeight, float fRenderZ);

   int GetNumHeightmapRows();
   int GetNumHeightmapCols();

   static CShaderProgram* GetShaderProgram();


   UINT uiVAO;

   bool bLoaded;
   bool bShaderProgramLoaded;
   int iRows;
   int iCols;

   glm::vec3 vRenderScale;

   CVertexBufferObject vboHeightmapData;
   CVertexBufferObject vboHeightmapIndices;

   static CShaderProgram spTerrain;
   static CShader shTerrainShaders[NUMTERRAINSHADERS];

Let's analyze the function LoadHeightMapFromImage(). I will paste it here by parts, and we will analyze each part. So the function begins like this:

bool CMultiLayeredHeightmap::LoadHeightMapFromImage(string sImagePath)
      bLoaded = false;
   FIBITMAP* dib(0);

   fif = FreeImage_GetFileType(sImagePath.c_str(), 0); // Check the file signature and deduce its format

   if(fif == FIF_UNKNOWN) // If still unknown, try to guess the file format from the file extension
      fif = FreeImage_GetFIFFromFilename(sImagePath.c_str());

   if(fif == FIF_UNKNOWN) // If still unknown, return failure
      return false;

   if(FreeImage_FIFSupportsReading(fif)) // Check if the plugin has reading capabilities and load the file
      dib = FreeImage_Load(fif, sImagePath.c_str());
      return false;

   BYTE* bDataPointer = FreeImage_GetBits(dib); // Retrieve the image data
   iRows = FreeImage_GetHeight(dib);
   iCols = FreeImage_GetWidth(dib);

   // We also require our image to be either 24-bit (classic RGB) or 8-bit (luminance)
   if(bDataPointer == NULL || iRows == 0 || iCols == 0 || (FreeImage_GetBPP(dib) != 24 && FreeImage_GetBPP(dib) != 8))
      return false;

   // How much to increase data pointer to get to next pixel data
   unsigned int ptr_inc = FreeImage_GetBPP(dib) == 24 ? 3 : 1;
   // Length of one row in data
   unsigned int row_step = ptr_inc*iCols;

   // ...

The first part is almost identical to part where we're loading textures. We just use FreeImage library to load image data, deduce its properties - whether it's 24-bit RGB image or 8-bit intensity image (exactly what we need). So there are few variables, that are interesting to us - bDataPointer is the pointer in memory to image data, in a row-major order (the image is stored as rows from top to bottom). iRows, iCols is the number of rows and columns of our heightmap, i.e. the size of image, i.e. width and height of the image. So it means, that our heightmap will have exactly iRows*iCols vertices in it.

Also notice last two rows with two variables:

Knowing the meaning of all important variables and data of image loaded in memory, we can move on to building OpenGL objects of it.

bool CMultiLayeredHeightmap::LoadHeightMapFromImage(string sImagePath)
   // ...

   // All vertex data are here (there are iRows*iCols vertices in this heightmap), we will get to normals later
   vector< vector< glm::vec3> > vVertexData(iRows, vector<glm::vec3>(iCols));
   vector< vector< glm::vec2> > vCoordsData(iRows, vector<glm::vec2>(iCols));

   float fTextureU = float(iCols)*0.1f;
   float fTextureV = float(iRows)*0.1f;

   FOR(i, iRows)
      FOR(j, iCols)
         float fScaleC = float(j)/float(iCols-1);
         float fScaleR = float(i)/float(iRows-1);
         float fVertexHeight = float(*(bDataPointer+row_step*i+j*ptr_inc))/255.0f;
         vVertexData[i][j] = glm::vec3(-0.5f+fScaleC, fVertexHeight, -0.5f+fScaleR);
         vCoordsData[i][j] = glm::vec2(fTextureU*fScaleC, fTextureV*fScaleR);

   // ...

This part ain't much difficult - what we do here is create a VBO in first line, adn then we want to precalculate vertex positions and its texture coordinates. What exactly we do is that we stretch heightmap points into range <-0.5, 0.5> on X and Z axis uniformly and <0.0, 1.0> on Y axis. The picture will surely help you to understand what I'm doing:

We wanna do it this way, because then we can easily scale whole heightmap to get desired render sizes. Evey single point in this grid is one height value, ranging from 0.0 to 1.0, which can be easily scaled to desired render height. And because it's in <-0.5, 0.5>, we will get the thing centered, for easier positioning of heightmap.

Another thing we are calculating here are texture coordinates. What we need to think through is how many times should we map a texture across heightmap. Well it depends on size of texture and things like that, but for this tutorial, I decided, that every 10 rows and every 10 columns we want to have one instance of texture in that dimension. That's why you can see two variables: fTextureU and fTextureV, which both represent how many times should we map the texture across respective dimension.

This was pretty easy part, only some linear calculations. The main concern in generating heightmap is calculating its normals.


Really, why?

OK, what's the problem with normals? First, let's think through what we have done so far. We have calculated only vertices with their texture coordinates. Let's imagine, we want to render heightmap now, without normals. How shall we do it? The answer is Indexed Rendering, as we did in Tutorial 5 - Indexed Drawing (why didn't I name it rendering instead? ). I will try to remind you this stuff here, but just briefly. Every row of quads in heightmap will be rendered using triangle strips. At the end of each row, we use primitive restart index to start a new bunch of triangle strips. This picture will help you to imagine it and understand - pay attention to the order of vertices, because this is the way I'm using:

As you can see, the rendering and wireframe model of heightmap is made up of triangles. And what we can do is to calculate the normal of each triangle. Yea, that's right. But does that help us? Yea, it does, but it isn't enough - every vertex of heightmap is surrounded by multiple triangles, so the normal of vertex should be calculated from normals of all surrounding triangles! In this tutorial, I just sum all normals of surrounding triangles, and then normalize final vector. Result looks more than fine.

In order to do so, I precalculate triangle normals first to have them all in one place. After this, I can proceed with calculating vertex normals. So we need to calculate normals for each quad in heightmap. There are (iRows-1)*(iCols-1) quads in heightmap. Every quad has two triangles. Therefore we need to calculate two normals per quad. Let's number them normal 0 and normal 1, as you can see here:

So what we gotta do is to precalculate these normals with consistent ordering of triangles. This code does exactly that:

bool CMultiLayeredHeightmap::LoadHeightMapFromImage(string sImagePath)
   // ...

   // Normals are here - the heightmap contains ( (iRows-1)*(iCols-1) quads, each one containing 2 triangles, therefore array of we have 3D array)
   vector< vector<glm::vec3> > vNormals[2];
   FOR(i, 2)vNormals[i] = vector< vector<glm::vec3> >(iRows-1, vector<glm::vec3>(iCols-1));

   FOR(i, iRows-1)
      FOR(j, iCols-1)
         glm::vec3 vTriangle0[] = 
         glm::vec3 vTriangle1[] = 

         glm::vec3 vTriangleNorm0 = glm::cross(vTriangle0[0]-vTriangle0[1], vTriangle0[1]-vTriangle0[2]);
         glm::vec3 vTriangleNorm1 = glm::cross(vTriangle1[0]-vTriangle1[1], vTriangle1[1]-vTriangle1[2]);

         vNormals[0][i][j] = glm::normalize(vTriangleNorm0);
         vNormals[1][i][j] = glm::normalize(vTriangleNorm1);

   // ...

When we're done with it, we can calculate final normals from this data. Let's take one vertex into consideration. Which triangles are adjacent to it? Image will help you to see it:

Now, we need to sum normals of these triangles, and then normalize final vector. Code below is doing this final normal calculation:

bool CMultiLayeredHeightmap::LoadHeightMapFromImage(string sImagePath)
   // ...

   vector< vector<glm::vec3> > vFinalNormals = vector< vector<glm::vec3> >(iRows, vector<glm::vec3>(iCols));

   FOR(i, iRows)
      FOR(j, iCols)
      // Now we wanna calculate final normal for [i][j] vertex. We will have a look at all triangles this vertex is part of, and then we will make average vector
      // of all adjacent triangles' normals

      glm::vec3 vFinalNormal = glm::vec3(0.0f, 0.0f, 0.0f);

      // Look for upper-left triangles
      if(j != 0 && i != 0)
         FOR(k, 2)vFinalNormal += vNormals[k][i-1][j-1];
      // Look for upper-right triangles
      if(i != 0 && j != iCols-1)vFinalNormal += vNormals[0][i-1][j];
      // Look for bottom-right triangles
      if(i != iRows-1 && j != iCols-1)
         FOR(k, 2)vFinalNormal += vNormals[k][i][j];
      // Look for bottom-left triangles
      if(i != iRows-1 && j != 0)
         vFinalNormal += vNormals[1][i][j-1];
      vFinalNormal = glm::normalize(vFinalNormal);

      vFinalNormals[i][j] = vFinalNormal; // Store final normal of j-th vertex in i-th row

   // ...

Putting data together for rendering

With all vertex data calculated, we can finally start adding them, vertex-by-vertex, to our first VBO:

bool CMultiLayeredHeightmap::LoadHeightMapFromImage(string sImagePath)
   // ...

   // First, create a VBO with only vertex data
   vboHeightmapData.CreateVBO(iRows*iCols*(2*sizeof(glm::vec3)+sizeof(glm::vec2))); // Preallocate memory
   FOR(i, iRows)
      FOR(j, iCols)
         vboHeightmapData.AddData(&vVertexData[i][j], sizeof(glm::vec3)); // Add vertex
         vboHeightmapData.AddData(&vCoordsData[i][j], sizeof(glm::vec2)); // Add tex. coord
         vboHeightmapData.AddData(&vFinalNormals[i][j], sizeof(glm::vec3)); // Add normal

   // ...

Then we create our second VBO, that stores indices. Note, that primitive restart index is index witha value of iRows*iCols, because it's the first free number, as vertices are indexed from 0 to iRows*iCols -1 , inclusive. If you don't know how to that indexed rendering, I will redirect you again to Tutorial 5 - Indexed Drawing for explanation how this works:

bool CMultiLayeredHeightmap::LoadHeightMapFromImage(string sImagePath)
   // ...

   int iPrimitiveRestartIndex = iRows*iCols;
   FOR(i, iRows-1)
      FOR(j, iCols)
         FOR(k, 2)
         int iRow = i+(1-k);
         int iIndex = iRow*iCols+j;
         vboHeightmapIndices.AddData(&iIndex, sizeof(int));
      // Restart triangle strips
      vboHeightmapIndices.AddData(&iPrimitiveRestartIndex, sizeof(int));

   glGenVertexArrays(1, &uiVAO);
   // Attach vertex data to this VAO

   // Vertex positions
   glVertexAttribPointer(0, 3, GL_FLOAT, GL_FALSE, 2*sizeof(glm::vec3)+sizeof(glm::vec2), 0);
   // Texture coordinates
   glVertexAttribPointer(1, 2, GL_FLOAT, GL_FALSE, 2*sizeof(glm::vec3)+sizeof(glm::vec2), (void*)sizeof(glm::vec3));
   // Normal vectors
   glVertexAttribPointer(2, 3, GL_FLOAT, GL_FALSE, 2*sizeof(glm::vec3)+sizeof(glm::vec2), (void*)(sizeof(glm::vec3)+sizeof(glm::vec2)));

   // And now attach index data to this VAO
   // Here don't forget to bind another type of VBO - the element array buffer, or simplier indices to vertices

   bLoaded = true// If get here, we succeeded with generating heightmap
   return true;

And that's all from loading! Now everything is prepared, rendering is just a matter of few calls:

void CMultiLayeredHeightmap::RenderHeightmap()

   spTerrain.SetUniform("fRenderHeight", vRenderScale.y);
   spTerrain.SetUniform("fMaxTextureU", float(iCols)*0.1f);
   spTerrain.SetUniform("fMaxTextureV", float(iRows)*0.1f);

   spTerrain.SetUniform("HeightmapScaleMatrix", glm::scale(glm::mat4(1.0), glm::vec3(vRenderScale)));

   // Now we're ready to render - we are drawing set of triangle strips using one call, but we g otta enable primitive restart

   int iNumIndices = (iRows-1)*iCols*2 + iRows-1;
   glDrawElements(GL_TRIANGLE_STRIP, iNumIndices, GL_UNSIGNED_INT, 0);

The Terrain Shader Program

Yea, calling render function was pretty short. But if we really want our terrain to have multiple layers of texture, we need to write a shader program for it. And that's the second part of this tutorial, because it's now a whole another thing. But it's really not difficult.

What we gotta do here is to render heightmap with texture according to its height.

Vertex Shader

Because our heightmap data are constructed in unit size, so that heightmap can be easily resizeable, first thing we will need to send to shader somehow is rendering size of heightmap. To do that, we simply send a scale matrix to our vertex shader. This is what our vertex shader looks like:

#version 330

uniform struct Matrices
   mat4 projMatrix;
   mat4 modelMatrix;
   mat4 viewMatrix;                                                                           
   mat4 normalMatrix;
} matrices;

layout (location = 0) in vec3 inPosition;
layout (location = 1) in vec2 inCoord;
layout (location = 2) in vec3 inNormal;

smooth out vec2 vTexCoord;
smooth out vec3 vNormal;
smooth out vec3 vWorldPos;
smooth out vec4 vEyeSpacePos;

uniform mat4 HeightmapScaleMatrix;

void main()
  vec4 inPositionScaled = HeightmapScaleMatrix*vec4(inPosition, 1.0);
  mat4 mMVP = matrices.projMatrix*matrices.viewMatrix*matrices.modelMatrix;
  gl_Position = mMVP*inPositionScaled;
  vEyeSpacePos = matrices.viewMatrix*matrices.modelMatrix*vec4(inPosition, 1.0);
  vTexCoord = inCoord;
   vNormal = inNormal;
  vec4 vWorldPosLocal = matrices.modelMatrix*inPositionScaled;
   vWorldPos = vWorldPosLocal.xyz;

The uniform mat4 HeightmapScaleMatrix; is our scale matrix, which is set before rendering heightmap. Before we proceed with classic transformation, we will multiply incoming vertex position with our scale matrix and store it in inPositionScaled. Then, we work with everything as usual.

Fragment Shader

Fragment shader is the last important thing, that requires attention. The purpose of it is to have multiple textures in multiple samplers, and then map them to our terrain according to its height. For this tutorial, I decided to go for 3 different textures when mapping terrain. These are ranges:

To visualize this, here is a helpful picture:

For the purpose of this tutorial, the range values are hardcoded in fragment shader. Of course, you may extend this all, and create some uniform array of ranges, to be able to change things at runtime. So finally, here is the first part of fragment shader, that calculates proper color from these three textures. These textures can be accessed with gSampler[0], gSampler[1] and gSampler[2]:

#version 330

smooth in vec2 vTexCoord;
smooth in vec3 vNormal;
smooth in vec3 vWorldPos;
smooth in vec4 vEyeSpacePos;

uniform sampler2D gSampler[5];
uniform sampler2D shadowMap;

uniform vec4 vColor;

#include "dirLight.frag"
uniform DirectionalLight sunLight;
uniform float fRenderHeight;
uniform float fMaxTextureU;
uniform float fMaxTextureV;

out vec4 outputColor;

void main()
   vec3 vNormalized = normalize(vNormal);
   vec4 vTexColor = vec4(0.0);
   float fScale = vWorldPos.y/fRenderHeight;

   const float fRange1 = 0.15f;
   const float fRange2 = 0.3f;
   const float fRange3 = 0.65f;
   const float fRange4 = 0.85f;

   if(fScale >= 0.0 && fScale <= fRange1)vTexColor = texture2D(gSampler[0], vTexCoord);
   else if(fScale <= fRange2)
      fScale -= fRange1;
      fScale /= (fRange2-fRange1);
      float fScale2 = fScale;
      fScale = 1.0-fScale; 
      vTexColor += texture2D(gSampler[0], vTexCoord)*fScale;
      vTexColor += texture2D(gSampler[1], vTexCoord)*fScale2;
   else if(fScale <= fRange3)vTexColor = texture2D(gSampler[1], vTexCoord);
   else if(fScale <= fRange4)
      fScale -= fRange3;
      fScale /= (fRange4-fRange3);
      float fScale2 = fScale;
      fScale = 1.0-fScale; 
      vTexColor += texture2D(gSampler[1], vTexCoord)*fScale;
      vTexColor += texture2D(gSampler[2], vTexCoord)*fScale2;      
   else vTexColor = texture2D(gSampler[2], vTexCoord);

   // ...


Notice, that everytime we are in transitioning part, we calculate scale (fScale variable). Then we add fScale much of one texture, and 1-fScale much of second texture. Have a look at these lines, and think about them until you understand them for 100% - they are the core part of this fragment shader.

Adding Path / Pavement

Everything is looking smooth and nice now. But what if I wanted to create a pavement going through arbitrary places? And yes, I do want to create one, so we will add additional functionality to the fragment shader, that will handle paths.

Our path needs two things - path texture, which will be mapped to places with path, and path map, which will tell fragment shader, where to put path. Our path map in this tutorial looks like this:

Our path texture, which is pure sand, is stored in gSampler[3], and path map is stored in gSampler[4]. What we need to do now is to map the path map texture over the whole heightmap. But the texture coordinates, that our fragment shader got from vertex shader are scaled according to number of columns and rows in the heightmap. So we need to rescale them first, and that's why I set uniform variables fMaxTextureU and fMaxTextureV, that tell us, what is the maximum texture coordinate value in each dimension. With this, we can easily find a path texture coordinate:

#version 330

smooth in vec2 vTexCoord;
smooth in vec3 vNormal;
smooth in vec3 vWorldPos;
smooth in vec4 vEyeSpacePos;

uniform sampler2D gSampler[5];
uniform sampler2D shadowMap;

uniform vec4 vColor;

#include "dirLight.frag"
uniform DirectionalLight sunLight;
uniform float fRenderHeight;
uniform float fMaxTextureU;
uniform float fMaxTextureV;

out vec4 outputColor;

void main()
   // ...
   vec2 vPathCoord = vec2(vTexCoord.x/fMaxTextureU, vTexCoord.y/fMaxTextureV);
   vec4 vPathIntensity = texture2D(gSampler[4], vPathCoord); // Black color means there is a path
   fScale = vPathIntensity.x;
   vec4 vPathColor = texture2D(gSampler[3], vTexCoord); 
   vec4 vFinalTexColor = fScale*vTexColor+(1-fScale)*vPathColor;

   vec4 vMixedColor = vFinalTexColor*vColor;
   vec4 vDirLightColor = GetDirectionalLightColor(sunLight, vNormal);

   outputColor = vMixedColor*(vDirLightColor);

Let's go through these lines:

The rest of the fragment shader is just applying directional light and outputting color. Hope this simple explanation helped you to understand it all. But I really encourage you to think through the whole fragment shader, analyze it, and really understand it, because this will raise your skills to another level and you will be able to apply this knowledge in many places .

Now before rendering our heightmap (calling RenderHeightmap() function, we only need to bind textures to different texture units and samplers. Here is the chunk of code that does this in RenderScene():

void RenderScene(LPVOID lpParam)
   // ...

   // Now we're going to render terrain

   hmWorld.SetRenderSize(300.0f, 35.0f, 300.0f);
   CShaderProgram* spTerrain = CMultiLayeredHeightmap::GetShaderProgram();


   spTerrain->SetUniform("matrices.projMatrix", oglControl->GetProjectionMatrix());
   spTerrain->SetUniform("matrices.viewMatrix", cCamera.Look());

   // We bind all 5 textures - 3 of them are textures for layers, 1 texture is a "path" texture, and last one is
   // the places in heightmap where path should be and how intense should it be
   FOR(i, 5)
      char sSamplerName[256];
      sprintf(sSamplerName, "gSampler[%d]", i);
      spTerrain->SetUniform(sSamplerName, i);

   // ... set some uniforms
   spTerrain->SetModelAndNormalMatrix("matrices.modelMatrix", "matrices.normalMatrix", glm::mat4(1.0));
   spTerrain->SetUniform("vColor", glm::vec4(1, 1, 1, 1));

   dlSun.SetUniformData(spTerrain, "sunLight");

   // ... and finally render heightmap

   // ...


This is how our terrain looks like:

Pretty neat isn't it? Of course, don't forget to load heightmap first in InitScene function, and also release it in ReleaseScene function. I'm pretty sure that graphics card drivers can deal with not releasing things, but why make their lives harder?

The heightmap name is consider_this_question.bmp. I forgot to change it before I uploaded tutorial, so I let it there for now . There's story behind this name. When I was coding these things, the Dream Theater (my favorite band) album came out, and Consider this question is the first lyrical part of Illumination Theory song . So that's why, in case you are wondering .

I'm not sure what next tutorial is gonna be about, but probably one of these things:

But I guess that the ordering I used here will be real ordering for next 3 tutorials. Farewell.

Download (27.17 MB)
5311 downloads. 18 comments


Enter the text from image:


KamorkasOi (kamorka@femdomfree.net) on 02.08.2017 17:50:19
Hot Girls Fuck Free , free indian porn tube video video dronk girls having sex interracial sex pic and video .
Huge Titty Fuck Video - hot teen latin suck sex black girls get fuck .
Blonde College Girl Fuck Real Teacher facial cumshot sex movie doctor exam movie pelvic orgasm .
<a href=http://trg.co.th/forum/index.php?topic=29889.new#new>xxx free latin</a>
<a href=http://cs-headshooter.cba.pl/viewtopic.php?p=10025#10025>jenni rivera sex movie</a>
<a href=http://growmarley.com/foro/index.php?topic=39920.new#new>free porn movie server</a>
<a href=http://funilariaepintura.net/viewtopic.php?f=9&t=67&p=2802#p2802>sexy blonde gangbang porn hub</a>
<a href=http://www.priceshock.co.uk/viewtopic.php?p=52544#52544>handjob porn hub</a>

Petite Big Boobs Girls Hardcore Porn : skin heads fuck black girls french lesbians xxx sex girl on girl bondage sex .
Porn Oldest Mature Movie full length closeup video first homemade sex movie les teen my exgirlfriend porn .
Video Sex Em Hd - mother fuck free movie stevens pornstar free video .
<a href=http://clprn.pro/053/puma-swede-st-anal-video.html>puma swede st anal video</a><a href=http://clprn.pro/058/porn-star-cumshot-compilation.html>porn star cumshot compilation</a><a href=http://clprn.pro/098/best-porn-website.html>best porn website</a><a href=http://clprn.pro/011/porn-celibrity-movie.html>porn celibrity movie</a><a href=http://clprn.pro/056/long-blonde-hair-sex-video.html>long blonde hair sex video</a><a href=http://clprn.pro/019/real-sex-wife.html>real sex wife</a><a href=http://clprn.pro/045/sex-videos-grandmas.html>sex videos grandmas</a><a href=http://clprn.pro/042/boy-sey-xxx.html>boy sey xxx</a><a href=http://clprn.pro/025/german-porn-video.html>german porn video</a><a href=http://clprn.pro/051/movie-tight-pussy-squirting.html>movie tight pussy squirting</a><a href=http://clprn.pro/033/free-sex-videos-beautiful-girls.html>free sex videos beautiful girls</a><a href=http://clprn.pro/043/private-porn-classic.html>private porn classic</a><a href=http://clprn.pro/051/rough-dirty-sex-movie.html>rough dirty sex movie</a><a href=http://clprn.pro/025/ebony-and-white-sex-video.html>ebony and white sex video</a><a href=http://clprn.pro/096/brazzers-video-mature-sex.html>brazzers video mature sex</a><a href=http://clprn.pro/028/classic-fucked-milf.html>classic fucked milf</a><a href=http://clprn.pro/086/hardcore-sexy-ass.html>hardcore sexy ass</a><a href=http://clprn.pro/097/africa-black-porn.html>africa black porn</a><a href=http://clprn.pro/020/panty-jobs-sex-video.html>panty jobs sex video</a><a href=http://clprn.pro/032/porn-office-sex-video.html>porn office sex video</a><a href=http://clprn.pro/002/college-girls-ass-fucking.html>college girls ass fucking</a><a href=http://clprn.pro/007/hollywood-sex-videos-film.html>hollywood sex videos film</a><a href=http://clprn.pro/048/black-lesbians-twat-cum.html>black lesbians twat cum</a><a href=http://clprn.pro/074/wife-fuck-when-told.html>wife fuck when told</a><a href=http://clprn.pro/087/women-flash-xxx-video.html>women flash xxx video</a><a href=http://clprn.pro/067/couple-seduce-teen-melanie-video.html>couple seduce teen melanie video</a><a href=http://clprn.pro/032/casting-couch-recording-sex-video.html>casting couch recording sex video</a><a href=http://clprn.pro/033>black girl blowjob cumshot</a><a href=http://clprn.pro/052/sex-toy-bdsm.html>sex toy bdsm</a><a href=http://clprn.pro/021/people-having-sex-anal-and-vagina.html>people having sex anal and vagina</a><a href=http://clprn.pro/052>sex of english</a><a href=http://clprn.pro/069/male-fuck-movie.html>male fuck movie</a><a href=http://clprn.pro/079/british-porn-film-free.html>british porn film free</a><a href=http://clprn.pro/062/free-porn-star-gallery-shoes.html>free porn star gallery shoes</a><a href=http://clprn.pro/096/peeing-black-girls.html>peeing black girls</a><a href=http://clprn.pro/024/map.html>super hot mom porn movies</a><a href=http://clprn.pro/002/fuck-my-slut-girlfriend.html>fuck my slut girlfriend</a><a href=http://clprn.pro/099/hardcore-hot-emo-porn.html>hardcore hot emo porn</a><a href=http://clprn.pro/083/babe-sex-video-free.html>babe sex video free</a><a href=http://clprn.pro/098/kappa-delta-sex-movie.html>kappa delta sex movie</a><a href=http://clprn.pro/011/teen-latin-video-xxx.html>teen latin video xxx</a><a href=http://clprn.pro/068/hard-corn-porn-free-video.html>hard corn porn free video</a><a href=http://clprn.pro/078/dumb-drunk-girls-sex.html>dumb drunk girls sex</a><a href=http://clprn.pro/016/xxx-the-movie.html>xxx the movie</a><a href=http://clprn.pro/024/aged-woman-orgasm-vieos.html>aged woman orgasm vieos</a><a href=http://clprn.pro/094/thais-and-anal-sex.html>thais and anal sex</a><a href=http://clprn.pro/044/lesbian-pussy-licking-orgasm.html>lesbian pussy licking orgasm</a><a href=http://clprn.pro/054/girlfriend-first-anal-movie.html>girlfriend first anal movie</a><a href=http://clprn.pro/069/free-porn-video-blowjob-tube.html>free porn video blowjob tube</a><a href=http://clprn.pro/059/fat-pussy-porn-gallery.html>fat pussy porn gallery</a><a href=http://clprn.pro/064/classic-seks-film.html>classic seks film</a><a href=http://clprn.pro/006/movie-sex-orgy-slut.html>movie sex orgy slut</a><a href=http://clprn.pro/044/girls-lesbian-training.html>girls lesbian training</a><a href=http://clprn.pro/035/pono-sex.html>pono sex</a><a href=http://clprn.pro/031/vibrators-for-anal-orgasm.html>vibrators for anal orgasm</a><a href=http://clprn.pro/084/round-ass-porn-gallery.html>round ass porn gallery</a><a href=http://clprn.pro/036/hidden-camera-sex-video-pings-india.html>hidden camera sex video pings india</a><a href=http://clprn.pro/070/free-milf-ass-fuck-video.html>free milf ass fuck video</a><a href=http://clprn.pro/063/creampie-anal-movie.html>creampie anal movie</a><a href=http://clprn.pro/063/hillbilly-fuck-video.html>hillbilly fuck video</a><a href=http://clprn.pro/046/girlfriend-handjob-tube-movie.html>girlfriend handjob tube movie</a><a href=http://clprn.pro/015/orgasm-every-day.html>orgasm every day</a><a href=http://clprn.pro/083/map.html>oral blowjob free movie</a><a href=http://clprn.pro/005/woman-and-woman-make-love.html>woman and woman make love</a><a href=http://clprn.pro/032/girl-woman-lesbian.html>girl woman lesbian</a><a href=http://clprn.pro/080/creampie-sex-movies.html>creampie sex movies</a><a href=http://clprn.pro/033/hot-blondes-lesbian-porn.html>hot blondes lesbian porn</a><a href=http://clprn.pro/083/teen-sluts-fuck-nude.html>teen sluts fuck nude</a><a href=http://clprn.pro/035/teen-in-medical-bondage-pic.html>teen in medical bondage pic</a><a href=http://clprn.pro/057/male-virgin-sex-movie.html>male virgin sex movie</a><a href=http://clprn.pro/046/sex-with-step-sister-video.html>sex with step sister video</a><a href=http://clprn.pro/057/rate-xxx-hardcore-video.html>rate xxx hardcore video</a><a href=http://clprn.pro/095/moms-hardcore-pic.html>moms hardcore pic</a><a href=http://clprn.pro/033/sex-vedios-xnxx-vedios.html>sex vedios xnxx vedios</a><a href=http://clprn.pro/038/por-sex-video.html>por sex video</a><a href=http://clprn.pro/046/blow-job-clips-free.html>blow job clips free</a><a href=http://clprn.pro/051/asian-girl-suck-big-black-cock.html>asian girl suck big black cock</a><a href=http://clprn.pro/089/hard-fuck-porn-video.html>hard fuck porn video</a><a href=http://clprn.pro/064/oral-sex-on-top.html>oral sex on top</a><a href=http://clprn.pro/042/brooke-young-sex.html>brooke young sex</a><a href=http://clprn.pro/006/kimberly-kane-sex-video.html>kimberly kane sex video</a><a href=http://clprn.pro/027/amateur-husband-and-wife-fuck-movie.html>amateur husband and wife fuck movie</a><a href=http://clprn.pro/029/indian-sex-xx-movie.html>indian sex xx movie</a><a href=http://clprn.pro/046/map.html>movie raven riley anal</a><a href=http://clprn.pro/094/granny-fucks-porn.html>granny fucks porn</a><a href=http://clprn.pro/078/amateur-wife-fucked-till-orgasm.html>amateur wife fucked till orgasm</a><a href=http://clprn.pro/028/porn-erotic-sex.html>porn erotic sex</a><a href=http://clprn.pro/005/frre-sexxxx.html>frre sexxxx</a><a href=http://clprn.pro/074/model-scam-sex-movie.html>model scam sex movie</a><a href=http://clprn.pro/020/sex-worker-movie.html>sex worker movie</a><a href=http://clprn.pro/052/watch-free-brazilian-porn.html>watch free brazilian porn</a><a href=http://clprn.pro/079/asian-lesbian-office-movie.html>asian lesbian office movie</a><a href=http://clprn.pro/099/free-asian-blow-job.html>free asian blow job</a><a href=http://clprn.pro/063/hard-core-adult-sex.html>hard core adult sex</a><a href=http://clprn.pro/080/download-india-xxx-com.html>download india xxx com</a><a href=http://clprn.pro/096/granny-having-sex-video.html>granny having sex video</a><a href=http://clprn.pro/096/forceful-anal-porn.html>forceful anal porn</a><a href=http://clprn.pro/020/gag-fucking-porn-video.html>gag fucking porn video</a><a href=http://clprn.pro/035/italia-amateur-anal.html>italia amateur anal</a><a href=http://clprn.pro/060/map.html>youtube like porn video</a><a href=http://clprn.pro/008/free-pornstar-hardcore-movie.html>free pornstar hardcore movie</a><a href=http://clprn.pro/026/bride-fuck-pic.html>bride fuck pic</a>
3058zVab (54db8sxylq@yahoo.com) on 15.12.2015 15:53:05
Hola Javier, Este1s usando de forma <a href="http://ovlfumnpr.com">inrtrcecoa</a> mysql_num_rows(). Esta funcif3n regresa el nfamero de filas en un resultado (despue9s de hacer un SELECT por ejemplo). Esta funcif3n "no cuenta", solo devuelve un valor del resulset generado despue9s del SELECT.En tu primer ejemplo, es obvio que te lleve me1s tiempo, ya que lo que te este1 consumiendo tiempo es la ejecucif3n de la consulta SELECT y no la funcif3n mysql_num_rows(). Verificalo cambiando la lednea $fInicio=microtime(true); despue9s del mysql_query() Siempre que quieras contar fila no lo hagas con un SELECT y despue9s un mysql_num_rows() porque, si bien arroja el mismo resultado, esto es ineficiente. La sentencia SQL COUNT este1 disef1ada para eso, para contar. Por eso es mucho me1s re1pido que un SELECT, porque un SELECT * recupera todos los datos de la tabla y te los trae a tu script (consumiendo me1s tiempo y obviamente memoria).Saludos,Pablo
notfunnyguy on 06.12.2016 08:51:08
learn english dude
koZuqgvm5Z5Z (73mkh8hw6@hotmail.com) on 11.12.2015 21:57:08
I've been using Flash for a few years, but I am shy about picking up Molehill bscuaee I expect it to have a huge learning curve. How long did it take for you to make this demo? Did you feel your learning curve was average for a new technology, or did you have to slave away at it to grasp its concepts?
Guest on 23.11.2015 16:07:53
Hi, I tried to implement your terrain, but I face off a several issues.
In my world terrain is inverted. I changed indexing from
int iRow = i+(1-k) to int iRow = i+k
and it shows fine until I put light on scene.
In my case this looks like a problem with normals. I added a geometry shader to show them all and saw that normals lay down on cliffs.
Seems they calculated to down part of terrain.
Also, I think that it's an issue with matrices. For example, my view matrix looks like
But your matrix is

Any clues for my problems? What i need to change on generation?
Guest on 23.11.2015 19:18:58
How I determine if terrain is inverted:
I simply enabled GL_CULL_FACE with GL_BACK face func.
Guest on 24.11.2015 07:51:45
I rechecked your and my programs and convinced that an issue with normals is only my issue.
But issue with face culling is exists.
Yuri (yuri@ccom.unh.edu) on 18.11.2015 20:14:10
Hi Michal,
thanks a lot - I've learned a lot from your work.
Do I understand correctly that you use orthographic projection in this tutorial? How would shader programs change to use perspective projection?
Yuri (yuri@ccom.unh.edu) on 19.11.2015 16:26:36
Hi again,
sorry - I was wrong. I was deceived by the name of the shader "ortho". The projection is indeed perspective, but I have found what confused me. I could not get correct result because your program has an error. You assume that vertical field of view is 45 degrees, while oglControl.SetProjection3D() accepts radians...
player on 25.02.2015 10:04:16
I have renderd a terrain from a heightmap file using the method of normals and now I want to move beyblade on my terrain. How can I use these normals to do my task. You can find my terrain on the following link:
Fred Cook on 15.06.2014 04:17:29
Dude thanks for this tutorial. I've been trying to find a nice way to blend between each textures on height maps for a while with out loading up a separate texture to the mix. Thanks this really helped :D
Michal Bubnar (michalbb1@gmail.com) on 02.07.2014 18:54:04
Well great, I'm really glad I could help
Jonathan on 26.03.2014 23:53:51
Should the second line here update vNormals[1] instead of vNormals[0]?
vNormals[0][i][j] = glm::normalize(vTriangleNorm0);
Michal Bubnar (michalbb1@gmail.com) on 02.07.2014 18:53:31
Yes it should, I have already fixed this
JR on 07.12.2013 01:01:21
I really like your tutorials because they provide a very down-to-earth and easy-to-grasp perspective on the way OpenGL 3+ works. Nowhere else on the internet have I been able to find a place where OpenGL 3+ is explained this well to beginners. It is maybe not 100% technically at all places, but by using simple and intuitive language you are doing a great job at teaching!
Thanks and keep up the great work.
Dima (dmitry.trok@gmail.com) on 10.10.2013 16:01:29
It's good, thx !
I'm waiting your animation's lesson ))
Fabián (fabianorue@gmail.com) on 06.10.2013 02:21:04
Thanks michall great tutorial!! Opengl is very easy with your explanations :) im grateful for your help.
Michal Bubnar (michalbb1@gmail.com) on 08.10.2013 16:32:35
Thank you I'm really glad I can help someone with all this stuff I put here.
Jump to page: