Jump to content

  • Log In with Google      Sign In   
  • Create Account


Member Since 08 Dec 2011
Offline Last Active Oct 19 2014 10:23 AM

Posts I've Made

In Topic: Instanced font rendering (continued)

04 August 2014 - 03:07 AM

Very nice:)

In Topic: Picking a set of vertices

03 August 2014 - 09:09 AM

Those are basic GL concepts, I could try to explain everything that but that will take too long, I suggest you to look at modern OpenGL books and tutorials (opengl version 3.3 and 4.x). You need to be strong in those concepts before you ever start writing a geometry shader that write to multiple streams :/


In short:


When GPU draws triangles on the screen it does nothing more than writing color values in "pixels" and Depth values in a Zbuffer (well that's not precise, nowadays all thos values are wrote to a framebuffer object)


The reason why if you render a box behind a wall you don't see the box is because of Z test. Basically each frame the Zbuffer is resetted. Each pixel of each primitive, performs a Z test (if Z testing is enabled!), if test fails the pixel is not drawn and some computations are skipped. If test succed the pixel is drawn and a new color and Z value are drawn.


When Z testing is enabled rendering order is not important: objects appears in correct order because nearest objects will "overwrite" farest objects, and farest objects will not overwrite nearest objects.


Occlusion query allows to query GPU for occlusion => You rendered a box behind a patch of gras and you want to know how much % of the box is visible. The occlusion query allows to know how much pixels are occluded (not rendered because Z test failed). This is a simple task for the GPU but even the most complex physics engine can't do that efficiently. However occlusion query may not be enough for selecting single vertices (most notable use of occlusion query is to show lens flares when sun is visibile in videogames).


To assign the index of each vertex to the vertex itself you just need to add the index as vertex attribute


Vertices are made of "components" each component have arbitrary values (usually values that make sense to you. not to the GPU)





The type and value is totally free and dependent only on your needs, for example instead of using 3x32bit floating points for position, you could use a 3x16bit integer if your model is made of cubes, this is up to you.


Since every 3D model is made by vertices that are stored in a buffer, those vertices have a implicit index. You must tell to the GPU wich vertices to pick for each triangle,


Example (a quad made by 2 triangles => each triangle have 3 vertices, but there are only 4 totale vertices)


A -----------B

|    \            |
|         \       |
|              \  |














... Since attributes to vertices are totally custom instead of providing a "Vertex Color", you could provide a "Vertex Index"  so that when vertex is wrote to a stream who will read the stream will know wich vertex that was. but that's just because you'll need it.


For visible vertices look also at here: https://www.opengl.org/discussion_boards/archive/index.php/t-183434.html

In Topic: Status of GL extension libraries

03 August 2014 - 08:16 AM

O_O incredible thanks! I still find links to old .spec files. Anyway digging into XML and python will be a little overkill but probably worth :)

In Topic: glm/opengl orbital camera C++

03 August 2014 - 04:37 AM

Depends if you need to orbit camera only left right or also up/down. You need to move camera position around a circle or on the surface of a sphere then.


You could use a quaternion (rotation around 1 axis) but the faster way is to compute directly the coordinate(and it is also simple)


Given the camera startin position is on XY plane (Z=0)


first rotate around Z axis for vertical scrolling.

currentY+=mouseY*speed; //vertical angle

if(currentY >89.f)
    currentY = 89.f;

    currentY = -89.f;

camPos.x = range*cos(currentY*DEG_TO_RAD);
camPos.y = range*sin(currentY*DEG_TO_RAD);
camPos.z = 0;

camPos = glm::rotate(camPos, rotX ,glm::vec3(0,1,0)); //rotate around vertical axis now

In Topic: glm/opengl orbital camera C++

02 August 2014 - 02:09 PM

You can do that in zillion ways. You need to make a point floating around your model at desired hieght (if your Up vector is Y, then use X = cos(time) and Z = sin(time) to have a circle flying camera). then you need just to build a lookAt matrix camera (position is the point and lookAt is the model feet).

To build the matrix search around the web but I think GLM already have those functionalities