takram-design-engineering / three-geospatial

Geospatial Rendering in Three.js
MIT License
32 stars 2 forks source link

Atmosphere: Add support for "OrthographicCamera" #4

Open gkjohnson opened 1 day ago

gkjohnson commented 1 day ago

Currently when rendering with an orthographic camera the atmosphere doesn't look right. It would be great to support an orthographic camera, as well. Are there any inherent limitations with the current approach that would prevent it from working?

You can recreate this by adding the orthographic property to the <Canvas> component.

image

edit: It looks like this is probably (in part) caused by the assumption that the camera position is the view ray origin in the fragment shaders. Instead we could probably using the inverse projection matrix to determine the ray origin at the near clip plane. Let me know what you think!

shotamatsuda commented 1 day ago

No, this doesn’t work with an OrthographicCamera currently. I agree it would be great to support it, but it’s a low priority for now. I don’t think there are any inherent limitations to implementing it. It will just need adding more conditions to handle the matrix and depth.

gkjohnson commented 1 day ago

it’s a low priority for now. ... It will just need adding more conditions to handle the matrix and depth.

I figured it would be - but this is something I can take a look at when I have some time!

It will just need adding more conditions to handle the matrix and depth.

What do you mean by this? Which depth and matrices specifically? These calculations in the vertex shader for the view parameters looked like the primary values that need to change.

shotamatsuda commented 1 day ago

Thanks! It would be very helpful.

What do you mean by this? Which depth and matrices specifically? These calculations in the vertex shader for the view parameters looked like the primary values that need to change.

For the sky shaders, that’s correct. But in AerialPerspectiveEffect, we also need the world positions of texels (not hard, but I’m lazy enough to skip it). There're other functions like PointOfView, which casts ray from the camera.