More Fun With Render Targets

Another week full of work, this time with a frustrating outcome – the work wasn’t very good. I’ve found that when exploring new ideas, you have to fail a bunch of times before you get something right – learning what doesn’t work helps you create what does. I’m making the second-last boss of the game now, and it’s sorta weird and high-concept, so this success-through-repeated-failure scenario is kind of to be expected, but that doesn’t make it any more pleasant to go through. It’ll be done next week, or I’ll eat my hat!

While I’m spinning my wheels here, I’m gonna show off some more fun with render targets! Check out this virtual-reality environment I made a while back.

Different areas of the environment pulse, scrolling grid lines fade in and out, and the entire level slowly shifts colour over time.

I’m using render targets to create and morph the tileset while the game is running, resulting in all the effects! I’ll follow with a breakdown of what I mean.

To start with, here’s the tileset. It contains all the information we need to achieve those results.

Well, all of them except one. To achieve the colour shifting, I have a few variations of the same tileset, just in different strong colours — blend any two together to get a final coloured tileset.  The colours used and the balance between them is constantly (slowly) being changed while the game is played, allowing the colour shifting to occur.

Combining tilesets to get a final colour. (Showing the top of the tileset only here.)

For parts of the environment to pulse, we use more render target goodness. You’ll notice the bottom of the tileset has the same tiles repeated at different brightnesses. That helps with designing the level – I mark off areas I want to glow with the brightened tiles.

Here it is in the editor. You can see the marked glowy areas.

At run time, I replace the brightened tiles with copies of the darkest set. So by default, all tiles will be dark and you won’t notice the special areas. When I mix the fully-bright tiles back over the copied dark ones, it causes parts of the world using those tiles to brighten. Having the two sets of copies allows different areas of the world to pulse at different times, making it look more organic.

The bottom of the tileset. At run-time, the brightened duplicates are replaced with the flat black version. The max-bright version is mixed back in as needed.

Finally, to achieve the scrolling grid lines. The tileset contains a little grid — if I pick a section of it and draw it on top of every tile, it adds the grid image to the tileset! If I slowly shift the area of the grid I’m using, it makes it look like the grid lines are moving instead.

Drawing different areas of the grid on top of the tiles.

In the end, you get a constantly-changing tileset that’s used to draw the game world, resulting in those neat effects! Here’s a rip from the game, showing what the tileset looks like as the game runs. I’m showing the bottom of the tileset since that’s where it’s easiest to notice the subtle effects.

So, uh, yeah! I’m not sure what the environment will be used for, if anything… maybe a tutorial? Maybe an optional arena for Challenge Mode? Sometimes I just get excited about the challenge of implementing an idea and run with it for a day. Not that I’m giving into those urges lately — this was done a while ago. Right now I gotta focus on getting the game done!! Until next week!