Skip to main content

Volumetric lines 2

I promised I was going to do a follow up on the Volumetric Lines episode, so here it is.

Like I said, it was very easy to change from regular lines, to using volumetric lines in PewPew. In fact, I already changed once the way lines are drawn: the early versions of PewPew used SDL without OpenGL, so the lines were drawn in software using the good old Bresenham. Switching to OpenGL forced me to reduce the coupling between the renderer, and the game engine. Here is all I had to do to make the switch to volumetric lines, besides the initialization:

#ifdef USE_VOLUMETRIC_LINES
for (int index=0; index < numberOfVertex; index+=6)
VolumeLineRenderer::getInstance().renderLine(
&vertexes[index],&vertexes[index+3]);
#else
glVertexPointer(3, VERTEX_TYPE, 0, vertexes);
glDrawArrays(GL_LINES, 0, numberOfVertex);
#endif



Here are some new screenshots comparing the regular render to Sebastien Hillaire's one with different line width.







Now this is running on a PC, not on an iPhone. I previously said that I could maybe port this glowing effect to a real iPhone/iPod Touch, but it requires programmable shaders, which are only available on the iPod Touch 3G and the iPhone 3GS. I only have an iPod Touch 2G, so I wouldn't be able to test it.

Anyway, if you do not like the glowing effect do not worry, because if I do manage to get this effect to work on a real device at a decent frame rate, I would put an option to keep the classic look :-)

Comments

  1. Hihi,

    Its possible to get the glowing line effect using standard opengl, by drawing the lines as a rectangle with alpha add blend mode. You can see the effect here:

    http://1.bp.blogspot.com/_nv4ljJGt1-A/S-c0xenKUxI/AAAAAAAAACc/J6u6cl_d7RA/s1600/editor1.jpg

    ReplyDelete
  2. haha, that's very true!
    But if you rotate the camera, the lines will look flat, right? It's not a problem if the camera is static, but in PewPew the camera can move.

    Totally unrelated, but I subscribed to your blog :)

    ReplyDelete

Post a Comment

Popular posts from this blog

PewPew Live's look in a nutshell

Occasionally someone will asked how I obtained the PPL look. In a nutshell: Draw everything with lines, including the text and the various icons. It's a lot of work, but besides looking unique it creates a consistent appearance which is a thing that a lot of indie games struggle with. The lines are screen-space projected lines with miter joins. Draw the lines with additive rendering. This means that if a red and green line overlap, the overlap will be yellow. There are a few things not drawn with additive rendering (like the background of buttons to improve readability), but they are exceptions. Add bloom. There's lots of different bloom implementations. Nowadays I use a bloom that is similarly to the one in  blender's eevee . If you see banding, use dithering. Optional: Add even more post-processing like (very slight) chromatic aberration, lens dirt, scan lines, curved monitor, and vignette. No post-processing, just lines Bloom! Ignore the missing bloom at the top All the...

A general state rollback technique for C++

I wanted to write this post for a while. It describes a C++ technique to implement rollback in the context of multiplayer games that I feel is quite interesting and useful. The tl;dr is: don't bother serializing individual objects, just rollback all the memory. Rollback-based multiplayer I've been working on a multiplayer version of PewPew, and for reasons that are outside of the scope of this post, I chose to implement multiplayer with deterministic lockstep and rollback. The basic idea behind rollback-based multiplayer is that the inputs of players are replicated to all the players. Whenever a player receives the inputs of another player, the state of the game is rolled back to the point where the input happened and fast-forwarded back to the present so that the state shown to a player takes into account the inputs of the other players. Because history is being re-computed, some events get undone. For example, it's possible a player saw themselves taking a bonus, but aft...

Ridiculously cheap depth of field effect for lines

I'm working on PewPew's sequel, for which I've revamped the graphics. Instead of drawing lines directly using OpenGL, each individual line segment is made up of two triangles whose vertexes are computed with shaders. Getting lines in 3D space to be properly displayed on a 2D screen is not trivial. In PewPew's sequel I use the screen-space projected lines, a technique very well described in the  Drawing Lines is Hard  post. The upside of drawing the lines yourself is that you are fully in control, which allows you to implement nice things such as joints, perspective, and even simulate depth of field. https://en.wikipedia.org/wiki/Depth_of_field Usually depth of field (DoF) in video games is implemented using a post-processing step that blurs the pixels with an intensity that is a function of the depth of the pixels. When we are rendering lines, we can approximate DoF directly when rendering the lines by having the vertex shader increase the width of lines and r...