I moved to a new URL! Check it out!

posts tagged with: sfml

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...

Dev Log: Animations

Dev Log: Animations
Finally got back into C# yesterday and refactored a bunch of my drawing code. I'm basically trying to take SFML and wrap it in a framework that resembles Flashpunk. Last night I got some animations working and I tested with my simple tilemap, and a familiar face from Offspring Fling!

Image


SFML is still proving to be super fun and easy to work with so far, especially since I'm using C#. Also for you C# developers check out Glide, which looks to be a super neato replacement for TweenLite in AS3. I'm planning on implementing it into my framework soon.

I've also been trying to figure out if texture atlasing is necessary with SFML and I can't seem to find any resources on the matter... that is one of the items on my to do list for this framework!

Dev Log: SFML C# Progress

Image


Nothing too exciting for a blog post today unfortunately, just a quick update on my SFML C# progress. Over the weekend I was able to add tile maps roughly following the tutorial right on the SFML website about using vertex arrays for custom shapes.

It was surprisingly straight forward to get a tile map with custom vertex arrays rolling. My first attempt actually involved using a render target. I rendered all the tiles directly to the render target, then used that target as a texture for another sprite. In theory this works well enough but the size of render target's is limited by the video card. On my main PC workstation I can make a render texture of 16000 something pixels, but my laptop can only handle 8000 something pixels, so this seemed like a dangerous way to do it. I switched to the vertex array thing and now I am super excited to try out different applications of the vertex arrays.

Still on my list of things to do are animations, tweening, collisions, and texture atlas support, as well as Ogmo Editor support. Plus probably a lot of refactoring. When the framework is lookin' better I'll release the source publicly so people can laugh at my code and help improve it or use it.

Screenshot Saturday: SFML C#

Image


Working on my C# framework for SFML.NET. C# is actually really neat and I've been having a lot of fun with it! Although I'm getting to the tricky parts now... gotta implement some stuff like animations, texture atlases, and collision next! I just found out how easy it is to use shaders on render textures in SFML too, so I'm pretty excited to start messing around in shader land in the coming weeks.