Sorry for a bit late replay, but after some digging I have found all the information needed to render particles correctly as they are rendered in TimeLineFX Editor.
Just to confirm, TimLineFX Editor uses TimeLineFX BlitzMax code library. Yes or no?
First, blend states from BlitzMax module you linked on the 1st page are not used. TimeLineFX has its own BlitzMax module where it configures blend states :
Case ALPHABLEND glEnable GL_BLEND glBlendFunc GL_ONE, GL_ONE_MINUS_SRC_ALPHA glDisable GL_ALPHA_TEST Case LIGHTBLEND glEnable GL_BLEND glBlendFunc GL_ONE, GL_ONE glDisable GL_ALPHA_TEST
Second, color is not used “as is”, but is multiplied by alpha value :
Method SetColor(red:Int, green:Int, blue:Int) currentred = red currentgreen = green currentblue = blue color4ubext = Min(Max(red, 0), 255) * currentalpha color4ubext = Min(Max(green, 0), 255) * currentalpha color4ubext = Min(Max(blue, 0), 255) * currentalpha glColor4ubv color4ubext End Method
Third, since color is multiplied by alpha, I assume texture color should also be multiplied by texture alpha :
float4 texture_pixel = shaderTexture.Sample (SampleType, input.texture_coordinates); texture_pixel.x = texture_pixel.x * texture_pixel.w; texture_pixel.y = texture_pixel.y * texture_pixel.w; texture_pixel.z = texture_pixel.z * texture_pixel.w; return texture_pixel * input.color;
Fourth, C++ library is ignoring IMPORT_OPTION attribute so images with GREYSCALE option are not loaded correctly. TimeLineFX loads such images by running them through this function first :
Function GreyScale:TPixmap(pixmap:TPixmap) Local pixmapcopy:TPixmap = CopyPixmap(pixmap).Convert(PF_RGBA8888) Local p:Byte Ptr Local c:Int For Local loc:Int = 0 Until pixmapcopy.capacity Step 4 p = pixmapcopy.pixels + loc c = Min((p *.3) + (p *.59) + (p *.11), p) p = 255 p = p p = p p = c Next Return pixmapcopy End Function
With all that information I can now render correctly particles with alpha blending. 🙂