4

I have a vertex shader that transforms vertices to create a fisheye affect. Is is possible to just use just the vertex shader and use fixed pipeline for the fragment portion.

So basically i have an application that doesnt use shaders. I want to apply a fisheye affect using a vertex shader to transform all vertices, and then leave it to the application to take care to lighting, texturing, etc?

If this is not possible, is it possible to get a fisheye affect by messing with the contents of the gl back buffer?

Thanks

Adham
  • 142
  • 1
  • 10

2 Answers2

3

If your code is on fixed function, then what you described is a problem - that's why having your graphics code in shaders is good: they let you change anything easily. Remember to use them in your next project. :)

OK, but for this particular I assume that you don't want to rewrite your whole rendering from scratch to shaders now...

You mentioned you want to have a "fisheye effect". Seems like you're lucky, because I believe you don't need shaders for that effect! If we're talking about the same effect, then you can achieve it just by replacing the GL_PROJECTION matrix from OpenGL's fixed function to a perspective matrix with a wider angle of vision.

Kos
  • 70,399
  • 25
  • 169
  • 233
  • Can you do this by creating a wider fov? http://local.wasp.uwa.edu.au/~pbourke/miscellaneous/domefisheye/fisheye/ If i can, then your right, im really lucky. I guess i should have called it a fisheye projection. – Adham Nov 22 '10 at 18:48
  • Hm, this thing looks more sophiscated; I was referring to the effect which you have in Quake when you set a high FOV (120 or so instead of 90), it's also sometimes called "fish eye". For what you're posting, indeed shaders would be needed, I think... Or maybe you can transform the vertices on the CPU? Do you have a lot of them? – Kos Nov 22 '10 at 19:03
  • Im open to anything right now so it doesnt matter. How would you transform the vertices on the CPU? – Adham Nov 22 '10 at 19:12
  • I was referring to giving up on the projection/modelview matrix stack and transforming the vertices by yourself in client code before sending them to OpenGL... No, wait- this could work (despite being suboptimal), but would pretty much destroy your lighting. So shaders are the last option imho - and luckily the best; you'll just need to re-implement the lighting in GLSL (not hard) and you will be able to fully enjoy the merits of programmable pipeline. I recommend not to avoid that. – Kos Nov 22 '10 at 19:18
1

Yes, it's possible, altough some cards (notably ATI) don't support using a vertex shader without a fragment shader.

Dr. Snoopy
  • 55,122
  • 7
  • 121
  • 140
  • So if i just compiled and used the vertex shader, everything else that the application does like texturing and lighting will remain? – Adham Nov 22 '10 at 14:59
  • I tried this and id doesnt seem to work. Pretty much everything is black. – Adham Nov 22 '10 at 15:49
  • I believe that the conclusion from Matias could read "it might be possible on some hardware, but that's an unreliable hack and don't do it". – Kos Nov 22 '10 at 16:55
  • How did you do it? On what HW? – Dr. Snoopy Nov 22 '10 at 18:59