Texture mapping shader example

I’m trying to understand how to map a texture onto my models using a shader. I’ve gone through the tutorial from Panda3D about the textures but I still have a few questions.
Python code:

class App(ShowBase, DirectObject):

	def __init__(self):
		ShowBase.__init__(self)
		DirectObject.__init__(self)

		self.setBackgroundColor(0.0, 0.0, 0.0)
		self.disableMouse()

		self.camLens.setNearFar(1.0, 50.0)
		self.camLens.setFov(45.0)

		self.camera.setPos(0.0, -10.0, 10.0)
		self.camera.lookAt(0.0, 0.0, 0.0)

		self.root = self.render.attachNewNode("Root")

		textureChecker = self.loader.loadTexture("Texture/checker.png")
		textureChecker.setWrapU(Texture.WMClamp)
		textureChecker.setWrapV(Texture.WMClamp)

		"""
		DIRTY
		Try to increase the setSort parameter and look at the results. Somehow we can
		influence the shader, nevertheless the cube is only textured with one texture.
		"""
		stageChecker = TextureStage("Checker")
		stageChecker.setSort(1)

		textureGrid = self.loader.loadTexture("Texture/grid_texture.png")
		textureGrid.setWrapU(Texture.WMClamp)
		textureGrid.setWrapV(Texture.WMClamp)

		stageGrid = TextureStage("Grid")
		stageGrid.setSort(2)

		modelCube = self.loader.loadModel("models/box.egg")

		cubes = []
		for x in [-3.0, 0.0, 3.0]:
			cube = modelCube.copyTo(self.root)
			cube.setPos(x, 0.0, 0.0)
			cubes += [cube]

		shader = self.loader.loadShader("Shaders/lesson7.sha")
		self.root.setShader(shader)

		"""
		In this sample we assign all three cubes the same textures. Get another image
		and try to assign one cube another texture.
		"""
		self.root.setTexture(stageChecker, textureChecker)
		self.root.setTexture(stageGrid, textureGrid)

		self.accept("escape", sys.exit)
		self.accept("o", self.oobe)

	def move(self, x, y, z):
		self.root.setX(self.root.getX() + x)
		self.root.setY(self.root.getY() + y)
		self.root.setZ(self.root.getZ() + z)

	def setup_keys(self):
		self.accept("d", self.move, [1.0, 0.0, 0.0])
		self.accept("a", self.move, [-1.0, 0.0, 0.0])
		self.accept("w", self.move, [0.0, 1.0, 0.0])
		self.accept("s", self.move, [0.0, -1.0, 0.0])
		self.accept("e", self.move, [0.0, 0.0, 1.0])
		self.accept("q", self.move, [0.0, 0.0, -1.0])

First of all, I’ve loaded my own textures and set the modes for how I want them to be displayed on the model.
I believe the TextureStage dictates the order and lets you specify which texture you want to use in your shaders?

When I perform the setTexture command, do I map the stage to the texture? This sets the order for the texture?

Since I used copyTo from the modelCube, each cube inherits the properties from the parent and so each cube has access to the textures that were added to root?

So far, I haven’t specified which vertex coordinates map to which texture coordinates correct? I believe that happens in the shader?

Here’s the shader from the tutorial:

void vshader(
    uniform float4x4 mat_modelproj,
    in float4 vtx_position : POSITION,
    in float2 vtx_texcoord0 : TEXCOORD0,
    out float2 l_my : TEXCOORD0,
    out float4 l_position : POSITION)
{
    l_position = mul(mat_modelproj, vtx_position);
    l_my = vtx_texcoord0;
}

void fshader(
    uniform sampler2D tex_0 : TEXUNIT0,
    in float2 l_my : TEXCOORD0,
    out float4 o_color : COLOR)
{
    o_color = tex2D(tex_0, l_my);
}

Here begins my confusion… First, when I run this, I don’t see my loaded textures. In the vertex shader, the vertex positions correspond to the local coordinates of the model correct? So that if I want the left face of the cube, it would run from (0,0,0) to (0, 1, 1)? How does the vertex shader know what texture coordinate to put for the vertex? And if I want to map a texture to the left side of the vertex would I interpolate where in the texture coordinate space I need to be in depending on the position of the vertex? So, if I wanted to have different textures for each face, I would determine which face I’m currently in and interpolate the texture coordinate? But then what is the use of vtx_texcoord0?

The fragment shader seems more self explanatory to me since it uses what I calculated in the vertex shader to look up the pixel value from the texture that I want to look at.
Thanks for clearing this up.