SceneKit renders fuzzy edges when plane geometry is large

Originator:miles.chris
Number:rdar://14273241 Date Originated:26-Jun-2013
Status:Closed Resolved:11-Sep-2013
Product:OS X SDK Product Version:10.9
Classification:Other Bug Reproducible:Always
 
26-Jun-2013 06:04 PM Chris Miles:
Summary:

When rendering a Scene Kit SCNPlane geometry of large size (for example, 204800x204800) with a texture image assigned to its material, the texture edges are rendered as randomised fuzzy edges rather than hard edges.


Steps to Reproduce:

Create a SCNPlane with large size and add to scene.

    CGFloat const largeSize = 204800;
    SCNPlane *plane = [SCNPlane planeWithWidth:largeSize height:largeSize];

Assign a texture with hard edges. For example, a simple checkerboard pattern.

    CGFloat textureScale = 2.0;
    plane.firstMaterial.diffuse.contents = [NSImage imageNamed:@"checkerboard128"];
    plane.firstMaterial.diffuse.contentsTransform = CATransform3DMakeScale(textureScale, textureScale, 1.0);
    plane.firstMaterial.diffuse.wrapS = SCNRepeat;
    plane.firstMaterial.diffuse.wrapT = SCNRepeat;
    plane.firstMaterial.diffuse.magnificationFilter = SCNNearestFiltering;
    plane.firstMaterial.diffuse.minificationFilter = SCNNearestFiltering;

Run the app and rotate the scene. The edges of the checkerboard pattern are rendered extremely fuzzy.

The larger the geometry the worse the fuzzy rendering gets.  Changing the size and/or scale of the texture does not appear to make any difference.

A sample project is attached that demonstrates the issue.


Expected Results:

It is expected that the plane is rendered with hard edges, matching the texture, which is the case when the plane geometry is much smaller.


Actual Results:

The plane is rendered with very fuzzy edges, like randomised noise, when rotated. The fuzzyness randomly varies as the scene is rotated.

This was tested to be the case on both 10.8.4 and 10.9 (DP2).


Regression:

n/a


Notes:

We suspect this may be due to loss of precision as the GPU attempts to shade such a large sized geometry. However, maybe there is something that Scene Kit can do in such circumstances, like increasing shader precision. Or maybe it is caused by some issue internal to Scene Kit that could be fixed.


27-Jun-2013 09:53 AM Chris Miles:
Update: if I tesselate the large plane (using segment count) I can fix the rendering issue when running on 10.9.

Note that in 10.8 setting the segment count has no effect. The rendering output still has fuzzy edges.

Example of how I set the tesselation on an SCPlane object:

        NSInteger tesselation = 64;
        [plane setWidthSegmentCount:tesselation];
        [plane setHeightSegmentCount:tesselation];

Is this the recommended way to fix this type of rendering issue?

Would it make sense for Scene Kit to choose a segment count automatically based on the plane size and GPU precision at run time, to avoid these types of rendering issues due to precision loss?



11-Sep-2013: Behaves correctly

Comments


Please note: Reports posted here will not necessarily be seen by Apple. All problems should be submitted at bugreport.apple.com before they are posted here. Please only post information for Radars that you have filed yourself, and please do not include Apple confidential information in your posts. Thank you!