Brian
Hi, I'm trying to setup my voxel farm scene dynamically through code. The idea is that users can mod the terrain with ease. I've set up a new IVoxelLayer and got the texture atlas and materials working well, however I'm having some trouble with some of the material settings. I wish to have a different texture drawn on the side of my material compared to the top.

I noticed that in the Toon Terrain example the Desert Top material is a sub material of the Desert material and they have different values set for angleMin and angleMax. This is exactly the behaviour I want to recreate but when I attempt to do so in code it has no effect. I've pasted a condensed version of my code below, can you tell me if there are any steps I am missing please? I tried copying the DemoGL example as that seems to load the material data from the project.dat file but it hasn't helped.


bool VoxelFarm::Client::CVoxelFarmEmpty::init()
{
    pimpl->materialLibrary.materialCount = 3;
    pimpl->materialLibrary.materialIndex = (VoxelFarm::CMaterial*)malloc(pimpl->materialLibrary.materialCount * sizeof(VoxelFarm::CMaterial));    
    memset(pimpl->materialLibrary.materialIndex, 0, pimpl->materialLibrary.materialCount * sizeof(VoxelFarm::CMaterial));
    pimpl->materialLibrary.materialIndex[2].subMaterials->push_back(1);        
    pimpl->materialLibrary.materialIndex[1].angleMin = 45;
    pimpl->materialLibrary.materialIndex[1].angleMax = 180;
    pimpl->materialLibrary.materialIndex[2].angleMin = -90;
    pimpl->materialLibrary.materialIndex[2].angleMax = 90;
}
0 0
voxelfarmtorres
The steps seem correct. I will double check with devs to see if the angles specified here are in degrees or in cos(angle) space.

How do you verify the submaterial is not applied?
0 0
Brian
Just by looking at it really. The sub material is quite different from the the main mesh. The initial terrain created by the IVoxelLayer implementation set's the terrain to the main mesh and that is the only material I see. (I know that CSimpleVoxelLayer_Perlnd2D::getContourData() set's the material based on the angle of the terrain. This works fine, I'm just trying various things to get sub materials working).

The other place I've seen the sub material not working is when calling stamp_passed_mesh. I just get the main material and the sub material isn't shown. Calling stamp_passed_mesh in the Toon Terrain example shows the sub material correctly.

One thing that I haven't setup properly yet is the material properties texture. However, as far as I can tell, there is no sub material data in the material properties texture. Could this be the source of my problem?
0 0
Brian
Hmm after looking a bit further it seems the sub materials are working to some extent. I noticed that at the boundary of cells there is sometimes a piece of vertical mesh and this is showing the sub material. However if I call stamp_passed_mesh or add_block it only shows the main grassy material on each surface. Does this info help narrow what the problem might be?

submaterial.PNG 
0 0
voxelfarmtorres
In the previous image, which texture corresponds to the material and which to the sub-material?
0 0
Brian
The green material is the main material (1) and brown is the sub material (2). I may have changed some of the angles since my last post. If so the current code is below. When adding and removing blocks I set the build material to 1. (Although I have also tried 2, but still no triplanar materials appeared.)


    pimpl->materialLibrary.materialIndex[1].subMaterials->push_back(2);
    pimpl->materialLibrary.materialIndex[1].angleMin = 45;
    pimpl->materialLibrary.materialIndex[1].angleMax = 180;
    pimpl->materialLibrary.materialIndex[2].angleMin = -90;
    pimpl->materialLibrary.materialIndex[2].angleMax = 90;
0 0