Is there any way of doing gravitational lensing in OSL?

(BlackRainbow) #1

Guys, i just wanted to know if there is any way of doing gravitational lensing via osl? Given other objects in scene, stars, background etc, can some object with its osl shader modify the direction of camera ways (continuously, within certain limits, either time or steps) according to formula of grav. lensing? Or is there other way of doing it?

I have found the way of doing it with refraction surfaces, have done few tests and renders, but it has certain limitations, but more you push it more render time it needs, and there are still certain details i couldn’t achieve with it.

I would appreciate any answer!

(Secrop) #2

Not really… OSL doens’t provide any way to make new closures, which would be the way to do it (i.e. a volumetric closure). A closure must be written in Cycles, and then it can be used from OSL.

What is possible in OSL, is to automatically adjust the properties of your refraction surfaces. You have a wider range of mathematical functions and tools, not to mention that it’s far better for editing/changing and version control… Nodes are a bit unpractical in this sense.

(BlackRainbow) #3

So unfortunate. Rendering with refraction surfaces on gpu is already slow, on osl it would slow down even more.

So basically the workflow would be calculate ray trajectory with correct formula and then assign appropriate values to shader, either ior or normal to surface intersections with calculated ray. Is it doable? Or have i got something wrong?

(Secrop) #4

It’s kind of doable… The problem is the ray trajectory in a high gravitational field is not straight. In cycles, this should be done with steps (as with the refraction planes from your ‘Gargantua’)… and even so, we must account for other rays not coming from the camera, frequency dephasing, and other very strange properties of light travel in these conditions. Worst case scenario, you’ll need a specific scene setup for each scene.

I confess my knowledge on light interaction to gravitational fields is not very deep, and probably there’s some way to get some good results, but I can’t think of any atm.

(BlackRainbow) #5

Thanx Secrop. i appreciate your help!