Jump to content
  • Advertisement
Sign in to follow this  

pixel junk style dirt rendering

This topic is 2810 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

hey guys, I have a tile based pixel shader problem. My 2d game is made up of platform tiles. the terrain looks really jagged, which is because it is made up of all square tiles. I was wondering if i could take my raw tile data, somehow feed it into a pixel shader and have it render a smoother terrain for me. from here im assuming the jump isnt too 'big' to making my pixel shader 'grow' grass on the outward facing tile faces, etc... just dont know where to start! how would i go about this?

Share this post

Link to post
Share on other sites

So, you basically want smooth transitions between grass and dirt for instance?
I think the most common solution is to prepare tile sets that have for every kind of neighbor configuration already tiles that blend between two textures.
As an example look at this tile set here.
You can automate the selection of the tiles a little. As an artist you could simply place grass and dirt (without any transitions). Afterwards you could write a method that looks for each tile at the 8 neighbors and replaces the tile in the center by an appropriate one that does blending.
Let’s say “o” is dirt and “x” is grass. We are always looking at the center.
o o o // top adjacent row
o o o // left neighbor, center, right neighbor
o o o // bottom adjacent row
In this case we wouldn’t need any blending to the borders, because all adjacent tiles have the same look. So we don’t change the tile in the center.

o o o
o o o
x o o
In this case you would replace the tile in the center by the tile at the very top right of the tile set I have linked above.
You either do this pre-processing in code or you let your artist place the right tiles in the first place. smile.png
Doing this with shaders is not strictly necessary unless you want more variety, I guess.


Share this post

Link to post
Share on other sites
alternatively you could have greyscale height maps for each tile texture and at the edges of tiles when in game draw both on top of each other with a height modifier in favour from one to the other.
if you make the height maps right you'll get a fairly accurate transition.
Take in the example of a brick path, bricks at .8 height, the gaps in between at .2 when going into a dirt path, dirt at .4 height. the gradiant modifier will change the brick height to .16 and gradually take it down to 0, thus it is no longer visible and in between a nice effect of the dirt coming through the gaps in between.

Its easier than I make it sound, I'm just not good with words.
Either way this would eliminate the need for a mass amount of textures for each transition, though such a solution may turn out prettier. Regardless if the artist is capable of making height maps well this method can be just as beautiful. and far more efficient.

Share this post

Link to post
Share on other sites
Sign in to follow this  

  • Advertisement

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

GameDev.net is your game development community. Create an account for your GameDev Portfolio and participate in the largest developer community in the games industry.

Sign me up!