Ive made a couple of simple mods to the above.
Change shadow texture size by changing the ssize variable.
Hiding the light with the main camera gets a solid shadow...somehow parenting the light to the camera, the light isn't hidden when the camera is? bug?
Using entityalpha b,0 instead of 0.1
Key 1 and 2 switch between perspective and orthoganol shadow camera.
Perspective is obviously more geometrically correct but orthoganol have a cleaner edge to the shadow, not sure which I like best.
Change shadow texture size by changing the ssize variable.
Hiding the light with the main camera gets a solid shadow...somehow parenting the light to the camera, the light isn't hidden when the camera is? bug?
Using entityalpha b,0 instead of 0.1
Key 1 and 2 switch between perspective and orthoganol shadow camera.
Perspective is obviously more geometrically correct but orthoganol have a cleaner edge to the shadow, not sure which I like best.
Graphics3D 800,600,32 SetBuffer BackBuffer() cam=CreateCamera() CameraRange cam,1,10000 MoveEntity cam,0,20,-40 ssize=256 m=CreateCube() ScaleMesh m,1,10,1 PositionEntity m,0,8,0 EntityColor m,100,100,100 l=CreateLight() b=CreateCube() ScaleMesh b,20,1,20 PositionEntity b,0,-1,0 EntityParent m,b t=CreateTexture(ssize,ssize) EntityTexture b,t shadowcam=CreateCamera() PositionEntity shadowcam,30,30,0 PointEntity shadowcam,m CameraViewport shadowcam,0,0,ssize,ssize CameraClsColor shadowcam,255,255,255 CameraProjMode shadowcam,2 CameraZoom shadowcam,.05 r#=32 While Not KeyHit(1) If KeyHit(2) CameraZoom shadowcam,1 CameraProjMode shadowcam,1 r#=64 EndIf If KeyHit(3) CameraZoom shadowcam,0.05 CameraProjMode shadowcam,2 r#=32 EndIf HideEntity cam HideEntity l ShowEntity shadowcam EntityAlpha b,0 RenderWorld ShowEntity cam ShowEntity l CopyRect 0,0,ssize,ssize,0,0,BackBuffer(),TextureBuffer(t) EntityAlpha b,1 For s=1 To CountSurfaces(b) surf=GetSurface(b,s) For v=0 To CountVertices(surf)-1 TFormPoint VertexX(surf,v),VertexY(surf,v),VertexZ(surf,v),b,shadowcam VertexTexCoords surf,v,TFormedX()/r+0.5,1-(TFormedY()/r+.5) Next Next HideEntity shadowcam TurnEntity b,0,1,0 RenderWorld CopyRect 0,0,ssize,ssize,0,0,TextureBuffer(t),BackBuffer() Flip Wend End