PDA

View Full Version : Problems with projecting a texture on a surface



SamKV
09-21-2010, 09:45 PM
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:
http://img815.imageshack.us/img815/6206/24859124.jpg (http://img815.imageshack.us/i/24859124.jpg/)

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

Alfonse Reinheart
09-22-2010, 12:25 AM
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.

SamKV
09-22-2010, 10:12 AM
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?

Alfonse Reinheart
09-22-2010, 01:48 PM
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?

SamKV
09-22-2010, 01:55 PM
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.

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.


No, but why would you want to?

Just wondering :P
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.

ugluk
09-22-2010, 09:18 PM
Just wondering :P
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.

ZbuffeR
09-23-2010, 01:24 AM
@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.

SamKV
09-23-2010, 08:02 AM
@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 :P

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