Posted: 17th May 2023 23:12
frustrated, frustrated, frustrated, frustrated

No matter what I do I have to have my camera view so far my programs slow down in 3d.

That is if I am using a sky box and this is getting very frustrating.

I thought I was lucky to find these two commands but they do not work, so they are bugged, I tested them fully in every way and they do not work.

SetObjectDepthRange()
SetObjectDepthReadMode()

When I set my Sky Box to a size of

SetObjectScale(SkyBox, 1000, 500, 1000)

I have to set my view to over 7000 to even see it.

So then I use the

SetObjectDepthRange()

and set it to 1,8000 and that sounds about correct for a reasonable view rate.

Nothing.

Then I set my sky box to view always no matter what with .

SetObjectDepthReadMode()

And nothing.

Sounds to me the read mode is bugged or the commands do not work.

If anyone knows anything about this please explain.

Thank you.
Posted: 18th May 2023 6:21
I think what you are looking for is SetCameraRange.
SetObjectDepthRange refers to the depth buffer as far as I know and it can only have values between 0.0 and 1.0.
Posted: 18th May 2023 6:33
I am setting my camera range and that is the problem, I can only set it real high to see the sky box, there is no in-between.

So if I set my

Setcamerarange() to 1,1000 I can not see my skybox, If I set it to 80000 I then can see my sky box.

So is there a way to tell a object to be drawn at all times no matter what range the camera is in?
Posted: 18th May 2023 8:13
Ok so I learned something.

Answer here
Posted: 18th May 2023 11:19
Hi

If you use a skybox (like a sphere uvmapped), perhap's you could fix this object to the player (or get the position of the player each frame). So you don't need to have a camerarange too far, only a camerarange to see the skybox, and the fps will be good.

+ Code Snippet
// Project: camerarange_skybox 
// Created: 2023-05-18

// show all errors
SetErrorMode(2)

// set window properties
SetWindowTitle( "camerarange_skybox" )
SetWindowSize( 1024, 768, 0 )
SetWindowAllowResize( 1 ) // allow the user to resize the window

// set display properties
SetVirtualResolution( 1024, 768 ) // doesn't have to match the window
SetOrientationAllowed( 1, 1, 1, 1 ) // allow both portrait and landscape on mobile devices
SetSyncRate( 30, 0 ) // 30fps instead of 60 to save battery
SetScissor( 0,0,0,0 ) // use the maximum available screen space, no black borders
UseNewDefaultFonts( 1 ) // since version 2.0.22 we can use nicer default fonts
SetAntialiasMode(1)


setcamerarange (1, 1, 1000)

skybox = CreateObjectSphere(490, 32,32)
SetObjectFogMode(skybox, 0)
SetObjectCullMode(skybox, 0)
SetObjectColor(skybox, 150, 200, 255, 255)
SetObjectLightMode(skybox, 0)

SetFogrange(100, 300)
SetFogMode(1)
SetFogcolor(170, 210, 255)

player = CreateObjectBox(10,20,10)
SetObjectPosition(player, 0, 10,0)
SetObjectColor(player, 200, 150, 100, 255)

ground = CreateObjectPlane(2000,2000)
RotateObjectLocalX(ground, 90)
SetObjectColor(ground, 50, 155,100,255)
s = 2 // speed

y = 50
z = 90
SetCameraPosition(1, getobjectX(player), y, getobjectZ(player)-z)

// Create some box to see the player walk
For i= 0 to 50
	box = CreateObjectBox(10,10,10)
	SetObjectPosition(box, random(0, 950), 5,random(0, 950))
next

do
    if GetRawKeyState(38)
		
		MoveObjectLocalZ(player, s)
		SetObjectPosition(skybox, getobjectX(player),0,getobjectZ(player))
		SetCameraPosition(1, getobjectX(player), y, getobjectZ(player)-z)
	elseif  GetRawKeyState(40)
		MoveObjectLocalZ(player, -s)
		SetObjectPosition(skybox, getobjectX(player),0,getobjectZ(player))
		SetCameraPosition(1, getobjectX(player), y, getobjectZ(player)-z)
	endif
	
    Print( ScreenFPS() )
    Sync()
loop


 
Posted: 18th May 2023 14:00
Thank you Blendman

I will look at your code and play with it.