5

I need to do planar reflection mapping in OpenGL. By using a virtual camera (with a reversed camera ray) at the back of reflective plane (a mirror), I rendered the scene to texture, which is then texture mapped to the mirror. The uvs of four corners of the mirror is specified then (using the result of gluProjection). The problem is by default, the uv coordinates are perspective-correctly interpolated, which is not desirable in this case. Is there any way to disable the perspective correction (without using GLSL)?

DQLin
  • 51
  • 3
  • The only thing I can think of is doing the perspective projection on the CPU, and using an ortho matrix... Does that work? –  Feb 03 '16 at 14:07
  • 5
    why not use glsl? You are going to need to learn to program a shader eventually why not now. – ratchet freak Feb 03 '16 at 14:54
  • 5
    It should be possible to do this using projective texture mapping, which can be done in fixed-function by providing 4-dimensional texcoords. I'd have to sit down and do the math to work out the details though. – Nathan Reed Feb 03 '16 at 16:48
  • @DanielMGessel I think that's a good idea. I'll try. – DQLin Feb 07 '16 at 05:05
  • @ratchetfreak Actually it's a project requirement... – DQLin Feb 07 '16 at 05:06
  • 1
    Nathan's right - you can undo perspective projection with a 4th coordinate (I too would have to work out the math); look into texture coordinate generation. I have vague memories that on (very) old hardware precision can crop up as an issue (I think implementing stipple this way was error prone - I never had to do it personally) - so if old hardware is why you're not able to use shaders, you may bump into some oddities at the pixel level. But it is a better approach, especially if you have alot of geometry or if you are using vertex buffers. –  Feb 07 '16 at 12:54
  • @DanielMGessel I figured it out. Just use(sz,tz,0,z) and it works, where z is z-coordinate in eye space. – DQLin Feb 09 '16 at 08:48
  • 1
    If you figured it out yourself, you might want to answer you own question then. – Christian Rau Oct 01 '17 at 16:16

0 Answers0