Materials and Alphablending doesn't seem to work properly
Posted: Thu Nov 19, 2015 8:23 am
I attached the altered Code of one of PureBasic's Examples to show the Problem; "BluePotPlant2.png" is a 32 Bit PNG-Image.
The Transparency is correct, but often Billboards that lie behind another one are drawn in front of them instead!
If you look at the Billboards from the other Side its correct.
The Problem comes with textured Meshes/Entities, too, not only with Billboards...
Can someone confirm this as a Bug or am I just doing something wrong?!
My System is Linux Mint 17 x64 with a Intel onboard Gfx-Chip GMA4500
The Transparency is correct, but often Billboards that lie behind another one are drawn in front of them instead!
If you look at the Billboards from the other Side its correct.
The Problem comes with textured Meshes/Entities, too, not only with Billboards...
Can someone confirm this as a Bug or am I just doing something wrong?!
My System is Linux Mint 17 x64 with a Intel onboard Gfx-Chip GMA4500
Code: Select all
;
; ------------------------------------------------------------
;
; PureBasic - Billboard
;
; (c) Fantaisie Software
;
; ------------------------------------------------------------
;
#CameraSpeed = 1
IncludeFile #PB_Compiler_Home + "examples/3d/Screen3DRequester.pb"
Define.f KeyX, KeyY, MouseX, MouseY
If InitEngine3D()
InitSprite()
InitKeyboard()
InitMouse()
If Screen3DRequester()
Add3DArchive(#PB_Compiler_Home + "examples/3d/Data/Textures", #PB_3DArchive_FileSystem)
; First create our material, with a little rotate effect
;
Material = CreateMaterial(#PB_Any, LoadTexture(0, "BluePotPlant2.png"))
;RotateMaterial(Material, 0.05, 1)
MaterialBlendingMode(Material, #PB_Material_AlphaBlend)
; Then create the billboard group and use the previous material
Billboard = CreateBillboardGroup(#PB_Any, MaterialID(Material), 10, 10)
AddBillboard(Billboard, -20, 0, -40)
AddBillboard(Billboard, 0, 0, -40)
AddBillboard(Billboard, 20, 0, -40)
Camera = CreateCamera(#PB_Any, 0, 0, 100, 100)
Repeat
Screen3DEvents()
If ExamineMouse()
MouseX = -MouseDeltaX() * #CameraSpeed * 0.05
MouseY = -MouseDeltaY() * #CameraSpeed * 0.05
EndIf
If ExamineKeyboard()
If KeyboardPushed(#PB_Key_Left)
KeyX = -#CameraSpeed
ElseIf KeyboardPushed(#PB_Key_Right)
KeyX = #CameraSpeed
Else
KeyX = 0
EndIf
If KeyboardPushed(#PB_Key_Up)
KeyY = -#CameraSpeed
ElseIf KeyboardPushed(#PB_Key_Down)
KeyY = #CameraSpeed
Else
KeyY = 0
EndIf
EndIf
RotateCamera(Camera, MouseY, MouseX, 0, #PB_Relative)
MoveCamera (Camera, KeyX, 0, KeyY)
RenderWorld()
Screen3DStats()
FlipBuffers()
Until KeyboardPushed(#PB_Key_Escape) Or Quit = 1
EndIf
Else
MessageRequester("Error", "The 3D Engine can't be initialized",0)
EndIf
End