问题
how i can work programaticly with spell effect in game
i have a effect look like this spell effect
i want to know how i can change the cale of the spell . like change color in distance or when u run some this effect goes to transparent and after 10 sec go to fade
or look at this spell and wepon in this pic like when you have a small wepon and u add a animation effect on it ( like fire or ice effect )
how you change the animation base on the size of the wepon
i have no idea how i have to implement that
thanks in advance
[Edit by Spektre] acording to comments I would change the question text to something like this:
- I need/want to program a spell effect visualization for game or whatever ...
- what are the common/usual approaches to do this (algorithms,graphics techniques)
- want to implement Ice/Fire/??? effects
- in form of rays/waves/field/cones...
- ideally by a single configurable effect routine (I guess this)
- also what are the exact names for some of these effects so I can do a search for them myself
- I want to use Unity3D environment
this is the way i want to know how i can make an dynamic spell effect
回答1:
well there are many approaches for this. I am no expert in the field and not a Unity3D user so I stick to basics:
particle system
It is an engine which visualize particles (many small moving objects). It is used for many effects like: rocket throttle,fire,lighting,changing glow,and many more. The trick is the use of blending so each particle is usually semi transparent ball. More transparent on the outside and more solid on the inside. When you draw more particles close together they blend to the desired continuous effect.
This can be done by single textured
QUAD
orTRIANGLE
. The texture can be white color with alpha channel coded transparency so color of the effect can be coded without change in the texture. Color,size and movement patterns can differ to each other and also with time. These three parameters define the effect look for example you want to cast a electric ray from caster to target so the movement pattern isLINE
. Now distort that line a little by some random numbers so theLINE
becomes aPOLYLINE
and on the Vertex of thisPOLYLINE
you can sometimes free a particle in random direction with limited duration so it will be like some sparks (do not forget to lower their size in time so they dissipate). Also you have to experiment with the speed and size/color of the main particle stream along thePOLYLINE
so it looks right. Some effect need to combine few different particle streams together.Search keywords: particle system,RGBA texture,blending,interpolation
this picture is taken from the link posted in the question. It is a nice example of two particle systems. Yellow straight
LINE
particle stream and greenPOLYLINE
particle stream. Also some green sparks around the main stream are present.texture animation
You can have a little cyclic movie (image by image) in an array of textures so you draw the texture on an plane (usually single
QUAD
orTRIANGLE
) and change the texture after some time to the next , and usually after last go from first again. You can also useBLEND
ing orSTENCIL
techniques to draw only the effect area. If the textures are white (colorless) then the color can be modulated by code. This is mostly used for explosions, fire,...this is simple explosion movie example it is not a cyclic animation so after last frame the effect stops (explosion has finite duration)
来源:https://stackoverflow.com/questions/21420706/how-i-can-work-programaticly-with-spell-effect-in-game