I have been struggling with poor rendering quality in the Scene Viewer on our Portal. Colored faces appear patchy or as if there is face conflict. The white patchiness is dynamic and shifts as models are rotated in the scene viewer. The models render as solid color surfaces in CityEngine prior to exporting as a scene layer packages. Any tips on ways to have these colors stay solid when rendering in the SceneViewer? Attached are screenshots of this issue where colored faces are not rendering consistently.
Are you generating double faces in your CityEngine models, such as two faces that are exactly on top of each other so that they fight to be rendered on the screen (z-fighting)?
This can happen for example if you create a floor plane for the floor but also do some reporting on the floor in a different rule. The geometry generated by the reporting rule can be eliminated by terminating the rule with NIL.
Or, there might be a bug at certain zoom levels. If you zoom out, do you still get this problem? If you zoom in to the closest zoom level, do you see the problem? Do you get different colors if you re-export the slpk and create a new scene viewer scene? If the problem is not fixed by the comment in the first paragraph (z-fighting), then would you mind posting your code and your CityEngine scene (.cej) file?
Thanks again for your help Cheryl. I do get the problem regardless of zoom level, though the flickering appears to change with zoom level. The polygon floor colors do render correctly as solid color surfaces in CE prior to exporting as scene layer packages. Adding the NIL after the attribute reporting did not appear to solve the issue.
Unfortunately, I will not be able to pass along the polygon feature data these models are generated from, but attached is the rule file that is being used. The rule file was originally written in CE 2015.
Thanks again!
Tess
It looks like there is z-fighting going on with the light gray building that the smaller rooms are on top of. I almost certain this is the problem. The rule you posted seems to only generate the rooms, and I don't think this rule is the cause of the problem. How did you make the light gray buildings? You could try to either lower the light gray plane of the gray building or raise the elevation of the small rooms by a small amount.
Are the colors incorrect? For example, if one floor is supposed to be blue, is the flickering color blue, or is it a completely different color? (I would like to know if the colors are incorrect because this would be an indication of a bug.)
Note: In your rule, there are still places where you could theoretically get z-fighting. The AddOutline rule ends up creating the floor with the desired color. However, for the rules Lot, Elevator, and StairMaster, it is possible to terminate with some shapes that are not NIL-ed. But, this is not the problem. If you have z-fighting due to the rule, you would see it in CityEngine too. It would also flicker in CityEngine when you move the camera around.
Note: If your Lot rule is executed, then normals would be reversed, but only for the shape that follows the shape tree to Lot. This would not reverse normals for the shapes that proceed through the shape tree to the other rules AddOutline, Report, Elevator, and StairMaster. The important idea I'm trying to say is that when rules are executed, a shape tree is created, and the terminal shapes of the shape tree contain the geometry that you see in the viewport. You can use the Model Hierarchy to visualize the shape tree (Window -> Show Model Hierarchy -> Inspect Model -> click on model).
The colors do appear to be consistent in the web scene and in CityEngine. Here are two images of the same floor plan. The top image is in the web scene and the bottom is in CityEngine. I am not quite sure what the light gray building would be or how to adjust their plane. I do see what you're taking about though. However, in addition, it does look like the halls and other corridors should be rendering as the same dark gray as seen in CityEngine prior to export. It also looks as if the hallways and corridors are also attempting to render in the right color in the web scene.
The Model Heirarchy Explorer is awesome!
I have also browsed over the additional links you attached, and they are definitely helpful. I will keep digging.
Thanks!
Tess
Oh, I thought the light gray background was another building that you had created yourself. Ok, in this case, it seems like it is just the background, or base map. (Note: In the Scene Viewer, you can switch the base map using the controls on the right side.) It also looks like your CityEngine scene is located at y=0, where the grid is visible. In the scene viewer, there is z-fighting between the base map and your models. To fix this, you should add a small elevation to your models in CityEngine before you export. One way to do this is to select all your models and use the move tool to either manually move them by pulling on the green axis handle or type in the amount you want to move the models in the edit box in the tool bar. For example, you could try to type in: 0 0.1 0. This will move your models 0.1m in the y direction.
Here are screenshots of the same floor plan with an offset of 0.01 meters with the street maps and imagery base maps:
There still appears to be some sort of face conflict (apparently with the ground surface) for the ground level floors in the web scene, even after a 0.1 m vertical offset. Also, as it would be nice to have these floors snapped to the ground, any options on how I might work around this conflict?
Thank you!
Tess
Maybe the z-fighting with the ground is not the problem. 0.1m might still be small. What happens if you raise it a very large amount? Does the problem ever go away (when increasing the elevation by some large enough amount)?
Instead of raising the shapes by a certain offset, you could also try extruding the ground shapes to give them a certain volume. Then, they can be on the ground, and they'll have a thickness, similar to real life.
When you say that there seems to be a conflict with the "ground surface", what do you mean by this? How are you making the ground surface? Does this imagery just come from the base map? Are the colors you see a mixture of the base map and the colors of the buildings from CityEngine? What happens if you try to export your CityEngine buildings with different colors? What kinds of colors do you see? Can you try to confirm that the problem is z-fighting between the CityEngine buildings and the base map?
Thank you so much. You have been super helpful. By removing the transparency and adding an extrusion to the fill color shapes on the first floor models, I was able to resolve most of the flickering. I am using a 10 meter DEM as a terrain surface in CityEngine, though I have not been exporting the terrain to our Portal. In web scenes, it appears to load to the 3D basemap correctly. I think the main issue with the flickering for my models is directly related to the uneven terrain. I am not sure of ways to navigate this. For the building in the screen shot below, I have extruded the floors by 1.3 m and am still receiving some z-conflict flickering due to the gentle hills of the terrain (e.g. the left side of the building shown). The colors are solid with no flickering in CityEngine, regardless of elevation offset or extrude height. The issue only seems to appear in the web scene.
I did change some of the colors around and it looks like the rendering remains consistent in the web scene. The colors are accurate and the z-conflict still appears to be in the same location. I will keep an eye out for any issues with color that may look buggy, though I haven't noticed any as of yet. I'll keep you posted if I run into anything.
Thanks again!
Turns out, I did find some color conflict. It appears in both CityEngine and the web scene.
web scene:
CityEngine: