This project is read-only.

Dynamic Terrain Splatting

Apr 3, 2013 at 5:03 PM
Edited Apr 4, 2013 at 11:26 PM
I am trying to change the alpha masks of splatted textures on a surface defined in xaml whenever certain events happen in the game. I have a snippet of my attempt to do this on github:

When I run this code in the context of my game, a little digging has revealed that the surface's material has the texture I gave it, but I see no change on the screen.

Any help in this respect will be very much appreciated.


I am running Engine Nine 1.6, by the way.
Apr 4, 2013 at 4:12 AM
It's because the mask textures were bound to BeginPaintGroupMaterialPart only when the material was constructed. You can try add the following lines to SetMaskTextures/SetMaskTextureScale method (MaterialPaintGroup.cs line 175/200):
        if (materialGroup != null && materialGroup.materialParts != null)
Tell me if it works for you, I'll commit the change if it solved your problem :)
Apr 5, 2013 at 4:34 AM
Thank you for your swift reply. Your suggestion seemed to work just fine!

Here is a link to my modified versions of the SetMaskTextures/SetMaskTextureScale static methods:

Will these changes appear in the 1.6 branch, or will they just go into master?

In case you're wondering, I am on a team trying to develop a 3D board game with terrain and animated characters to make it more engaging. It has been a great experience building this game on your platform.
Apr 5, 2013 at 5:16 AM
I just ran into another problem here. I'm looking into it, but I thought I would let you know.

When I set the mask texture of a surface, the shaders in the CustomMaterialParts (All defined in xaml) immediately stop working. If you need more information, I'd be happy to give it to you.
Apr 5, 2013 at 5:29 AM
When you say you are using 1.6 do you mean you are using the source code from the 1.6 branch? That was actually the codebase for 1.4 (It is our communication fault)

What has stopped working, did it crashed?
Apr 5, 2013 at 2:33 PM
Edited Apr 5, 2013 at 2:34 PM
We are using the exact source code checked out from your nine.1.6 branch on the git repo.

It doesn't crash, but the shader that I have on one of the splatted material parts stops animating the material when I set the mask texture.

For example,
    <CustomMaterialPart xml:space="preserve">
        float Time:TIME;
        void PixelShader(inout float2 uv:TEXCOORD0)
            uv += frac(Time * 0.05f);
    <DiffuseMaterialPart Texture="{ContentReference Textures/Lava}" />
    <SpecularMaterialPart SpecularColor="0.5, 0.5, 0.5" SpecularPower="64" />
Here I have a shader as a custom material part which animates the texture to slide across the terrain. It stops moving when I change the mask texture. Does that help clear things up?
Apr 6, 2013 at 4:25 AM
This discussion has been copied to a work item. Click here to go to the work item and continue the discussion.