Projected Textures

What I’m trying to do is project a texture onto a surface and have the texture only show up one time, and not repeated.

I tried these settings:

SurfaceObj.setTexScale(ts, 1, 1);

self.Texture.setWrapU(Texture.WMClamp)
self.Texture.setWrapV(Texture.WMClamp)

The projected texture did show up only once, but it stretched out at the bottom, which I believe is do to the WMClamp call.

Is there a way to achieve the effect I’m looking for (which is a texture projected only once, cleanly)?

I solved it…

self.Texture.setWrapU(Texture.WMBorderColor)
self.Texture.setWrapV(Texture.WMBorderColor)
self.Texture.setBorderColor(VBase4(1, 1, 1, 0))

:smiley:

I think it sucks how the color of a surface is changed even when using projected textures with alpha.

From what I’ve tried, keeping the original surface color is impossible and the texture mode doesn’t make any difference.

If your surface is “blue’ish” in color and you set a texture project of a texture that’s black, your “blue’ish” color now becomes more grey scale looking.

“Bummer…”

:cry:

You’re describing the default mode, MModulate. If you want complete replacement, use MReplace. Of course this will also lose the lighting color, as the Panda3D manual page describes.

It’s possible to retain the lighting color using an additional TextureStage and a more advanced stacking of properties; or you can write a custom shader that does it. Or you can just use MDecal, which loses the lighting color only where the texture is.

All of these are properties of the texture pipeline, regardless of whether you are using projected textures or ordinary textures. (Projected textures are just a special trick with UV’s and do not affect the texture pipeline.) Note also that the texture pipeline is defined by OpenGL (and DirectX) and isn’t under Panda’s control.

David

I actually use decal mode, since the other modes do not serve my cause. The effect turned out nice as long as the textures were similar; that is…grass being mixed with other grass or dirt being mixed with other dirt.

The color boost looks good.

However, when you do something odd like use a projected texture (MDecal) to place a very odd texture (lets say a texture of a space ship) that lovely “boom” of color goes grey toned on you or something worst.

The order of the texture stages do play a role in it, but if a texture is going to be projected on top, it can’t be the first texture stage or it gets covered.

It would probably take another shader generator for this one, because Panda’s current texture modes seem to take into account the whole texture stage, versus modifying the pixels which lay just beneath the projected texture only.

I thought using the alpha and decal mode would fix this because nothing should blend where there is nothing (the alpha), but to my surprise…that wasn’t the case.

Oh well…

There’s another way I can accomplish what I want to, but it’s going to require more programming work. :open_mouth: