Thursday, 24 October 2013

Hypochondria Update #4 - Shaders

So for the past while I've been trying to dip my toes into the vast ocean that is HLSL shader programming....and oh my is it a vast ocean. But after some initial terror I've had some success :-) The two main things I was trying to achieve were some simple lighting (for starters) and textured polygons. I haven't even attempted shadow casting yet because I may end up bald if I try (from tearing my hair out in frustration), but I would like to give it a try at some point because it's something that I think adds a certain level of polish and proffessionalism to any game if done well.

So here's an example of what I've managed to hack together so far:

As you can see, I just have some point lights at the moment that simply light up everything underneath them (foreground and background). I'm not sure yet if I will leave it like that or if I will make layer specific lighting. Maybe it would be best to add it in as an option. I aslo changed the stomach acid shader to make it glow. Super realistic eh? ;-) I'm quite happy with the overall effect for now. I think it's a nice step up from what I had before. This doesn't represent the final look of the game though. It's just a start.

The other big change I made (as you may have noticed) is the terrain. After discussing with a friend of mine I decided that the terrain I had looked too flat and rigid. It didn't really suit the setting (inside a living human). So I'm redesigning everything to have curvy terrain :-) I made a bezier curve editor (basically the pen tool from photoshop) for my level editor so that I can quickly build these shapes. These are then triangulated (I think I'll do a seperate blog post on that) in order to give me a filled polygon which can then be textured and highlighted/shaded using shaders. This should hopefully speed up the development process beacuse I can now just build my terrain using the curve editor and the game will take care of all the drawing for me. All I have to do is make some nice textures in photoshop instead of hand-drawing loads of images. The texture in the image above is just for test purposes and won't actually be used in the final game.

In terms of collision detection and player movement for the curvy terrain I'm still using a path system similar to the one described in the last post for the "sticky" surfaces. But I scrapped that one and re-wrote it from scratch again becuase I noticed it was a bit crap. Works pretty nicely now apart from a few little bugs that still need to be squashed.

Here's a short video I made showing the first few levels with the above mentioned improvements:

So that's it in a nutshell for this post.
Take it easy ;-)