Shadow Projection

I’m trying to create a shadow by projecting a simple black texture onto the ground using another object as the projector but it keeps making the entire floor black instead of a small spot. I’m thinking I missed a step or something. I looked in the reference and in the texture projection section there supposedly is some source code but I when I click on the image like it says, nothing comes up.

Oops, the wiki code has changed since that page was written, and clicking on images no longer does anything. I’ve just updated the page with a direct link instead, you can check out the page again for the code in question.

As to your particular problem, you may find it helpful to project a texture that includes some detail, instead of a plain black texture. If nothing else, it will doubtless make it much easier to tell what is going wrong. (My first guess: a plain black texture, with a repeat mode of either WMRepeat, will always extend out over the entire surface anyway, regardless of what projection mode you use.)

David

Thanks for fixing the link. I had to modify what was being used in the reference a bit, but I eventually got the results I wanted.

For some reason when I used Decal mode and the setBorderColor script it turned my entire object that color. It did project the other texture but it was doing a replace instead of a Decal. This is what I used. The projector stuff is pretty much the same though.

        self.textureShadow =     loader.loadTexture("../assets/textures/shadow.png")
        self.textureShadow.setWrapU(Texture.WMClamp)
        self.textureShadow.setWrapV(Texture.WMClamp)
        self.textureStage = TextureStage('ts')
        self.textureStage.setSort(1)
        self.textureStage.setMode(TextureStage.MBlend)
        self.textureStage.setColor(Vec4(0,0,0,1))

Thanks again

It turned your entire object the border color? That is, no part of the texture itself was visible on your object? It sounds like your projector wasn’t pointed in the right direction, then, and you were projecting your texture somewhere else.

David