masking texture in shader

Hi guys,

So let’s say I have a mesh I create dynamically, as well as a texture and a mask.
I want to use the mask to, runtime, change it to hide/show parts of the mesh - so to mask parts of the texture dynamically.
Any ideas? I’m trying to use this shader:

Shader “Transparent/VertexLit with Z” {
Properties {
_Color (“Main Color”, Color) = (1,1,1,1)
_SpecColor (“Spec Color”, Color) = (1,1,1,0)
_Emission (“Emissive Color”, Color) = (0.0,0.0,0.0,0)
_Shininess (“Shininess”, Range (0.1, 1)) = 1
_MainTex (“Base (RGB) Trans (A)”, 2D) = “white” {}
_Mask (“Mask”, 2D) = “white” {}
_BumpMap (“Bumpmap”, 2D) = “bump” {}
}

SubShader {
Tags {“RenderType”=“Transparent” “Queue”=“Transparent”}
// Render into depth buffer only
Pass {
ColorMask 0
}
// Render normally
Pass {
ZWrite Off
Blend SrcAlpha OneMinusSrcAlpha
ColorMask RGB
Material {
Diffuse [_Color]
Ambient [_Color]
Shininess [_Shininess]
Specular [_SpecColor]
Emission [_Emission]
}
Lighting On
SetTexture [_Mask] {combine texture alpha}
//SetTexture [_Mask] {combine texture}
SetTexture [_MainTex] {Combine texture * primary DOUBLE, texture * primary}
//SetTexture [_MainTex] {combine texture * primary DOUBLE, texture * previous}

}
}
}

How do you define the placement of this mask? Do you define this from the screen position of a texture you drag around, or how?

At the moment I set the alpha of the texture to 0 or 1, runtime. Dunno if that’s the most efficient way…

But how do you place it? I mean, if you want to mask something off on an object, and want this mask to not simply be based on the uvs (because if that is what you want, just pick a transparent shader), then you still need to define how this texture should be placed in relation to the object. Maybe I’m misunderstanding something here… A simple 0-1 is just a value, not a placement. And if a mask should make ANY sense, it needs to know where to be placed…right?