PDA

View Full Version : Refraction



Catman
03-05-2003, 05:04 PM
Hello! I've searched the forum, but I didn't find an answer to my question. I'd like to implement refraction using the CPU (not GPU), but I can't find any good tutorials on this topic. Is there anyone who can help me with some links (to some tutorials)? Mainly I'd like to implement water refraction... Thanks.

Zeno
03-05-2003, 08:04 PM
This is a physics question, not an OpenGL question. Look up Snell's Law on Google.

-- Zeno

rgpc
03-06-2003, 12:34 AM
Originally posted by Zeno:
This is a physics question, not an OpenGL question. Look up Snell's Law on Google.

-- Zeno

Actually I think this is a perfectly valid question unless, of course, Catman is trying to implement it without Opengl (though why you'd want to use the CPU rather than the GPU is a bit beyond me - unless of course you don't have a GPU).

If you have a look at some of the older nVidia (and probably the older ATI) demos, you might find some that don't use the newer extensions (but essentially anything you do with Opengl that doesn't force the driver back to Software will execute on the GPU).

I guess one way you could approach it is to look at the demos, see what they do with Opengl (i would expect it's just tex coords primarily) and do the necessary adjustments to the tex coords etc. before you render your objects.

V-man
03-06-2003, 05:12 AM
They don't teach basic physics anymore in high school (or your country's equivalent)?

We learned this in grade 10.

And certainly can be done in GL. The CG shader site has one and I think it uses fragment programs.

Catman
03-06-2003, 02:52 PM
rgpc, Zeno, of course I want to use OpenGL, I thought it is obvious in an opengl forum... http://www.opengl.org/discussion_boards/ubb/smile.gif

Well, I've found some paper on refraction, but they just explain the theory and I need some tutorials with some code...

And I'd like to use CPU insted of GPU because I'd like it to work on any card. http://www.opengl.org/discussion_boards/ubb/smile.gif

[This message has been edited by Catman (edited 03-06-2003).]

Humus
03-06-2003, 03:17 PM
I have an "Reflection and refractions" demo on my site (http://esprit.campus.luth.se/~humus/) . It uses GL_ATI_fragment_shader though, so it'll require a Radeon 8500 or better. The technique could be altered to work on the CPU for any card. What you then need is a fairly high tesselation and calculated the texture coords yourself for each vertex, instead of in the demo do it for each pixel.

[This message has been edited by Humus (edited 03-06-2003).]

Zeno
03-06-2003, 07:47 PM
Sorry, I didn't mean to sound so snappy in my post. If you have any specific problems with it, post here and I'll try to help.

-- Zeno

[This message has been edited by Zeno (edited 03-06-2003).]

Catman
03-07-2003, 01:08 AM
Zeno, no problem... http://www.opengl.org/discussion_boards/ubb/smile.gif

Humus, I thinks I saw your demo but I have a geforce, so I couldn't test it... But I'll try to figure out something from it...

bakery2k
03-07-2003, 01:14 AM
I have a refraction example using NV_vertex_program, based on the papers from nVidia, at http://users.ox.ac.uk/~univ1234
I'll port it to ARB_vertex_program when I have the time, but for now I hope it is helpful.

[This message has been edited by bakery2k (edited 03-07-2003).]

rgpc
03-07-2003, 04:15 PM
Originally posted by Catman:
And I'd like to use CPU insted of GPU because I'd like it to work on any card. http://www.opengl.org/discussion_boards/ubb/smile.gif


What you really want to ask for is a demo that uses GL without any proprietry extensions (or unextended GL). (ie. no VP/FP's)

cbwan
03-08-2003, 02:20 AM
you should look at paul diefenbach thesis called "Multi-pass Pipeline Rendering::
http://www.openworlds.com/employees/paul/

lots of interesting stuff on reflection, refraction etc..
--
cb

Catman
03-09-2003, 05:38 PM
rgpc, yes, I wanted to say that, but didn't know how... http://www.opengl.org/discussion_boards/ubb/smile.gif

cbwan, thanks for the link.