it seems Samuel have solved this problem before here:
http://www.purebasic.fr/english/viewtop ... 44#p421777
i can't now prepare a suitable batman sign but i have a previously made transparent texture so save this texture:
http://s13.postimg.org/wezihh3l3/batman.png
and replace its name in the AlphaToShadow.MATERIAL samuel have posted at line 24 write texture batman.png -1
and run the code there you will see the shadow of the picture on the ground (the picture in a transparent texture are textured over a cube, and the light cast its shadow on the ground) it is amazing to look at the shadow of a texture.
in the future i will use samuel code and material to make more decorative effect and presentation with a suitable texture and on a plane so it will look like a textured spotlight.
i hope Samuel will agree to repost his code again changed very slightly to show the effect more so the users can run it easily.
put all code and the batman.png picture in the same folder.
AlphaToShadow.MATERIAL ---> by Samuel
Code: Select all
material Transparent
{
receive_shadows off
transparency_casts_shadows off
technique Default
{
pass Main
{
ambient 0.8 0.8 0.8 0.8
specular 0 0 0 0 0
emissive 0.8 0.8 0.8 0.8
cull_hardware none
cull_software none
scene_blend alpha_blend
alpha_rejection greater 128
depth_write on
texture_unit
{
//CHANGE Spark1.png To a texture that has some alpha.
texture batman.png -1
}
}
}
}
the code ___ by Samuel changed a liitle
Code: Select all
;PRESS Escape to exit
#CameraSpeed = 1
Define.f KeyX, KeyY, MouseX, MouseY
If InitEngine3D()
InitSprite()
InitKeyboard()
InitMouse()
ExamineDesktops()
DeskWid=DesktopWidth(0)
DeskHei=DesktopHeight(0)
Add3DArchive(".", #PB_3DArchive_FileSystem);####SET THE PATH TO YOUR MATERIAL SCRIPT.
Add3DArchive(".", #PB_3DArchive_FileSystem);####SET THE PATH TO YOUR TEXTURE THAT THE MATERIAL SCRIPT USES.
If OpenWindow(0, 0, 0, DeskWid, DeskHei, "Alpha to Shadow", #PB_Window_ScreenCentered)
If OpenWindowedScreen(WindowID(0), 0, 0, DeskWid, DeskHei, 0, 0, 0)
Parse3DScripts()
GetScriptMaterial(BoxMaterial, "Transparent")
;LoadTexture(5,"SpotLight2.png")
;AddMaterialLayer(BoxMaterial, TextureID(5) ,#PB_Material_Replace )
;DisableMaterialLighting(BoxMaterial, 0)
BoxMesh=CreateCube(#PB_Any,40)
BoxEntity=CreateEntity(#PB_Any,MeshID(BoxMesh),MaterialID(BoxMaterial),0,0,0)
PlaneTexture=CreateTexture(#PB_Any,32,32)
StartDrawing(TextureOutput(PlaneTexture))
Box(0,0,32,32,RGB(255,255,255))
StopDrawing()
PlaneMaterial=CreateMaterial(#PB_Any, TextureID(PlaneTexture))
PlaneMesh=CreatePlane(#PB_Any,10000,10000,10,10,10,10)
PlaneEntity=CreateEntity(#PB_Any,MeshID(PlaneMesh),MaterialID(PlaneMaterial),0,-40,0)
EntityRenderMode(PlaneEntity,0)
CreateCamera(0, 0, 0, 100, 100)
MoveCamera(0, -50, 0, 120, #PB_Absolute)
CameraBackColor(0, RGB(255,255,0))
CameraLookAt(0,0,-10,0)
CreateLight(0,RGB(100,100,100),0,100,0)
WorldShadows(#PB_Shadow_TextureAdditive, 0, RGB(127, 127, 127), 4096)
Repeat
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(BoxEntity,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