Game Development Community

The tile blending effect

by Hugeone · in Torque Game Builder · 10/20/2005 (4:48 am) · 8 replies

In the game, we need some resources, that I want to make it through blending effect.
I have two origin picture, following as:
Sea Tile:
www.bihua360.com/t2d/tile_sea.jpgGrass Tile:
www.bihua360.com/t2d/tile_grass.jpg
I want to use the mask to blending the two tiles. The mask follow as:
www.bihua360.com/t2d/mask.jpg
The result follow as:
www.bihua360.com/t2d/mask_result.jpg
Using the T2D engine , how to do it ?
Anybody can tell me , Thanks.

#1
10/22/2005 (8:24 am)
Obviously this effect is considerably easier to prerender. Assuming that prerendering is not an option, your next best bet would be to use the OpenGL stencil buffer. Unfortunately T2D does not currently have a stencil buffer object though a stencil buffer scene object is not terribly difficult to create. The OpenGL stencil buffer does not do "blending" per say, all it can do is accept or reject fragments. To acheive the effect you desire with the stencil buffer, what you would have to do is render the image 4 times using different stencil masks for each level.

What you are attempting to do appears to be somewhat proprietary to your game so it probably isn't reasonable to assume that the engine should be able to achieve this exact effect. If you wait long enough, someone (myself or someone else) will provide a T2D stencil mask object which you should be able to adapt to your purpose, but as the saying goes: "if you want it now, you'll have to build it yourself" :) The OpenGL redbook would be a good place to start.
#2
10/22/2005 (8:46 am)
@Matthew

What you said is that I can find the solution in the OpenGL reabook. lol
I will consult the relative book in the next time. If you have time to do it, please post your method in here. I will know it quickly. Thanks a lot.
#3
10/22/2005 (1:49 pm)
Perhaps use anti-grain to prerender.
#4
10/22/2005 (8:46 pm)
I wouldn't start hacking OpenGL code, but that's just me... I'd rather spend my time scripting and making art...

@Huge- instead of having a separate mask image, why not create 2 separate tiles for the sea, one with no alpha channel and one with a stepped alpha channel that goes to 0 alpha. (transparent). Then simply layer the sea w/ alpha channel over the grass tile - et voila exactly what you have for "The result follow as". You wouldn't even need to set blending modes.

If you want to do it with a mask, and I think it may be possible to do it with T2D blending modes, play around with T2D Blending Demo. I played with it a while using your images and could not achieve the affect, but did get close. This shows your images overlapping sprites with various blend effects applied:
mindlube.com/garagegames-forum/screenshot_005-00001.png
Always fun to mess around with blending modes :-)
#5
10/23/2005 (1:30 am)
@Alex

Hi, thank you give me a reply.
You offer to me a method "why not create 2 separate tiles for the sea, one with no alpha channel and one with a stepped alpha channel that goes to 0 alpha. (transparent) ... ", I want to know how to edit the tile source image, please give me two sample images. lol

You can use my sample image and to edit the sample image, thanks a lot.

On the other hands, I also play around the " T2D Blending Demo", but I cannot find a blending method that can show the blend effect.
#6
10/23/2005 (9:17 am)
How to edit it, depends completely on what graphics app you are using. For the sea make it like this image you already made, except use a transparent background instead of the grass image.

www.bihua360.com/t2d/mask_result.jpg
#7
10/23/2005 (9:17 am)
And use a format that supports alpha channel (e.g. not jpg)
#8
10/23/2005 (6:46 pm)
The steps:
1 source tile_sea.jpg destination mask.bmp
LayerMode: ZERO ONE_MINUS_SRC_COLOR
2 clip the blending effect file and save as a new file:step1.png;
3 source tile_grass.jpg destination mask.bmp
LayerMode: ZERO SRC_COLOR
4 clip the blending effect file and save as a new file:step2.png;
5 source step1.png destination step2.png
LayerMode: ONE ONE
6 the final effect