Dear coomunity,
Im trying to create a circular avatar of the 3d character in the HUD. I use a camera projecting to a render texture. And drawing the texture with:
Graphics.DrawTexture(Rect(0,0,84,84), avatarTexture1, new Rect(0, 0, 1, 1), 0, 0, 0, 0, avatarMaterial);
Where avatarTexture1 is the rendertexture and avatarMaterial is a material with a mask shader.
I use a alpha mask in combination with the following shader:
Shader "MaskedTexture"
{
Properties
{
_MainTex ("Base (RGB)", 2D) = "white" {}
_Mask ("Culling Mask", 2D) = "white" {}
_Cutoff ("Alpha cutoff", Range (0,1)) = 0.1
}
SubShader
{
Tags {"Queue"="Transparent"}
Lighting Off
ZWrite Off
Blend SrcAlpha OneMinusSrcAlpha
AlphaTest GEqual [_Cutoff]
Pass
{
SetTexture [_Mask] {combine texture}
SetTexture [_MainTex] {combine texture, previous}
}
}
}
This works perfectly in the Unity editor, but NOT in the webplayer. What could be the problem?
Ps. Drawing the avatar without the material attached works in the webplayer, but then the avatar is not masked (circle shape) which is what I need…