1
\$\begingroup\$

I need to have one object that is always visible/rendered (a lens flare, to be exact). I don't want to set the camera far plane to the maximum possible distance between camera and the sun (performance reasons). Are there any tricks to this? Is this even possible? I could obviously play math and update flare's position so it's always no further than a camera far plane at the correct angle but I also want it to change size depending on the distance as well.

If there are some solutions to such a problem I would be very thankful for answers on how it can be done in three.js.

\$\endgroup\$

1 Answer 1

2
\$\begingroup\$

Lens flare is always in front of any thing rendered so you may as well just disable the depth test when you draw it as the last thing.

A sun/skybox can be drawn first with depth writing disabled.

Changing the size is as easy as doing the perspective divide in the vertex shader explicitly and clamping the Z to -1,1. Or instead of putting the far plane at your sun, put the sun at the far plane.

\$\endgroup\$
1
  • \$\begingroup\$ Thanks for the answer, but I don't really understand how does this solve my problem...I don't have problem with changing the size since it's simply scaling with (1 / distance) but for this to work I need the lens flare object to be at sun's position. How can I render the lens flare that is further than my far plane? Putting the sun/flare at the far plane IS the solution. But are there any other solutions like multiple scenes/cameras/renderers? \$\endgroup\$ Feb 25, 2015 at 17:51

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .