OpenGL and OpenSceneGraph, mask projective texture

Hi,

I am beginner in the OpenGL and OpenSceneGraph. I have made a program for Projecting textures using fragment and vertex shaders. The problem is that texture is projected throughout the object.
I have an idea to deal with this by using shadows (depth) map. The position of light source is the same like the position of the projector, which I used for Projecting texture.
The idea is to disguise (mask) all the textures of the object that are in shadow. Actually, I want to projects a texture only to do visible part of object (at the time of shooting).
How to create a shadow (depth) map in OSG and send it to OpenGL sheader? How to mask unwanted texture on 3D model?

Thank you!

Cheers,
Mateo