Hi,
i`m trying to get a projector to behave like a real world projector, i managed to project the texture on an object with this extremely simple shader:
Shader "Projector/Texture" {
Properties {
_ShadowTex ("Base (RGB)", 2D) = "" { TexGen ObjectLinear }
}
Subshader {
Tags { "RenderType"="Opaque" }
Pass {
SetTexture [_ShadowTex] {
Matrix [_Projector]
}
}
}
}
this looks exactly the way i want it to be when the camera is in the same position as the projector. My problem is that the texture is applied to all surfaces within the frustum of the projector not taking into account the line of sight of the projector. When i move the camera it looks like this:
The object looks like this (please ignore the Lights):
what i want to achieve is that the texture is only applied to surfaces within the line of sight of the projector and having no texture on everything that the projector cant “see” (for example the wall behind the pillars).
I have tried to do some ZTests in the Shader but they always refer to the current Cameras Depthbuffer for testing and not to the Projectors Buffer.
Any help would be very much appreciated.
David