I've been trying to figure out a way to mix textures in USDZ, but I can't find anything.
Say I have a model with three textures and three UV Channels. I have texture A on channel 1, texture B on channel 2, and a mask texture on channel 3. I want to blend texture A with texture B using the mask texture and use this composition as color texture. Its a simple math like:
(A * mask) + (B * (1 - mask))
Is there no way of doing this by editing the USDA material def? I did get the textures connected to the respective UV channels, they show up with the assigned UVs when viewing on iOS, but can't find any documentation on adding/multipying the textures.
Need a way to define Texture3 in USDA code for desired result. Or a similar workaround:
def Material "MixedMaterial"
{
token outputs:surface.connect = </Object1/MixedMaterial/SurfaceShader.outputs:surface>
def Shader "SurfaceShader"
{
uniform token info:id = "UsdPreviewSurface"
color3f inputs:diffuseColor.connect = </Object1/MixedMaterial/Texture3.outputs:rgb>
token outputs:surface
}
def Shader "Texture0"
{
uniform token info:id = "UsdUVTexture"
asset inputs:file = @textureA.jpg@
float2 inputs:st.connect = </Object1/MixedMaterial/Texture0/TexCoordReader0.outputs:result>
token inputs:wrapS = "repeat"
token inputs:wrapT = "repeat"
float outputs:r
float3 outputs:rgb
def Shader "TexCoordReader0"
{
uniform token info:id = "UsdPrimvarReader_float2"
token inputs:varname = "UV_Channel_1"
float2 outputs:result
}
}
def Shader "Texture1"
{
uniform token info:id = "UsdUVTexture"
asset inputs:file = @textureB.jpg@
float2 inputs:st.connect = </Object1/MixedMaterial/Texture1/TexCoordReader1.outputs:result>
token inputs:wrapS = "repeat"
token inputs:wrapT = "repeat"
float outputs:r
float3 outputs:rgb
def Shader "TexCoordReader1"
{
uniform token info:id = "UsdPrimvarReader_float2"
token inputs:varname = "UV_Channel_2"
float2 outputs:result
}
}
def Shader "Texture2"
{
uniform token info:id = "UsdUVTexture"
asset inputs:file = @Mask.jpg@
float2 inputs:st.connect = </Object1/MixedMaterial/Texture1/TexCoordReader2.outputs:result>
token inputs:wrapS = "repeat"
token inputs:wrapT = "repeat"
float outputs:r
float3 outputs:rgb
def Shader "TexCoordReader2"
{
uniform token info:id = "UsdPrimvarReader_float2"
token inputs:varname = "UV_Channel_3"
float2 outputs:result
}
}
}