I moved to a new URL! Check it out!

posts tagged with: csharp

Dev Log: SFML Text Woes

Dev Log: SFML Text Woes
My most recent development is getting text working in my SFML based framework. Unfortunately I've run into some sort of problem with the text rendering though.

Image


Whenever I render text, there seems to be a tiny artifact that appears on the upper left corner for the first character of the string, but it only appears in certain positions. The artifact seems to be less than a pixel since moving it around the screen causes it to flicker on and off. In this example I'm rendering text 9 times, 8 times for the outline, and once for the center, and you can see the artifact also rendered 9 times in the top left corner of the Q character.

Image


This is happening independent of fonts, and characters. The only instance I have seen this not occur is when the text is never moving on the screen, or when the first character actually occupies the upper left corner of its bounding box (for example the Y character in Arial.)

Does anyone out there know what's going on here and how I can fix it? If it makes any difference, currently my framework renders everything to a render texture which is then drawn to the window... not sure if this has anything to do with it, but I've been running tests with just drawing SFML text straight to the window with similar results so far.

Programming!

Screenshot Saturday

Image


Just now getting back into coding stuff! I'm almost to the point where I can actually start building a game instead of just random testing scenarios, woohoo!

New Game Mockup!

New Game Mockup!
Now that I'm doing all this stuff with C# and SFML, some people have been wondering what exactly it is I'm doing with it! I have two games that I want to try and make with my new C# knowledge. They're both previous game jam games of mine, and here's what I want to do first:

Image


Image


You may recognize this from the game I made for Ludum Dare 17. It's actually available for download in my games section -- just scroll down to Gaiadi and download it to give it a whirl. Gaiadi is just a prototype, but now I want to turn the concept into a fully fleshed out game.

I've been trying to get this project going for a long time now, and I think attempting it in a high resolution will be pretty fun ... as long as nothing goes horribly wrong! This is by no means a guarantee that I will be releasing this game any time soon, but just what I'll be focusing on for the next big chunk of time.

As for my metroidvania project in flash from Global Game Jam... that's not 100% dead, but right now I am putting it on hold to focus on this.

Dev Log: Parallax and Repeating

Dev Log: Parallax and Repeating
Just churning away at my SFML framework that I'm building with C#. The past two days I've added parallax scrolling (similar to Flashpunk's scrollX and scrollY variables) to images, as well as the ability for images to repeat. The cool thing about the repeating is that it's being done at the base image class, so even animated sprites can be repeated across the screen!

Image


Also if you're working with SFML C# yourself, you should check out this TextureAtlas class written by Mark J. A. Smith. I have yet to implement something like this in my framework yet because I haven't really noticed performance issues, but using texture atlases can greatly reduce the amount of texture switching between drawing things, which helps a lot with performance.

Back to work!

Some Shader Resources

Some Shader Resources
As I've been messing around with C# and SFML, one of the major benefits is the support for shaders! I've been crawling the internet trying to find examples of shaders, but for awhile all I could find were types like this that created entire images, or produced super elaborate effects that I wasn't really interested in.

Image


After a quick trip to Twitter I realized that what I was looking for were post processing shaders. I want to be able to adjust an image that I've already drawn for the most part, instead of creating new imagery. A lot of people gave me suggestions (mostly Sven) so here's a quick list of what was found!

GeekXLab


There's a handful of post processing shaders here that all look pretty neat, but unfortunately I can only get some of them to work with SFML right off the bat. Others throw errors that I don't yet know how to diagnose. They also have some software you can use to demo the shaders in, which is pretty rad! A couple of them worked right off the bat, like Thermal Vision, Dream Vision, and Pixelation, but the rest I have to mess with to figure out.

nVidia Shader Library


It turns out the nVidia site has a bunch of shader examples but unfortunately none of them seem to be in GLSL. The CgFX shaders should be able to compile into GLSL though. I haven't personally tried any of the shaders here, but it seems like a good sampling.

Image


hunterk GLSL Shaders


Somewhere a mysterious mediafire folder full of shaders exists. This one was pointed out to me by Loren, and I haven't dug too deeply into this yet. It's a lot easier to browse the sites that have previews of all the shaders, but it looks like there's a lot of cool stuff to be found in the depths of these files.

Shaders for Game Programmers and Artists


This book was recommended by Sven, and the fact that it might be also geared toward artists is interesting. This was published in 2004 and I'm not sure how much has changed in the world of shaders since, and I'm also unsure on how much focus there is on post processing vs. other types of shaders in here, but maybe worth a look!

Pixel Art GLSL Shading


I was also pointed in the direction of this beautiful piece of work which uses shaders to light pixel art in an incredibly good looking way. I haven't checked out the real time demo yet, but just that preview image looks absolutely delicious!

Photoshop Blend Mode Math


Of course there is this classic post about Photoshop GLSL shaders that I first started looking at in the early days of Snapshot development. I really wanted Photoshop blending modes since I do all of my art in Photoshop anyway. I haven't tried these out in real time yet in SFML, but it looks promising!

Image


That's all I got so far! I'll see what happens in the coming weeks in shader town. I've had some fun just pixelating and blurring and warping stuff so far. One of my next game projects in C# will be having a lot of special effects (I hope) so I need to become a shader master as soon as possible. If you know of any awesome resources not featured here please let me know!

Oh also here's a pro tip for writing shaders: don't use Visual Studio C#. It seems to be adding funky white space characters that causes the shader compiler in SFML to fail. So on that topic, what is an awesome shader IDE?

Screenshot Saturday: Shaders!

Image


BEHOLD I have finally implemented a shader! (It's actually just the example blur shader that comes with SFML.)

Ever since I started working on Snapshot I've always wanted to take advantage of pixel shaders for 2d games, and now with C# and SFML I've been able to finally do it. I'm pretty excited for where this can take me, but now I have to actually learn how to write GLSL shaders which looks pretty tough...