Change Nebula 3D Rendering to enable Distant Nebulas
Summary
This PR changes the 3D rendering of the nebulas, such that instead of disappearing by a factor of the distance, they instead turn almost opaque at a distance, such that they can visually conceal other objects behind them.
This need came from a group I play with, that spotted a "hidden" object very easily on the main viewer, thus turning a longer scenario into a direct course into the nebula.
Changes Made
- Shader file:
- Created a new shader file (
nebula.shader) specifically for the nebula graphic.
- Created a new shader file (
- Nebula graphics:
- The graphics for the Nebulae was changed to have transparency, to allow the shader to do the pre-multiplied alpha calculations.
- Nebula SpaceObject:
- Added blend functions:
GL_SRC_ALPHAandGL_ONE_MINUS_SRC_ALPHA. - Made the
alphacalculation linear to the distance.- This may need to be improved, to prevent the quads from "clipping" through the player ship.
- Clamped the
alphato prevent the white-out effect from high distance nebulae. - Removed the
* 0.8fscaling, since it's not apparently needed.
- Added blend functions:
Notes
- The colors may not be super pleasing, but could be improved by adjusting or adding nebula-graphics.
- It may be a good idea to implement a faded "cutoff", to ensure the nebulae at extreme distances are not rendered.
- Performance-wise I saw no noticeable effect, compared to the official release, but it's only measured with the builtin FPS and timing-gizmos.
- Adding a user-setting for controlling the maximum rendering-distances may be a good idea, if the performance is affected too much on some hardware.
Oh, and by the way, regarding the notes: I'm most likely implementing the suggested changes in my fork at some point anyway, but if this PR is interesting enough to the main project, I'll gladly prioritise it to be included in this PR before an eventual merge.
And of course, fully respect the design choices, if this PR does not align. 😊👍
Increasing render_range in the new nebula_render component of ECS gets you pretty close to this, as well. I +1 this idea.