Graphical Improvements and Terrestrial Planet Generation

I’ve been working some more on graphics for my randomly generated terrestrial planet. I’ve now implemented a bump map.

I’m not 100% happy with the effect, it’s really very blocky, but I think it will do for now. There might be some tricks I can do like bi-cubic sampling the height-field or something like that.

Fleet Battles 2015-06-01 23-16-26-14 Fleet Battles 2015-06-01 23-16-45-41

Lens Flare

I’ve added the following Lens Flare effect. It produces artefacts and then does a shaping effect on them to make them look a little more like they came from a Lens.

There’s some chromatic distortion as well.

Fleet Battles 2015-05-23 15-35-05-24-ex

More engine work

I found as I learn more about OpenGL and GLSL I find it easier and easier to decipher graphical concepts.

So now I’ve managed to completely figure out bloom, HDR and real Atmospheric Scattering.

I’ve also completed my Noise Engine for the CPU side of things, I’m looking into doing stuff with compute shaders to animate the noise in real time.

For now, here’s the new and improved planet. More after the jump.

Fleet Battles 2015-05-21 21-40-51-95

Continue reading “More engine work”

More UI work completed

I’ve done a bit of refactoring of my UI code and brought it down a few hundred lines of code.

I’ve also started noting the performance. Right now, a window with a table and a bit of text and another window with just text gets me around 500-550 fps. This is from a base of about 2500 (if nothing is being drawn to the screen).

I have no idea if this is acceptable or not. In contrast, my scene with a sun and an earth runs at about 200-250 fps. The thing is; I’m doing things in the most inefficient way.

So; I put some work into speeding up the code. Everything in the UI uses a single shader for one. Next is to get everything to use a single VBO; it’s not doing that now because my text quads are drawn with position info in the vertices, whereas everything else uses a translation and scale matrix to define the position.

If they both use the translation matrix, I can remove any need to bind different buffers between calls. This should make things faster.

Also, everything at the moment binds it’s texture. However everything uses the same texture (except text); so I may be able to remove the  glBindTexture calls for a lot of the time. Probably via a texture manager or something.

If it’s still not fast enough; I’ve been reading about instance drawing and also about using textures to hold position info (R,G is x,y and B,A is w,h). I think I can combine these so that my gl_InstanceID in the vertex shader is my lookup into the texture of position info. I’d probably also need a second texture to hold UV coords seeing as these don’t change much either (textures rather than providing a lookup array to the shader, only because that would need to be updated and passed each frame anyway).

Here’s a picture:

SpaceEngineUI 2015-01-02 23-16-02-99

Scrolling Box Complete

I’m pretty sure I’m now 99% complete with the scrolling boxes. There were a couple of bugs; one which was interesting.

Because the  box essentially draws its contents onto a render texture, the render texture created is the size of the screen. Then, as the box is scrolled, basically the region of this texture that’s then drawn to the boxes quad is updated.

What I found was that I was drawing the contents at normal window position on this texture. So a box close to the edge of the screen would result in the contents being partially drawn offscreen. Which is fine. Until you scroll and then the “region” of the texture you’re drawing is actually not on the texture. Graphical glitch.

Easy fix was to just draw to 0,0 on the texture and accommodate this in the region calculation. It also means that I can use a much smaller texture; probably the size of the widget contents. However, there would be a problem if that widget changed it’s size, I would then need to regenerate the texture, or resize it; and I’m concerned about the overhead needed. For now the screen dimensions cover all possible cases, so I’m using it until there’s performance problems.

I’ve also enabled mouse wheel and touch-pad scrolling via SDL2. So that’s pretty handy, makes it much more usable. I’m basically trying to recreate everything that people are used to.

ShaderTool + Making a Sun

I purchased a really cool beta tool called ShaderTool. It let’s you visualize a shader effect.

It helped me create this:

animShaderTool 2014-10-19 21-30-47-51393

There’s more I need to do to it. But soon I will have bitchin’ suns in the game.

UI + Glow

The UI is coming along nicely (I need to work out how to do animated gifs to show stuff off). It’s widget based with a good input handling system, I just need to work on using several textured quads so that the windows can be styled nicely.

UI with transparency
UI with transparency

I’ve also done a bit of work with post-processing effect shaders to produce a glow on the more luminous areas. Here’s a couple of screenshots showing the sun from the perspective of an Earth and the result of the reflection of sunlight over the desert (it’s not quite right over the ocean yet, so still need to work on that).

Continue reading “UI + Glow”

Camera + specular-map lighting + more

I’ve spent the last couple days trying to work out view-space vs world-space and how to incorporate lights into my shaders. It’s been difficult. The concept of a View space vs World space and when to use which is not a simple one.

Anyway, I now have materials with specular maps and diffuse maps (and a fallback to color when diffuse isn’t provided). My shaders are all working correctly and producing the lighting effects. I’ve also added a arcball type of camera only because I needed to see the lighting move around in real time.

Continue reading “Camera + specular-map lighting + more”