Jump to content

  • Log In with Google      Sign In   
  • Create Account

Laval B

Member Since 30 Jul 2010
Offline Last Active Yesterday, 03:52 AM

#5247403 Terrain LOD

Posted by Laval B on 18 August 2015 - 09:50 AM

If you're using DirectX 11-grade graphics cards, doing the LOD tessellation in the Hull/Domain shader stages is fairly neat, and avoids some of the difficulties of having to patch up T-junctions between LOD levels.  I've played around with it both this way, and more the way you are describing:

Not the greatest screenshot, but this is from my hardware-tessellated version.  I'm sure that I'm not doing things in the most optimal way, but on the hardware I was using(GTX560), the hardware-tessellated version was considerably faster.



Yes, hardware tessellation is something i need to investigate more. I have toyed a bit with a terrain tessellation demo that was published in GPU Pro 4 and it looked very neat indeed. The performace were very good on my development machine (GTX 780 Ti x2). When i tried it on a smaller card (Quadro 600) which has DX11 feature level but much less cores, it was running fine but very close to the minimum frame time with only the terrain.


I'm thinking tessellation might be good for smaller tasks like morphing in character animation when the character is close to the camera. 


Tessellation is indeed interesting for very dynamic surfaces like character's faces and water simulation. Like i told you, i need to get a good grip of it and the associated cost.


I may also have to support DX10 level hardware so i will need a falback.


Tank you for your post, i will read your references when i get back home.

#5247348 Terrain LOD

Posted by Laval B on 18 August 2015 - 04:01 AM

Yeah... some of these ideas are not very good. You only load the terrain once, and that's at level initialization time. 


The terrain can be very large and will not necessarily be entirely loaded at once. With a structure like this, the index buffers of the leaves can be reused because chunks are loaded in leaves.


The same applies to vertex normals. There's no reason why you can't just get this info at load time and store it in a custom vertex object for each terrain vertex. In fact, if you're going to be creating a height map texture for your terrain, you can also create a normal map texture for your terrain.


With modern hardware, which is the target platform, it is faster to do a bit more calculations then to transfer larger amount of data. This is especially true when loading out of core data in the background.



You're making 3D terrain. You don't use quad trees for 3D environments, you use octrees.


The quadtree is the data structure used for culling and lod selection. Each node will contain the maximum and minimum height of the terrain for the area covered by the node. 

#5199766 Codebase with multiple back-ends

Posted by Laval B on 23 December 2014 - 04:17 PM

I think a simple but somehow less manageable approach is just to use template and typedef:


In some way that's pretty much what i do ... I put the various implementations into different files (.h and .cpp) and i use include files that include the proper headers for the platform/configuration i want to compile. It's less messy that way because there isn't a bunch of conditional ifdef all over the place. It's not necessarily possible nor desirable to put all the code inline.


The real problem is not the code but the configurations and the project/make file that need to be setup on a per configuration and a per platform, basis. Remember that everything isn't just a matter of code, like linker setups and libraty paths.

#5112744 Qt and OpenGL

Posted by Laval B on 28 November 2013 - 08:11 AM

Have you tried using qglClearColor? Or calling glClearColor before clearing? Qt probably calls glClearColor by itself before going in the paintGL method.


qglClearColor doesn't change anything. According to the documentation the only functions that are called by the framework are makeCurrent and swapBuffers. I have also tried calling makeCurrent in renderGL, initializeGL and resizeGL to make sure the right context was used and it didn't change anything. According to the documentation, you only need to call makeCurrent if you call gl functions outside of those functions (the overriden ones).



Check exactly which Qt version you have downloaded. The 5.x generation of Qt is so far available in two versions: one using real OpenGL and one using OpenGL ES via a DirectX emulator. If you are using the emulated OpenGL you need to make sure all your OpenGL is including the emulator headers (somewhere in Qt 3rdparty folder) and you cannot just link to the usual OpenGL libraries.


I'm using Qt 5.1.1 for Windows 64 bits VS2012. There is a version of Qt 5.1.1 for Windows 64 bits VS2012 OpenGL which is not the one i'm using. Is that what you are referring to ?


An emulated framework limited to OpenGL ES is definitely not what i need. The engine uses core profile 3.3 and above. 

#5102175 Behavior of assignment with user data in Lua

Posted by Laval B on 17 October 2013 - 10:56 AM

Nevermind, it's a stupid question. I'll just implement a clone method.

#5101522 lightuser data in Lua

Posted by Laval B on 15 October 2013 - 06:39 AM

Hello everyone.


An application we are working on needs some parts to be scripted. The scripts will only act as callbacks to controle some  part of the execution of some transactions. To do so, it must expose a few objects from the host application. The lifetime of these objects is well controled by the host and they will outlive the execution of the script. The logical choice seems to be the use of lightuser data.


We have exposed these objects using functions and lightuser data and it does work. However, lightuser data don't have their individual metatable. Instead, they all share the same so they all share the same metamethods. It would be great though if we could associate specific methods to each object exposed (like it can be done with full user data) so it would be possible to use object oriented programming notations on those objects from the script.


At the moment, we have to use a notation like this :

function f(user, logger)

   setName(user, "name")
   setGroup(user, "group")

   output(logger, "User is set.")


instead of 

function f(user, logger)


   logger:output("User is set.")


Is there a way to do this with lightuser data ?

#5075319 Uniform blocks and Uniform buffer objects

Posted by Laval B on 04 July 2013 - 03:10 PM

Ok, i think i figured it out. I can't use only one binding point, i need to have one for each uniform block. But i can use only one ubo and bind different part of the ubo to each uniform block using glBindBufferRange.


I still have one question though, must i call glGetUniformBlockIndex and glUniformBlockBinding after the program has been linked ?

#5068236 States managed by a VAO

Posted by Laval B on 08 June 2013 - 09:11 AM

Thank you for the clear answer smile.png


It makes sense indeed, i didn't pay attention when i read the glVertexAttribPointer/glEnableVertexAttribArray part and got confused when they say :


<array> is the vertex array object name. The resulting vertex array

object is a new state vector, comprising all the state values listed in
tables 6.6 (except for the CLIENT_ACTIVE_TEXTURE selector state), 6.7,
and 6.8 (except for the ARRAY_BUFFER_BINDING state).


Ref http://www.opengl.org/registry/specs/ARB/vertex_array_object.txt


I forgot that vertex attributes are not necessarily in the same vbo (over 95 % of my vbo are filled with interleaved data).


Now, index buffer will get bound when binding the VAO. I guess i can still bind the index buffer separately after binding the VAO (which will update the VAO state every time though). If i do this, i will have to make sure to bind index buffer 0 if I render a VAO with no index buffer. Would that be a problem ? You see, my code base pretty much separates the vertex (and the vertext attribute specification) from the index.

#5064790 Finding a process

Posted by Laval B on 25 May 2013 - 09:23 AM

The problem doesn't come from EnumProcesses but from OpenProcess. Try using the snapshot api.
If all you need to do is to determine if the given process is running or not, you could just write a function like the following :
bool IsProcessRunning3264(LPCTSTR pProcessName)
    bool bRetVal        = false;
    HANDLE hSnapshot    = NULL;
    PROCESSENTRY32 pe32 = {0};

    //    Take a snapshot of all processes in the system (including system processes).
    hSnapshot = CreateToolhelp32Snapshot(TH32CS_SNAPPROCESS, 0);

    if(hSnapshot != INVALID_HANDLE_VALUE)
        pe32.dwSize = sizeof(PROCESSENTRY32);

        //    Retrieve the informations of the first process of the snapshot. 
        if(Process32First(hSnapshot, &pe32))
                CString str(pe32.szExeFile);

                if(str.CompareNoCase(pProcessName) == 0)
                    bRetVal = true;

            }while(Process32Next(hSnapshot, &pe32));
    return bRetVal;



Hope this helps.

#5033815 C/C++ JSON library

Posted by Laval B on 18 February 2013 - 11:21 AM

Hello everyone


We are switching some of our homemade communication protocol from XML to JSON. This means we need to be able to encode/decode JSON strings. The applications are written in C++ and some must be compiled on Windows as well as Solaris. I've check libraries listed here http://www.json.org/. Though there is a plethora of libs written in C/C++, lots of them aren't interesting for various reasons : many are only parser but we also need the encoder, some are just too big and have too many features we don't need (http clients, ftp client, etc), some are missing key features like good utf-8 support, others aren't thread-safe ...


So far, my choice would probably be json-c-0.9. There is a few things i need to check but this one seems to be a good trade-off. I was wondering what you guys are using (in C or C++ of course). I have no preference for C or C++ as long as the C++ libraries don't overuse exceptions.


Thanks for your answers.

#5003923 Problem with oci library

Posted by Laval B on 25 November 2012 - 05:28 AM

Does your installshield place the executable file in Program File (x86) ? If so, this is likely to be your problem. When OCI is loaded, it gets the current directory and composes all the paths to find other files it needs like <oracle_home>/network/admin where your tnsname.ora is. Unfortunatly, oci libraries before version 11 have a bug with string having parenthesis and can't compose their internal paths right in that case. The solution is either install your application in another directory or use version 11.2 of the library.

#4985693 Tab order with MFC tab control

Posted by Laval B on 01 October 2012 - 03:24 AM

You need to give your children dialogs the WS_EX_CONTROLPARENT style. This is easily done using the property page of the dialog in the resource editor. There is a property called Controle parent, make sure it is true for all your pages. Also, make sure the dialogs are children of the parent dialog and not the tab control.

#4961349 Hardware Occlusion Queries, why use them next frame?

Posted by Laval B on 20 July 2012 - 09:56 AM

As a side note, in GPU Pro 2, there is a good article describing the use of hierarchical z-buffer queries using a render target that looks very interesting.

#4960060 FPU mode

Posted by Laval B on 17 July 2012 - 10:59 AM

EDIT: The source is buried at the bottom, here is the direct link: http://www.christian.../fpmath/xpfpa.h

Very interesting and useful. It explains and clarifies alot of things.

danke schön

#4959938 FPU mode

Posted by Laval B on 17 July 2012 - 03:28 AM

Not entirely true... for example, the outputs of SSE2 instructions can be made to converge to (close to) FPU instructions with appropriate settings. This might be useful if, say, one wants a 64-bit app to generate similar results to a 32-bit app, within some tolerance.

Thank you, this is the case.