I would like to be able to automatically shift a map with a radial gradient (say black to white) for controlling the level of detail. If the center of the radial gradient is always right below my viewpoint, I could use the grey levels to change the level of detail as a function of the distance from the viewpoint. Could this be done with Python?
Hello Nicolai Steinø
Yes, this is possible with a function layer (reference point is the center).

Here is a simple CGA rule that colors buildings by LOD:
attr LOD = 0
@StartRule
Lot --> extrude(rand(10,30)) ColorByLOD
ColorByLOD -->
case LOD > 3: color(1,0,0)
case LOD > 2: color(1,1,0)
case LOD > 1: color(0,1,0)
else: color(0,0,1)Make sure the rule attribute LOD is connected to the layer attribute:

When you move the camera, call the following python script:
from scripting import *
# get a CityEngine instance
ce = CE()
if __name__ == '__main__':
l = ce.getObjectsFrom(ce.scene, ce.isLayer, ce.withName("'LOD"))[0]
CameraPoI = ce.get3DViews()[0].getCameraPoI()
ce.setAttributeLayerExtents(l, [CameraPoI[0],CameraPoI[2],3000,3000])
ce.setLayerAttributes(l, "attr LOD = sin(u * 180) * sin(v * 180) * 4")
sceneShapes = ce.getObjectsFrom(ce.scene, ce.isShape)
ce.generateModels(sceneShapes, False)Then your city should look like this:

This is genuinely cool! Thanks a lot.
Amazing!
"Make sure the rule attribute LOD is connected to the layer attribute"
How do you do that? ![]()
In the Inspector, click on the drop down arrow next to the rule attribute (see Thomas's screenshot) -> Connect Attribute -> Layer attribute -> select LOD.