Making parts of Texture2D transparent in XNA -
i'm starting game development , thought game tank wars or worms nice. hardest part can think of far making terrain destructible , want know how it's done before doing easy parts.
i thought explosion have mask texture scaled different weapons. using mask should make underlying terrain transparent (and optionally draw dark border). http://mikakolari.fi/wp-content/uploads/2010/10/terrain.png how achieve that? have change alpha value pixel pixel or can use kind of masking technique? drawing blue circle on top of terrain isn't option.
i have versions 3.1 , 4.0 of xna.
this difficult question answer - because there many ways it. , there pros , cons each method. i'll give overview:
as overall design, need keep track of: original texture, "darkness" applied, , "transparency" applied. 1 thing can sure want "accumulate" results of explosions somewhere - don't want doing maintaining list of explosions have ever happened.
so have surfaces texture, darkness , transparency. merge darkness , transparency single surface single channel stores "normal", "dark" (or level of darkness) , "transparent".
because don't want dark rings progressively darker intersect, when apply explosion darkness layer max
function (math.max
in c#).
to produce final texture write darkness/transparency texture original texture or copy of (you need update area each explosion touches).
or use pixel shader combine them - details of beyond scope of question. (also pixel shader won't work on xna 4.0 on windows phone 7.)
Comments
Post a Comment