shader INVDecalTexture : material
{
	uniform texture2D decalTexture;
	uniform float4x4  decalTransform;
	uniform int       layer;
	uniform bool      HasAlphaChannel = false;
	uniform float     AlphaThreshhold = 1.0f;
    
    // texture coord for basic material 
	varying float2 uv;
	varying float2 uv1;
	varying float2 uv2;
	varying float2 uv3;
	varying float2 uv4;
	varying float2 uv5;
	varying float2 uv6;
	varying float2 uv7;

	varying float3			tangent;
    varying float3			bitangent;

    void scattering()
    {
      	float2 uvs[8] = { uv, uv1, uv2, uv3, uv4, uv5, uv6, uv7};
		float2 texcoord= uvs[layer];

		float2 uvDecal = ( float4(texcoord.x, texcoord.y, 0.0, 1.0) * decalTransform).xy;
		float4 clr     = decalTexture.lookup(uvDecal).rgba;
		
        ///////////////////////////////////////////////////////////////////
        // Diffuse
        ///////////////////////////////////////////////////////////////////
        BSDF diffLobe = lambert(clr.rgb, rt_ShadingNormal);

        ///////////////////////////////////////////////////////////////////
        // Transparency
        ///////////////////////////////////////////////////////////////////
        BSDF transpLobe  = transparent(float3(1.0));
		
        ///////////////////////////////////////////////////////////////////
        // Final Mix
        ///////////////////////////////////////////////////////////////////
        rt_Scattering = mix(clr.a, transpLobe, diffLobe);
    }
       
}
