Reply To: DX 11 implementation
Home › Forums › TimelineFX Module › DX 11 implementation › Reply To: DX 11 implementation
Veki
Hi Peterigz.
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
https://github.com/peterigz/rigz.mod/blob/master/glmax2dext.mod/glmax2dext.bmx
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[0] = Min(Max(red, 0), 255) * currentalpha
color4ubext[1] = Min(Max(green, 0), 255) * currentalpha
color4ubext[2] = Min(Max(blue, 0), 255) * currentalpha
glColor4ubv color4ubext
End Method
https://github.com/peterigz/rigz.mod/blob/master/glmax2dext.mod/glmax2dext.bmx
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[0] *.3) + (p[1] *.59) + (p[2] *.11), p[3])
p[0] = 255
p[1] = p[0]
p[2] = p[0]
p[3] = c
Next
Return pixmapcopy
End Function
https://github.com/peterigz/rigz.mod/blob/master/singlesurface.mod/singlesurface.bmx
With all that information I can now render correctly particles with alpha blending. š