Incorrect behavior of the texture projection

I tried to implement a light cookie image, but I ran into a quirk, the texture projection does not take into account the depth buffer, as well as the direction of the normals, in addition to this it is projected into both sides. This video demonstrates this problem, I’m not sure if it’s a bug.

My code, which is nothing unusual.

tex_flashlight = Texture("Flashlight")"data/textures/flaight4.png")

ts_flashlight = TextureStage('ts_flashlight')
ts_flashlight.set_color(LVecBase4f(0, 0, 0, 1))

self.lens = PerspectiveLens()
self.lens.set_near_far(0.01, 100)

slight = Spotlight('flashlight')
slight.set_color((20, 20, 20, 1))
slight.set_attenuation(LVecBase3f(0, 1, 0))
slight.set_shadow_caster(True, 1024, 1024)

self.node_path = NodePath(slight)
self.node_path.set_pos(0.5, 0.5, 1.2), tex_flashlight, self.node_path)

It is worth noting that the lighting correctly takes into account the depth buffer.

1 Like

It seems I jumped to conclusions, the light source is rendered correctly because it has shadows. However, when the shadow is turned off, the light also passes through all objects. Perhaps a solution for texture projection would be to use a shadow map for a rendering test.

1 Like

Texture projection is just a fancy way to transform the texture coordinates. It’s not related to shadowing. It is not currently supported by Panda to combine the two features, to my knowledge, you will need to use a custom shader.