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.

This is a physics question, not an OpenGL question. Look up Snell’s Law on Google.

– Zeno

Originally posted by Zeno:
[b]This is a physics question, not an OpenGL question. Look up Snell’s Law on Google.

– Zeno[/b]

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.

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.

rgpc, Zeno, of course I want to use OpenGL, I thought it is obvious in an opengl forum…

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.

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

I have an “Reflection and refractions” demo on my site . 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).]

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).]

Zeno, no problem…

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…

I have a refraction example using NV_vertex_program, based on the papers from nVidia, at
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).]

Originally posted by Catman:
And I’d like to use CPU insted of GPU because I’d like it to work on any card.

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)

you should look at paul diefenbach thesis called "Multi-pass Pipeline Rendering::

lots of interesting stuff on reflection, refraction etc…


rgpc, yes, I wanted to say that, but didn’t know how…

cbwan, thanks for the link.