challenging shadow technique requires sideways global tex coords

In game engines, you can bake a shadow from, say, a stationary box onto a floor (also
stationary), and the effect is realistic. However, if, say, a rolling sphere rolls by the box,
the viewer soon sees that the same shadow that is on the floor has no effect on the sphere.

In an attempt to fix this problem, you can take the same baked shadow image for the floor,
and apply it to the sphere using global texture coordinates so that, no matter where the
sphere is, the image stays still, and the sphere reveals whatever part of the image it is
currently positioned over.

This time, when the sphere rolls by the box, the shadow is “revealed” onto the sphere.
This works great, if the sphere is always floor-bound. But what if the sphere needs to move up and down?

(the blend file I’ve attached will demonstrate up to this point)

Well, you’d need to use two more images (one that aligns with the x axis, and another which aligns with the y axis).

Using multiplication, all the shadow bakes (as separate textures) can be layered over the object. (Shadow information from one axis will be controlled by the other axises because at a given point, say that x=1, but y or z = 0, so the excess shadow will be factored to 0)

The question is:
In blender, using the GLSL materials, is there a way to apply Global Texture Coordinates along any other axis than the default?

When I perfect the technique, I’ll publish the when/why/how in a tutorial.

Unless, of course, someone else has already done this technique… anyways, all help and leads are appreciated.

Thank you in advance :slight_smile:

Attachments

lighting.blend (659 KB)

you might have to write a custom GLSL shader to do that. Cool idea tho

Awe, really? You can’t do global coords on x or y? fml…