This is ridiculously simple.
Okay, we all know you can render an object from the point of view of the light and transform camera coords into UV coords, and do some real-time lighting, but there were always problems actually applying it to game use. Edges went beyond the camera size and other bad stuff happened.
If you poke around in Unreal }{ you'll notice that shadows are just transparent objects that are raised slightly from the surface they are on. Multitexturing doesn't produce the z-fighting that I have seen shadows give on occasion in the engine.
Step 1.
Identify what object you want to cast a shadow for and what light source you are using.
Step 2.
Render the object from the light source. Transform Vertex positions to screen coordinates to make sure your viewport is big enough to accomodate the whole object.
Step 3.
For every surface that is facing the camera, and the camera faces, transform it to camera space coordinates. Do not transform screen coordinates. Correct for Z position relative to the camera by calculating a slope from the area filled by the shadowed object. If the corrected vertex position lies outside the area given by the most-outlying vertices in the object we are shadowing, it is not shadowed.
Step 4.
Knowing which surfaces receive shadows and which do not, copy the surfaces and texture these new, transparent surfaces with the render output. Assign UV coordinates based on x and y position, where x and y are relative to the extreme values for their given z position relative to the camera.
The key difference here is you should assign UV coordinates by transforming the vertex position to camera space and correcting with tformedz(), rather than using screen coordinates. Your code would probably multiply the transformed x and y coordinates by tformedz() and some constant, derived from the area and closeness of the shadowed object.
Alternatively, you can do even faster shadows by simply using a pre-rendered shadow texture, like the fans and other map objects in Unreal }{ have.
Okay, we all know you can render an object from the point of view of the light and transform camera coords into UV coords, and do some real-time lighting, but there were always problems actually applying it to game use. Edges went beyond the camera size and other bad stuff happened.
If you poke around in Unreal }{ you'll notice that shadows are just transparent objects that are raised slightly from the surface they are on. Multitexturing doesn't produce the z-fighting that I have seen shadows give on occasion in the engine.
Step 1.
Identify what object you want to cast a shadow for and what light source you are using.
Step 2.
Render the object from the light source. Transform Vertex positions to screen coordinates to make sure your viewport is big enough to accomodate the whole object.
Step 3.
For every surface that is facing the camera, and the camera faces, transform it to camera space coordinates. Do not transform screen coordinates. Correct for Z position relative to the camera by calculating a slope from the area filled by the shadowed object. If the corrected vertex position lies outside the area given by the most-outlying vertices in the object we are shadowing, it is not shadowed.
Step 4.
Knowing which surfaces receive shadows and which do not, copy the surfaces and texture these new, transparent surfaces with the render output. Assign UV coordinates based on x and y position, where x and y are relative to the extreme values for their given z position relative to the camera.
The key difference here is you should assign UV coordinates by transforming the vertex position to camera space and correcting with tformedz(), rather than using screen coordinates. Your code would probably multiply the transformed x and y coordinates by tformedz() and some constant, derived from the area and closeness of the shadowed object.
Alternatively, you can do even faster shadows by simply using a pre-rendered shadow texture, like the fans and other map objects in Unreal }{ have.