. it do the same as in the material script, but we don't need the material script.
#PB_Material_AlphaReject: Enables alpha reject on the texture (useful for semi transparent textures like trees, window, etc).
@Samuel, you told me long time ago somewhere that we can add specific materials to every submesh when i have tried to make a points mesh contains several sizes of sprite points, so i have used this approach
i have changed it trasparency to 30% opacity. i don't know how to do it correctly in photoshop, it is a complex program. so i have changed only the ocean tranparency part .the #PB_Material_AlphaReject works better with semi transparent textures in which it can increase or decrease the trasparency.
by the way we can't cast the color of the semi tranparent mat to the shadow such as the color of stained glass on the table. may be but i have no idea
Code: Select all
#CameraSpeed = 1
Define.f KeyX, KeyY, MouseX, MouseY
If InitEngine3D()
InitSprite()
InitKeyboard()
InitMouse()
ExamineDesktops()
DeskWid=DesktopWidth(0)
DeskHei=DesktopHeight(0)
Add3DArchive(".", #PB_3DArchive_FileSystem)
Add3DArchive(#PB_Compiler_Home + "examples/3d/Data/Textures", #PB_3DArchive_FileSystem)
If OpenWindow(0, 0, 0, DeskWid, DeskHei, "Alpha to Shadow ..... use mouse/arrows to move/rotate the cam", #PB_Window_ScreenCentered)
If OpenWindowedScreen(WindowID(0), 0, 0, DeskWid, DeskHei, 0, 0, 0)
;Parse3DScripts()
Tex = LoadTexture(#PB_Any, "world_map2.png");"3d-clipart-ghost-1.png")
Mat = CreateMaterial(#PB_Any, TextureID(Tex))
MaterialBlendingMode(Mat, #PB_Material_AlphaBlend)
MaterialCullingMode(Mat, #PB_Material_NoCulling )
SetMaterialAttribute(Mat, #PB_Material_DepthCheck, #True)
SetMaterialAttribute(Mat, #PB_Material_DepthWrite ,1)
SetMaterialAttribute(Mat, #PB_Material_AlphaReject, 75);128
CreateMaterial(0,LoadTexture(0,"Geebee2.bmp"))
MaterialCullingMode(0, #PB_Material_NoCulling )
PlaneTexture = LoadTexture(#PB_Any, "MRAMOR6X6.jpg");"3d-clipart-ghost-1.png")
PlaneMaterial=CreateMaterial(#PB_Any, TextureID(PlaneTexture))
PlaneMesh=CreatePlane(#PB_Any,400,400,1,1,1,1)
PlaneEntity=CreateEntity(#PB_Any,MeshID(PlaneMesh),MaterialID(PlaneMaterial),0,-40,0)
EntityRenderMode(PlaneEntity,0);#PB_Entity_CastShadow )
CreateCamera(0, 0, 0, 100, 100)
MoveCamera(0, 0, 20, 80, #PB_Absolute)
CameraBackColor(0, RGB(255,255,0))
CameraLookAt(0,0,-20,0)
CreateLight(0,RGB(150,150,150),0,100,0)
CreateMesh(0)
MeshVertexPosition(-5,-5,0)
MeshVertexTextureCoordinate(0,0)
MeshVertexPosition(-5,5,0)
MeshVertexTextureCoordinate(0,1)
MeshVertexPosition(5,5,0)
MeshVertexTextureCoordinate(1,1)
MeshVertexPosition(5,-5,0)
MeshVertexTextureCoordinate(1,0)
MeshFace(0,1,2)
MeshFace(0,2,3)
AddSubMesh()
MeshVertexPosition(5,-5,10)
MeshVertexTextureCoordinate(0,0)
MeshVertexPosition(-5,-5,10)
MeshVertexTextureCoordinate(0,1)
MeshVertexPosition(-5,-5,0)
MeshVertexTextureCoordinate(1,1)
MeshVertexPosition(5,-5,0)
MeshVertexTextureCoordinate(1,0)
MeshFace(0,1,2)
MeshFace(0,2,3)
AddSubMesh()
MeshVertexPosition(5,5,0)
MeshVertexTextureCoordinate(0,0)
MeshVertexPosition(5,5,10)
MeshVertexTextureCoordinate(0,1)
MeshVertexPosition(5,-5,10)
MeshVertexTextureCoordinate(1,1)
MeshVertexPosition(5,-5,0)
MeshVertexTextureCoordinate(1,0)
MeshFace(0,1,2)
MeshFace(0,2,3)
FinishMesh(#True)
NormalizeMesh(0)
UpdateMeshBoundingBox(0)
SetMeshMaterial(0, MaterialID(0), 0)
SetMeshMaterial(0, MaterialID(Mat), 1)
SetMeshMaterial(0, MaterialID(Mat), 2)
;-Entity
CreateEntity(0, MeshID(0), #PB_Material_None)
ScaleEntity(0, 2, 2, 2)
;WorldShadows(#PB_Shadow_TextureAdditive, 0, RGB(127, 127, 127), 4096)
WorldShadows(#PB_Shadow_TextureModulative, 0, RGB(127, 127, 127), 4096)
EntityRenderMode(BoxEntity, #PB_Entity_CastShadow )
Repeat
Repeat
ev = WindowEvent()
Until ev=0
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
RotateEntity(0,0,0.5,0,#PB_Relative)
RotateCamera(0, MouseY, MouseX, 0, #PB_Relative)
MoveCamera(0, KeyX, 0, KeyY)
RenderWorld()
FlipBuffers()
Until KeyboardPushed(#PB_Key_Escape)
EndIf
EndIf
Else
MessageRequester("Error", "The 3D Engine can't be initialized", 0)
EndIf
End