Commit ba7145cd authored by Thomas Albrecht's avatar Thomas Albrecht

(hopefully) improved LOD assignment scheme

parent fdfe749a
......@@ -50,13 +50,6 @@ class random_number(object):
def __call__(self):
return self.callback(self.min, self.max)
#random_LOD = random_number(int, 0, 2)
def random_LOD():
r = random.uniform(0,1)
#if r < 0.7: return 2 # -- 60% detail
if r < 0.7: return 1 # 70% rough
return 0 # 30% bare
def random_level_height(place="city"):
""" Calculates the height for each level of a building based on place and random factor"""
#FIXME: other places (e.g. village)
......@@ -477,12 +470,18 @@ def make_lightmap_dict(buildings):
return lightmap_dict
def decide_LOD(buildings):
"""Decide on the building's LOD based on area, number of levels, and some randomness."""
for b in buildings:
lod = random_LOD()
if b.area < 150: lod = 1
if b.area > 500: lod = 0
if b.levels > 5: lod = 0 # tall buildings always LOD bare
#if b.levels < 3: lod = 2 # small buildings always LOD detail
r = random.uniform(0,1)
if r < parameters.LOD_PERCENTAGE_DETAIL: lod = 2 # -- detail
else: lod = 1 # rough
if b.levels > parameters.LOD_ALWAYS_ROUGH_ABOVE_LEVELS: lod = 1 # tall buildings -> rough
if b.levels > parameters.LOD_ALWAYS_BARE_ABOVE_LEVELS: lod = 0 # -- really tall buildings -> bare
if b.levels < parameters.LOD_ALWAYS_DETAIL_BELOW_LEVELS: lod = 2 # small buildings -> detail
if b.area < parameters.LOD_ALWAYS_DETAIL_BELOW_AREA: lod = 2
if b.area > parameters.LOD_ALWAYS_ROUGH_ABOVE_AREA: lod = 1
# mat = lod
b.LOD = lod
tools.stats.count_LOD(lod)
......
......@@ -67,7 +67,15 @@ BUILDING_CITY_LEVEL_HEIGHT_MODE = 3.3
BUILDING_CITY_LEVEL_HEIGHT_HEIGH = 3.6
# FIXME: same parameters for place = town, village, suburb
LOD_PERCENTAGE_ROUGH = 0.7
# -- the more buildings end up in LOD rough or bare, the more work for your GPU.
# Increasing any of the following parameters will decrease GPU load.
LOD_ALWAYS_DETAIL_BELOW_AREA = 150 # -- below this area, buildings will always be LOD detail
LOD_ALWAYS_ROUGH_ABOVE_AREA = 500 # -- above this area, buildings will always be LOD rough
LOD_ALWAYS_ROUGH_ABOVE_LEVELS = 6 # -- above this number of levels, buildings will always be LOD rough
LOD_ALWAYS_BARE_ABOVE_LEVELS = 10 # -- really tall buildings will be LOD bare
LOD_ALWAYS_DETAIL_BELOW_LEVELS = 3 # -- below this number of levels, buildings will always be LOD detail
LOD_PERCENTAGE_DETAIL = 0.5 # -- of the remaining buildings, this percentage will be LOD detail,
# the rest will be LOD rough.
OBSTRUCTION_LIGHT_MIN_LEVELS = 15 # -- put obstruction lights on buildings with >= given levels
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment