Making rays of light to curve with a custom functions

Hi,
I’m new to Unity, and not sure if this is the right forum… Please redirect me if I’m wrong.
In my project, I’m trying to simulate a world with weird phisics, in which light curves up and around according to a specific function.
No need for reflections, shadows, or extreme frame rates. Just a basic showcase of these strange physics. How should I approach this?

I … have no idea what you’re really trying to do. Are you looking to show the results of weird gravity by changing the lighting on objects?

Understand, generally speaking there are no rays used for real time rendering (ignoring recent real time raytracing stuff, and light map baking). It’s all simple math like “this surface is at this position, pointing in this direction, the light is at this position, dot(surface pos - light pos, surface direction) = lighting.”

If you’re looking to have objects be lit by gravity bent light rays, you’d have to use custom shaders that determine the light direction(s) in a completely different way. Maybe a 3D texture that stores a resulting ray direction (and attention) per texel, calculated with a compute shader or on then CPU, and then sampled in the objects’ shader to get the light direction?

Yes, that’s roughly what I was trying to say. It’s not enough though to determine a direction for each ray - I have to determine its entire route, because it doesn’t necessarily travel in any straight line, and may curve around obstacles.
I would need to create an entirely new concept of “a ray”, and I have no idea where to start…
Do you have any directions for me?
Thanks in advance :slight_smile:

So, you want to make simulation which is similar to behaviour of black holes from astronomy (these objects have “infinite” gravity, so even light cannot escape from them and spacetime is deformed) ?

It can be done by programming shaders with custom lighting model.

Not really… I’m trying to create a model of a flat earth, that does fit our observations (to poke a bit fun at flat-earthers).
So if the earth isn’t curved down, but things still disappear over the horizon, then light must curve up (or more precisely, curve down until it touches the ground, and then curve up). Said curve must follow a very specific formula to fit all observations at all altitudes.
Sure, maybe for this specific task I can do some shader trickery, with an orthograpic camera pointing up that blends itself with the main camera in some way, but I want to learn the general principle, given there are a few other manipulations I must perform on the light for the model to fit other observations, like the angles of sunrise.

So is it possible to build completely new way of ray tracing / marching, in which rays don’t follow straight lines? I don’t care that much about CPU time etc. It’s just a demo.

Ray don’t actually follow straight line in earth atmosphere due to indice of refractions between space and air… also light curve when there is difference of temperature modifying those indice of refraction creating so call mirage …


https://www.hko.gov.hk/education/article_e.htm?title=ele_00493


http://www.planet-science.com/categories/under-11s/our-world/2012/01/what-is-a-mirage.aspx

The effect you are looking for is therefore refraction and it’s everywhere (look through a lens for example).

Not sure it’s the best way to poke fun at flat earther :wink:

Well, not exactly. I’m not trying to recreate atmospheric refraction, but model an imaginary phenomenon of light globally curving upwards.
Refraction shaders mostly relocate pixels that have already been rendered, but in the flat-earth dream-world I’m creating, the curvature of light might allow you to see around solid object, or behind your own back, in a way that no single camera can render normally.

And flerfers are usually hamless lol

1 Like

I mean the logic should be the same anyway, you just have magic refraction due to heavenly energy!