If anybody tested and can post here if LOD work better with more performance using from bge or with python code?
thanks
If anybody tested and can post here if LOD work better with more performance using from bge or with python code?
thanks
roll through a list of scene objects but only x objects per frame, after you reach the end, start over at the beginning
for each object you can set the mesh w/replaceMesh(), and turn invisible/visible and in upbge you can use suspendPhysics() / restorePhysics()
import bge
cont = bge.logic.getCurrentController()
own = cont.owner
def main:
run = round(len(own.scene.objects)*.1)
if 'index' not in own:
own['index'] = 0
for i in range(run):
current = own.scene.objects[own['index']]
if own.scene.active_camera.getDistanceTo(current)> current['ViewDist']
if 'Vsible' in current:
current.visible = False
del current['Visible']
elif 'Visible' not in current:
current['visible'] = True
current.visible=True
if own.scene.active_camera.getDistanceTo(current)> current['PhysDist']
if 'Physics' in current:
current.suspendPhysics()
del current['Physics']
elif 'Physics'] not in current:
current['Phyiscs'] = True
current.restorePhysics()
#you can do replace mesh stuff here as well
own['index']+=1
if own['index']> (len(own.scene.objects-1):
own['index']=0
main()
also note you can set states here as well**
do you know about bitmask ?
i have tested both. the builtin lod is many times faster then even my simplest python solution.
it depends if the # of objects in the scene that are far away
replace mesh is best done by built in LOD - however that wonât turn logic/physics/visibility
upbge has a lod variable you can use to adapt your states without having to compute distance.
just make a mesh with zero verts, then it gets invisible.
doesnt matter if there is one object, or one million objects. the builtin will always be faster. maybe not noticable, but still true.
âreplace mesh is best done by built in LOD - however that wonât turn logic/physics/visibilityâ
turning it invisible /suspend phyiscs will use less resources than a empty mesh*
marking the object as âfreeâ and slapping it ahead of the actor using other logic and mutating it into a new object is probably the best solution if the world is very large.
yes but i use BGE and ask about BGE not upbge
you tell then module of BGE LOD with distance object per object about camera player write in C and C++ is better then write one script example affect 1 tree add 30 times in one map?
index = all objects?
like objects [ ]
i wish made example my tree have 500 faces to distance 25. for distance 50 will have 200 faces for 100 will have 100 faces and for distance 200 will invisible.its good?will have around 10 trees bettween distance 50
for bge (works in 2.74), you can use:
def grass(cont):
owner = cont.owner
mesh = owner.meshes[0]
lod = 0
if mesh.name == "Grass.LOW":
lod = 1
owner["LOD"] = lod
10,000 objects, builtin lod, module mode: 60fps, 65% logic
but what about distance? combine with BGE?
if you know what lod its at, then you dont need to know the distance.
your script is init? mesh name is check by camera like prop name?need repeat dont said me nothing
on each grass, there is a python controller (always true pulse) set to module point to level.grass
when the builtin lod sets the object to a lower lod, the mesh name changes.
grass_lod.zip (1000.0 KB)
you have 10000 objects grass? i work with planes and made control+J after object ready in my map have just 3 small grass(large area) cover around 30% percent of map.hope animate at 10.0 player distance before need create a better LOD possible.The objective is when player in grass grass will have quality, then rest of map have low quality, when player out of grass grass stay low quality and terrain improve quality
thats just a benchmark to show how fast the builtin lod system is. and how slow python is.
configure the grass object to use script mode, and the fps cuts in half.
add a print() and the game just about locks up.
each line of python chops a few more fps.
i understand what your trying to do, and that method is better for the most part. just remember, the more verts in your object, the slower it will be to change the mesh. regardless of how its being replaced.
in my experience, 10,000 verts is too much to replace. i dont recommend adding lod to a landscape.
i have access to a computer that has an hd630 intel gpu. disabling âLightsâ lets me run several hundred thousand verts at vsync 60fps.
yes internal BGE LOD may be have C or C++ procedural and this 2 languages are best to made this.I go use internal for grass trees rocks only.i think will help to FPS.python is good bu not for all in BGE.like i said will work with objects with max 500 faces to reduce to 200 to 100 and will made for distance > 200 will put empty mesh understand? no invisble but mesh without vertices effect like invisble but not is
i see here