Problems with projecting a texture on a surface

Greetings, I am in the process of understanding how to project a texture into my scene but ran into a little snag…

After getting my test application up and running and got the projection texture technique working (somewhat), I’ve noticed that the surfaces that the texture is being projected on is using the same texture as the projection. My projection texture is clamped by the way.

Expectation is that I should be able to texture the cube and projection texture separately. Though I am not sure what I need to do to work around this.

Code sample: http://pastebin.com/sc1wMF7L

Screenshot:

Tutorial that my code is based on: http://www.opengl.org/resources/code/samples/mjktips/projtex/index.html

I’ve noticed that the surfaces that the texture is being projected on is using the same texture as the projection.

Unless the projection is actually separate geometry (and if you’re using those samples, it isn’t), then the projected texture is the texture your surfaces are using. That’s how you’re projecting it; by having those surfaces use texture coordinates that place the texture in a position that makes it look as though it’s being projected.

If you want the surface to have its own texture in addition to the projected one, then you need multitexturing.

Is multitexturing a common solution when working with projected textures? I would assume so since there isn’t any other way to project something on a textured surface.

You also mentioned that it could be separate geometry, meaning the actual projection could be geometry of its own while the cube room is its own geometry. Could it be easily achieved through that?

Is multitexturing a common solution when working with projected textures?

Multitexturing is sufficiently common that it’s not even a feature anymore. Multitexturing is like triangle rendering or vertex transforms; it’s simply what GPU’s do.

You also mentioned that it could be separate geometry, meaning the actual projection could be geometry of its own while the cube room is its own geometry. Could it be easily achieved through that?

No, but why would you want to?

Fair enough. I wasn’t sure how other developers would tackle that and I thought there would be better ways to achieve that effect. I am also targeting my application for low end machines that doesn’t support shaders and most of GL’s extensions so I am pretty much looking for the most simplest and cheapest way to do it without having to rely on fancy shaders and extensions.

Just wondering :stuck_out_tongue:
I am actually using multitexturing in a lot of cases and I would sometimes reach the limit on how many active textures I could combine. So thats why I was wondering if there was other ways to do without multitexturing, but it looks like thats what I am going to have to do.

Just wondering :stuck_out_tongue:
I am actually using multitexturing in a lot of cases and I would sometimes reach the limit on how many active textures I could combine. So thats why I was wondering if there was other ways to do without multitexturing, but it looks like thats what I am going to have to do.

Yeah, multipass rendering. It’s sloooooow though.

@SamKV : Multitexturing within a GLSL shader allows to use more different textures than in ‘classic GL’ multitexturing, I guess the code base only uses the classic method.

Yeah that would be nice, though I am targeting my application for GPUs that doesn’t support shaders and OpenGL 1.2 or below. I also had bad experience with GLSL and ATI cards :stuck_out_tongue:

Though for the projection issue, I am considering using stencil buffers instead of multitexturing.