Hello everyone!
I'm trying to create a particle emitter using a PolyVector for all the particles, separating each one by a PolyNewStrip. I also want each particle to fade away independently.
My problem is that with this approach it seams I can only change the AlphaMode of the whole PolyVector, instead of the alphaMode of each separated PolyNewStrip (so that each particle can disappear at a random time). I've seen that there is an OpenGL instruction to tint each PolyVector with an RGBA color (which I'd use to tint each particle with an increasing alpha), but I can't seem to find an equivalent instruction in GLBasic.
I'm also open to (and will welcome) any new approach you can give me.
Thank you in advance!
No, that works. You can use individual ALPHAMODEs before each POLYVECTOR. You can even change just one point. You cannot go over zero in one POLYSTART-END call.
You can do this with TYPEs within POLYVECTOR too.
Have a look here: http://www.glbasic.com/forum/index.php?topic=7472
The easy way is to set the alphamode before each polyvector.
STARTPOLY...
ALPHAMODE n
POLYVECTOR...
ALPHAMODE n
POLYVECTOR...
ALPHAMODE n
POLYVECTOR...
ENDPOLY
That was it!
My problem was that I tested if it worked using something like this:
STARTPOLY...
ALPHAMODE 0.1
POLYVECTOR...
(...)
POLYNEWSTRIP
ALPHAMODE 1
POLYVECTOR...
(...)
ENDPOLY
And if you do that (use 1 for the last AlphaMode) then both PolyNewStrips use AlphaMode 1 (is this a bug?). I never thought of using a number close to 1 instead of 1 (i.e., 0.99). Now it works perfectly.
Thank you all very much!!
I am having exactly the same issue using POLYNEWSTRIP. In my main code I have the STARTPOLY and ENDPOLY commands and this function gets called numerous times within my loop to blit sprites onto the screen. So for example if I have..
ALPHAMODE -1
PV_SPRITEZOOM (192, 100, 100)
ALPHAMODE 0
PV_SPRITEZOOM (192, 132, 100)
ALPHAMODE 1
PV_SPRITEZOOM (192, 164, 100)
Every sprite is set to ALPHAMODE 1, I'm using v11.414, is this a bug???
... PVSPRITE Function
FUNCTION PV_SPRITEZOOM: sprite, xpos#, ypos#, scale#=1
// Auto Position
xpos# = xpos# * ZOOM#
ypos# = ypos# * ZOOM#
scale# = scale# * ZOOM#
// Texture UV Info.
patx = SPR_PV[sprite].SPR_PV_X
paty = SPR_PV[sprite].SPR_PV_Y
patxx = SPR_PV[sprite].SPR_PV_X + SPR_PV[sprite].SPR_PV_W
patyy = SPR_PV[sprite].SPR_PV_Y + SPR_PV[sprite].SPR_PV_H
// Sprite Info.
pminx = xpos
pminy = ypos
pmaxx = pminx + SPR_PV[sprite].SPR_PV_W * scale#
pmaxy = pminy + SPR_PV[sprite].SPR_PV_H * scale#
POLYVECTOR pminx, pminy, patx , paty , RGB(255,255,255) // Top-Left
POLYVECTOR pminx, pmaxy, patx , patyy, RGB(255,255,255) // Bottom-Left
POLYVECTOR pmaxx, pminy, patxx, paty , RGB(255,255,255) // Top-Right
POLYVECTOR pmaxx, pmaxy, patxx, patyy, RGB(255,255,255)// Bottom-Right
POLYNEWSTRIP
ENDFUNCTION
Works fine for me with v414.
I use a single STARTPOLY/ENDPOLY to draw absolutely everything - including particles with varying levels of alpha:
ALPHATESTING 0.001
STARTPOLY ID_ATLAS, 2
map.draw()
particleManager.draw()
game.draw()
ALPHAMODE 0.999
Prnt("FPS:" + fps, 40*sX, 10*sY, 0xffffff, 0x00ff00, 0.3*sX, 0.3*sY)
ALPHAMODE -0.0001
ENDPOLY
Each of the draw commands (and the Prnt) all just draw with POLYVECTOR and POLYNEWSTRIP as you do. I wonder if it's how you're using the alphamode (haven't looked in ages, I got it working and left it!) :)
//Andy
When you say how I'm using ALPHAMODE, what do you mean? Seems we're both doing the same here :-) I am using VIEWPORT higher up in the code but this shouldn't make any difference right.
I don't use viewport, but can't see that being an issue.
Try putting ALPHAMODE -0.0001 after you've finished drawing (just before ENDPOLY)
//Andy
Quote from: Ocean on 2013-Jul-12
Can someone please explain why you would want to use transparency for 3D object creation VERSUS putting the transparency into the texture bitmap?
I hate to admit that I don't have an in-depth understanding of the discussion so far.. :(
I'm using polyvectors for sprites and some do have transparency in them which is fine, but doesn't help if I want to fade sprites out or make some bright for additive effects. However so far when trying the ALPHAMODE setting in between each POLYNEWSTRIP it does nothing and just keeps the first or last ALPHAMODE setting.
If I use.. ALPHAMODE -1 or ALPHAMODE -0.99999999 before my ENDPOLY then all the ALPHA settings are the same regardless. However if I use ALPHAMODE -0.99999997 before the ENDPOLY it works. Something is broken in Kansas surely?????
EDIT: The negative alphas work but switching between + and - only the negative work :/
You can't switch between -ve and +ve in a polyvector operation (start/endpoly) as that means you're trying to change the blend mode. It will use whichever you started with and then clamp to those limits. If you're using -ve values then 0 is seen as a different mode, so you need to use a value less than this. Similarly, if you're using +ve (additive blend) then you need to keep all values over 0.
Quote from: fivesprites on 2013-Jul-12
You can't switch between -ve and +ve in a polyvector operation (start/endpoly) as that means you're trying to change the blend mode. It will use whichever you started with and then clamp to those limits. If you're using -ve values then 0 is seen as a different mode, so you need to use a value less than this. Similarly, if you're using +ve (additive blend) then you need to keep all values over 0.
Aha, why thank you :)
Alex_R
Take a llok at this code, he is using a particle like system with STARTPOLY
http://www.glbasic.com/forum/index.php?topic=4251.msg54989#msg54989 (http://www.glbasic.com/forum/index.php?topic=4251.msg54989#msg54989)
Quote from: aroldo on 2013-Jul-27
Alex_R
Take a llok at this code, he is using a particle like system with STARTPOLY
http://www.glbasic.com/forum/index.php?topic=4251.msg54989#msg54989 (http://www.glbasic.com/forum/index.php?topic=4251.msg54989#msg54989)
Will take a nose at the alpha side of thing but I think my issue is going from +1 to -1 and passing the 0 threshold which won't work in a single start/endpoly cycle, might just have 2 setup, one for alpha and shadows and then one for multiplied brightness, but thanks for the link, always good to nose at other code. Just have to study the variables more as its not in native language of English but the code is there to show what everything is :D