Jump to content

  • Log In with Google      Sign In   
  • Create Account

Interested in a FREE copy of HTML5 game maker Construct 2?

We'll be giving away three Personal Edition licences in next Tuesday's GDNet Direct email newsletter!

Sign up from the right-hand sidebar on our homepage and read Tuesday's newsletter for details!


Member Since 04 Oct 2010
Offline Last Active Today, 02:21 AM

#5193711 Compression questions

Posted by Chris_F on 19 November 2014 - 09:02 PM

This is a nice article about compressing normals (in a g-buffer): http://aras-p.info/texts/CompactNormalStorage.html


In general, the trend on modern hardware seems to be that math gets cheaper and cheaper while bandwidth gets (relatively) more expensive. So compression at the cost of a few ops is often worthwhile. It does depend on the specific hardware and use case though (and I'm no expert).


I think half floats would struggle a bit to cover 1000m at 0.1m intervals. A half float is only 16 bits so only has 65536 possible values, plus most of them will be focused close to zero, so perhaps not appropriate for position data. Half floats are probably fine for direction and colour though.


I found this a while back. Still have yet to go through and read all of it, but it looked interesting. http://jcgt.org/published/0003/02/01/paper.pdf

#5190399 Normal map artifact still here.

Posted by Chris_F on 31 October 2014 - 09:21 AM

I believe Johnny is referring to this: http://interplayoflight.wordpress.com/2013/05/17/correctly-interpolating-viewlight-vectors-on-large-triangles/

#5190329 Why don't you use GCC on windows?

Posted by Chris_F on 31 October 2014 - 05:17 AM

I do use GCC(MinGW-w64) on Windows. I'd like to be able to switch over to Clang, especially if they ever port libc++ to Windows.

#5188969 how to limit fps in glut ?

Posted by Chris_F on 24 October 2014 - 01:47 PM

As far as I know GLUT doesn't have any way of enabling vsync. Maybe you should consider using a modern

library like GLFW or SDL. In GLFW you would call:



#5188870 With regards to texturing, what is "linear space" and "nonlinear...

Posted by Chris_F on 24 October 2014 - 01:15 AM

They are talking about sRGB encoding. Ordinary images (as in photographs with 8 bits per component) are typically encoded in the sRGB color space. You cannot perform math with these values until you have first converted them to linear RGB color space. If you create a texture using a sRGB format (e.g. GL_SRGB8_ALPHA8 or DXGI_FORMAT_R8G8B8A8_UNORM_SRGB) then this conversion happens automatically when you sample the texture.


Some additional information: http://www.gamedev.net/topic/652795-clarifications-gamma-correction-srgb/#entry5127278

#5188388 Scenes with large and small elements

Posted by Chris_F on 21 October 2014 - 02:38 PM

Of course, it's unfeasible to render such a scene using metres as my base unit, as I have to specify the spacecraft's position in hundreds of thousands of metres relative to the centre of Earth, and using such massive numbers to position objects in Direct3D seems to cause problems.


Hundreds of thousands of meters doesn't sound like a whole lot, not if you are using 32-bit floats. If you were simulating the entire galaxy, I could see this being an issue, but you are only simulating Earth out to LEO.


Edit: Then again, now that I think about it you would only have accuracy to like 1/10th of a meter far away from the origin. If the origin is centered around the spacecraft then maybe it wouldn't be an issue. You don't need better than 1/10th of a meter accuracy for something >100,000 km away.


Also, it doesn't really matter if you are using meters, kilometers or millimeters as your base unit. This has no effect on the precision of the calculation when you are working with floating point numbers, as you are only changing the exponent.

#5188241 SDL2 vs SDL2/OpenGL

Posted by Chris_F on 20 October 2014 - 10:24 PM

Plain old SDL is basically for making Mario Brothers clones. If you want to do anything more advanced than that, you will need to use OpenGL.

#5187477 OpenGL 4.5 DSA and Dummy Window

Posted by Chris_F on 16 October 2014 - 02:37 PM

DSA changes nothing about context creation or windows.

#5185659 Using SDL with OpenGL

Posted by Chris_F on 07 October 2014 - 07:05 PM

Not tested. smile.png


#include <SDL.h>
#include <GL/glew.h>
#include <cstdlib>

int main(int argc, char* argv[])
    if (SDL_Init(SDL_INIT_VIDEO) < 0) exit(EXIT_FAILURE);

    SDL_GL_SetAttribute(SDL_GL_DOUBLEBUFFER, 1);
    SDL_GL_SetAttribute(SDL_GL_DEPTH_SIZE, 24);


    if (!window) exit(EXIT_FAILURE);

    SDL_GLContext context = SDL_GL_CreateContext(window);

    if (!context) exit(EXIT_FAILURE);

    SDL_GL_MakeCurrent(window, context);

    if (glewInit() != GLEW_OK) exit(EXIT_FAILURE);

    glClearColor (1.0, 0.0, 0.0, 1.0);

    bool running = true;

    while (running)
        SDL_Event event;
        while (SDL_PollEvent(&event))
            switch (event.type)
                case SDL_KEYDOWN:
                    switch (event.key.keysym.sym)
                        case SDLK_ESCAPE:
                        running = false;

                case SDL_QUIT:
                    running = false;



#5185221 Texture Storage + Texture Views AND mipmapping

Posted by Chris_F on 05 October 2014 - 10:41 PM

I could not fathom a reason for why immutable texture vs. mutable texture would have an effect on how the mipmaps are being generated. In the case of RTT you would have no choice but to use glGenerateMipmaps. Well, maybe you could do it yourself with a compute shader if that is available to you. I wonder what the performance difference would be if any.


Also, maybe try using glHint(GL_GENERATE_MIPMAP_HINT, GL_NICEST).

#5184863 LOL - I wrote a poem about OpenGL

Posted by Chris_F on 03 October 2014 - 06:20 PM

Now write an ode to opengl drivers.

#5183604 glDrawElements with glBufferSubData ? -> 2 or more indexes ?

Posted by Chris_F on 28 September 2014 - 07:52 PM

Absolutely, you can in modern OpenGL. Google programmable vertex pulling. One way would be to store your incidences as vertex attributes. Then you store your actual vertex attributes in a SSBO. In your vertex shader you index the SSBO arrays using the incidences stored in the vertex attributes. The second way of handling it would be to forgo traditional vertex attributes all together. Just bind a blank VAO (must be using a core profile context) and store both your vertex attributes and incidences inside of SSBOs. In your vertex shader you index the arrays containing your incidences using gl_VertexID. Then you take those and use them to index the arrays containing your vertex attributes. In both cases you would be using glDrawArrays instead of glDrawElements.


You'll probably get better performance if you just stick to the traditional method, and you'll definitely get wider compatibility.

#5183381 SDL vs SDL2

Posted by Chris_F on 27 September 2014 - 07:57 PM

Just use SDL 2. It's the current API and the one the developers suggest you use. SDL 1.2 exists for backwards comparability.

#5183031 problem with my text rendering

Posted by Chris_F on 25 September 2014 - 07:47 PM

Is your framebuffer the same size as your window client area?

#5183017 Nvidia GI Hardware Support

Posted by Chris_F on 25 September 2014 - 05:40 PM


I'm confused. Nvidia supports GL_ARB_sparse_texture with both Kepler and Fermi, so why is this a Maxwell only feature?


GL_ARB_sparse_texture extension only concerns 2D texture.



Read the spec. It supports 2D textures, array textures, cube maps, cube map arrays, 3D textures and rectangular textures.