Shadow mapping problem

I am pretty sure that shadow maps/fake caustics work by simply applying a texture to a lamp, but… argh! Look at the angle of the lamp and the mapping of the texture! Am I missing something?
I was just preparing for an underwater scene and just wanted to check if everything works as I expect.

http://www.nicohagen.com/images/img/lightmapping.jpg

Are you using procedural textures or an image? I just tried it with some procedurals and it worked out ok. I don’t think you can use a bitmap image because it’ll stretch.

Try using voroni noise and increase the size in the noise options a bit.

It works the way you expect it to here
http://members.shaw.ca/rjplus/shadowmap.jpg

It looks as though you have the texture mapped to the objects as well as or rather than the lamp. Also be sure to set your lamp texture mapping to view or global

edit bitmapped images work fine, I’ve used them to fake light through windows etc. and cast the proper shadows.

GreyBeard

What noise values did you use GreyBeard? Those caustics look really good.

That’s good to know, I always thought they would stretch. Now you mention it, there’s no reason why they should as they’re being projected the same as the procedural textures.

What noise values did you use GreyBeard? Those caustics look really good.

Voronoi f1 – noise size 1.5 depth 2.0

Here’s what an image mapped texture looks like (black and white using calc alpha). Looks better when you blur the image texture, I didn’t do that here.

http://members.shaw.ca/rjplus/window.jpg

Of course my test is not meant to achieve the fake caustics effect. I am using an image texture and the way I see it, the projection is wrong. It could even be that the projection of the procedurals is wrong, but you don’t see it that clearly because of the nature of procedurals.

I mean, they have to be stretched, don’t they?

Did I find a bug? Or a ‘feature’? :wink:

nico,

I believe you are misunderstanding how it works. Putting a texture on a lamp is not the same as shining a spot light through a plane with a texture on it. Putting a texture with alpha on a plane in front of the spot light would give the distortion you are expecting. Your first picture shows how a texture on a lamp works – in areas the spot would normally completely illuminate the light/shadow pattern is mapped either to global, window or object coordinates. Your lamp texture looks to be mapped globally which means it projected along the z-axis (not the direction of the spot) just like with material textures and therefore you see the texture stretching along the z axis (the sides of your cube).

edit
You can map in the direction of the spot by using the object mapping option with the object being an empty with the z axis in the direction of the spot
http://members.shaw.ca/rjplus/shadobject.jpg
(sorry about the dark image)

Hope this helps,
GreyBeard

GreyBeard, you are right. I actually thought that using a texture on a light would be like shining through a plane with alpha texture.

But now I ask: What sense does it make to map the texture like this? The only cases I could think of would be simulating caustics, light shining through brushwork etc. I all of these cases I want the texture mapped from the light source.

I must be possible to create a real shadow map. Using a plane with alphe would be pretty resource-eating I guess.

I all of these cases I want the texture mapped from the light source.

Yes you usually want it mapped from the light source and therefore use an empty at the same position as the light source with the z axis pointing in the same direction as the spot and an object mapping (the empty). I usually map sea bed caustics globally however because it easier and no empty is required. If your camera and spot are aligned you can use “view” mapping and the empty isn’t required. You have to remember that raytracing and therefore shadows through planes with alpha are a relatively recent addition to blender. We used to have to be more creative to achieve the results we wanted.

edit for instance if I wanted the shadows in my previous picture to fan out from the light source and get fuzzier in the distance I would actually draw my shadow texture that way

Hope this helps,
GreyBeard

Is it possible to animate the fake caustics using the lamp texture? I mean without moving the lamp so that it’s cyclic.

Also, how do you stop lamp textures from tiling. Say I attach a single image to a lamp texture, how do I stop it repeating?

Is it possible to animate the fake caustics using the lamp texture? I mean without moving the lamp so that it’s cyclic.

Yes, with the pointer/cursor in the lamp texture panel just use the “i” key to insert a key for locations and or size. You can the edit the ipo curves as with any other type of animation. I usually use several lamps overlapping each other repeating their animations in a different number of frames (I use prime numbers like 37). This way although the individual patterns repeat the effect as a whole doesn’t appear to repeat.

Also, how do you stop lamp textures from tiling

The same way as with other textures, in the panel where you load your texture their are extend, repeat, clip options. You may have to play with the dx, dy, dz and size buttons in the lamp texture panel to get it where you want.

http://members.shaw.ca/rjplus/norepeat.jpg

Hope this helps
GreyBeard

Thanks Greybeard, that’s a big help. :smiley: