asc-community / MxEngine

C++ open source 3D game engine
BSD 3-Clause "New" or "Revised" License
1.12k stars 59 forks source link

[Rendering] Lens flare phase1 #66

Open fall2019 opened 1 year ago

fall2019 commented 1 year ago

add lens flare

fall2019 commented 1 year ago
lensflare2
fall2019 commented 1 year ago

image

fall2019 commented 1 year ago

I resolved most of the comments. Remaining ones may need further discussion.

MomoDeve commented 1 year ago

@fall2019 https://github.com/asc-community/MxEngine/pull/66#discussion_r1216715067 are you planning to fix this?

fall2019 commented 1 year ago

@fall2019 #66 (comment) are you planning to fix this?

Yep

MomoDeve commented 1 year ago

Whats my general concern - in lots of shader I see dependencies on scene luminance. It never should be there. You should handle all cases when light on scene have max luminance of 1, and when light have luminance of max 1000, or 100'000, etc...). To handle that you should introduce the least amount of constants - I guess only threshould value, which is multiple, so for example when light is twice the average - compute the halo. I can imagine the issue here - when you are close to light, you get really big average from average white texture. For that ok, you can use tonemapping values, we have 'white point', 'min/max luminance'. If there is no tonemapping component in camera object, you can assume the values are defaults (like in its initialization)

MomoDeve commented 1 year ago

also please leave comments what you changed in your commits so I can review the code faster 🙏

fall2019 commented 1 year ago

Will check comments later tonight

fall2019 commented 1 year ago

handle any luminance and improve formatting

MomoDeve commented 1 year ago

Try using smoothstep (https://registry.khronos.org/OpenGL-Refpages/gl4/html/smoothstep.xhtml) for ghost and halo to make a smooth transition for lights of different intensitities (thus for different average luminance). Right now halo circle is always too bright, the effect is strictly clamped then light intensity is beyong cirtain theshold whichs not good

You should have a luminance point value when halo start appearing and point when it becomes at its max and a smooth transition between. For example you can see that orange light on SandboxApplication scene does not have halo at all, because its luminance is a bit lower when whites. I expect it to have it, but not so bright as for whites. But do not tweak parameters so the effect become visible for this particular light, it should work for large range of light sources with smooth transition depending on their intensities

fall2019 commented 5 months ago

Try using smoothstep (https://registry.khronos.org/OpenGL-Refpages/gl4/html/smoothstep.xhtml) for ghost and halo to make a smooth transition for lights of different intensitities (thus for different average luminance). Right now halo circle is always too bright, the effect is strictly clamped then light intensity is beyong cirtain theshold whichs not good

You should have a luminance point value when halo start appearing and point when it becomes at its max and a smooth transition between. For example you can see that orange light on SandboxApplication scene does not have halo at all, because its luminance is a bit lower when whites. I expect it to have it, but not so bright as for whites. But do not tweak parameters so the effect become visible for this particular light, it should work for large range of light sources with smooth transition depending on their intensities

Fix mipmap level Remove brightness clamping so that it can support larger range of light sources.So the orange light on SandboxApplication scene issue is fixed. It still not perfect. But seems better than before.

MomoDeve commented 5 months ago

Mostly fine. but I not really like that sky on sponza gives the halo, also the halo is too strong for fires

You can move forward with other PR. I will finish this PR myself