Terrain issues?

Feb 28, 2013 at 11:00 AM
I'm having some problems with the terrain in Engine Nine! I have managed to successfully generate a square of terrain, however when I move the camera, the amount of terrain you can see changes. The problem is best described using the pictures attached. It looks like a problem with the near and far planes, however they are set to 1 and 20000 respectively. Any help would be greatly appreciated!!

Image

Image

Image
Coordinator
Mar 1, 2013 at 7:23 AM
Hi tom,

It seems to be a problem caused by bounding box and frustum culling. Can you enable diagnostic drawing using scene.DrawDiagnostics and how me a screenshot of how the bounding boxes look like?
Mar 1, 2013 at 10:50 AM
Hi yufeih, thanks for the rapid response!

I enabled diagnostic drawing using the following code, but it didn't seem to do anything.. I tried putting it in the update method and draw method, but still couldn't see any bounding boxes..
        GraphicsDevice graphicsDevice = GraphicsDevice;
        TimeSpan elapsedTime = gameTime.ElapsedGameTime;
        scene.DrawDiagnostics(graphicsDevice, elapsedTime);

Developer
Mar 1, 2013 at 11:00 AM
Do you generate the Terrain in Code?

Note:
If you set the heightmap like this it wont update the Surface's Boundingboxes.
Surface.Heightmap.LoadHeightmap(float[] heightmap)
Mar 1, 2013 at 11:03 AM
I generate the terrain in myScene.xaml like so:

<Surface Heightmap="{ContentReference Assets/firstHeightMap}" Transform.Scale="3, 3, 3"
        Transform.Position="0, -50, 0" LevelOfDetailEnabled="True" 
        TextureTransform.Scale="0.3, 0.3" VertexType="VertexPositionNormalTangentBinormalTexture">

<MaterialGroup MaterialPaintGroup.MaskTextureScale="5, 5">

    <MaterialPaintGroup.MaskTextures>
        <Splatter>
                <ExternalReference>"{ContentReference Assets/firstHeightMap}"</ExternalReference>
                <ExternalReference>"{ContentReference Assets/firstHeightMap}"</ExternalReference>
        </Splatter>
    </MaterialPaintGroup.MaskTextures>

    <MaterialPaintGroup>
        <DiffuseMaterialPart Texture="{ContentReference Assets/image_14}" />
    </MaterialPaintGroup>

    <MaterialPaintGroup>
        <DiffuseMaterialPart Texture="{ContentReference Assets/image_16}" />
        <SpecularMaterialPart SpecularColor="0.5, 0.5, 0.5" SpecularPower="64" />
        <NormalMapMaterialPart NormalMap="{ContentReference Assets/image_16}" />
    </MaterialPaintGroup>

    <DirectionalLightMaterialPart />
</MaterialGroup>
</Surface>
So not using a float for the heightmap?
Developer
Mar 1, 2013 at 11:10 AM
I was pointing out if your doing it in code.

Draw Diagnostic
protected override void Draw(GameTime gameTime)
{
    scene.Draw(GraphicsDevice, (float)gameTime.ElapsedGameTime.TotalSeconds);
    scene.DrawDiagnostics(GraphicsDevice, (float)gameTime.ElapsedGameTime.TotalSeconds);
}
Mar 1, 2013 at 11:17 AM
Oh I see, I'm sorry! My problem was I was doing the draw diagnostics before my scene.Draw.. D'oh!

Image
Image

From these, would I be correct in assuming I'm not generating my terrain quite properly? It only seems to have bounding boxes in the closest corner?
Developer
Mar 1, 2013 at 11:27 AM
Transform.Scale="3, 3, 3"
Might be the issue, try setting the Step higher in the Content Pipeline instead.
Mar 1, 2013 at 11:46 AM
Edited Mar 1, 2013 at 11:47 AM
Hmm, partially fixed the problem! Taking out the Transform.Scale did stop the weird clipping issues. However, now that I've set the step higher (10) the terrain pops out completely flat..

EDIT: Please disregard that! I realised straight after posting what my issue was! Another stupid moment! Thank you very much for the help!
Coordinator
Mar 1, 2013 at 12:17 PM
Edited Mar 1, 2013 at 12:21 PM
Adjust the Height property along with Step.