Archived

This topic is now archived and is closed to further replies.

Sil

Multipass alpha blending with tiles

Recommended Posts

Sil    151
I'm attempting to render a giant texture offscreen (256x256 pixels) from various single textures (16x16 pixels) that have transitions into one another if their texture index (t) is less than 64. However, if their index is above 64, they partake in no blending whatsoever. The offscreen texture is rendered by a tile map of 17x17 vertices (16x16 tiles). My desired setup is that I first render a tile with its base texture by calling DrawQuad(x,y,t,a,b) where a is 0 and b is 0 so that it will use the mid section of the alpha mask for blending (the mid section is empty, so there is no blending). The second step would be to check the surrounding tiles and see what bleeds into the current tile and from that call DrawQuad(x,y,t,a,b) where a is a value from -1 to 1 and b is a value from -1 to 1, and where a and b can't both be 0. This will create the appropriate mask and then render the tile with the next texture t. The alpha mask I propose looks kind of like this (for the time being): 1 1 1 1 1 0 0 1 1 0 0 1 1 1 1 1 So in order to draw a blend to the south-west tile (x-1,y+1), I'd have to draw the south-west tile on the current tile with a transparency mask generated from a=-1, b=1 which would look like: 1 0 1 1 where the 1s would be the alpha transitions in a bitmap file. My problem lies in the usage of combining the alpha mask with the texture before or during its rendering onto the giant texture. I figured the process for each tile would be: (base texture)<-(alpha mask 1)<-(transition 1)<-(alpha mask n)<-(transition n) which in theory sounds like it would work fine. I'm hoping there are some simple flags to set using settexturestagestate that I haven't figured out yet, perhaps even changing some during the drawing process, because all I can seem to get is this far: (base texture)<-(alpha mask 1) with no transitions at all because the alpha map affects the base texture rather than the subsequent transition. I'd appreciate any help I can get on this, or any links to where I could learn more about similar methods in drawing tiles with alpha masks. [edited by - Sil on May 28, 2003 12:21:55 AM]

Share this post


Link to post
Share on other sites