Spirits
Hi,

I'm starting to work with Voxel Studio and Unity.
I'm just trying to do some test to export the terrain generated with Voxel Studio into Unity.
I followed the online documentation to setup the client and export the bundle to the right Streaming Assets folder (With the include Materials checkbox checked). But once the terrain is loaded inside Unity everything appears black without texture.

I might have miss something. Anyone already had this kind of issues ?

I'm using unity 2018.1.1f1 and Voxel Studio 3.0.1.5

Please see the attached screenshots.

Thank you very much,
Regards.


In Voxel Studio

VoxelStudio.png
  
Result in Unity
Unity.png 
0 0
Ericool
Hi Spirits,
This issue is related to Unity 2018 and we fixed it for the upcoming release.
You can quickly fix the shader compilation error by replacing some code in the plugin common cginc shader.
In Assets/Voxel Farm Unity Plugin/Resources/shaders/cellrender_common.cginc,
you can add at the top of the file :

#if defined(SHADER_API_D3D11) || defined(SHADER_API_XBOXONE) || defined(UNITY_COMPILER_HLSLCC) || defined(SHADER_API_PSSL) || (defined(SHADER_TARGET_SURFACE_ANALYSIS) && !defined(SHADER_TARGET_SURFACE_ANALYSIS_MOJOSHADER))
#define UNITY_LOAD_TEX2D(tex, coord) tex.Load(int3(coord, 0))
#else
#define UNITY_LOAD_TEX2D(tex, coord) tex2Dfetch(tex, int4(coord, 0, 0))
#endif

then simply replace the function loadMaterialProperty by this :

inline float loadMaterialProperty(int materialId, int propertyId)
{
#ifdef VOXELFARM_SUPPORTS_TEXEL_FETCHING
const float4 texel = UNITY_LOAD_TEX2D(materialProperties, int2(materialId, propertyId));
#else
const float2 texelSize = materialPropertiesTextureProperty.xy;
const float4 texel = UNITY_SAMPLE_TEX2D(materialProperties, float2(propertyId, materialId) * texelSize + 0.5 * texelSize);
#endif

#ifdef VOXELFARM_SUPPORTS_FLOATING_POINT_TEXTURE
return texel.r;
#else
return DecodeRGBAFloat(texel.rgba);
#endif
}

I hope it helped you.
Have a nice day.
0 0
Spirits
Hi Ericool,

I think the fix you gave me depends on other changes you made on other part of the shader, so it won't work out of the box.
But just by changing the previous definition of UNITY_LOAD_TEX2D  with


#if defined(SHADER_API_D3D11) || defined(SHADER_API_XBOXONE) || defined(UNITY_COMPILER_HLSLCC) || defined(SHADER_API_PSSL) || (defined(SHADER_TARGET_SURFACE_ANALYSIS) && !defined(SHADER_TARGET_SURFACE_ANALYSIS_MOJOSHADER))
#define UNITY_LOAD_TEX2D(tex, coord) tex.Load(int3(coord, 0))
#else
#define UNITY_LOAD_TEX2D(tex, coord) tex2Dfetch(tex, int4(coord, 0, 0))
#endif


It works fine, there is no need to replace the loadMaterialProperty function otherwise it will cause some error (e.g "
materialPropertiesTextureProperty" undefined and also VOXELFARM_SUPPORTS_TEXEL_FETCHING and VOXELFARM_SUPPORTS_FLOATING_POINT_TEXTURE is never defined in any case elsewhere)

Anyway, the temp fix seems to work, I hope a better solution will come soon with the next release.

Thank you very much.
Regards.
0 0
Ericool
Hi Spirits,
Yes we'll include a better solution for the next release.
In case you want to find where we define these macros, you'll have to look at the script voxelfarm_ atlas.cs within the method SetMaterialMacros(..).
0 0
Ericool
Hi Spirits, 
I see I actually made a mistake within LoadMaterialProperty,

const float4 texel = UNITY_LOAD_TEX2D(materialProperties, int2(propertyId, materialId));

not int2(materialId, propertyId).

Sorry for that.
0 0