Hi,
Has anyone managed to get the Distance parameter of WorldShadows to work?
I would assume that it wouldn't draw the shadows of objects that are more than Distance away from the camera, but it doesn't seem to do anything.
I've tried changing the WorldShadows.pb example from -1 to 30 and then pulling the camera back with the cursor keys, but nothing happens to the shadows.
Could someone try it out and let me know if it's working as expected, or what I should be expecting?
Thanks in advance,
Julian
WorldShadows Distance working?
Re: WorldShadows Distance working?
Hello, Julian
I've had this same problem for a quite some time. As far as I know when you exceed the distance (that was set with the worldshadows)
the shadows should disappear. Unfortunately, I have never succeeded in making that happen. My guess would be that there is a bug in it.
There is a way to make the shadows disappear if you don't mind some basic math. In this example you will see a cube over a plane. When you zoom
the camera out past 50 units the shadows from the cube will disappear.
Then if you zoom back in the shadows will reappear when closer then 50 units.
I use EntityRenderMode(#Entity,#Mode) to accomplish this.
I set #Mode to 0 to disable the shadows and then set #Mode to #PB_Entity_CastShadow to make the shadows reappear.
Hope that made sense if not I can try to explain myself better.
I've had this same problem for a quite some time. As far as I know when you exceed the distance (that was set with the worldshadows)
the shadows should disappear. Unfortunately, I have never succeeded in making that happen. My guess would be that there is a bug in it.
There is a way to make the shadows disappear if you don't mind some basic math. In this example you will see a cube over a plane. When you zoom
the camera out past 50 units the shadows from the cube will disappear.
Then if you zoom back in the shadows will reappear when closer then 50 units.
I use EntityRenderMode(#Entity,#Mode) to accomplish this.
I set #Mode to 0 to disable the shadows and then set #Mode to #PB_Entity_CastShadow to make the shadows reappear.
Hope that made sense if not I can try to explain myself better.
Code: Select all
;*******PRESS ESCAPE TO EXIT*******
Define.d KeyY,KeyX
InitEngine3D()
InitSprite()
InitKeyboard()
InitMouse()
ExamineDesktops()
DeskWid=DesktopWidth(0)
DeskHei=DesktopHeight(0)
OpenWindow(0,0,0,DeskWid,DeskHei,"Test",#PB_Window_ScreenCentered)
OpenWindowedScreen(WindowID(0),0,0,DeskWid,DeskHei)
CreateTexture(0,32,32)
StartDrawing(TextureOutput(0))
Box(0,0,32,32,RGB(200,200,200))
StopDrawing()
CreateMaterial(0,TextureID(0))
CreatePlane(0,100,100,1,1,1,1)
CreateEntity(0,MeshID(0),MaterialID(0),0,-10,0)
CreateCube(1,5)
CreateEntity(1,MeshID(1),MaterialID(0),0,0,0)
CreateLight(0,RGB(245,245,205),5,40,10)
CreateCamera(0,0,0,100,100)
MoveCamera(0,0,0,30,#PB_Absolute)
KeyY=30
WorldShadows(#PB_Shadow_Modulative)
Repeat
Event=WaitWindowEvent(0)
If ExamineKeyboard()
If KeyboardPushed(#PB_Key_Up)
KeyY=KeyY-0.5
ElseIf KeyboardPushed(#PB_Key_Down)
KeyY=KeyY+0.5
EndIf
EndIf
If KeyY>50
EntityRenderMode(1,0)
ElseIf Key<50
EntityRenderMode(1,#PB_Entity_CastShadow)
EndIf
MoveCamera(0,KeyX,0,KeyY,#PB_Absolute)
CameraLookAt(0,0,0,0)
RenderWorld()
FlipBuffers()
Until KeyboardPushed(#PB_Key_Escape)
Re: WorldShadows Distance working?
Hi Samuel,
Thanks for the suggestion, that's a good idea. However, I'm using StaticGeometry, and I don't think I can alter the shadows after its been created. I guess I could create a static geometry for every object I place down, and remove/readd and change the shadow state, but I think that would defeat the purpose of using staticgeometry.
I'm wondering if there is a shadow removal feature for staticgeometry that hasnt been implemented yet.
I might have a play using entities instead so I can use your shadow trick, and see how much of a performance hit I take on this.
Thanks
Julian
Thanks for the suggestion, that's a good idea. However, I'm using StaticGeometry, and I don't think I can alter the shadows after its been created. I guess I could create a static geometry for every object I place down, and remove/readd and change the shadow state, but I think that would defeat the purpose of using staticgeometry.
I'm wondering if there is a shadow removal feature for staticgeometry that hasnt been implemented yet.
I might have a play using entities instead so I can use your shadow trick, and see how much of a performance hit I take on this.
Thanks
Julian
Re: WorldShadows Distance working?
I have no idea if its possible to deactivate shadows on a StaticGeometry. I don't use them very often.
As for the entitys being a huge draw on performance that is a possibility, but depending on what your doing there
are ways around that.
For example if your creating a world for a game you could try using CameraRange(#Camera, Near, Far) to cut down on Rendering.
It's hard to say for sure because I don't know what you are doing, but with Purebasic I've always found a way to
accomplish things without to much of a hassle.
As for the entitys being a huge draw on performance that is a possibility, but depending on what your doing there
are ways around that.
For example if your creating a world for a game you could try using CameraRange(#Camera, Near, Far) to cut down on Rendering.
It's hard to say for sure because I don't know what you are doing, but with Purebasic I've always found a way to
accomplish things without to much of a hassle.
