Take the 2-minute tour ×
Game Development Stack Exchange is a question and answer site for professional and independent game developers. It's 100% free, no registration required.

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.

share|improve this question

1 Answer 1

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.

share|improve this answer
    
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? –  tomi.lee.jones Feb 25 at 17:51

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.